use of org.apache.ibatis.session.Configuration in project mybatis-3 by mybatis.
the class ProviderTest method shouldUseProvider.
@Test
public void shouldUseProvider() throws Exception {
Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/multidb/ProviderConfig.xml");
DefaultSqlSessionFactory sqlSessionFactory = (DefaultSqlSessionFactory) new SqlSessionFactoryBuilder().build(reader);
Configuration c = sqlSessionFactory.getConfiguration();
assertEquals("translated", c.getDatabaseId());
}
use of org.apache.ibatis.session.Configuration in project mybatis-3 by mybatis.
the class InvalidNamedConstructorArgsTest method missingRequiredJavaType.
@Test
public void missingRequiredJavaType() {
ex.expect(BuilderException.class);
ex.expectMessage(allOf(containsString("'org.apache.ibatis.submitted.named_constructor_args.InvalidNamedConstructorArgsTest$ConstructorMissingRequiresJavaType.select-void'"), containsString("'org.apache.ibatis.submitted.named_constructor_args.User'"), containsString("[id]")));
Configuration configuration = sqlSessionFactory.getConfiguration();
configuration.addMapper(ConstructorMissingRequiresJavaType.class);
}
use of org.apache.ibatis.session.Configuration in project mybatis-3 by mybatis.
the class NamedConstructorArgsTest method setUp.
@BeforeClass
public static void setUp() throws Exception {
// create an SqlSessionFactory
Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/named_constructor_args/mybatis-config.xml");
sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
reader.close();
Configuration configuration = sqlSessionFactory.getConfiguration();
configuration.setUseActualParamName(false);
configuration.addMapper(Mapper.class);
// populate in-memory database
SqlSession session = sqlSessionFactory.openSession();
Connection conn = session.getConnection();
reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/named_constructor_args/CreateDB.sql");
ScriptRunner runner = new ScriptRunner(conn);
runner.setLogWriter(null);
runner.runScript(reader);
reader.close();
session.close();
}
use of org.apache.ibatis.session.Configuration in project mybatis-3 by mybatis.
the class WrongMapperTest method shouldFailForBothOneAndMany.
@Test(expected = RuntimeException.class)
public void shouldFailForBothOneAndMany() throws Exception {
Configuration configuration = new Configuration();
configuration.addMapper(MapperWithOneAndMany.class);
}
use of org.apache.ibatis.session.Configuration in project mybatis-3 by mybatis.
the class WrongNamespacesTest method shouldFailForWrongNamespace.
@Test(expected = RuntimeException.class)
public void shouldFailForWrongNamespace() throws Exception {
Configuration configuration = new Configuration();
configuration.addMapper(WrongNamespaceMapper.class);
}
Aggregations