Search in sources :

Example 96 with Configuration

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

the class XmlMapperBuilderTest method createInstanceWithAbstractClass.

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

        {
        }
    };
    expectedException.expect(BuilderException.class);
    expectedException.expectMessage(is("Error creating instance. Cause: java.lang.InstantiationException: org.apache.ibatis.builder.BaseBuilder"));
    builder.createInstance("org.apache.ibatis.builder.BaseBuilder");
}
Also used : Configuration(org.apache.ibatis.session.Configuration) Test(org.junit.Test)

Example 97 with Configuration

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

the class XmlMapperBuilderTest method useCacheRefNamespaceIsNull.

@Test
public void useCacheRefNamespaceIsNull() {
    MapperBuilderAssistant builder = new MapperBuilderAssistant(new Configuration(), "resource");
    expectedException.expect(BuilderException.class);
    expectedException.expectMessage(is("cache-ref element requires a namespace attribute."));
    builder.useCacheRef(null);
}
Also used : Configuration(org.apache.ibatis.session.Configuration) Test(org.junit.Test)

Example 98 with Configuration

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

the class XmlMapperBuilderTest method resolveClassWithNotFound.

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

        {
        }
    };
    expectedException.expect(BuilderException.class);
    expectedException.expectMessage(is("Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'ddd'.  Cause: java.lang.ClassNotFoundException: Cannot find class: ddd"));
    builder.resolveClass("ddd");
}
Also used : Configuration(org.apache.ibatis.session.Configuration) Test(org.junit.Test)

Example 99 with Configuration

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

the class XmlMapperBuilderTest method resolveParameterModeWithUndefinedValue.

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

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

Example 100 with Configuration

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

the class XmlMapperBuilderTest method mappedStatementWithOptions.

@Test
public void mappedStatementWithOptions() 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();
    MappedStatement mappedStatement = configuration.getMappedStatement("selectWithOptions");
    assertThat(mappedStatement.getFetchSize(), is(200));
    assertThat(mappedStatement.getTimeout(), is(10));
    assertThat(mappedStatement.getStatementType(), is(StatementType.PREPARED));
    assertThat(mappedStatement.getResultSetType(), is(ResultSetType.SCROLL_SENSITIVE));
    assertThat(mappedStatement.isFlushCacheRequired(), is(false));
    assertThat(mappedStatement.isUseCache(), is(false));
}
Also used : Configuration(org.apache.ibatis.session.Configuration) InputStream(java.io.InputStream) XMLMapperBuilder(org.apache.ibatis.builder.xml.XMLMapperBuilder) MappedStatement(org.apache.ibatis.mapping.MappedStatement) Test(org.junit.Test)

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