use of com.github.springtestdbunit.annotation.DatabaseSetup in project mybatis.flying by limeng32.
the class CacheTest method test21.
@Test
@IfProfileValue(name = "CACHE", value = "true")
@DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest2/test.datasource2.xml")
@ExpectedDatabase(connection = "dataSource2", assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/cacheTest2/test.datasource2.result.xml")
@DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest2/test.datasource2.result.xml")
public void test21() {
String name = "ann";
String roleName = "user";
String newRoleName = "admin";
Account2_ a = new Account2_();
Role2_ r = new Role2_();
r.setName(roleName);
role2Service.insert(r);
a.setName(name);
a.setRole(r);
account2Service.insert(a);
Account2_ account2_ = account2Service.select(a.getId());
Assert.assertEquals(roleName, account2_.getRole().getName());
Role2_ r2 = role2Service.select(r.getId());
r2.setName(newRoleName);
role2Service.update(r2);
account2_ = account2Service.select(a.getId());
Assert.assertEquals(newRoleName, account2_.getRole().getName());
}
use of com.github.springtestdbunit.annotation.DatabaseSetup 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.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();
}
use of com.github.springtestdbunit.annotation.DatabaseSetup in project thingsboard by thingsboard.
the class JpaBasePluginDaoTest method testFindByTenantIdAndPageLink.
@Test
@DatabaseSetup("classpath:dbunit/empty_dataset.xml")
public void testFindByTenantIdAndPageLink() {
UUID tenantId1 = UUIDs.timeBased();
UUID tenantId2 = UUIDs.timeBased();
createPluginsTwoTenants(tenantId1, tenantId2, "plugin_");
List<PluginMetaData> rules1 = pluginDao.findByTenantIdAndPageLink(new TenantId(tenantId1), new TextPageLink(20, "plugin_"));
assertEquals(20, rules1.size());
List<PluginMetaData> rules2 = pluginDao.findByTenantIdAndPageLink(new TenantId(tenantId1), new TextPageLink(20, "plugin_", rules1.get(19).getId().getId(), null));
assertEquals(10, rules2.size());
List<PluginMetaData> rules3 = pluginDao.findByTenantIdAndPageLink(new TenantId(tenantId1), new TextPageLink(20, "plugin_", rules2.get(9).getId().getId(), null));
assertEquals(0, rules3.size());
}
use of com.github.springtestdbunit.annotation.DatabaseSetup in project thingsboard by thingsboard.
the class JpaBasePluginDaoTest method testFindAllTenantRulesByTenantId.
@Test
@DatabaseSetup(value = "classpath:dbunit/empty_dataset.xml")
public void testFindAllTenantRulesByTenantId() {
UUID tenantId1 = UUIDs.timeBased();
UUID tenantId2 = UUIDs.timeBased();
createTenantsAndSystemPlugins(tenantId1, tenantId2, "name_");
List<PluginMetaData> rules1 = pluginDao.findAllTenantPluginsByTenantId(tenantId1, new TextPageLink(40, "name_"));
assertEquals(40, rules1.size());
List<PluginMetaData> rules2 = pluginDao.findAllTenantPluginsByTenantId(tenantId1, new TextPageLink(40, "name_", rules1.get(19).getId().getId(), null));
assertEquals(20, rules2.size());
List<PluginMetaData> rules3 = pluginDao.findAllTenantPluginsByTenantId(tenantId1, new TextPageLink(40, "name_", rules2.get(19).getId().getId(), null));
assertEquals(0, rules3.size());
}
Aggregations