use of indi.mybatis.flying.pojo.Account2_ in project mybatis.flying by limeng32.
the class CacheTest method testNPlusOne.
/* 一个展示n+1问题的测试用例 */
@Test
@IfProfileValue(name = "CACHE", value = "true")
@ExpectedDatabase(connection = "dataSource2", assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/cacheTest/testNPlusOne.datasource2.result.xml")
@DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/testNPlusOne.datasource2.result.xml")
public void testNPlusOne() {
Role2_ r = new Role2_();
r.setId(1);
r.setName("root");
role2Service.insert(r);
Role2_ r2 = new Role2_();
r2.setId(2);
r2.setName("user");
role2Service.insert(r2);
Account2_ a = new Account2_();
a.setId(21);
a.setEmail("10");
a.setRole(r);
account2Service.insert(a);
Account2_ a2 = new Account2_();
a2.setId(22);
a2.setEmail("11");
a2.setRole(r);
account2Service.insert(a2);
Collection<Account2_> accounts = account2Service.selectAll(new Account2_());
Assert.assertEquals(2, accounts.size());
}
use of indi.mybatis.flying.pojo.Account2_ in project mybatis.flying by limeng32.
the class AccountTest method testInsert.
/**
* 测试insert功能(有乐观锁)
*/
@Test
@DatabaseSetups({ @DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTest/testInsert.datasource.xml"), @DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTest/testInsert.datasource2.xml") })
@ExpectedDatabases({ @ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTest/testInsert.datasource.result.xml"), @ExpectedDatabase(connection = "dataSource2", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTest/testInsert.datasource2.result.xml") })
@DatabaseTearDowns({ @DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTest/testInsert.datasource.result.xml"), @DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTest/testInsert.datasource2.result.xml") })
public void testInsert() {
Account_ a = new Account_();
a.setId(1L);
a.setName("ann");
a.setEmail("ann@live.cn");
a.setPassword("5a690d842935c51f26f473e025c1b97a");
a.setActivated(true);
a.setActivateValue("");
accountService.insert(a);
Role2_ role2_ = new Role2_();
role2_.setName("new");
role2Service.insert(role2_);
LoginLog_ loginLog_ = new LoginLog_();
loginLog_.setLoginIP("old");
loginLogService.insert(loginLog_);
LoginLogSource2 loginLogSource2 = new LoginLogSource2();
loginLogSource2.setLoginIP("new");
loginLogSource2Service.insert(loginLogSource2);
Collection<LoginLogSource2> c = loginLogSource2Service.selectAll(new LoginLogSource2());
LoginLogSource2[] loginLogSource2s = c.toArray(new LoginLogSource2[1]);
Assert.assertEquals("new", loginLogSource2s[0].getLoginIP());
Account2_ account2_ = new Account2_();
account2_.setEmail("l@x.com");
account2_.setNickname("nick");
account2_.setRole(role2_);
account2Service.insert(account2_);
Collection<Account2_> c2 = account2Service.selectAll(new Account2_());
Account2_[] account2_s = c2.toArray(new Account2_[1]);
Assert.assertEquals("new", account2_s[0].getRole().getName());
}
use of indi.mybatis.flying.pojo.Account2_ in project mybatis.flying by limeng32.
the class CacheTest1 method testNPlusOne.
/* 一个展示n+1问题的测试用例 */
@Test
@IfProfileValue(name = "CACHE", value = "true")
@ExpectedDatabase(connection = "dataSource2", assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/cacheTest/testNPlusOne.datasource2.result.xml")
@DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/testNPlusOne.datasource2.result.xml")
public void testNPlusOne() {
Role2_ r = new Role2_();
r.setId(1);
r.setName("root");
role2Service.insert(r);
Role2_ r2 = new Role2_();
r2.setId(2);
r2.setName("user");
role2Service.insert(r2);
Account2_ a = new Account2_();
a.setId(21);
a.setEmail("10");
a.setRole(r);
account2Service.insert(a);
Account2_ a2 = new Account2_();
a2.setId(22);
a2.setEmail("11");
a2.setRole(r);
account2Service.insert(a2);
Collection<Account2_> accounts = account2Service.selectAll(new Account2_());
Assert.assertEquals(2, accounts.size());
}
use of indi.mybatis.flying.pojo.Account2_ in project mybatis.flying by limeng32.
the class CacheTest 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 indi.mybatis.flying.pojo.Account2_ in project mybatis.flying by limeng32.
the class CacheTest method test21.
@Test
@IfProfileValue(name = "CACHE", value = "true")
@DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest2/test.datasource2.xml")
@ExpectedDatabase(connection = "dataSource2", assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/cacheTest2/test.datasource2.result.xml")
@DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest2/test.datasource2.result.xml")
public void test21() {
String name = "ann";
String roleName = "user";
String newRoleName = "admin";
Account2_ a = new Account2_();
Role2_ r = new Role2_();
r.setName(roleName);
role2Service.insert(r);
a.setName(name);
a.setRole(r);
account2Service.insert(a);
Account2_ account2_ = account2Service.select(a.getId());
Assert.assertEquals(roleName, account2_.getRole().getName());
Role2_ r2 = role2Service.select(r.getId());
r2.setName(newRoleName);
role2Service.update(r2);
account2_ = account2Service.select(a.getId());
Assert.assertEquals(newRoleName, account2_.getRole().getName());
}
Aggregations