org.springframework.test.context.junit4.SpringRunner Java Examples

The following examples show how to use org.springframework.test.context.junit4.SpringRunner. 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: ArkBootRunnerTest.java    From sofa-ark with Apache License 2.0 5 votes vote down vote up
@Test
public void test() {
    Assert.assertNotNull(sampleService);
    Assert.assertNotNull(pluginManagerService);
    Assert.assertTrue("SampleService".equals(sampleService.say()));

    ArkBootRunner runner = new ArkBootRunner(ArkBootRunnerTest.class);
    Field field = ReflectionUtils.findField(ArkBootRunner.class, "runner");
    Assert.assertNotNull(field);

    ReflectionUtils.makeAccessible(field);
    BlockJUnit4ClassRunner springRunner = (BlockJUnit4ClassRunner) ReflectionUtils.getField(
        field, runner);
    Assert.assertTrue(springRunner.getClass().getCanonicalName()
        .equals(SpringRunner.class.getCanonicalName()));

    ClassLoader loader = springRunner.getTestClass().getJavaClass().getClassLoader();
    Assert.assertTrue(loader.getClass().getCanonicalName()
        .equals(TestClassLoader.class.getCanonicalName()));

    Assert.assertEquals(0, TestValueHolder.getTestValue());
    eventAdminService.sendEvent(new ArkEvent() {
        @Override
        public String getTopic() {
            return "test-event-A";
        }
    });
    Assert.assertEquals(10, TestValueHolder.getTestValue());
    eventAdminService.sendEvent(new ArkEvent() {
        @Override
        public String getTopic() {
            return "test-event-B";
        }
    });
    Assert.assertEquals(20, TestValueHolder.getTestValue());
}