use of com.github.springtestdbunit.annotation.DatabaseTearDown in project mybatis.flying by limeng32.
the class CacheTest method testInsertSnowFlakeCache.
/* 一个在缓存状态下使用自定义主键生成器insert的测试用例 */
/* 使用普通方式增加一个Account,查询数量为1,再使用自定义主键方式增加一个Account,查询数量为2 */
@Test
@IfProfileValue(name = "CACHE", value = "true")
@ExpectedDatabase(connection = "dataSource1", assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/cacheTest/testInsertSnowFlakeCache.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/testInsertSnowFlakeCache.result.xml")
public void testInsertSnowFlakeCache() {
Account_ account = new Account_();
account.setName("ann");
accountService.insert(account);
int i = accountService.count(new Account_());
Assert.assertEquals(1, i);
Account_ account2 = new Account_();
account2.setName("bob");
accountService.insertSnowFlake(account2);
int i2 = accountService.count(new Account_());
Assert.assertEquals(2, i2);
}
use of com.github.springtestdbunit.annotation.DatabaseTearDown in project mybatis.flying by limeng32.
the class ConditionInTest method testConditionIn.
/**
* 测试无外键情况下condition:in功能
*/
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionInTest/testConditionIn.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionInTest/testConditionIn.xml")
public void testConditionIn() {
Account_Condition ac = new Account_Condition();
List<String> nameC = new ArrayList<>();
nameC.add("ann");
ac.setNameIn(nameC);
Collection<Account_> c = accountService.selectAll(ac);
Assert.assertEquals(1, c.size());
nameC.add("bob");
Collection<Account_> c2 = accountService.selectAll(ac);
Assert.assertEquals(2, c2.size());
List<String> nameC2 = new ArrayList<>();
ac.setNameIn(nameC2);
Collection<Account_> c3 = accountService.selectAll(ac);
Assert.assertEquals(2, c3.size());
}
use of com.github.springtestdbunit.annotation.DatabaseTearDown in project mybatis.flying by limeng32.
the class ConditionInTest method testConditionIn4.
/**
* 测试无外键情况下condition:in功能且变量类型为时间的情况
*/
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionInTest/testConditionIn4.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/conditionInTest/testConditionIn4.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionInTest/testConditionIn4.xml")
public void testConditionIn4() {
LoginLog_Condition lc = new LoginLog_Condition();
List<Date> timeC = new ArrayList<>();
Calendar c = Calendar.getInstance(), c2 = Calendar.getInstance();
c.clear();
c2.clear();
c.set(1970, 0, 1, 8, 0, 0);
c2.set(1970, 0, 1, 8, 0, 1);
timeC.add(c.getTime());
timeC.add(c2.getTime());
lc.setLoginTimeIn(timeC);
int count = loginLogService.count(lc);
Assert.assertEquals(2, count);
}
use of com.github.springtestdbunit.annotation.DatabaseTearDown in project mybatis.flying by limeng32.
the class ConditionInTest method testConditionIn3.
/**
* 测试无外键情况下condition:in功能且变量类型为数字的情况
*/
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionInTest/testConditionIn3.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionInTest/testConditionIn3.xml")
public void testConditionIn3() {
Account_Condition ac = new Account_Condition();
List<Integer> opLockC = new ArrayList<>();
opLockC.add(1);
opLockC.add(2);
ac.setOpLockIn(opLockC);
int count = accountService.count(ac);
Assert.assertEquals(2, count);
}
use of com.github.springtestdbunit.annotation.DatabaseTearDown in project mybatis.flying by limeng32.
the class ConditionInTest method testConditionIn2.
/**
* 测试有外键情况下condition:in功能
*/
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionInTest/testConditionIn2.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionInTest/testConditionIn2.xml")
public void testConditionIn2() {
LoginLog_Condition lc = new LoginLog_Condition();
List<String> loginIpC = new ArrayList<>();
loginIpC.add("11");
loginIpC.add("22");
lc.setLoginIPIn(loginIpC);
Account_Condition ac = new Account_Condition();
List<String> nameC = new ArrayList<>();
nameC.add("ann");
nameC.add("bob");
ac.setNameIn(nameC);
lc.setAccount(ac);
Collection<LoginLog_> c = loginLogService.selectAll(lc);
Assert.assertEquals(2, c.size());
int count = loginLogService.count(lc);
Assert.assertEquals(2, count);
}
Aggregations