use of org.apache.servicecomb.swagger.invocation.InvocationType in project incubator-servicecomb-java-chassis by apache.
the class TestShutdownHookHandler method testShutdownHookHandlerReject.
@Test
public void testShutdownHookHandlerReject() throws Exception {
Deencapsulation.setField(ShutdownHookHandler.INSTANCE, "shuttingDown", true);
Holder<InvocationType> typeHolder = new Holder<>(InvocationType.PRODUCER);
Invocation invocation = new MockUp<Invocation>() {
@Mock
public InvocationType getInvocationType() {
return typeHolder.value;
}
}.getMockInstance();
ShutdownHookHandler handler = ShutdownHookHandler.INSTANCE;
handler.handle(invocation, asyncResp -> {
InvocationException e = asyncResp.getResult();
Assert.assertEquals(((CommonExceptionData) e.getErrorData()).getMessage(), "shutting down in progress");
Assert.assertEquals(e.getStatusCode(), 590);
});
typeHolder.value = InvocationType.CONSUMER;
handler.handle(invocation, asyncResp -> {
InvocationException e = asyncResp.getResult();
Assert.assertEquals(((CommonExceptionData) e.getErrorData()).getMessage(), "shutting down in progress");
Assert.assertEquals(e.getStatusCode(), 490);
});
}
Aggregations