use of com.github.springtestdbunit.annotation.DatabaseSetup in project mybatis.flying by limeng32.
the class OrTest method testOr6.
/* 一个只有单独入参的或逻辑测试用例 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/orTest/testOr6.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/orTest/testOr6.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/orTest/testOr6.result.xml")
public void testOr6() {
LoginLog_Condition lc = new LoginLog_Condition();
lc.setAccount(new Account_Condition());
lc.getAccount().setRole(new Role_Condition());
((Role_Condition) lc.getAccount().getRole()).setAccountNameEquals("ann");
int i = loginLogService.count(lc);
Assert.assertEquals(2, i);
LoginLog_Condition lc2 = new LoginLog_Condition();
lc2.setAccount(new Account_Condition());
lc2.getAccount().setRole(new Role_Condition());
((Role_Condition) lc2.getAccount().getRole()).setNameEquals("admin");
int i2 = loginLogService.count(lc2);
Assert.assertEquals(4, i2);
}
use of com.github.springtestdbunit.annotation.DatabaseSetup in project mybatis.flying by limeng32.
the class OrTest method testOr7.
/* 一个dbAssociationTypeHandler型外键的或逻辑测试用例 */
@Test
@DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/orTest/testOr7.datasource2.xml")
@ExpectedDatabase(connection = "dataSource2", assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/orTest/testOr7.datasource2.result.xml")
@DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/orTest/testOr7.datasource2.result.xml")
public void testOr7() {
LoginLogSource2Condition loginLogSource2 = new LoginLogSource2Condition();
loginLogSource2.setAccountEqualsOr(1L, 2L);
int i = loginLogSource2Service.count(loginLogSource2);
Assert.assertEquals(4, i);
}
use of com.github.springtestdbunit.annotation.DatabaseSetup in project mybatis.flying by limeng32.
the class OrTest method testOr1.
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/orTest/testOr1.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/orTest/testOr1.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/orTest/testOr1.result.xml")
public void testOr1() {
LoginLog_Condition lc1 = new LoginLog_Condition();
lc1.setLoginIPHeadLikeOr("a", "b");
lc1.setIpLikeFilter("1");
Collection<LoginLog_> LoginLogC = loginLogService.selectAll(lc1);
Assert.assertEquals(2, LoginLogC.size());
LoginLog_Condition lc2 = new LoginLog_Condition();
lc2.setLoginIPLikeOr("b1", "c1");
Collection<LoginLog_> LoginLogC2 = loginLogService.selectAll(lc2);
Assert.assertEquals(2, LoginLogC2.size());
int c2 = loginLogService.count(lc2);
Assert.assertEquals(2, c2);
LoginLog_Condition lc3 = new LoginLog_Condition();
lc3.setLoginIPHeadLikeOrTailLike("a", "2");
int c3 = loginLogService.count(lc3);
Assert.assertEquals(2, c3);
LoginLog_Condition lc4 = new LoginLog_Condition();
lc4.setLoginIPEqualsOr("a1", "z3");
int c4 = loginLogService.count(lc4);
Assert.assertEquals(2, c4);
LoginLog_Condition lc5 = new LoginLog_Condition();
lc5.setLoginIPLikeOr("a1", "b1");
lc5.setLoginIPEqualsOr("b1", "c1");
int c5 = loginLogService.count(lc5);
Assert.assertEquals(1, c5);
LoginLog_Condition lc6 = new LoginLog_Condition();
lc6.setNumEqualsOr(1, 2);
int c6 = loginLogService.count(lc6);
Assert.assertEquals(2, c6);
LoginLog_Condition lc7 = new LoginLog_Condition();
lc7.setNumEqualsOrLoginIPLike(1, "b1");
Collection<LoginLog_> LoginLogC7 = loginLogService.selectAll(lc7);
Assert.assertEquals(2, LoginLogC7.size());
LoginLog_ l1 = new LoginLog_();
l1.setLoginIP("a1");
LoginLog_ loginLog_1 = loginLogService.selectOne(l1);
LoginLog_ l2 = new LoginLog_();
l2.setLoginIP("b1");
LoginLog_ loginLog_2 = loginLogService.selectOne(l2);
LoginLog_Condition lc8 = new LoginLog_Condition();
lc8.setLoginTimeEqualsOr(loginLog_1.getLoginTime(), loginLog_2.getLoginTime());
int c8 = loginLogService.count(lc8);
Assert.assertEquals(2, c8);
LoginLog_Condition lc9 = new LoginLog_Condition();
lc9.setStatusEqualsOr(LogStatus.b, LogStatus.t);
int c9 = loginLogService.count(lc9);
Assert.assertEquals(2, c9);
LoginLog_Condition lc10 = new LoginLog_Condition();
lc10.setLoginIPNotEqualsOr("z2", "z3");
int c10 = loginLogService.count(lc10);
Assert.assertEquals(6, c10);
LoginLog_Condition lc11 = new LoginLog_Condition();
lc11.setNumGtOrLt(5, 2);
int c11 = loginLogService.count(lc11);
Assert.assertEquals(2, c11);
LoginLog_Condition lc12 = new LoginLog_Condition();
lc12.setNumGeOrLe(5, 2);
int c12 = loginLogService.count(lc12);
Assert.assertEquals(4, c12);
LoginLog_Condition lc13 = new LoginLog_Condition();
Object[] o13 = { 5, 2 };
lc13.setNumGtOrLe(o13);
int c13 = loginLogService.count(lc13);
Assert.assertEquals(3, c13);
LoginLog_Condition lc14 = new LoginLog_Condition();
lc14.setNumGeOrLt(5, 2);
int c14 = loginLogService.count(lc14);
Assert.assertEquals(3, c14);
LoginLog_Condition lc15 = new LoginLog_Condition();
Object[] o15 = { true, false };
lc15.setStatusIsNullOr(o15);
int c15 = loginLogService.count(lc15);
Assert.assertEquals(6, c15);
LoginLog_Condition lc16 = new LoginLog_Condition();
// 最后一个参数无意义
lc16.setStatusIsNullOrLoginIPEquals(false, "a1", "b1", "c1");
int c16 = loginLogService.count(lc16);
Assert.assertEquals(4, c16);
}
use of com.github.springtestdbunit.annotation.DatabaseSetup in project mybatis.flying by limeng32.
the class SelectOneTest method testSelectOne3.
/**
* 测试selectOne3,缓存测试
*/
@Test
@DatabaseSetup(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/selectOneTest/testSelectOne3.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/selectOneTest/testSelectOne3.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/selectOneTest/testSelectOne3.result.xml")
public void testSelectOne3() {
Account_ a1 = new Account_();
a1.setName("ann");
accountService.insert(a1);
Account_ a2 = new Account_();
a2.setName("bob");
accountService.insert(a2);
Account_ ac = new Account_();
Account_ account1 = accountService.selectOne(ac);
Assert.assertEquals("ann", account1.getName());
Collection<Account_> accountC = accountService.selectAll(ac);
Assert.assertEquals(2, accountC.size());
}
use of com.github.springtestdbunit.annotation.DatabaseSetup in project mybatis.flying by limeng32.
the class ThreadTest method testExampleThread.
/**
* 这是一个展示Junit配合Groboutils进行多线程测试的例子,在这个例子中accountInsert以子线程的方式执行多次,
* 主线程会等待子线程全部执行完后再结束
*/
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/threadTest/testExampleThread.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/threadTest/testExampleThread.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/threadTest/testExampleThread.result.xml")
public void testExampleThread() throws Throwable {
// 实例化 TestRunnable 类
TestRunnable tr1, tr2;
tr1 = new accountInsert(2L, "ann");
tr2 = new accountInsert(3L, "ann");
// 把实例传递给 MTTR
TestRunnable[] trs = { tr1, tr2 };
MultiThreadedTestRunner mttr = new MultiThreadedTestRunner(trs);
// 执行MTTR和线程
mttr.runTestRunnables();
}
Aggregations