use of com.github.springtestdbunit.annotation.ExpectedDatabases in project mybatis.flying by limeng32.
the class CacheTest method testAccountTypeHandlerUsingCache.
/* 一个证明缓存对跨库关联也有效的测试用例 */
@Test
@IfProfileValue(name = "CACHE", value = "true")
@DatabaseSetups({ @DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/cacheTest/testAccountTypeHandlerUsingCache.datasource.xml"), @DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/cacheTest/testAccountTypeHandlerUsingCache.datasource2.xml") })
@ExpectedDatabases({ @ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/cacheTest/testAccountTypeHandlerUsingCache.datasource.result.xml"), @ExpectedDatabase(connection = "dataSource2", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/cacheTest/testAccountTypeHandlerUsingCache.datasource2.result.xml") })
@DatabaseTearDowns({ @DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/testAccountTypeHandlerUsingCache.datasource.result.xml"), @DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/testAccountTypeHandlerUsingCache.datasource2.result.xml") })
public void testAccountTypeHandlerUsingCache() {
Role_ r = new Role_();
r.setId(101);
r.setName("user");
roleService.insert(r);
Account_ a = new Account_();
a.setId(1L);
a.setEmail("ann@live.cn");
a.setRole(r);
accountService.insert(a);
Account_ a2 = new Account_();
a2.setId(2L);
a2.setEmail("bob@live.cn");
accountService.insert(a2);
LoginLog_ l = new LoginLog_();
l.setId(2);
l.setLoginIP("2");
loginLogService.insert(l);
LoginLogSource2 l2 = new LoginLogSource2();
l2.setId(21);
l2.setLoginIP("ip0");
l2.setAccount(a);
loginLogSource2Service.insert(l2);
LoginLogSource2 loginLogSource2 = loginLogSource2Service.select(21);
Assert.assertEquals("user", loginLogSource2.getAccount().getRole().getName());
Account_ account = accountService.select(1L);
LoginLogSource2 loginLogSource4 = loginLogSource2Service.select(21);
loginLogSource4.setLoginIP("ip00");
loginLogSource2Service.updateNoFlush(loginLogSource4);
account = accountService.select(1L);
accountService.update(account);
LoginLogSource2 loginLogSource5 = loginLogSource2Service.select(21);
Assert.assertEquals("ip00", loginLogSource5.getLoginIP());
Assert.assertEquals(1, loginLogSource5.getAccount().getOpLock().intValue());
}
use of com.github.springtestdbunit.annotation.ExpectedDatabases in project mybatis.flying by limeng32.
the class DirectSqlTest method testDirectSelect.
/**
* flying托管与非托管共存的情况
*/
@Test
@DatabaseSetups({ @DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/directSqlTest/testDirectSelect.xml") })
@ExpectedDatabases({ @ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/directSqlTest/testDirectSelect.result.xml") })
@DatabaseTearDowns({ @DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/directSqlTest/testDirectSelect.result.xml") })
public void testDirectSelect() {
Account_ account1 = accountService.selectDirect(1);
Assert.assertEquals("ann", account1.getName());
Assert.assertEquals("5a690d842935c51f26f473e025c1b97a", account1.getPassword());
Account_ account2 = accountService.select(1);
Assert.assertNull(account2.getPassword());
Account_ account3 = accountService.selectEverything(1);
Assert.assertEquals("5a690d842935c51f26f473e025c1b97a", account3.getPassword());
Map<String, Object> map = new HashMap<>(4);
map.put("name", "bob");
map.put("email", "bob@live.cn");
Collection<Account_> c1 = accountService.selectAllDirect(map);
for (Account_ t : c1) {
Assert.assertEquals("5a690d842935c51f26f473e025c1b97b", t.getPassword());
}
Account_ a1 = new Account_();
a1.setName("bob");
a1.setEmail("bob@live.cn");
Collection<Account_> c2 = accountService.selectAll(a1);
for (Account_ t : c2) {
Assert.assertNull(t.getPassword());
}
Collection<Account_> c3 = accountService.selectAllEverything(a1);
for (Account_ t : c3) {
Assert.assertEquals("5a690d842935c51f26f473e025c1b97b", t.getPassword());
}
}
use of com.github.springtestdbunit.annotation.ExpectedDatabases in project mybatis.flying by limeng32.
the class IgnoreInsertAndUpdateTest method testUpdate.
@Test
@DatabaseSetups({ @DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/ignoreInsertAndUpdateTest/testUpdate.datasource2.xml") })
@ExpectedDatabases({ @ExpectedDatabase(connection = "dataSource2", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/ignoreInsertAndUpdateTest/testUpdate.datasource2.result.xml") })
@DatabaseTearDowns({ @DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/ignoreInsertAndUpdateTest/testUpdate.datasource2.result.xml") })
public void testUpdate() {
Detail2_ detail = detail2Service.select(1);
detail.setName("n1New");
detail.setDetail("dNew");
LoginLogSource2 log = loginLogSource2Service.select(12);
detail.setLoginLogSource2(log);
detail2Service.updateWithoutName(detail);
Detail2_ detail2 = detail2Service.select(2);
detail2.setName(null);
detail2.setNumber(null);
detail2.setLoginLogSource2(null);
detail2Service.updatePersistentWithoutName(detail2);
}
use of com.github.springtestdbunit.annotation.ExpectedDatabases 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());
}
}
use of com.github.springtestdbunit.annotation.ExpectedDatabases 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);
}
Aggregations