use of indi.mybatis.flying.pojo.LoginLogSource2 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.LoginLogSource2 in project mybatis.flying by limeng32.
the class CacheTest1 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 indi.mybatis.flying.pojo.LoginLogSource2 in project mybatis.flying by limeng32.
the class IgnoreInsertAndUpdateTest method testInsert.
@Test
@DatabaseSetups({ @DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/ignoreInsertAndUpdateTest/testInsert.datasource2.xml") })
@ExpectedDatabases({ @ExpectedDatabase(connection = "dataSource2", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/ignoreInsertAndUpdateTest/testInsert.datasource2.result.xml") })
@DatabaseTearDowns({ @DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/ignoreInsertAndUpdateTest/testInsert.datasource2.result.xml") })
public void testInsert() {
Detail2_ d = new Detail2_(), d2 = new Detail2_();
d.setName("n");
d.setNumber(123);
d.setDetail("d");
d.setCreatetime(Calendar.getInstance().getTime());
detail2Service.insertWithoutName(d);
d2.setName("n2");
d2.setNumber(234);
d2.setDetail("d2");
d2.setCreatetime(Calendar.getInstance().getTime());
LoginLogSource2 loginLog2 = new LoginLogSource2();
loginLog2.setId(22);
d2.setLoginLogSource2(loginLog2);
detail2Service.insertWithoutFoo(d2);
}
use of indi.mybatis.flying.pojo.LoginLogSource2 in project mybatis.flying by limeng32.
the class IgnoreInsertAndUpdateTest method testInsertBatch.
@Test
@DatabaseSetups({ @DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/ignoreInsertAndUpdateTest/testInsertBatch.datasource2.xml") })
@ExpectedDatabases({ @ExpectedDatabase(connection = "dataSource2", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/ignoreInsertAndUpdateTest/testInsertBatch.datasource2.result.xml") })
@DatabaseTearDowns({ @DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/ignoreInsertAndUpdateTest/testInsertBatch.datasource2.result.xml") })
public void testInsertBatch() {
Collection<Detail2_> dc = new ArrayList<>();
Detail2_ d1 = new Detail2_();
d1.setCreatetime(Calendar.getInstance().getTime());
d1.setName("n1");
d1.setNumber(123);
d1.setDetail("d");
LoginLogSource2 loginLog21 = new LoginLogSource2();
loginLog21.setId(11);
d1.setLoginLogSource2(loginLog21);
dc.add(d1);
Detail2_ d2 = new Detail2_();
d2.setCreatetime(Calendar.getInstance().getTime());
d2.setName("n2");
d2.setNumber(456);
d2.setDetail("e");
LoginLogSource2 loginLog22 = new LoginLogSource2();
loginLog22.setId(22);
d2.setLoginLogSource2(loginLog22);
dc.add(d2);
detail2Service.insertBatchWithoutName(dc);
}
use of indi.mybatis.flying.pojo.LoginLogSource2 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());
}
Aggregations