Search in sources :

Example 11 with DatabaseTearDowns

use of com.github.springtestdbunit.annotation.DatabaseTearDowns in project mybatis.flying by limeng32.

the class NoApplicationContextProviderTest method testNormal.

@Test
@IfProfileValue(name = "NO_PROVIDER", value = "true")
@DatabaseSetups({ @DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/noApplicationContextProviderTest/testNormal.datasource.xml"), @DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/noApplicationContextProviderTest/testNormal.datasource2.xml") })
@ExpectedDatabases({ @ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/noApplicationContextProviderTest/testNormal.datasource.result.xml"), @ExpectedDatabase(connection = "dataSource2", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/noApplicationContextProviderTest/testNormal.datasource2.result.xml") })
@DatabaseTearDowns({ @DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/noApplicationContextProviderTest/testNormal.datasource.result.xml"), @DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/noApplicationContextProviderTest/testNormal.datasource2.result.xml") })
public void testNormal() {
    Account_ a = accountService.selectWithoutCache(1);
    assertEquals("r", a.getRole().getName());
    Role_ r = roleService.selectWithoutCache(51);
    assertEquals("r", r.getName());
    try {
        Account22 account22 = account22Service.select(11);
        fail("Expected an Exception to be thrown");
    } catch (Exception e) {
        assertEquals("Can not find the ApplicationContextProvider bean in the context", e.getCause().getCause().getMessage());
    }
}
Also used : Account22(indi.mybatis.flying.pojo.Account22) Account_(indi.mybatis.flying.pojo.Account_) Role_(indi.mybatis.flying.pojo.Role_) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases) DatabaseTearDowns(com.github.springtestdbunit.annotation.DatabaseTearDowns) IfProfileValue(org.springframework.test.annotation.IfProfileValue)

Example 12 with DatabaseTearDowns

use of com.github.springtestdbunit.annotation.DatabaseTearDowns in project mybatis.flying by limeng32.

the class OrTest method testOrMashup.

/* 一个在缓存状态下或逻辑查询的测试用例 */
/* 需要同时涉及同库外键和跨库外键 */
@Test
@DatabaseSetups({ @DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/orTest/testOrMashup.dataSource1.xml"), @DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/orTest/testOrMashup.dataSource2.xml") })
@ExpectedDatabases({ @ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/orTest/testOrMashup.dataSource1.result.xml"), @ExpectedDatabase(connection = "dataSource2", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/orTest/testOrMashup.dataSource2.result.xml") })
@DatabaseTearDowns({ @DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/orTest/testOrMashup.dataSource1.result.xml"), @DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/orTest/testOrMashup.dataSource2.result.xml") })
public void testOrMashup() {
    LoginLogSource2Condition l2c = new LoginLogSource2Condition();
    l2c.setAccountEqualsOr2(1L, 2L, "23453");
    int i1 = loginLogSource2Service.count(l2c);
    Assert.assertEquals(3, i1);
    LoginLogSource2Condition l2c2 = new LoginLogSource2Condition();
    l2c2.setAccountEqualsOr3(1L, 2L, "23453", "d4");
    Detail2_ d2c = new Detail2_();
    d2c.setLoginLogSource2(l2c2);
    int i2 = detail2Service.count(d2c);
    Assert.assertEquals(4, i2);
}
Also used : Detail2_(indi.mybatis.flying.pojo.Detail2_) LoginLogSource2Condition(indi.mybatis.flying.pojo.condition.LoginLogSource2Condition) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases) DatabaseTearDowns(com.github.springtestdbunit.annotation.DatabaseTearDowns)

Aggregations

DatabaseTearDowns (com.github.springtestdbunit.annotation.DatabaseTearDowns)12 ExpectedDatabases (com.github.springtestdbunit.annotation.ExpectedDatabases)12 Test (org.junit.Test)12 DatabaseSetups (com.github.springtestdbunit.annotation.DatabaseSetups)11 Account_ (indi.mybatis.flying.pojo.Account_)6 Detail2_ (indi.mybatis.flying.pojo.Detail2_)4 LoginLogSource2 (indi.mybatis.flying.pojo.LoginLogSource2)4 IfProfileValue (org.springframework.test.annotation.IfProfileValue)4 Role2_ (indi.mybatis.flying.pojo.Role2_)3 Role_ (indi.mybatis.flying.pojo.Role_)3 Account22 (indi.mybatis.flying.pojo.Account22)2 Account2_ (indi.mybatis.flying.pojo.Account2_)2 LoginLog_ (indi.mybatis.flying.pojo.LoginLog_)2 LoginLogSource2Condition (indi.mybatis.flying.pojo.condition.LoginLogSource2Condition)2 LoginLog_Condition (indi.mybatis.flying.pojo.condition.LoginLog_Condition)1 HashMap (java.util.HashMap)1