use of com.alipay.sofa.ark.springboot.runner.ArkBootRunner in project sofa-ark by alipay.
the class ArkBootRunnerTest method test.
@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());
}
Aggregations