use of com.github.springtestdbunit.annotation.DatabaseTearDown in project mybatis.flying by limeng32.
the class ConditionTest method testConditionTailLike.
/**
* 测试condition:tailLike功能
*/
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionTest/testConditionTailLike.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionTest/testConditionTailLike.xml")
public void testConditionTailLike() {
Account_Condition ac = new Account_Condition();
ac.setEmailTailLike("live.cn");
Collection<Account_> c = accountService.selectAll(ac);
Account_[] accounts = c.toArray(new Account_[c.size()]);
Assert.assertEquals(1, accounts.length);
Assert.assertEquals("ann@live.cn", accounts[0].getEmail());
}
use of com.github.springtestdbunit.annotation.DatabaseTearDown in project mybatis.flying by limeng32.
the class InternalCacheTest method testCacheThread.
/**
* 这是一个展示Junit配合Groboutils进行多线程测试的例子,在这个例子中accountInsert以子线程的方式执行多次,
* 主线程会等待子线程全部执行完后再结束
*/
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/internalCacheTest/testCacheThread.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/internalCacheTest/testCacheThread.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/internalCacheTest/testCacheThread.result.xml")
public void testCacheThread() throws Throwable {
// 实例化 TestRunnable 类
TestRunnable tr1, tr2;
tr1 = new acctionSelect();
tr2 = new acctionUpdate();
// 把实例传递给 MTTR
TestRunnable[] trs = { tr1, tr2 };
MultiThreadedTestRunner mttr = new MultiThreadedTestRunner(trs);
// 执行MTTR和线程
mttr.runTestRunnables();
}
use of com.github.springtestdbunit.annotation.DatabaseTearDown in project mybatis.flying by limeng32.
the class NotEqualConditionTest method testConditionGreaterThan.
/**
* 测试condition:greaterThan功能
*/
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/notEqualConditionTest/testConditionGreaterThan.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/notEqualConditionTest/testConditionGreaterThan.xml")
public void testConditionGreaterThan() {
LoginLog_Condition lc = new LoginLog_Condition(), lc2 = new LoginLog_Condition(), lc3 = new LoginLog_Condition(), lc4 = new LoginLog_Condition();
lc.setLoginTimeGreaterThan(new Date(1));
lc.setIdGreaterThan(0);
Collection<LoginLog_> c = loginLogService.selectAll(lc);
Assert.assertEquals(1, c.size());
LoginLog_[] loginlogs = c.toArray(new LoginLog_[c.size()]);
Assert.assertEquals("0.0.0.1", loginlogs[0].getLoginIP());
lc2.setLoginTimeGreaterThan(new Date());
Collection<LoginLog_> c2 = loginLogService.selectAll(lc2);
Assert.assertEquals(0, c2.size());
lc3.setIdGreaterThan(10);
int count3 = loginLogService.count(lc3);
Assert.assertEquals(0, count3);
lc3.setIdGreaterThan(null);
lc3.setIdGreaterOrEqual(10);
count3 = loginLogService.count(lc3);
Assert.assertEquals(1, count3);
lc3.setIdGreaterOrEqual(null);
lc3.setLoginTime(loginlogs[0].getLoginTime());
count3 = loginLogService.count(lc3);
Assert.assertEquals(1, count3);
lc3.setLoginTime(null);
lc3.setLoginTimeNotEqual(loginlogs[0].getLoginTime());
count3 = loginLogService.count(lc3);
Assert.assertEquals(0, count3);
lc4.setIdGreaterThan(9);
int count4 = loginLogService.count(lc4);
Assert.assertEquals(1, count4);
lc4.setIdGreaterThan(null);
lc4.setIdLessThan(11);
count4 = loginLogService.count(lc4);
Assert.assertEquals(1, count4);
lc4.setIdLessThan(10);
count4 = loginLogService.count(lc4);
Assert.assertEquals(0, count4);
lc4.setIdLessThan(null);
lc4.setIdLessOrEqual(10);
count4 = loginLogService.count(lc4);
Assert.assertEquals(1, count4);
lc4.setIdLessOrEqual(null);
lc4.setIdNotEqual(10);
count4 = loginLogService.count(lc4);
Assert.assertEquals(0, count4);
}
use of com.github.springtestdbunit.annotation.DatabaseTearDown in project mybatis.flying by limeng32.
the class NullOrNotTest method testNullOrNot.
/**
* 测试NullOrNot关键字
*/
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/nullOrNotTest/testNullOrNot.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/nullOrNotTest/testNullOrNot.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/nullOrNotTest/testNullOrNot.xml")
public void testNullOrNot() {
Account_Condition ac = new Account_Condition();
ac.setEmailIsNull(true);
Collection<Account_> accountC = accountService.selectAll(ac);
Assert.assertEquals(1, accountC.size());
int count = accountService.count(ac);
Assert.assertEquals(1, count);
Account_Condition ac2 = new Account_Condition();
ac2.setEmailIsNull(false);
Collection<Account_> accountC2 = accountService.selectAll(ac2);
Assert.assertEquals(1, accountC2.size());
int count2 = accountService.count(ac2);
Assert.assertEquals(1, count2);
Account_Condition ac3 = new Account_Condition();
Collection<Account_> accountC3 = accountService.selectAll(ac3);
Assert.assertEquals(2, accountC3.size());
int count3 = accountService.count(ac3);
Assert.assertEquals(2, count3);
Account_Condition ac4 = new Account_Condition();
ac4.setRoleIsNull(true);
Collection<Account_> accountC4 = accountService.selectAll(ac4);
for (Account_ a : accountC4) {
Assert.assertEquals("bob", a.getName());
}
int count4 = accountService.count(ac4);
Assert.assertEquals(1, count4);
Account_Condition ac5 = new Account_Condition();
ac5.setRoleIsNull(false);
Collection<Account_> accountC5 = accountService.selectAll(ac5);
for (Account_ a : accountC5) {
Assert.assertEquals("ann", a.getName());
}
int count5 = accountService.count(ac5);
Assert.assertEquals(1, count5);
}
use of com.github.springtestdbunit.annotation.DatabaseTearDown 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);
}
Aggregations