private void settingsElement(Properties props) throws Exception { configuration.setAutoMappingBehavior(AutoMappingBehavior.valueOf(props.getProperty("autoMappingBehavior", "PARTIAL"))); configuration.setAutoMappingUnknownColumnBehavior(AutoMappingUnknownColumnBehavior.valueOf(props.getProperty("autoMappingUnknownColumnBehavior", "NONE"))); configuration.setCacheEnabled(booleanValueOf(props.getProperty("cacheEnabled"), true)); configuration.setProxyFactory((ProxyFactory) createInstance(props.getProperty("proxyFactory"))); configuration.setLazyLoadingEnabled(booleanValueOf(props.getProperty("lazyLoadingEnabled"), false)); configuration.setAggressiveLazyLoading(booleanValueOf(props.getProperty("aggressiveLazyLoading"), true)); configuration.setMultipleResultSetsEnabled(booleanValueOf(props.getProperty("multipleResultSetsEnabled"), true)); configuration.setUseColumnLabel(booleanValueOf(props.getProperty("useColumnLabel"), true)); configuration.setUseGeneratedKeys(booleanValueOf(props.getProperty("useGeneratedKeys"), false)); configuration.setDefaultExecutorType(ExecutorType.valueOf(props.getProperty("defaultExecutorType", "SIMPLE"))); configuration.setDefaultStatementTimeout(integerValueOf(props.getProperty("defaultStatementTimeout"), null)); configuration.setDefaultFetchSize(integerValueOf(props.getProperty("defaultFetchSize"), null)); configuration.setMapUnderscoreToCamelCase(booleanValueOf(props.getProperty("mapUnderscoreToCamelCase"), false)); configuration.setSafeRowBoundsEnabled(booleanValueOf(props.getProperty("safeRowBoundsEnabled"), false)); configuration.setLocalCacheScope(LocalCacheScope.valueOf(props.getProperty("localCacheScope", "SESSION"))); configuration.setJdbcTypeForNull(JdbcType.valueOf(props.getProperty("jdbcTypeForNull", "OTHER"))); configuration.setLazyLoadTriggerMethods(stringSetValueOf(props.getProperty("lazyLoadTriggerMethods"), "equals,clone,hashCode,toString")); configuration.setSafeResultHandlerEnabled(booleanValueOf(props.getProperty("safeResultHandlerEnabled"), true)); configuration.setDefaultScriptingLanguage(resolveClass(props.getProperty("defaultScriptingLanguage"))); configuration.setCallSettersOnNulls(booleanValueOf(props.getProperty("callSettersOnNulls"), false)); configuration.setLogPrefix(props.getProperty("logPrefix")); configuration.setLogImpl(resolveClass(props.getProperty("logImpl"))); configuration.setConfigurationFactory(resolveClass(props.getProperty("configurationFactory"))); }
private void settingsElement(Properties props) throws Exception { configuration.setAutoMappingBehavior(AutoMappingBehavior.valueOf(props.getProperty("autoMappingBehavior", "PARTIAL"))); configuration.setAutoMappingUnknownColumnBehavior(AutoMappingUnknownColumnBehavior.valueOf(props.getProperty("autoMappingUnknownColumnBehavior", "NONE"))); configuration.setCacheEnabled(booleanValueOf(props.getProperty("cacheEnabled"), true)); configuration.setProxyFactory((ProxyFactory) createInstance(props.getProperty("proxyFactory"))); configuration.setLazyLoadingEnabled(booleanValueOf(props.getProperty("lazyLoadingEnabled"), false)); configuration.setAggressiveLazyLoading(booleanValueOf(props.getProperty("aggressiveLazyLoading"), false)); configuration.setMultipleResultSetsEnabled(booleanValueOf(props.getProperty("multipleResultSetsEnabled"), true)); configuration.setUseColumnLabel(booleanValueOf(props.getProperty("useColumnLabel"), true)); configuration.setUseGeneratedKeys(booleanValueOf(props.getProperty("useGeneratedKeys"), false)); configuration.setDefaultExecutorType(ExecutorType.valueOf(props.getProperty("defaultExecutorType", "SIMPLE"))); configuration.setDefaultStatementTimeout(integerValueOf(props.getProperty("defaultStatementTimeout"), null)); configuration.setDefaultFetchSize(integerValueOf(props.getProperty("defaultFetchSize"), null)); configuration.setMapUnderscoreToCamelCase(booleanValueOf(props.getProperty("mapUnderscoreToCamelCase"), false)); configuration.setSafeRowBoundsEnabled(booleanValueOf(props.getProperty("safeRowBoundsEnabled"), false)); configuration.setLocalCacheScope(LocalCacheScope.valueOf(props.getProperty("localCacheScope", "SESSION"))); configuration.setJdbcTypeForNull(JdbcType.valueOf(props.getProperty("jdbcTypeForNull", "OTHER"))); configuration.setLazyLoadTriggerMethods(stringSetValueOf(props.getProperty("lazyLoadTriggerMethods"), "equals,clone,hashCode,toString")); configuration.setSafeResultHandlerEnabled(booleanValueOf(props.getProperty("safeResultHandlerEnabled"), true)); configuration.setDefaultScriptingLanguage(resolveClass(props.getProperty("defaultScriptingLanguage"))); configuration.setCallSettersOnNulls(booleanValueOf(props.getProperty("callSettersOnNulls"), false)); configuration.setUseActualParamName(booleanValueOf(props.getProperty("useActualParamName"), true)); configuration.setReturnInstanceForEmptyRow(booleanValueOf(props.getProperty("returnInstanceForEmptyRow"), false)); configuration.setLogPrefix(props.getProperty("logPrefix")); @SuppressWarnings("unchecked") Class<? extends Log> logImpl = (Class<? extends Log>) resolveClass(props.getProperty("logImpl")); configuration.setLogImpl(logImpl); configuration.setConfigurationFactory(resolveClass(props.getProperty("configurationFactory"))); }
private void settingsElement(Properties props) throws Exception { configuration.setAutoMappingBehavior(AutoMappingBehavior.valueOf(props.getProperty("autoMappingBehavior", "PARTIAL"))); configuration.setAutoMappingUnknownColumnBehavior(AutoMappingUnknownColumnBehavior.valueOf(props.getProperty("autoMappingUnknownColumnBehavior", "NONE"))); configuration.setCacheEnabled(booleanValueOf(props.getProperty("cacheEnabled"), true)); configuration.setProxyFactory((ProxyFactory) createInstance(props.getProperty("proxyFactory"))); configuration.setLazyLoadingEnabled(booleanValueOf(props.getProperty("lazyLoadingEnabled"), false)); configuration.setAggressiveLazyLoading(booleanValueOf(props.getProperty("aggressiveLazyLoading"), true)); configuration.setMultipleResultSetsEnabled(booleanValueOf(props.getProperty("multipleResultSetsEnabled"), true)); configuration.setUseColumnLabel(booleanValueOf(props.getProperty("useColumnLabel"), true)); configuration.setUseGeneratedKeys(booleanValueOf(props.getProperty("useGeneratedKeys"), false)); configuration.setDefaultExecutorType(ExecutorType.valueOf(props.getProperty("defaultExecutorType", "SIMPLE"))); configuration.setDefaultStatementTimeout(integerValueOf(props.getProperty("defaultStatementTimeout"), null)); configuration.setDefaultFetchSize(integerValueOf(props.getProperty("defaultFetchSize"), null)); configuration.setMapUnderscoreToCamelCase(booleanValueOf(props.getProperty("mapUnderscoreToCamelCase"), false)); configuration.setSafeRowBoundsEnabled(booleanValueOf(props.getProperty("safeRowBoundsEnabled"), false)); configuration.setLocalCacheScope(LocalCacheScope.valueOf(props.getProperty("localCacheScope", "SESSION"))); configuration.setJdbcTypeForNull(JdbcType.valueOf(props.getProperty("jdbcTypeForNull", "OTHER"))); configuration.setLazyLoadTriggerMethods(stringSetValueOf(props.getProperty("lazyLoadTriggerMethods"), "equals,clone,hashCode,toString")); configuration.setSafeResultHandlerEnabled(booleanValueOf(props.getProperty("safeResultHandlerEnabled"), true)); configuration.setDefaultScriptingLanguage(resolveClass(props.getProperty("defaultScriptingLanguage"))); configuration.setCallSettersOnNulls(booleanValueOf(props.getProperty("callSettersOnNulls"), false)); configuration.setUseActualParamName(booleanValueOf(props.getProperty("useActualParamName"), true)); configuration.setLogPrefix(props.getProperty("logPrefix")); @SuppressWarnings("unchecked") Class<? extends Log> logImpl = (Class<? extends Log>)resolveClass(props.getProperty("logImpl")); configuration.setLogImpl(logImpl); configuration.setConfigurationFactory(resolveClass(props.getProperty("configurationFactory"))); }
@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()); }
@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())); }
private void settingsElement(Properties props) throws Exception { configuration.setAutoMappingBehavior(AutoMappingBehavior.valueOf(props.getProperty("autoMappingBehavior", "PARTIAL"))); configuration.setAutoMappingUnknownColumnBehavior(AutoMappingUnknownColumnBehavior.valueOf(props.getProperty("autoMappingUnknownColumnBehavior", "NONE"))); configuration.setCacheEnabled(booleanValueOf(props.getProperty("cacheEnabled"), true)); configuration.setProxyFactory((ProxyFactory) createInstance(props.getProperty("proxyFactory"))); configuration.setLazyLoadingEnabled(booleanValueOf(props.getProperty("lazyLoadingEnabled"), false)); configuration.setAggressiveLazyLoading(booleanValueOf(props.getProperty("aggressiveLazyLoading"), false)); configuration.setMultipleResultSetsEnabled(booleanValueOf(props.getProperty("multipleResultSetsEnabled"), true)); configuration.setUseColumnLabel(booleanValueOf(props.getProperty("useColumnLabel"), true)); configuration.setUseGeneratedKeys(booleanValueOf(props.getProperty("useGeneratedKeys"), false)); configuration.setDefaultExecutorType(ExecutorType.valueOf(props.getProperty("defaultExecutorType", "SIMPLE"))); configuration.setDefaultStatementTimeout(integerValueOf(props.getProperty("defaultStatementTimeout"), null)); configuration.setDefaultFetchSize(integerValueOf(props.getProperty("defaultFetchSize"), null)); configuration.setMapUnderscoreToCamelCase(booleanValueOf(props.getProperty("mapUnderscoreToCamelCase"), false)); configuration.setSafeRowBoundsEnabled(booleanValueOf(props.getProperty("safeRowBoundsEnabled"), false)); configuration.setLocalCacheScope(LocalCacheScope.valueOf(props.getProperty("localCacheScope", "SESSION"))); configuration.setJdbcTypeForNull(JdbcType.valueOf(props.getProperty("jdbcTypeForNull", "OTHER"))); configuration.setLazyLoadTriggerMethods(stringSetValueOf(props.getProperty("lazyLoadTriggerMethods"), "equals,clone,hashCode,toString")); configuration.setSafeResultHandlerEnabled(booleanValueOf(props.getProperty("safeResultHandlerEnabled"), true)); configuration.setDefaultScriptingLanguage(resolveClass(props.getProperty("defaultScriptingLanguage"))); @SuppressWarnings("unchecked") Class<? extends TypeHandler> typeHandler = (Class<? extends TypeHandler>)resolveClass(props.getProperty("defaultEnumTypeHandler")); configuration.setDefaultEnumTypeHandler(typeHandler); configuration.setCallSettersOnNulls(booleanValueOf(props.getProperty("callSettersOnNulls"), false)); configuration.setUseActualParamName(booleanValueOf(props.getProperty("useActualParamName"), true)); configuration.setReturnInstanceForEmptyRow(booleanValueOf(props.getProperty("returnInstanceForEmptyRow"), false)); configuration.setLogPrefix(props.getProperty("logPrefix")); @SuppressWarnings("unchecked") Class<? extends Log> logImpl = (Class<? extends Log>)resolveClass(props.getProperty("logImpl")); configuration.setLogImpl(logImpl); configuration.setConfigurationFactory(resolveClass(props.getProperty("configurationFactory"))); }
@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(); }
@Test public void shouldSuccessfullyLoadXMLConfigFile() throws Exception { String resource = "org/apache/ibatis/builder/CustomizedSettingsMapperConfig.xml"; InputStream inputStream = Resources.getResourceAsStream(resource); Properties props = new Properties(); props.put("prop2", "cccc"); XMLConfigBuilder builder = new XMLConfigBuilder(inputStream, null, props); 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())); assertTrue(config.getTypeAliasRegistry().getTypeAliases().get("blogauthor").equals(Author.class)); assertTrue(config.getTypeAliasRegistry().getTypeAliases().get("blog").equals(Blog.class)); assertTrue(config.getTypeAliasRegistry().getTypeAliases().get("cart").equals(Cart.class)); assertThat(config.getTypeHandlerRegistry().getTypeHandler(Integer.class), is(instanceOf(CustomIntegerTypeHandler.class))); assertThat(config.getTypeHandlerRegistry().getTypeHandler(Long.class), is(instanceOf(CustomLongTypeHandler.class))); assertThat(config.getTypeHandlerRegistry().getTypeHandler(String.class), is(instanceOf(CustomStringTypeHandler.class))); assertThat(config.getTypeHandlerRegistry().getTypeHandler(String.class, JdbcType.VARCHAR), is(instanceOf(CustomStringTypeHandler.class))); ExampleObjectFactory objectFactory = (ExampleObjectFactory)config.getObjectFactory(); assertThat(objectFactory.getProperties().size(), is(1)); assertThat(objectFactory.getProperties().getProperty("objectFactoryProperty"), is("100")); assertThat(config.getObjectWrapperFactory(), is(instanceOf(CustomObjectWrapperFactory.class))); assertThat(config.getReflectorFactory(), is(instanceOf(CustomReflectorFactory.class))); ExamplePlugin plugin = (ExamplePlugin)config.getInterceptors().get(0); assertThat(plugin.getProperties().size(), is(1)); assertThat(plugin.getProperties().getProperty("pluginProperty"), is("100")); Environment environment = config.getEnvironment(); assertThat(environment.getId(), is("development")); assertThat(environment.getDataSource(), is(instanceOf(UnpooledDataSource.class))); assertThat(environment.getTransactionFactory(), is(instanceOf(JdbcTransactionFactory.class))); assertThat(config.getDatabaseId(), is("derby")); assertThat(config.getMapperRegistry().getMappers().size(), is(4)); assertThat(config.getMapperRegistry().hasMapper(CachedAuthorMapper.class), is(true)); assertThat(config.getMapperRegistry().hasMapper(CustomMapper.class), is(true)); assertThat(config.getMapperRegistry().hasMapper(BlogMapper.class), is(true)); assertThat(config.getMapperRegistry().hasMapper(NestedBlogMapper.class), is(true)); }
@Test public void shouldSuccessfullyLoadXMLConfigFile() throws Exception { String resource = "org/apache/ibatis/builder/CustomizedSettingsMapperConfig.xml"; InputStream inputStream = Resources.getResourceAsStream(resource); Properties props = new Properties(); props.put("prop2", "cccc"); XMLConfigBuilder builder = new XMLConfigBuilder(inputStream, null, props); Configuration config = builder.parse(); assertThat(config.getAutoMappingBehavior()).isEqualTo(AutoMappingBehavior.NONE); assertThat(config.getAutoMappingUnknownColumnBehavior()).isEqualTo(AutoMappingUnknownColumnBehavior.WARNING); assertThat(config.isCacheEnabled()).isFalse(); assertThat(config.getProxyFactory()).isInstanceOf(CglibProxyFactory.class); assertThat(config.isLazyLoadingEnabled()).isTrue(); assertThat(config.isAggressiveLazyLoading()).isTrue(); assertThat(config.isMultipleResultSetsEnabled()).isFalse(); assertThat(config.isUseColumnLabel()).isFalse(); assertThat(config.isUseGeneratedKeys()).isTrue(); assertThat(config.getDefaultExecutorType()).isEqualTo(ExecutorType.BATCH); assertThat(config.getDefaultStatementTimeout()).isEqualTo(10); assertThat(config.getDefaultFetchSize()).isEqualTo(100); assertThat(config.isMapUnderscoreToCamelCase()).isTrue(); assertThat(config.isSafeRowBoundsEnabled()).isTrue(); assertThat(config.getLocalCacheScope()).isEqualTo(LocalCacheScope.STATEMENT); assertThat(config.getJdbcTypeForNull()).isEqualTo(JdbcType.NULL); assertThat(config.getLazyLoadTriggerMethods()).isEqualTo((Set<String>) new HashSet<String>(Arrays.asList("equals", "clone", "hashCode", "toString", "xxx"))); assertThat(config.isSafeResultHandlerEnabled()).isFalse(); assertThat(config.getDefaultScriptingLanuageInstance()).isInstanceOf(RawLanguageDriver.class); assertThat(config.isCallSettersOnNulls()).isTrue(); assertThat(config.getLogPrefix()).isEqualTo("mybatis_"); assertThat(config.getLogImpl().getName()).isEqualTo(Slf4jImpl.class.getName()); assertThat(config.getVfsImpl().getName()).isEqualTo(JBoss6VFS.class.getName()); assertThat(config.getConfigurationFactory().getName()).isEqualTo(String.class.getName()); assertTrue(config.getTypeAliasRegistry().getTypeAliases().get("blogauthor").equals(Author.class)); assertTrue(config.getTypeAliasRegistry().getTypeAliases().get("blog").equals(Blog.class)); assertTrue(config.getTypeAliasRegistry().getTypeAliases().get("cart").equals(Cart.class)); assertThat(config.getTypeHandlerRegistry().getTypeHandler(Integer.class)).isInstanceOf(CustomIntegerTypeHandler.class); assertThat(config.getTypeHandlerRegistry().getTypeHandler(Long.class)).isInstanceOf(CustomLongTypeHandler.class); assertThat(config.getTypeHandlerRegistry().getTypeHandler(String.class)).isInstanceOf(CustomStringTypeHandler.class); assertThat(config.getTypeHandlerRegistry().getTypeHandler(String.class, JdbcType.VARCHAR)).isInstanceOf(CustomStringTypeHandler.class); assertThat(config.getTypeHandlerRegistry().getTypeHandler(RoundingMode.class)).isInstanceOf(EnumOrdinalTypeHandler.class); ExampleObjectFactory objectFactory = (ExampleObjectFactory)config.getObjectFactory(); assertThat(objectFactory.getProperties().size()).isEqualTo(1); assertThat(objectFactory.getProperties().getProperty("objectFactoryProperty")).isEqualTo("100"); assertThat(config.getObjectWrapperFactory()).isInstanceOf(CustomObjectWrapperFactory.class); assertThat(config.getReflectorFactory()).isInstanceOf(CustomReflectorFactory.class); ExamplePlugin plugin = (ExamplePlugin)config.getInterceptors().get(0); assertThat(plugin.getProperties().size()).isEqualTo(1); assertThat(plugin.getProperties().getProperty("pluginProperty")).isEqualTo("100"); Environment environment = config.getEnvironment(); assertThat(environment.getId()).isEqualTo("development"); assertThat(environment.getDataSource()).isInstanceOf(UnpooledDataSource.class); assertThat(environment.getTransactionFactory()).isInstanceOf(JdbcTransactionFactory.class); assertThat(config.getDatabaseId()).isEqualTo("derby"); assertThat(config.getMapperRegistry().getMappers().size()).isEqualTo(4); assertThat(config.getMapperRegistry().hasMapper(CachedAuthorMapper.class)).isTrue(); assertThat(config.getMapperRegistry().hasMapper(CustomMapper.class)).isTrue(); assertThat(config.getMapperRegistry().hasMapper(BlogMapper.class)).isTrue(); assertThat(config.getMapperRegistry().hasMapper(NestedBlogMapper.class)).isTrue(); inputStream.close(); }