use of net.sourceforge.groboutils.junit.v1.MultiThreadedTestRunner 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 net.sourceforge.groboutils.junit.v1.MultiThreadedTestRunner 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();
}
Aggregations