use of com.github.springtestdbunit.annotation.DatabaseSetups in project mybatis.flying by limeng32.
the class AccountTypeHandlerTest method testAccountTypeHandler.
/* 测试AccountTypeHandler的功能 */
// @Test
@DatabaseSetups({ @DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTypeHandlerTest/testAccountTypeHandler.datasource.xml"), @DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTypeHandlerTest/testAccountTypeHandler.datasource2.xml") })
@ExpectedDatabases({ @ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTypeHandlerTest/testAccountTypeHandler.datasource.result.xml"), @ExpectedDatabase(connection = "dataSource2", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTypeHandlerTest/testAccountTypeHandler.datasource2.result.xml") })
@DatabaseTearDowns({ @DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTypeHandlerTest/testAccountTypeHandler.datasource.result.xml"), @DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTypeHandlerTest/testAccountTypeHandler.datasource2.result.xml") })
public void testAccountTypeHandler() {
LoginLogSource2 longinLogSource0 = loginLogSource2Service.selectWithoutAccount(22);
Assert.assertNull(longinLogSource0.getAccount());
LoginLogSource2 longinLogSource = loginLogSource2Service.select(22);
Assert.assertNotNull(longinLogSource);
Assert.assertNotNull(longinLogSource.getAccount());
Assert.assertEquals("ann@live.cn", longinLogSource.getAccount().getEmail());
Account_ ac = new Account_();
ac.setId(1L);
LoginLogSource2 l2c = new LoginLogSource2();
l2c.setAccount(ac);
Collection<LoginLogSource2> loginLogSource2C = loginLogSource2Service.selectAll(l2c);
Assert.assertEquals(2, loginLogSource2C.size());
for (LoginLogSource2 e : loginLogSource2C) {
Assert.assertEquals("ann@live.cn", e.getAccount().getEmail());
}
LoginLogSource2 loginLogSource2 = loginLogSource2Service.select(24);
Assert.assertNull(loginLogSource2.getAccount());
LoginLogSource2 loginLogSource3 = loginLogSource2Service.select(25);
Assert.assertNull(loginLogSource3.getAccount());
Account_ ac2 = new Account_();
ac2.setId(2L);
LoginLogSource2 l2c2 = new LoginLogSource2();
l2c2.setAccount(ac2);
LoginLogSource2 loginLogSource4 = loginLogSource2Service.selectOne(l2c2);
loginLogSource4 = loginLogSource2Service.selectOne(l2c2);
loginLogSource4 = loginLogSource2Service.selectOne(l2c2);
loginLogSource4 = loginLogSource2Service.selectOne(l2c2);
loginLogSource4 = loginLogSource2Service.selectOne(l2c2);
Assert.assertEquals("bob@live.cn", loginLogSource4.getAccount().getEmail());
Account_ ac3 = new Account_();
ac3.setId(1L);
LoginLogSource2 l2c3 = new LoginLogSource2();
l2c3.setAccount(ac3);
l2c3.setLoginIP("ip1");
int i = loginLogSource2Service.count(l2c3);
Assert.assertEquals(1, i);
Account_ account2 = accountService.select(2);
loginLogSource2.setAccount(account2);
loginLogSource2Service.update(loginLogSource2);
loginLogSource4.setAccount(null);
loginLogSource2Service.updatePersistent(loginLogSource4);
Account_ account = accountService.select(1);
loginLogSource2Service.loadAccount(account, new LoginLogSource2());
Assert.assertEquals(2, account.getLoginLogSource2().size());
}
use of com.github.springtestdbunit.annotation.DatabaseSetups in project mybatis.flying by limeng32.
the class CacheTest1 method test22.
@Test
@IfProfileValue(name = "CACHE", value = "true")
@DatabaseSetups({ @DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest2/test2.datasource1.xml"), @DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest2/test2.datasource2.xml") })
@ExpectedDatabases({ @ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/cacheTest2/test2.datasource1.result.xml"), @ExpectedDatabase(connection = "dataSource2", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/cacheTest2/test2.datasource2.result.xml") })
@DatabaseTearDowns({ @DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest2/test2.datasource1.result.xml"), @DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest2/test2.datasource2.result.xml") })
public void test22() {
String name = "ann";
String roleName = "user";
String newRoleName = "admin";
Account_ a = new Account_();
Role_ r = new Role_();
r.setName(roleName);
roleService.insert(r);
a.setName(name);
a.setRole(r);
accountService.insert(a);
Account_ account_ = accountService.select(a.getId());
Assert.assertEquals(roleName, account_.getRole().getName());
Role_ r12 = roleService.select(r.getId());
r12.setName(newRoleName);
roleService.update(r12);
account_ = accountService.select(a.getId());
Assert.assertEquals(newRoleName, account_.getRole().getName());
Account2_ a2 = new Account2_();
Role2_ r2 = new Role2_();
r2.setName(roleName);
role2Service.insert(r2);
a2.setName(name);
a2.setRole(r2);
account2Service.insert(a2);
Account2_ account2_ = account2Service.select(a2.getId());
Assert.assertEquals(roleName, account2_.getRole().getName());
Role2_ r22 = role2Service.select(r2.getId());
r22.setName(newRoleName);
role2Service.update(r22);
account2_ = account2Service.select(a2.getId());
Assert.assertEquals(newRoleName, account2_.getRole().getName());
}
use of com.github.springtestdbunit.annotation.DatabaseSetups 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.DatabaseSetups 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);
}
use of com.github.springtestdbunit.annotation.DatabaseSetups in project mybatis.flying by limeng32.
the class BatchProcessTest method testBatchInsert2.
@Test
@DatabaseSetups({ @DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchInsert2.datasource.xml") })
@ExpectedDatabases({ @ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchInsert2.datasource.result.xml") })
@DatabaseTearDowns({ @DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchInsert2.datasource.result.xml") })
public void testBatchInsert2() {
Collection<Account_> ac = new ArrayList<>();
Role_ r1 = new Role_(), r2 = new Role_(), r3 = new Role_();
r1.setId(1);
r2.setId(2);
r3.setId(3);
Account_ a = new Account_();
// a.setName("ann");
a.setEmail("ann@live.cn");
a.setPassword("5a690d842935c51f26f473e025c1b97a");
a.setActivated(true);
a.setActivateValue("");
// a.setRole(r1);
ac.add(a);
Account_ a2 = new Account_();
a2.setName("bob");
a2.setEmail("bob@live.cn");
a2.setPassword("6a690d842935c51f26f473e025c1b97a");
a2.setActivated(true);
a2.setActivateValue("");
a2.setDelegateRoleId(22L);
ac.add(a2);
Account_ a3 = new Account_();
a3.setName("carl");
a3.setEmail("carl@live.cn");
a3.setPassword("7a690d842935c51f26f473e025c1b97a");
a3.setActivated(true);
a3.setActivateValue("");
a3.setRole(r3);
ac.add(a3);
accountService.insertSnowFlakeBatch(ac);
for (Account_ e : ac) {
Assert.assertNotNull(e.getId());
}
}
Aggregations