com.github.springtestdbunit.annotation.DatabaseTearDown Java Examples

The following examples show how to use com.github.springtestdbunit.annotation.DatabaseTearDown. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConditionInTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
/** 测试无外键情况下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);
}
 
Example #2
Source File: AccountTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
/** 测试deputyRole */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTest/testDeputy.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTest/testDeputy.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTest/testDeputy.xml")
public void testDeputy() {
	Account_ account = accountService.select(1);
	Assert.assertEquals("role1", account.getRole().getName());
	Assert.assertEquals("role2", account.getRoleDeputy().getName());

	Role_ rc = new Role_();
	rc.setName("role1");
	Role_ rdc = new Role_();
	rdc.setName("role2");
	Account_ ac = new Account_();
	ac.setRole(rc);
	ac.setRoleDeputy(rdc);
	Collection<Account_> accountC = accountService.selectAll(ac);
	Assert.assertEquals(1, accountC.size());

	int count = accountService.count(ac);
	Assert.assertEquals(1, count);
}
 
Example #3
Source File: OrTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #4
Source File: OrTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
@Test
@DatabaseSetups({
		@DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/orTest/testOrMashup.dataSource1.xml"),
		@DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/orTest/testOrMashup.dataSource2.xml"), })
@ExpectedDatabases({
		@ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/orTest/testOrMashup.dataSource1.result.xml"),
		@ExpectedDatabase(connection = "dataSource2", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/orTest/testOrMashup.dataSource2.result.xml"), })
@DatabaseTearDowns({
		@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/orTest/testOrMashup.dataSource1.result.xml"),
		@DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/orTest/testOrMashup.dataSource2.result.xml"), })
public void testOrMashup() {
	LoginLogSource2Condition l2c = new LoginLogSource2Condition();
	l2c.setAccountEqualsOr2(1L, 2L, "23453");
	int i1 = loginLogSource2Service.count(l2c);
	Assert.assertEquals(3, i1);

	LoginLogSource2Condition l2c2 = new LoginLogSource2Condition();
	l2c2.setAccountEqualsOr3(1L, 2L, "23453", "d4");
	Detail2_ d2c = new Detail2_();
	d2c.setLoginLogSource2(l2c2);
	int i2 = detail2Service.count(d2c);
	Assert.assertEquals(4, i2);
}
 
Example #5
Source File: BatchProcessTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchUpdate11.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchUpdate11.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchUpdate11.xml")
public void testBatchUpdate11() {
	List<String> nameC = new ArrayList<>();
	nameC.add("a2");
	nameC.add("b");
	Account_Condition ac = new Account_Condition();
	ac.setEmail("[email protected]");
	ac.setNameIn(nameC);
	accountService.update(ac);

	Account_Condition ac2 = new Account_Condition();
	ac2.setEmail("[email protected]");
	ac2.setNameIn(new ArrayList<String>());
	accountService.update(ac2);
}
 
Example #6
Source File: BatchProcessTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchUpdate10.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchUpdate10.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchUpdate10.xml")
public void testBatchUpdate10() {
	Account_Condition ac = new Account_Condition();
	ac.setEmail("[email protected]");
	ac.setNameIsNull(true);
	accountService.update(ac);

	Account_Condition ac2 = new Account_Condition();
	ac2.setEmail("[email protected]");
	ac2.setNameIsNull(false);
	ac2.setActivateValueEqual("aaa");
	accountService.update(ac2);
}
 
Example #7
Source File: PrefixTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
@Test
@DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/prefixTest/testSelect4.xml")
@ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/prefixTest/testSelect4.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/prefixTest/testSelect4.result.xml")
public void testSelect4() {
	Detail_ dc = new Detail_();
	dc.setName("d3");
	LoginLog_Condition lc = new LoginLog_Condition();
	lc.setIdNotEqual(102);
	dc.setLoginLog(lc);
	lc.setAccount(new Account_());
	lc.getAccount().setRoleDeputy(new Role_Condition());
	((Role_Condition) (lc.getAccount().getRoleDeputy())).setNameNotEquals("roleDeputy3");
	Collection<Detail_> detailC = detailService.selectAllPrefix2(dc);
	Assert.assertEquals(1, detailC.size());
}
 
Example #8
Source File: ConditionNotInTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
/** 测试有外键情况下condition:notIn功能 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionNotInTest/testConditionIn2.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionNotInTest/testConditionIn2.xml")
public void testConditionNotIn2() {
	LoginLog_Condition lc = new LoginLog_Condition();
	Account_Condition ac = new Account_Condition();
	List<String> nameC = new ArrayList<>();
	nameC.add("ann");
	nameC.add("bob");
	ac.setNameNotIn(nameC);
	lc.setAccount(ac);
	Collection<LoginLog_> c = loginLogService.selectAll(lc);
	Assert.assertEquals(0, c.size());
	int count = loginLogService.count(lc);
	Assert.assertEquals(0, count);

	Collection<LoginLog_> c2 = loginLogService.selectAllPrefix(lc);
	Assert.assertEquals(0, c2.size());
	int count2 = loginLogService.count(lc);
	Assert.assertEquals(0, count2);
}
 
Example #9
Source File: ConditionNotInTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
/** 测试无外键情况下condition:notIn功能 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionNotInTest/testConditionIn.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionNotInTest/testConditionIn.xml")
public void testConditionNotIn() {
	Account_Condition ac = new Account_Condition();
	List<String> nameC = new ArrayList<>();
	nameC.add("ann");
	ac.setNameNotIn(nameC);
	Collection<Account_> c = accountService.selectAll(ac);
	Assert.assertEquals(1, c.size());

	nameC.add("bob");
	Collection<Account_> c2 = accountService.selectAll(ac);
	Assert.assertEquals(0, c2.size());

	List<String> nameC2 = new ArrayList<>();
	ac.setNameNotIn(nameC2);
	Collection<Account_> c3 = accountService.selectAll(ac);
	Assert.assertEquals(2, c3.size());
}
 
Example #10
Source File: IgnoreInsertAndUpdateTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
@Test
@DatabaseSetups({
		@DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/ignoreInsertAndUpdateTest/testUpdate.datasource2.xml") })
@ExpectedDatabases({
		@ExpectedDatabase(connection = "dataSource2", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/ignoreInsertAndUpdateTest/testUpdate.datasource2.result.xml") })
@DatabaseTearDowns({
		@DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/ignoreInsertAndUpdateTest/testUpdate.datasource2.result.xml") })
public void testUpdate() {
	Detail2_ detail = detail2Service.select(1);
	detail.setName("n1New");
	detail.setDetail("dNew");
	LoginLogSource2 log = loginLogSource2Service.select(12);
	detail.setLoginLogSource2(log);
	detail2Service.updateWithoutName(detail);

	Detail2_ detail2 = detail2Service.select(2);
	detail2.setName(null);
	detail2.setNumber(null);
	detail2.setLoginLogSource2(null);
	detail2Service.updatePersistentWithoutName(detail2);
}
 
Example #11
Source File: IgnoreInsertAndUpdateTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #12
Source File: WhiteListTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
@Test
@DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteList.xml")
@ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteList.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteList.result.xml")
public void testWhiteList() {
	Account_ account = accountService.selectSimple(1);
	Assert.assertNull(account.getEmail());
	Assert.assertNull(account.getPassword());
	Assert.assertNull(account.getPermission().getName());
	Assert.assertNull(account.getPermission().getFakeId());

	LoginLog_ l = new LoginLog_();
	l.setLoginIP("ip1");
	LoginLog_ loginLog = loginLogService.selectOneSimple(l);
	Assert.assertNull(loginLog.getLoginIP2());
	Assert.assertNull(loginLog.getAccount().getEmail());
	Assert.assertNull(loginLog.getAccount().getPassword());
	Assert.assertNull(loginLog.getAccount().getPermission().getName());
	Assert.assertNull(loginLog.getAccount().getPermission().getFakeId());
}
 
Example #13
Source File: WhiteListTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
@Test
@DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteListInsert.xml")
@ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteListInsert.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteListInsert.result.xml")
public void testWhiteListInsert() {
	Account_ account = new Account_();
	account.setName("name");
	account.setEmail("email");
	account.setPassword("aaa");
	Role_ role = new Role_();
	role.setId(11);
	account.setRole(role);
	Permission permission = new Permission();
	permission.setId(22);
	account.setPermission(permission);
	accountService.insertSimpleNoName(account);
}
 
Example #14
Source File: ConditionNotInTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
/** 测试无外键情况下condition:notIn功能且变量类型为时间的情况 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionNotInTest/testConditionIn4.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionNotInTest/testConditionIn4.xml")
public void testConditionNotIn4() {
	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.setLoginTimeNotIn(timeC);
	int count = loginLogService.count(lc);
	Assert.assertEquals(0, count);
}
 
Example #15
Source File: AccountTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
/** 测试limiter功能 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTest/testLimiter.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTest/testLimiter.xml")
public void testLimiter() {
	Account_Condition ac = new Account_Condition();
	ac.setLimiter(new PageParam(1, 2));
	Collection<Account_> c = accountService.selectAll(ac);
	Account_[] accounts = c.toArray(new Account_[c.size()]);
	Assert.assertEquals(2, accounts.length);
	Assert.assertEquals(1, accounts[0].getId().intValue());
	Assert.assertEquals(2, accounts[1].getId().intValue());
	Assert.assertEquals(2, ac.getLimiter().getMaxPageNum());
	ac.setSorter(new SortParam(new Order(Account_Condition.field_id, Conditionable.Sequence.DESC)));
	c = accountService.selectAll(ac);
	accounts = c.toArray(new Account_[c.size()]);
	Assert.assertEquals(2, accounts.length);
	Assert.assertEquals(4, accounts[0].getId().intValue());
	Assert.assertEquals(3, accounts[1].getId().intValue());
}
 
Example #16
Source File: AccountTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
/** 测试CostumizeStatus功能 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTest/testCostumizeStatus.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTest/testCostumizeStatus.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTest/testCostumizeStatus.xml")
public void testCostumizeStatus() {
	Account_ a = accountService.select(1);
	Assert.assertEquals("发布", a.getStatus().text());
	Account_ ac = new Account_();
	ac.setStatus(StoryStatus_.p);
	Collection<Account_> c = accountService.selectAll(ac);
	Assert.assertEquals(1, c.size());
	Account_ a2 = accountService.select(2);
	Assert.assertEquals(StoryStatus_.s, a2.getStatus());
	a2.setStatus(StoryStatus_.c);
	accountService.update(a2);
	Account_ a3 = accountService.select(3);
	Assert.assertNull(a3.getStatus());
	a3.setPassword("5a690d842935c51f26f473e025c1b97a");
	accountService.updatePersistent(a3);
	Account_ a4 = accountService.select(3);
	Assert.assertNull(a4.getStatus());
}
 
Example #17
Source File: AccountTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
/** 测试sorter功能 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTest/testSorter.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTest/testSorter.xml")
public void testSorter() {
	Account_Condition ac = new Account_Condition();
	ac.setSorter(new SortParam(new Order(Account_Condition.field_name, Conditionable.Sequence.DESC)));
	Collection<Account_> c = accountService.selectAll(ac);
	Account_[] accounts = c.toArray(new Account_[c.size()]);
	Assert.assertEquals("ann", accounts[3].getName());
	ac.setSorter(new SortParam(new Order(Account_Condition.field_name, Conditionable.Sequence.DESC),
			new Order(Account_Condition.field_password, Conditionable.Sequence.DESC)));
	c = accountService.selectAll(ac);
	accounts = c.toArray(new Account_[c.size()]);
	Assert.assertEquals(new Long(4), accounts[0].getId());
	ac.setSorter(new SortParam(new Order(Account_Condition.field_name, Conditionable.Sequence.DESC),
			new Order(Account_Condition.field_name, Conditionable.Sequence.ASC)));
	c = accountService.selectAll(ac);
	accounts = c.toArray(new Account_[c.size()]);
	Assert.assertEquals("ann", accounts[3].getName());
}
 
Example #18
Source File: WhiteListTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
@Test
@DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteListInsertBatch.xml")
@ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteListInsertBatch.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteListInsertBatch.result.xml")
public void testWhiteListInsertBatch() {
	Account_ account = new Account_();
	account.setName("name");
	account.setEmail("email");
	account.setPassword("aaa");
	Role_ role = new Role_();
	role.setId(11);
	account.setRole(role);
	Permission permission = new Permission();
	permission.setId(22);
	account.setPermission(permission);

	Collection<Account_> ac = new ArrayList<>();
	ac.add(account);
	accountService.insertBatchSimpleNoName(ac);
}
 
Example #19
Source File: ConditionTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
/** 测试condition:headLike功能 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionTest/testConditionHeadLike.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionTest/testConditionHeadLike.xml")
public void testConditionHeadLike() {
	Account_Condition ac = new Account_Condition();
	ac.setEmailHeadLike("ann");
	Collection<Account_> c = accountService.selectAll(ac);
	Account_[] accounts = c.toArray(new Account_[c.size()]);
	Assert.assertEquals(1, accounts.length);
	Assert.assertEquals("[email protected]", accounts[0].getEmail());

	Account_Condition3 ac2 = new Account_Condition3();
	ac2.setEmailHeadLike("1");
	Collection<Account_> c2 = accountService.selectAll(ac2);
	Account_[] accounts2 = c2.toArray(new Account_[c2.size()]);
	Assert.assertEquals(1, accounts2.length);
	Assert.assertEquals("[email protected]", accounts2[0].getEmail());
}
 
Example #20
Source File: JpaTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
@Test
@DatabaseSetups({
		@DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/jpaTest/testDetail2.datasource2.xml") })
@ExpectedDatabases({
		@ExpectedDatabase(connection = "dataSource2", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/jpaTest/testDetail2.datasource2.result.xml") })
@DatabaseTearDowns({
		@DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/jpaTest/testDetail2.datasource2.result.xml") })
public void testDetail2() {
	Detail2_ detail2 = detail2Service.select(1);
	Assert.assertEquals("n", detail2.getName());
	Assert.assertEquals(123, detail2.getNumber().intValue());
	Assert.assertEquals("l", detail2.getLoginLogSource2().getLoginIP());
	loginLogSource2Service.update(detail2.getLoginLogSource2());

	Detail2_ detail2_2 = new Detail2_();
	detail2_2.setName("name");
	detail2_2.setDetail("detail");
	detail2_2.setNumber(321);
	detail2Service.insert(detail2_2);

	Detail2_ detail2_c = new Detail2_();
	detail2_c.setName("name");
	detail2_c.setDetail("detail");
	Detail2_ detail2_3 = detail2Service.selectOne(detail2_c);
	Assert.assertEquals(detail2_2.getId(), detail2_3.getId());
}
 
Example #21
Source File: WhiteListTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
@Test
@DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteListUpdatePersistent.xml")
@ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteListUpdatePersistent.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteListUpdatePersistent.result.xml")
public void testWhiteListUpdatePersistent() {
	Account_ account = accountService.select(1);
	account.setName("bob");
	account.setEmail("[email protected]");
	account.setPassword("bbb");
	account.setStatus(StoryStatus_.p);
	account.setActivateValue(null);
	Role_ role = new Role_();
	role.setId(33);
	account.setRole(role);
	accountService.updatePersistentSimpleNoName(account);
}
 
Example #22
Source File: AccountTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
@Test
@DatabaseSetups({
		@DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTest/testTransactive2.datasource.xml"),
		@DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTest/testTransactive2.datasource2.xml") })
@ExpectedDatabases({
		@ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTest/testTransactive2.datasource.result.xml"),
		@ExpectedDatabase(connection = "dataSource2", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTest/testTransactive2.datasource2.result.xml") })
@DatabaseTearDowns({
		@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTest/testTransactive2.datasource.result.xml"),
		@DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTest/testTransactive2.datasource2.result.xml") })
public void testTransactive2() {
	try {
		transactiveService.addAccountTransactive();
	} catch (ConfigurerException e) {
		e.printStackTrace();
	}
}
 
Example #23
Source File: ConditionTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
/** 测试多重外键情况下sorter是否能正确发挥作用 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionTest/testSorterWithMultiAssociation.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/conditionTest/testSorterWithMultiAssociation.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionTest/testSorterWithMultiAssociation.xml")
public void testSorterWithMultiAssociation() {
	Role_Condition rc1 = new Role_Condition();
	rc1.setName("role1");
	Role_Condition rc2 = new Role_Condition();
	rc2.setName("role2");
	Account_Condition ac = new Account_Condition();
	ac.setRole(rc1);
	ac.setRoleDeputy(rc2);
	ac.setSorter(new SortParam(new Order("name", Sequence.ASC)));
	Collection<Account_> accountC = accountService.selectAll(ac);
	Account_[] accounts = accountC.toArray(new Account_[accountC.size()]);
	Assert.assertEquals(3, accounts.length);
	Assert.assertEquals("bob", accounts[0].getName());
}
 
Example #24
Source File: SelectOneTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
/** 测试selectOne1 */
@Test
@DatabaseSetup(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/selectOneTest/testSelectOne1.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/selectOneTest/testSelectOne1.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/selectOneTest/testSelectOne1.result.xml")
public void testSelectOne1() {
	Account_ a1 = new Account_();
	a1.setName("ann");
	a1.setEmail("[email protected]");
	accountService.insert(a1);
	Account_ a2 = new Account_();
	a2.setName("bob");
	a2.setEmail("[email protected]");
	accountService.insert(a2);

	accountService.update(a2);
	accountService.updatePersistent(a2);
	Account_ account_ = accountService.select(a2.getId());

	Account_ ac = new Account_();
	ac.setName("bob");
	ac.setEmail("[email protected]");
	Account_ account = accountService.selectOne(ac);
	Assert.assertEquals("[email protected]", account.getEmail());
}
 
Example #25
Source File: SelectOneTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
/** 测试selectOne2 */
@Test
@DatabaseSetup(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/selectOneTest/testSelectOne2.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/selectOneTest/testSelectOne2.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/selectOneTest/testSelectOne2.result.xml")
public void testSelectOne2() {
	Account_ a1 = new Account_();
	a1.setName("ann");
	a1.setEmail("[email protected]");
	accountService.insert(a1);
	Account_ a2 = new Account_();
	a2.setName("ann");
	a2.setEmail("[email protected]");
	accountService.insert(a2);

	Account_Condition ac = new Account_Condition();
	ac.setLimiter(new PageParam(1, 2));
	ac.setSorter(new SortParam(new Order("id", Sequence.ASC)));
	ac.setName("ann");
	Account_ account = accountService.selectOne(ac);
	Assert.assertEquals("[email protected]", account.getEmail());
	Assert.assertNull(ac.getLimiter());
}
 
Example #26
Source File: SelectOneTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
/** 测试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());
}
 
Example #27
Source File: DelegateTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/delegateTest/testDelegateCondition.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/delegateTest/testDelegateCondition.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/delegateTest/testDelegateCondition.xml")
public void testDelegateCondition() {
	LoginLog_Condition lc = new LoginLog_Condition();
	lc.setIpLikeFilter("0.1");
	Account_ a = new Account_();
	a.setName("ann");
	a.setDelegateRoleId(3L);
	lc.setAccount(a);
	LoginLog_ loginLog = loginLogService.selectOne(lc);
	Assert.assertEquals("0.0.0.1", loginLog.getLoginIP());

	a.setDelegateRoleId(4L);
	loginLog = loginLogService.selectOne(lc);
	Assert.assertNull(loginLog);
}
 
Example #28
Source File: DelegateTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/delegateTest/testDelegateInsertBatch.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/delegateTest/testDelegateInsertBatch.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/delegateTest/testDelegateInsertBatch.xml")
public void testDelegateInsertBatch() {
	Collection<LoginLog_> c = new LinkedList<>();
	LoginLog_ l1 = new LoginLog_();
	l1.setLoginIP("0.0.0.1");
	l1.setDelegateAccountId(1L);
	c.add(l1);
	LoginLog_ l2 = new LoginLog_();
	l2.setLoginIP("0.0.0.2");
	l2.setDelegateAccountId(2L);
	c.add(l2);
	loginLogService.insertBatch(c);
}
 
Example #29
Source File: DelegateTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/delegateTest/testDelegateUpdate.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/delegateTest/testDelegateUpdate.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/delegateTest/testDelegateUpdate.xml")
public void testDelegateUpdate() {
	LoginLog_ loginLog = loginLogService.select(1);
	loginLog.setAccount(null);
	loginLog.setDelegateAccountId(2L);
	loginLogService.update(loginLog);

	// 当login.getAccount()不为null时,修改accountId不起作用
	LoginLog_ loginLog2 = loginLogService.select(1);
	loginLog2.setDelegateAccountId(11L);
	loginLogService.update(loginLog2);

}
 
Example #30
Source File: WhiteListTest.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
@Test
@DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteListUpdate.xml")
@ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteListUpdate.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/whiteListTest/testWhiteListUpdate.result.xml")
public void testWhiteListUpdate() {
	Account_ account = accountService.select(1);
	account.setName("bob");
	account.setEmail("[email protected]");
	account.setPassword("bbb");
	account.setStatus(StoryStatus_.p);
	account.setActivateValue("bv");
	Role_ role = new Role_();
	role.setId(2);
	account.setRole(role);
	Permission permission = new Permission();
	permission.setId(22);
	account.setPermission(permission);
	accountService.updateSimpleNoName(account);
}