Java Code Examples for com.github.springtestdbunit.assertion.DatabaseAssertionMode#NON_STRICT_UNORDERED

The following examples show how to use com.github.springtestdbunit.assertion.DatabaseAssertionMode#NON_STRICT_UNORDERED . 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: 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 2
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 3
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/testBatchUpdate12.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchUpdate12.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchUpdate12.xml")
public void testBatchUpdate12() {
	List<String> nameC = new ArrayList<>();
	nameC.add("a2");
	nameC.add("b");
	Account_Condition ac = new Account_Condition();
	ac.setEmail("[email protected]");
	ac.setNameNotIn(nameC);
	accountService.update(ac);

	Account_ a2 = new Account_();
	a2.setId(2L);
	a2.setPassword("aaa");
	// wrong opLock
	a2.setOpLock(10);
	accountService.update(a2);
}
 
Example 4
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 5
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 6
Source File: CacheTest1.java    From mybatis.flying with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 7
Source File: BatchProcessTest.java    From mybatis.flying with Apache License 2.0 5 votes vote down vote up
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchUpdatePersistent.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchUpdatePersistent.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchUpdatePersistent.xml")
public void testBatchUpdatePersistent() {
	Account_Condition ac = new Account_Condition();
	ac.setId(1L);
	ac.setName("a2");
	ac.setOpLock(1);
	ac.setActivated(false);
	accountService.updatePersistent(ac);
}
 
