Search in sources :

Example 41 with Configuration

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

the class XmlMapperBuilderTest method useCacheRefNamespaceIsUndefined.

@Test
public void useCacheRefNamespaceIsUndefined() {
    MapperBuilderAssistant builder = new MapperBuilderAssistant(new Configuration(), "resource");
    expectedException.expect(IncompleteElementException.class);
    expectedException.expectMessage(is("No cache for namespace 'eee' could be found."));
    builder.useCacheRef("eee");
}
Also used : Configuration(org.apache.ibatis.session.Configuration) Test(org.junit.Test)

Example 42 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 43 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 44 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 45 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)

Aggregations

Configuration (org.apache.ibatis.session.Configuration)121 Test (org.junit.Test)85 SqlSessionFactoryBuilder (org.apache.ibatis.session.SqlSessionFactoryBuilder)30 Environment (org.apache.ibatis.mapping.Environment)19 Reader (java.io.Reader)18 BoundSql (org.apache.ibatis.mapping.BoundSql)18 BaseDataTest (org.apache.ibatis.BaseDataTest)17 MappedStatement (org.apache.ibatis.mapping.MappedStatement)17 DynamicSqlSource (org.apache.ibatis.scripting.xmltags.DynamicSqlSource)17 Connection (java.sql.Connection)16 TextSqlNode (org.apache.ibatis.scripting.xmltags.TextSqlNode)16 JdbcTransactionFactory (org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory)16 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 StatementHandler (org.apache.ibatis.executor.statement.StatementHandler)10 WhereSqlNode (org.apache.ibatis.scripting.xmltags.WhereSqlNode)10