Search in sources :

Example 1 with InvocationType

use of io.servicecomb.core.invocation.InvocationType in project java-chassis by ServiceComb.

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(io.servicecomb.core.Invocation) InvocationException(io.servicecomb.core.exception.InvocationException) Holder(javax.xml.ws.Holder) InvocationType(io.servicecomb.core.invocation.InvocationType) Mock(mockit.Mock) Test(org.junit.Test)

Aggregations

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