Example 8
Source File: CacheTest1.java    From mybatis.flying with Apache License 2.0 5 votes vote down vote up
@Test
@IfProfileValue(name = "CACHE", value = "true")
@ExpectedDatabase(connection = "dataSource1", assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/cacheTest/testCacheHit.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/testCacheHit.result.xml")
public void testCacheHit() {
	Role_ role1 = new Role_(), role2 = new Role_();
	role1.setName("silver");
	roleService.insert(role1);

	role2.setName("gold");
	roleService.insert(role2);

	Account_ a1 = new Account_(), a2 = new Account_(), a3 = new Account_();
	a1.setName("ann");
	a1.setRole(role1);
	accountService.insert(a1);

	a2.setName("bob");
	a2.setRole(role1);
	accountService.insert(a2);

	a3.setName("cal");
	a3.setRole(role2);
	accountService.insert(a3);

	Account_ ac1 = new Account_();
	Role_ rc1 = new Role_();
	rc1.setId(role1.getId());
	ac1.setRole(rc1);
	Collection<Account_> accountC1 = accountService.selectAll(ac1);
	Assert.assertEquals(2, accountC1.size());

	Account_ ac2 = new Account_();
	Role_ rc2 = new Role_();
	rc2.setId(role2.getId());
	ac2.setRole(rc2);
	Collection<Account_> accountC2 = accountService.selectAll(ac2);
	Assert.assertEquals(1, accountC2.size());
}
 
Example 9
Source File: CacheTest1.java    From mybatis.flying with Apache License 2.0 5 votes vote down vote up
@Test
@IfProfileValue(name = "CACHE", value = "true")
@ExpectedDatabase(connection = "dataSource1", assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/cacheTest/testPaginationUsingCacheIndeed.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/testPaginationUsingCacheIndeed.result.xml")
public void testPaginationUsingCacheIndeed() {
	Role_ role1 = new Role_(), role2 = new Role_(), role3 = new Role_();
	role1.setName("normal");
	roleService.insert(role1);

	role2.setName("silver");
	roleService.insert(role2);

	role3.setName("gold");
	roleService.insert(role3);

	Role_Condition rc = new Role_Condition();
	rc.setLimiter(new PageParam(1, 2));
	rc.setSorter(new SortParam(new Order("name", Conditionable.Sequence.ASC)));
	Collection<Role_> c1 = roleService.selectAll(rc);
	Assert.assertEquals(2, c1.size());
	Role_[] roles = c1.toArray(new Role_[c1.size()]);
	Assert.assertEquals("gold", roles[0].getName());

	Map<String, Object> m = new HashMap<>(4);
	m.put("name", "gold1");
	m.put("id", roles[0].getId());
	roleService.updateDirect(m);

	Role_Condition rc2 = new Role_Condition();
	rc2.setLimiter(new PageParam(1, 2));
	rc2.setSorter(new SortParam(new Order("name", Conditionable.Sequence.ASC)));
	Collection<Role_> c2 = roleService.selectAll(rc2);
	Assert.assertEquals(2, c2.size());
	Role_[] roles2 = c2.toArray(new Role_[c2.size()]);
	Assert.assertEquals("gold", roles2[0].getName());
}
 
Example 10
Source File: CacheTest1.java    From mybatis.flying with Apache License 2.0 5 votes vote down vote up
@Test
@IfProfileValue(name = "CACHE", value = "true")
@ExpectedDatabase(connection = "dataSource2", assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/cacheTest/testNPlusOne.datasource2.result.xml")
@DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/testNPlusOne.datasource2.result.xml")
public void testNPlusOne() {
	Role2_ r = new Role2_();
	r.setId(1);
	r.setName("root");
	role2Service.insert(r);

	Role2_ r2 = new Role2_();
	r2.setId(2);
	r2.setName("user");
	role2Service.insert(r2);

	Account2_ a = new Account2_();
	a.setId(21);
	a.setEmail("10");
	a.setRole(r);
	account2Service.insert(a);

	Account2_ a2 = new Account2_();
	a2.setId(22);
	a2.setEmail("11");
	a2.setRole(r);
	account2Service.insert(a2);

	Collection<Account2_> accounts = account2Service.selectAll(new Account2_());
	Assert.assertEquals(2, accounts.size());
}
 
Example 11
Source File: CacheTest1.java    From mybatis.flying with Apache License 2.0 5 votes vote down vote up
@Test
@IfProfileValue(name = "CACHE", value = "true")
@ExpectedDatabases({
		@ExpectedDatabase(connection = "dataSource1", assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/cacheTest/testNPlusOne2.datasource1.result.xml"),
		@ExpectedDatabase(connection = "dataSource2", assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/cacheTest/testNPlusOne2.datasource2.result.xml"), })
@DatabaseTearDowns({
		@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/testNPlusOne2.datasource1.result.xml"),
		@DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/testNPlusOne2.datasource2.result.xml"), })
public void testNPlusOne2() {
	Role2_ r = new Role2_();
	r.setId(1);
	r.setName("root");
	role2Service.insert(r);

	Role2_ r2 = new Role2_();
	r2.setId(2);
	r2.setName("user");
	role2Service.insert(r2);

	Account22 a = new Account22();
	a.setId(21);
	a.setEmail("10");
	a.setRole(r);
	account22Service.insert(a);

	Account22 a2 = new Account22();
	a2.setId(22);
	a2.setEmail("11");
	a2.setRole(r);
	account22Service.insert(a2);

	Collection<Account22> accounts = account22Service.selectAll(new Account22());
	Assert.assertEquals(2, accounts.size());
	Collection<Account22> accounts2 = account22Service.selectAll(new Account22());
	Collection<Account22> accounts3 = account22Service.selectAll(new Account22());
}
 
Example 12
Source File: PostsControllerIT.java    From JavaSpringMvcBlog with MIT License 5 votes vote down vote up
@Test
@ExpectedDatabase(value = "data-posts-added.xml", assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED)
@DatabaseTearDown(value = "data.xml", type = DatabaseOperation.TRUNCATE_TABLE) // to reset id sequence, otherwise other tests that insert tags will fail on ExpectedDatabase
public void shouldAddPosts() throws Exception {
    String title = "new post title";
    String text = "new post short text===cut===new post full text Lorem ipsum";
    String tags = "c++, java, hello world";

    mockMvc.perform(post("/posts/create").with(userAdmin()).with(csrf())
            .contentType(MediaType.APPLICATION_FORM_URLENCODED)
            .param("title", title)
            .param("text", text)
            .param("tags", tags))
            .andExpect(status().isFound())
            .andExpect(model().hasNoErrors())
            .andExpect(view().name("redirect:/posts"));

    String text2 = "new post 2 text Lorem ipsum dolor sit amet, consectetur adipiscing elit";
    String tags2 = "java";

    mockMvc.perform(post("/posts/create").with(userAdmin()).with(csrf())
            .contentType(MediaType.APPLICATION_FORM_URLENCODED)
            .param("title", title)
            .param("text", text2)
            .param("tags", tags2))
            .andExpect(status().isFound())
            .andExpect(model().hasNoErrors())
            .andExpect(view().name("redirect:/posts"));
}
 
Example 13
Source File: PostsControllerIT.java    From JavaSpringMvcBlog with MIT License 5 votes vote down vote up
@Test
@ExpectedDatabase(value = "data-post-edited.xml", assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED)
@DatabaseTearDown(value = "data.xml", type = DatabaseOperation.TRUNCATE_TABLE) // to reset id sequence, otherwise other tests that insert tags will fail on ExpectedDatabase
public void shouldEditPosts() throws Exception {
    String title = "edited title";
    String text = "edited Lorem ipsum dolor sit amet, consectetur adipiscing elit";
    String tags = "c, c++, c#";

    mockMvc.perform(post("/posts/1/edit").with(userAdmin()).with(csrf())
            .contentType(MediaType.APPLICATION_FORM_URLENCODED)
            .param("title", title)
            .param("text", text)
            .param("tags", tags))
            .andExpect(status().isFound())
            .andExpect(model().hasNoErrors())
            .andExpect(view().name("redirect:/posts/1"));

    String text2 = "edited short===cut===edited Lorem ipsum dolor sit amet, consectetur adipiscing elit";
    String tags2 = "c++, meow";

    mockMvc.perform(post("/posts/2/edit").with(userAdmin()).with(csrf())
            .contentType(MediaType.APPLICATION_FORM_URLENCODED)
            .param("title", title)
            .param("text", text2)
            .param("tags", tags2))
            .andExpect(status().isFound())
            .andExpect(model().hasNoErrors())
            .andExpect(view().name("redirect:/posts/2"));
}
 
Example 14
Source File: CacheTest1.java    From mybatis.flying with Apache License 2.0 4 votes vote down vote up
@Test
@IfProfileValue(name = "CACHE", value = "true")
@ExpectedDatabase(connection = "dataSource1", assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/cacheTest/testCacheHitByDirectSql.result.xml")
@DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/testCacheHitByDirectSql.result.xml")
public void testCacheHitByDirectSql() {
	Role_ role1 = new Role_(), role2 = new Role_();
	role1.setName("silver");
	roleService.insert(role1);

	role2.setName("gold");
	roleService.insert(role2);

	Account_ a1 = new Account_(), a2 = new Account_(), a3 = new Account_();
	a1.setName("ann");
	a1.setEmail("[email protected]");
	a1.setRole(role1);
	accountService.insert(a1);

	a2.setName("bob");
	a2.setEmail("[email protected]");
	a2.setRole(role1);
	accountService.insert(a2);

	a3.setName("cal");
	a3.setEmail("[email protected]");
	a3.setRole(role2);
	accountService.insert(a3);

	Map<String, Object> map1 = new HashMap<>(4);
	map1.put("role_id", role1.getId());
	Collection<Account_> c1 = accountService.selectAccountByRole(map1);
	Assert.assertEquals(2, c1.size());

	Map<String, Object> map2 = new HashMap<>(4);
	map2.put("role_id", role2.getId());
	Collection<Account_> c2 = accountService.selectAccountByRole(map2);
	Assert.assertEquals(1, c2.size());

	Map<String, Object> map3 = new HashMap<>(4);
	map3.put("name", "ann");
	map3.put("email", "[email protected]");
	Collection<Account_> c3 = accountService.selectAllDirect(map3);
	Assert.assertEquals(1, c3.size());

	Account_ account1 = accountService.select(a1.getId());
	Assert.assertEquals("ann", account1.getName());

	Account_ account2 = accountService.select(a2.getId());
	Assert.assertEquals("bob", account2.getName());

	Account_ account3 = accountService.select(a1.getId());
	Assert.assertEquals("ann", account3.getName());
}
 
Example 15
Source File: CacheTest1.java    From mybatis.flying with Apache License 2.0 4 votes vote down vote up
@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("[email protected]");
	a.setRole(r);
	accountService.insert(a);

	Account_ a2 = new Account_();
	a2.setId(2L);
	a2.setEmail("[email protected]");
	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());
}