use of org.apache.ibatis.datasource.unpooled.UnpooledDataSource in project mybatis-3 by mybatis.
the class ReverseIncludeTest method getSqlSessionFactoryJavaConfig.
private SqlSessionFactory getSqlSessionFactoryJavaConfig() throws Exception {
Configuration configuration = new Configuration();
Environment environment = new Environment("development", new JdbcTransactionFactory(), new UnpooledDataSource("org.hsqldb.jdbcDriver", "jdbc:hsqldb:mem:xmlextref", null));
configuration.setEnvironment(environment);
configuration.addMapper(ReverseIncludePersonMapper.class);
SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(configuration);
initDb(sqlSessionFactory);
return sqlSessionFactory;
}
use of org.apache.ibatis.datasource.unpooled.UnpooledDataSource in project mybatis-3 by mybatis.
the class XmlExternalRefTest method getSqlSessionFactoryJavaConfig.
private SqlSessionFactory getSqlSessionFactoryJavaConfig() throws Exception {
Configuration configuration = new Configuration();
Environment environment = new Environment("development", new JdbcTransactionFactory(), new UnpooledDataSource("org.hsqldb.jdbcDriver", "jdbc:hsqldb:mem:xmlextref", null));
configuration.setEnvironment(environment);
configuration.addMapper(PersonMapper.class);
configuration.addMapper(PetMapper.class);
SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(configuration);
initDb(sqlSessionFactory);
return sqlSessionFactory;
}
use of org.apache.ibatis.datasource.unpooled.UnpooledDataSource in project mybatis-3 by mybatis.
the class SameIdTest method getSqlSessionFactoryJavaConfig.
private SqlSessionFactory getSqlSessionFactoryJavaConfig() throws Exception {
Configuration configuration = new Configuration();
Environment environment = new Environment("development", new JdbcTransactionFactory(), new UnpooledDataSource("org.hsqldb.jdbcDriver", "jdbc:hsqldb:mem:xmlextref", null));
configuration.setEnvironment(environment);
configuration.addMapper(SameIdPersonMapper.class);
configuration.addMapper(SameIdPetMapper.class);
SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(configuration);
initDb(sqlSessionFactory);
return sqlSessionFactory;
}
use of org.apache.ibatis.datasource.unpooled.UnpooledDataSource in project mybatis-3 by mybatis.
the class XmlConfigBuilderTest method shouldSuccessfullyLoadXMLConfigFile.
@Test
void shouldSuccessfullyLoadXMLConfigFile() throws Exception {
// System.setProperty(XPathParser.KEY_USE_XSD, "true");
String resource = "org/apache/ibatis/builder/xsd/CustomizedSettingsMapperConfig.xml";
try (InputStream inputStream = Resources.getResourceAsStream(resource)) {
XMLConfigBuilder builder = new XMLConfigBuilder(inputStream);
Configuration config = builder.parse();
assertEquals(AutoMappingBehavior.NONE, config.getAutoMappingBehavior());
assertEquals(AutoMappingUnknownColumnBehavior.WARNING, config.getAutoMappingUnknownColumnBehavior());
assertFalse(config.isCacheEnabled());
assertTrue(config.getProxyFactory() instanceof CglibProxyFactory);
assertTrue(config.isLazyLoadingEnabled());
assertTrue(config.isAggressiveLazyLoading());
assertFalse(config.isMultipleResultSetsEnabled());
assertFalse(config.isUseColumnLabel());
assertTrue(config.isUseGeneratedKeys());
assertEquals(ExecutorType.BATCH, config.getDefaultExecutorType());
assertEquals(Integer.valueOf(10), config.getDefaultStatementTimeout());
assertEquals(Integer.valueOf(100), config.getDefaultFetchSize());
assertTrue(config.isMapUnderscoreToCamelCase());
assertTrue(config.isSafeRowBoundsEnabled());
assertEquals(LocalCacheScope.STATEMENT, config.getLocalCacheScope());
assertEquals(JdbcType.NULL, config.getJdbcTypeForNull());
assertEquals(new HashSet<>(Arrays.asList("equals", "clone", "hashCode", "toString", "xxx")), config.getLazyLoadTriggerMethods());
assertFalse(config.isSafeResultHandlerEnabled());
assertTrue(config.getDefaultScriptingLanguageInstance() instanceof RawLanguageDriver);
assertTrue(config.isCallSettersOnNulls());
assertEquals("mybatis_", config.getLogPrefix());
assertEquals(Slf4jImpl.class.getName(), config.getLogImpl().getName());
assertEquals(JBoss6VFS.class.getName(), config.getVfsImpl().getName());
assertEquals(String.class.getName(), config.getConfigurationFactory().getName());
assertTrue(config.isShrinkWhitespacesInSql());
assertEquals(Author.class, config.getTypeAliasRegistry().getTypeAliases().get("blogauthor"));
assertEquals(Blog.class, config.getTypeAliasRegistry().getTypeAliases().get("blog"));
assertEquals(Cart.class, config.getTypeAliasRegistry().getTypeAliases().get("cart"));
assertTrue(config.getTypeHandlerRegistry().getTypeHandler(Integer.class) instanceof CustomIntegerTypeHandler);
assertTrue(config.getTypeHandlerRegistry().getTypeHandler(Long.class) instanceof CustomLongTypeHandler);
assertTrue(config.getTypeHandlerRegistry().getTypeHandler(String.class) instanceof CustomStringTypeHandler);
assertTrue(config.getTypeHandlerRegistry().getTypeHandler(String.class, JdbcType.VARCHAR) instanceof CustomStringTypeHandler);
ExampleObjectFactory objectFactory = (ExampleObjectFactory) config.getObjectFactory();
assertEquals(1, objectFactory.getProperties().size());
assertEquals("100", objectFactory.getProperties().getProperty("objectFactoryProperty"));
assertTrue(config.getObjectWrapperFactory() instanceof CustomObjectWrapperFactory);
assertTrue(config.getReflectorFactory() instanceof CustomReflectorFactory);
ExamplePlugin plugin = (ExamplePlugin) config.getInterceptors().get(0);
assertEquals(1, plugin.getProperties().size());
assertEquals("100", plugin.getProperties().getProperty("pluginProperty"));
Environment environment = config.getEnvironment();
assertEquals("development", environment.getId());
assertTrue(environment.getDataSource() instanceof UnpooledDataSource);
assertTrue(environment.getTransactionFactory() instanceof JdbcTransactionFactory);
assertEquals("derby", config.getDatabaseId());
assertEquals(4, config.getMapperRegistry().getMappers().size());
assertTrue(config.getMapperRegistry().hasMapper(CachedAuthorMapper.class));
assertTrue(config.getMapperRegistry().hasMapper(CustomMapper.class));
assertTrue(config.getMapperRegistry().hasMapper(BlogMapper.class));
assertTrue(config.getMapperRegistry().hasMapper(NestedBlogMapper.class));
} finally {
// System.clearProperty(XPathParser.KEY_USE_XSD);
}
}
use of org.apache.ibatis.datasource.unpooled.UnpooledDataSource in project mybatis-3 by mybatis.
the class BaseDataTest method createUnpooledDataSource.
public static UnpooledDataSource createUnpooledDataSource(String resource) throws IOException {
Properties props = Resources.getResourceAsProperties(resource);
UnpooledDataSource ds = new UnpooledDataSource();
ds.setDriver(props.getProperty("driver"));
ds.setUrl(props.getProperty("url"));
ds.setUsername(props.getProperty("username"));
ds.setPassword(props.getProperty("password"));
return ds;
}
Aggregations