Search in sources :

Example 1 with InvocationType

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);
    });
}
Also used : Invocation(org.apache.servicecomb.core.Invocation) InvocationException(org.apache.servicecomb.swagger.invocation.exception.InvocationException) Holder(javax.xml.ws.Holder) InvocationType(org.apache.servicecomb.swagger.invocation.InvocationType) Mock(mockit.Mock) Test(org.junit.Test)

Aggregations

Holder (javax.xml.ws.Holder)1 Mock (mockit.Mock)1 Invocation (org.apache.servicecomb.core.Invocation)1 InvocationType (org.apache.servicecomb.swagger.invocation.InvocationType)1 InvocationException (org.apache.servicecomb.swagger.invocation.exception.InvocationException)1 Test (org.junit.Test)1