Search in sources :

Example 76 with Configuration

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

the class DynamicSqlSourceTest method shouldTrimNoSetClause.

@Test
public void shouldTrimNoSetClause() throws Exception {
    final String expected = "UPDATE BLOG";
    DynamicSqlSource source = createDynamicSqlSource(new TextSqlNode("UPDATE BLOG"), new SetSqlNode(new Configuration(), mixedContents(new IfSqlNode(mixedContents(new TextSqlNode("   , ID = ?   ")), "false"), new IfSqlNode(mixedContents(new TextSqlNode(", NAME = ?  ")), "false"))));
    BoundSql boundSql = source.getBoundSql(null);
    assertEquals(expected, boundSql.getSql());
}
Also used : DynamicSqlSource(org.apache.ibatis.scripting.xmltags.DynamicSqlSource) TextSqlNode(org.apache.ibatis.scripting.xmltags.TextSqlNode) Configuration(org.apache.ibatis.session.Configuration) BoundSql(org.apache.ibatis.mapping.BoundSql) IfSqlNode(org.apache.ibatis.scripting.xmltags.IfSqlNode) SetSqlNode(org.apache.ibatis.scripting.xmltags.SetSqlNode) BaseDataTest(org.apache.ibatis.BaseDataTest) Test(org.junit.Test)

Example 77 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 78 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 79 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 80 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)

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