use of org.apache.servicecomb.core.executor.ReactiveExecutor in project incubator-servicecomb-java-chassis by apache.
the class TestAbstractRestInvocation method scheduleInvocationNormal.
@Test
public void scheduleInvocationNormal(@Mocked OperationMeta operationMeta) {
long time = 123;
new MockUp<System>() {
@Mock
long nanoTime() {
return time;
}
};
Holder<InvocationStartEvent> eventHolder = new Holder<>();
Object subscriber = new Object() {
@Subscribe
public void onStart(InvocationStartEvent event) {
eventHolder.value = event;
}
};
EventManager.register(subscriber);
Executor executor = new ReactiveExecutor();
requestEx = new AbstractHttpServletRequest() {
};
requestEx.setAttribute(RestConst.REST_REQUEST, requestEx);
new Expectations() {
{
restOperation.getOperationMeta();
result = operationMeta;
operationMeta.getExecutor();
result = executor;
}
};
Holder<Boolean> result = new Holder<>();
restInvocation = new AbstractRestInvocationForTest() {
@Override
protected void runOnExecutor() {
result.value = true;
}
};
restInvocation.requestEx = requestEx;
restInvocation.restOperationMeta = restOperation;
restInvocation.scheduleInvocation();
EventManager.unregister(subscriber);
Assert.assertTrue(result.value);
Assert.assertEquals(time, invocation.getStartTime());
Assert.assertSame(invocation, eventHolder.value.getInvocation());
}
Aggregations