当前位置: 首页>>代码示例>>Java>>正文


Java XMLConfigBuilder.parse方法代码示例

本文整理汇总了Java中org.apache.ibatis.builder.xml.XMLConfigBuilder.parse方法的典型用法代码示例。如果您正苦于以下问题:Java XMLConfigBuilder.parse方法的具体用法?Java XMLConfigBuilder.parse怎么用?Java XMLConfigBuilder.parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ibatis.builder.xml.XMLConfigBuilder的用法示例。


在下文中一共展示了XMLConfigBuilder.parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: registerJavaTypeInitializingTypeHandler

import org.apache.ibatis.builder.xml.XMLConfigBuilder; //导入方法依赖的package包/类
@Test
public void registerJavaTypeInitializingTypeHandler() {
  final String MAPPER_CONFIG = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
      + "<!DOCTYPE configuration PUBLIC \"-//mybatis.org//DTD Config 3.0//EN\" \"http://mybatis.org/dtd/mybatis-3-config.dtd\">\n" 
      + "<configuration>\n" 
      + "  <typeHandlers>\n"
      + "    <typeHandler javaType=\"org.apache.ibatis.builder.XmlConfigBuilderTest$MyEnum\"\n"
      + "      handler=\"org.apache.ibatis.builder.XmlConfigBuilderTest$EnumOrderTypeHandler\"/>\n" 
      + "  </typeHandlers>\n" 
      + "</configuration>\n";

  XMLConfigBuilder builder = new XMLConfigBuilder(new StringReader(MAPPER_CONFIG));
  builder.parse();

  TypeHandlerRegistry typeHandlerRegistry = builder.getConfiguration().getTypeHandlerRegistry();
  TypeHandler<MyEnum> typeHandler = typeHandlerRegistry.getTypeHandler(MyEnum.class);

  assertTrue(typeHandler instanceof EnumOrderTypeHandler);
  assertArrayEquals(MyEnum.values(), ((EnumOrderTypeHandler) typeHandler).constants);
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:21,代码来源:XmlConfigBuilderTest.java

示例2: unknownSettings

import org.apache.ibatis.builder.xml.XMLConfigBuilder; //导入方法依赖的package包/类
@Test
public void unknownSettings() {
  final String MAPPER_CONFIG = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
          + "<!DOCTYPE configuration PUBLIC \"-//mybatis.org//DTD Config 3.0//EN\" \"http://mybatis.org/dtd/mybatis-3-config.dtd\">\n"
          + "<configuration>\n"
          + "  <settings>\n"
          + "    <setting name=\"foo\" value=\"bar\"/>\n"
          + "  </settings>\n"
          + "</configuration>\n";

  expectedException.expect(BuilderException.class);
  expectedException.expectMessage("The setting foo is not known.  Make sure you spelled it correctly (case sensitive).");

  XMLConfigBuilder builder = new XMLConfigBuilder(new StringReader(MAPPER_CONFIG));
  builder.parse();
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:17,代码来源:XmlConfigBuilderTest.java

示例3: unknownJavaTypeOnTypeHandler

import org.apache.ibatis.builder.xml.XMLConfigBuilder; //导入方法依赖的package包/类
@Test
public void unknownJavaTypeOnTypeHandler() {
  final String MAPPER_CONFIG = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
          + "<!DOCTYPE configuration PUBLIC \"-//mybatis.org//DTD Config 3.0//EN\" \"http://mybatis.org/dtd/mybatis-3-config.dtd\">\n"
          + "<configuration>\n"
          + "  <typeAliases>\n"
          + "    <typeAlias type=\"a.b.c.Foo\"/>\n"
          + "  </typeAliases>\n"
          + "</configuration>\n";

  expectedException.expect(BuilderException.class);
  expectedException.expectMessage("Error registering typeAlias for 'null'. Cause: ");

  XMLConfigBuilder builder = new XMLConfigBuilder(new StringReader(MAPPER_CONFIG));
  builder.parse();
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:17,代码来源:XmlConfigBuilderTest.java

示例4: parseMybatisConfiguration

import org.apache.ibatis.builder.xml.XMLConfigBuilder; //导入方法依赖的package包/类
public Configuration parseMybatisConfiguration(XMLConfigBuilder parser) {
    Configuration configuration = parser.parse();

    if (dependentEngineMybatisTypeAliasConfigs != null) {
        for (CustomMybatisTypeAliasConfig typeAliasConfig : dependentEngineMybatisTypeAliasConfigs) {
            configuration.getTypeAliasRegistry().registerAlias(typeAliasConfig.getAliasName(), typeAliasConfig.getTypeHandlerClass());
        }
    }
    if (dependentEngineMybatisTypeHandlerConfigs != null) {
        for (CustomMyBatisTypeHandlerConfig typeHandlerConfig : dependentEngineMybatisTypeHandlerConfigs) {
            configuration.getTypeHandlerRegistry().register(typeHandlerConfig.getJavaTypeClass(), typeHandlerConfig.getJdbcType(), typeHandlerConfig.getTypeHandlerClass());
        }
    }

    parseDependentEngineMybatisXMLMappers(configuration);
    parseCustomMybatisXMLMappers(configuration);
    return configuration;
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:19,代码来源:AbstractEngineConfiguration.java

示例5: shouldSuccessfullyLoadMinimalXMLConfigFile

import org.apache.ibatis.builder.xml.XMLConfigBuilder; //导入方法依赖的package包/类
@Test
public void shouldSuccessfullyLoadMinimalXMLConfigFile() throws Exception {
  String resource = "org/apache/ibatis/builder/MinimalMapperConfig.xml";
  InputStream inputStream = Resources.getResourceAsStream(resource);
  XMLConfigBuilder builder = new XMLConfigBuilder(inputStream);
  Configuration config = builder.parse();
  assertNotNull(config);
  assertThat(config.getAutoMappingBehavior(), is(AutoMappingBehavior.PARTIAL));
  assertThat(config.getAutoMappingUnknownColumnBehavior(), is(AutoMappingUnknownColumnBehavior.NONE));
  assertThat(config.isCacheEnabled(), is(true));
  assertThat(config.getProxyFactory(), is(instanceOf(JavassistProxyFactory.class)));
  assertThat(config.isLazyLoadingEnabled(), is(false));
  assertThat(config.isAggressiveLazyLoading(), is(true));
  assertThat(config.isMultipleResultSetsEnabled(), is(true));
  assertThat(config.isUseColumnLabel(), is(true));
  assertThat(config.isUseGeneratedKeys(), is(false));
  assertThat(config.getDefaultExecutorType(), is(ExecutorType.SIMPLE));
  assertNull(config.getDefaultStatementTimeout());
  assertNull(config.getDefaultFetchSize());
  assertThat(config.isMapUnderscoreToCamelCase(), is(false));
  assertThat(config.isSafeRowBoundsEnabled(), is(false));
  assertThat(config.getLocalCacheScope(), is(LocalCacheScope.SESSION));
  assertThat(config.getJdbcTypeForNull(), is(JdbcType.OTHER));
  assertThat(config.getLazyLoadTriggerMethods(), is((Set<String>) new HashSet<String>(Arrays.asList("equals", "clone", "hashCode", "toString"))));
  assertThat(config.isSafeResultHandlerEnabled(), is(true));
    assertThat(config.getDefaultScriptingLanuageInstance(), is(instanceOf(XMLLanguageDriver.class)));
  assertThat(config.isCallSettersOnNulls(), is(false));
  assertNull(config.getLogPrefix());
  assertNull(config.getLogImpl());
  assertNull(config.getConfigurationFactory());
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:32,代码来源:XmlConfigBuilderTest.java

示例6: shouldSuccessfullyLoadXMLConfigFileWithPropertiesUrl

import org.apache.ibatis.builder.xml.XMLConfigBuilder; //导入方法依赖的package包/类
@Test
public void shouldSuccessfullyLoadXMLConfigFileWithPropertiesUrl() throws Exception {
  String resource = "org/apache/ibatis/builder/PropertiesUrlMapperConfig.xml";
  InputStream inputStream = Resources.getResourceAsStream(resource);
  XMLConfigBuilder builder = new XMLConfigBuilder(inputStream);
  Configuration config = builder.parse();
  assertThat(config.getVariables().get("driver").toString(), is("org.apache.derby.jdbc.EmbeddedDriver"));
  assertThat(config.getVariables().get("prop1").toString(), is("bbbb"));

}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:11,代码来源:XmlConfigBuilderTest.java

示例7: parseIsTwice

import org.apache.ibatis.builder.xml.XMLConfigBuilder; //导入方法依赖的package包/类
@Test
public void parseIsTwice() throws Exception {
  String resource = "org/apache/ibatis/builder/MinimalMapperConfig.xml";
  InputStream inputStream = Resources.getResourceAsStream(resource);
  XMLConfigBuilder builder = new XMLConfigBuilder(inputStream);
  builder.parse();

  expectedException.expect(BuilderException.class);
  expectedException.expectMessage("Each XMLConfigBuilder can only be used once.");
  builder.parse();
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:12,代码来源:XmlConfigBuilderTest.java

示例8: propertiesSpecifyResourceAndUrlAtSameTime

import org.apache.ibatis.builder.xml.XMLConfigBuilder; //导入方法依赖的package包/类
@Test
public void propertiesSpecifyResourceAndUrlAtSameTime() {
  final String MAPPER_CONFIG = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
          + "<!DOCTYPE configuration PUBLIC \"-//mybatis.org//DTD Config 3.0//EN\" \"http://mybatis.org/dtd/mybatis-3-config.dtd\">\n"
          + "<configuration>\n"
          + "  <properties resource=\"a/b/c/foo.properties\" url=\"file:./a/b/c/jdbc.properties\"/>\n"
          + "</configuration>\n";

  expectedException.expect(BuilderException.class);
  expectedException.expectMessage("The properties element cannot specify both a URL and a resource based property file reference.  Please specify one or the other.");

  XMLConfigBuilder builder = new XMLConfigBuilder(new StringReader(MAPPER_CONFIG));
  builder.parse();
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:15,代码来源:XmlConfigBuilderTest.java

示例9: shouldSuccessfullyLoadXMLConfigFile

import org.apache.ibatis.builder.xml.XMLConfigBuilder; //导入方法依赖的package包/类
@Test
public void shouldSuccessfullyLoadXMLConfigFile() throws Exception {
  String resource = "org/apache/ibatis/builder/CustomizedSettingsMapperConfig.xml";
  InputStream inputStream = Resources.getResourceAsStream(resource);
  XMLConfigBuilder builder = new XMLConfigBuilder(inputStream);
  Configuration config = builder.parse();

  assertThat(config.getAutoMappingBehavior(), is(AutoMappingBehavior.NONE));
  assertThat(config.getAutoMappingUnknownColumnBehavior(), is(AutoMappingUnknownColumnBehavior.WARNING));
  assertThat(config.isCacheEnabled(), is(false));
  assertThat(config.getProxyFactory(), is(instanceOf(CglibProxyFactory.class)));
  assertThat(config.isLazyLoadingEnabled(), is(true));
  assertThat(config.isAggressiveLazyLoading(), is(false));
  assertThat(config.isMultipleResultSetsEnabled(), is(false));
  assertThat(config.isUseColumnLabel(), is(false));
  assertThat(config.isUseGeneratedKeys(), is(true));
  assertThat(config.getDefaultExecutorType(), is(ExecutorType.BATCH));
  assertThat(config.getDefaultStatementTimeout(), is(10));
  assertThat(config.getDefaultFetchSize(), is(100));
  assertThat(config.isMapUnderscoreToCamelCase(), is(true));
  assertThat(config.isSafeRowBoundsEnabled(), is(true));
  assertThat(config.getLocalCacheScope(), is(LocalCacheScope.STATEMENT));
  assertThat(config.getJdbcTypeForNull(), is(JdbcType.NULL));
  assertThat(config.getLazyLoadTriggerMethods(), is((Set<String>) new HashSet<String>(Arrays.asList("equals", "clone", "hashCode", "toString", "xxx"))));
  assertThat(config.isSafeResultHandlerEnabled(), is(false));
  assertThat(config.getDefaultScriptingLanuageInstance(), is(instanceOf(RawLanguageDriver.class)));
  assertThat(config.isCallSettersOnNulls(), is(true));
  assertThat(config.getLogPrefix(), is("mybatis_"));
  assertThat(config.getLogImpl().getName(), is(Slf4jImpl.class.getName()));
  assertThat(config.getVfsImpl().getName(), is(JBoss6VFS.class.getName()));
  assertThat(config.getConfigurationFactory().getName(), is(String.class.getName()));

}
 
开发者ID:txazo,项目名称:mybatis,代码行数:34,代码来源:XmlConfigBuilderTest.java

示例10: shouldSuccessfullyLoadMinimalXMLConfigFile

import org.apache.ibatis.builder.xml.XMLConfigBuilder; //导入方法依赖的package包/类
@Test
public void shouldSuccessfullyLoadMinimalXMLConfigFile() throws Exception {
  String resource = "org/apache/ibatis/builder/MinimalMapperConfig.xml";
  InputStream inputStream = Resources.getResourceAsStream(resource);
  XMLConfigBuilder builder = new XMLConfigBuilder(inputStream);
  Configuration config = builder.parse();
  assertNotNull(config);
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:9,代码来源:XmlConfigBuilderTest.java

示例11: shouldSuccessfullyLoadMinimalXMLConfigFile

import org.apache.ibatis.builder.xml.XMLConfigBuilder; //导入方法依赖的package包/类
@Test
public void shouldSuccessfullyLoadMinimalXMLConfigFile() throws Exception {
  String resource = "org/apache/ibatis/builder/MinimalMapperConfig.xml";
  InputStream inputStream = Resources.getResourceAsStream(resource);
  XMLConfigBuilder builder = new XMLConfigBuilder(inputStream);
  Configuration config = builder.parse();
  assertNotNull(config);
  assertThat(config.getAutoMappingBehavior(), is(AutoMappingBehavior.PARTIAL));
  assertThat(config.isCacheEnabled(), is(true));
  assertThat(config.getProxyFactory(), is(instanceOf(JavassistProxyFactory.class)));
  assertThat(config.isLazyLoadingEnabled(), is(false));
  assertThat(config.isAggressiveLazyLoading(), is(true));
  assertThat(config.isMultipleResultSetsEnabled(), is(true));
  assertThat(config.isUseColumnLabel(), is(true));
  assertThat(config.isUseGeneratedKeys(), is(false));
  assertThat(config.getDefaultExecutorType(), is(ExecutorType.SIMPLE));
  assertNull(config.getDefaultStatementTimeout());
  assertNull(config.getDefaultFetchSize());
  assertThat(config.isMapUnderscoreToCamelCase(), is(false));
  assertThat(config.isSafeRowBoundsEnabled(), is(false));
  assertThat(config.getLocalCacheScope(), is(LocalCacheScope.SESSION));
  assertThat(config.getJdbcTypeForNull(), is(JdbcType.OTHER));
  assertThat(config.getLazyLoadTriggerMethods(), is((Set<String>) new HashSet<String>(Arrays.asList("equals", "clone", "hashCode", "toString"))));
  assertThat(config.isSafeResultHandlerEnabled(), is(true));
    assertThat(config.getDefaultScriptingLanuageInstance(), is(instanceOf(XMLLanguageDriver.class)));
  assertThat(config.isCallSettersOnNulls(), is(false));
  assertNull(config.getLogPrefix());
  assertNull(config.getLogImpl());
  assertNull(config.getConfigurationFactory());
}
 
开发者ID:toulezu,项目名称:play,代码行数:31,代码来源:XmlConfigBuilderTest.java

示例12: shouldSuccessfullyLoadXMLConfigFile

import org.apache.ibatis.builder.xml.XMLConfigBuilder; //导入方法依赖的package包/类
@Test
public void shouldSuccessfullyLoadXMLConfigFile() throws Exception {
  String resource = "org/apache/ibatis/builder/CustomizedSettingsMapperConfig.xml";
  InputStream inputStream = Resources.getResourceAsStream(resource);
  XMLConfigBuilder builder = new XMLConfigBuilder(inputStream);
  Configuration config = builder.parse();

  assertThat(config.getAutoMappingBehavior(), is(AutoMappingBehavior.NONE));
  assertThat(config.isCacheEnabled(), is(false));
  assertThat(config.getProxyFactory(), is(instanceOf(CglibProxyFactory.class)));
  assertThat(config.isLazyLoadingEnabled(), is(true));
  assertThat(config.isAggressiveLazyLoading(), is(false));
  assertThat(config.isMultipleResultSetsEnabled(), is(false));
  assertThat(config.isUseColumnLabel(), is(false));
  assertThat(config.isUseGeneratedKeys(), is(true));
  assertThat(config.getDefaultExecutorType(), is(ExecutorType.BATCH));
  assertThat(config.getDefaultStatementTimeout(), is(10));
  assertThat(config.getDefaultFetchSize(), is(100));
  assertThat(config.isMapUnderscoreToCamelCase(), is(true));
  assertThat(config.isSafeRowBoundsEnabled(), is(true));
  assertThat(config.getLocalCacheScope(), is(LocalCacheScope.STATEMENT));
  assertThat(config.getJdbcTypeForNull(), is(JdbcType.NULL));
  assertThat(config.getLazyLoadTriggerMethods(), is((Set<String>) new HashSet<String>(Arrays.asList("equals", "clone", "hashCode", "toString", "xxx"))));
  assertThat(config.isSafeResultHandlerEnabled(), is(false));
  assertThat(config.getDefaultScriptingLanuageInstance(), is(instanceOf(RawLanguageDriver.class)));
  assertThat(config.isCallSettersOnNulls(), is(true));
  assertThat(config.getLogPrefix(), is("mybatis_"));
  assertThat(config.getLogImpl().getName(), is(Slf4jImpl.class.getName()));
  assertThat(config.getConfigurationFactory().getName(), is(String.class.getName()));

}
 
开发者ID:toulezu,项目名称:play,代码行数:32,代码来源:XmlConfigBuilderTest.java

示例13: shouldSuccessfullyLoadMinimalXMLConfigFile

import org.apache.ibatis.builder.xml.XMLConfigBuilder; //导入方法依赖的package包/类
@Test
public void shouldSuccessfullyLoadMinimalXMLConfigFile() throws Exception {
  String resource = "org/apache/ibatis/builder/MinimalMapperConfig.xml";
  InputStream inputStream = Resources.getResourceAsStream(resource);
  XMLConfigBuilder builder = new XMLConfigBuilder(inputStream);
  Configuration config = builder.parse();
  assertNotNull(config);
  assertThat(config.getAutoMappingBehavior()).isEqualTo(AutoMappingBehavior.PARTIAL);
  assertThat(config.getAutoMappingUnknownColumnBehavior()).isEqualTo(AutoMappingUnknownColumnBehavior.NONE);
  assertThat(config.isCacheEnabled()).isTrue();
  assertThat(config.getProxyFactory()).isInstanceOf(JavassistProxyFactory.class);
  assertThat(config.isLazyLoadingEnabled()).isFalse();
  assertThat(config.isAggressiveLazyLoading()).isFalse();
  assertThat(config.isMultipleResultSetsEnabled()).isTrue();
  assertThat(config.isUseColumnLabel()).isTrue();
  assertThat(config.isUseGeneratedKeys()).isFalse();
  assertThat(config.getDefaultExecutorType()).isEqualTo(ExecutorType.SIMPLE);
  assertNull(config.getDefaultStatementTimeout());
  assertNull(config.getDefaultFetchSize());
  assertThat(config.isMapUnderscoreToCamelCase()).isFalse();
  assertThat(config.isSafeRowBoundsEnabled()).isFalse();
  assertThat(config.getLocalCacheScope()).isEqualTo(LocalCacheScope.SESSION);
  assertThat(config.getJdbcTypeForNull()).isEqualTo(JdbcType.OTHER);
  assertThat(config.getLazyLoadTriggerMethods()).isEqualTo((Set<String>) new HashSet<String>(Arrays.asList("equals", "clone", "hashCode", "toString")));
  assertThat(config.isSafeResultHandlerEnabled()).isTrue();
  assertThat(config.getDefaultScriptingLanuageInstance()).isInstanceOf(XMLLanguageDriver.class);
  assertThat(config.isCallSettersOnNulls()).isFalse();
  assertNull(config.getLogPrefix());
  assertNull(config.getLogImpl());
  assertNull(config.getConfigurationFactory());
  assertThat(config.getTypeHandlerRegistry().getTypeHandler(RoundingMode.class)).isInstanceOf(EnumTypeHandler.class);
  inputStream.close();
}
 
开发者ID:mybatis,项目名称:mybatis-3,代码行数:34,代码来源:XmlConfigBuilderTest.java

示例14: shouldSuccessfullyLoadXMLConfigFileWithPropertiesUrl

import org.apache.ibatis.builder.xml.XMLConfigBuilder; //导入方法依赖的package包/类
@Test
public void shouldSuccessfullyLoadXMLConfigFileWithPropertiesUrl() throws Exception {
  String resource = "org/apache/ibatis/builder/PropertiesUrlMapperConfig.xml";
  InputStream inputStream = Resources.getResourceAsStream(resource);
  XMLConfigBuilder builder = new XMLConfigBuilder(inputStream);
  Configuration config = builder.parse();
  assertThat(config.getVariables().get("driver").toString()).isEqualTo("org.apache.derby.jdbc.EmbeddedDriver");
  assertThat(config.getVariables().get("prop1").toString()).isEqualTo("bbbb");
  inputStream.close();
}
 
开发者ID:mybatis,项目名称:mybatis-3,代码行数:11,代码来源:XmlConfigBuilderTest.java

示例15: parseIsTwice

import org.apache.ibatis.builder.xml.XMLConfigBuilder; //导入方法依赖的package包/类
@Test
public void parseIsTwice() throws Exception {
  String resource = "org/apache/ibatis/builder/MinimalMapperConfig.xml";
  InputStream inputStream = Resources.getResourceAsStream(resource);
  XMLConfigBuilder builder = new XMLConfigBuilder(inputStream);
  builder.parse();

  when(builder).parse();
  then(caughtException()).isInstanceOf(BuilderException.class)
    .hasMessage("Each XMLConfigBuilder can only be used once.");
  inputStream.close();
}
 
开发者ID:mybatis,项目名称:mybatis-3,代码行数:13,代码来源:XmlConfigBuilderTest.java


注:本文中的org.apache.ibatis.builder.xml.XMLConfigBuilder.parse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。