Search in sources :

Example 26 with Configuration

use of org.apache.ibatis.session.Configuration in project mybatis-3 by mybatis.

the class XmlMapperBuilderTest method resolveTypeHandlerNoAssignable.

@Test
public void resolveTypeHandlerNoAssignable() {
    BaseBuilder builder = new BaseBuilder(new Configuration()) {

        {
        }
    };
    expectedException.expect(BuilderException.class);
    expectedException.expectMessage(is("Type java.lang.Integer is not a valid TypeHandler because it does not implement TypeHandler interface"));
    builder.resolveTypeHandler(String.class, "integer");
}
Also used : Configuration(org.apache.ibatis.session.Configuration) Test(org.junit.Test)

Example 27 with Configuration

use of org.apache.ibatis.session.Configuration in project mybatis-3 by mybatis.

the class XmlMapperBuilderTest method shouldSuccessfullyLoadXMLMapperFile.

@Test
public void shouldSuccessfullyLoadXMLMapperFile() throws Exception {
    Configuration configuration = new Configuration();
    String resource = "org/apache/ibatis/builder/AuthorMapper.xml";
    InputStream inputStream = Resources.getResourceAsStream(resource);
    XMLMapperBuilder builder = new XMLMapperBuilder(inputStream, configuration, resource, configuration.getSqlFragments());
    builder.parse();
}
Also used : Configuration(org.apache.ibatis.session.Configuration) InputStream(java.io.InputStream) XMLMapperBuilder(org.apache.ibatis.builder.xml.XMLMapperBuilder) Test(org.junit.Test)

Example 28 with Configuration

use of org.apache.ibatis.session.Configuration in project mybatis-3 by mybatis.

the class XmlMapperBuilderTest method resolveJdbcTypeWithUndefinedValue.

@Test
public void resolveJdbcTypeWithUndefinedValue() {
    BaseBuilder builder = new BaseBuilder(new Configuration()) {

        {
        }
    };
    expectedException.expect(BuilderException.class);
    expectedException.expectMessage(startsWith("Error resolving JdbcType. Cause: java.lang.IllegalArgumentException: No enum"));
    expectedException.expectMessage(endsWith("org.apache.ibatis.type.JdbcType.aaa"));
    builder.resolveJdbcType("aaa");
}
Also used : Configuration(org.apache.ibatis.session.Configuration) Test(org.junit.Test)

Example 29 with Configuration

use of org.apache.ibatis.session.Configuration in project mybatis-3 by mybatis.

the class BlobInputStreamTypeHandlerTest method setupSqlSessionFactory.

@BeforeClass
public static void setupSqlSessionFactory() throws Exception {
    DataSource dataSource = BaseDataTest.createUnpooledDataSource("org/apache/ibatis/type/jdbc.properties");
    BaseDataTest.runScript(dataSource, "org/apache/ibatis/type/BlobInputStreamTypeHandlerTest.sql");
    TransactionFactory transactionFactory = new JdbcTransactionFactory();
    Environment environment = new Environment("Production", transactionFactory, dataSource);
    Configuration configuration = new Configuration(environment);
    configuration.addMapper(Mapper.class);
    sqlSessionFactory = new SqlSessionFactoryBuilder().build(configuration);
}
Also used : Configuration(org.apache.ibatis.session.Configuration) TransactionFactory(org.apache.ibatis.transaction.TransactionFactory) JdbcTransactionFactory(org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory) Environment(org.apache.ibatis.mapping.Environment) SqlSessionFactoryBuilder(org.apache.ibatis.session.SqlSessionFactoryBuilder) JdbcTransactionFactory(org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory) DataSource(javax.sql.DataSource) BeforeClass(org.junit.BeforeClass)

Example 30 with Configuration

use of org.apache.ibatis.session.Configuration in project mybatis-3 by mybatis.

the class ClobReaderTypeHandlerTest method setupSqlSessionFactory.

@BeforeClass
public static void setupSqlSessionFactory() throws Exception {
    DataSource dataSource = BaseDataTest.createUnpooledDataSource("org/apache/ibatis/type/jdbc.properties");
    BaseDataTest.runScript(dataSource, "org/apache/ibatis/type/ClobReaderTypeHandlerTest.sql");
    TransactionFactory transactionFactory = new JdbcTransactionFactory();
    Environment environment = new Environment("Production", transactionFactory, dataSource);
    Configuration configuration = new Configuration(environment);
    configuration.addMapper(Mapper.class);
    sqlSessionFactory = new SqlSessionFactoryBuilder().build(configuration);
}
Also used : Configuration(org.apache.ibatis.session.Configuration) TransactionFactory(org.apache.ibatis.transaction.TransactionFactory) JdbcTransactionFactory(org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory) Environment(org.apache.ibatis.mapping.Environment) SqlSessionFactoryBuilder(org.apache.ibatis.session.SqlSessionFactoryBuilder) JdbcTransactionFactory(org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory) DataSource(javax.sql.DataSource) BeforeClass(org.junit.BeforeClass)

Aggregations

Configuration (org.apache.ibatis.session.Configuration)118 Test (org.junit.Test)85 SqlSessionFactoryBuilder (org.apache.ibatis.session.SqlSessionFactoryBuilder)30 Environment (org.apache.ibatis.mapping.Environment)19 Reader (java.io.Reader)18 BaseDataTest (org.apache.ibatis.BaseDataTest)17 DynamicSqlSource (org.apache.ibatis.scripting.xmltags.DynamicSqlSource)17 BoundSql (org.apache.ibatis.mapping.BoundSql)16 TextSqlNode (org.apache.ibatis.scripting.xmltags.TextSqlNode)16 JdbcTransactionFactory (org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory)16 Connection (java.sql.Connection)15 MappedStatement (org.apache.ibatis.mapping.MappedStatement)15 DefaultObjectFactory (org.apache.ibatis.reflection.factory.DefaultObjectFactory)13 SqlSession (org.apache.ibatis.session.SqlSession)13 SqlSessionFactory (org.apache.ibatis.session.SqlSessionFactory)13 Properties (java.util.Properties)12 IfSqlNode (org.apache.ibatis.scripting.xmltags.IfSqlNode)12 UnpooledDataSource (org.apache.ibatis.datasource.unpooled.UnpooledDataSource)10 WhereSqlNode (org.apache.ibatis.scripting.xmltags.WhereSqlNode)10 Statement (java.sql.Statement)9