Search in sources :

Example 1 with TestRunnable

use of net.sourceforge.groboutils.junit.v1.TestRunnable 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 {
    // 实例化 TestRunnableTestRunnable tr1, tr2;
    tr1 = new acctionSelect();
    tr2 = new acctionUpdate();
    // 把实例传递给 MTTR
    TestRunnable[] trs = { tr1, tr2 };
    MultiThreadedTestRunner mttr = new MultiThreadedTestRunner(trs);
    // 执行MTTR和线程
    mttr.runTestRunnables();
}
Also used : TestRunnable(net.sourceforge.groboutils.junit.v1.TestRunnable) MultiThreadedTestRunner(net.sourceforge.groboutils.junit.v1.MultiThreadedTestRunner) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 2 with TestRunnable

use of net.sourceforge.groboutils.junit.v1.TestRunnable 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 {
    // 实例化 TestRunnableTestRunnable 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();
}
Also used : TestRunnable(net.sourceforge.groboutils.junit.v1.TestRunnable) MultiThreadedTestRunner(net.sourceforge.groboutils.junit.v1.MultiThreadedTestRunner) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Aggregations

DatabaseSetup (com.github.springtestdbunit.annotation.DatabaseSetup)2 DatabaseTearDown (com.github.springtestdbunit.annotation.DatabaseTearDown)2 ExpectedDatabase (com.github.springtestdbunit.annotation.ExpectedDatabase)2 MultiThreadedTestRunner (net.sourceforge.groboutils.junit.v1.MultiThreadedTestRunner)2 TestRunnable (net.sourceforge.groboutils.junit.v1.TestRunnable)2 Test (org.junit.Test)2