Search in sources :

Example 6 with RestProducerInvocation

use of org.apache.servicecomb.common.rest.RestProducerInvocation in project incubator-servicecomb-java-chassis by apache.

the class TestVertxRestDispatcher method failureHandlerErrorDataWithInvocation.

@Test
public void failureHandlerErrorDataWithInvocation(@Mocked RoutingContext context, @Mocked InvocationException e) {
    RestProducerInvocation restProducerInvocation = new RestProducerInvocation();
    ErrorDataDecoderException edde = new ErrorDataDecoderException(e);
    new Expectations() {

        {
            context.get(RestConst.REST_PRODUCER_INVOCATION);
            result = restProducerInvocation;
            context.failure();
            returns(edde, edde);
        }
    };
    Deencapsulation.invoke(dispatcher, "failureHandler", context);
    Assert.assertSame(e, this.throwable);
}
Also used : Expectations(mockit.Expectations) RestProducerInvocation(org.apache.servicecomb.common.rest.RestProducerInvocation) ErrorDataDecoderException(io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.ErrorDataDecoderException) Test(org.junit.Test)

Example 7 with RestProducerInvocation

use of org.apache.servicecomb.common.rest.RestProducerInvocation in project incubator-servicecomb-java-chassis by apache.

the class TestVertxRestDispatcher method failureHandlerNormal.

@Test
public void failureHandlerNormal(@Mocked RoutingContext context) {
    RestProducerInvocation restProducerInvocation = new RestProducerInvocation();
    Exception e = new Exception();
    new Expectations() {

        {
            context.get(RestConst.REST_PRODUCER_INVOCATION);
            result = restProducerInvocation;
            context.failure();
            returns(e, e);
        }
    };
    Deencapsulation.invoke(dispatcher, "failureHandler", context);
    Assert.assertSame(e, this.throwable);
}
Also used : Expectations(mockit.Expectations) RestProducerInvocation(org.apache.servicecomb.common.rest.RestProducerInvocation) InvocationException(org.apache.servicecomb.swagger.invocation.exception.InvocationException) ErrorDataDecoderException(io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.ErrorDataDecoderException) Test(org.junit.Test)

Example 8 with RestProducerInvocation

use of org.apache.servicecomb.common.rest.RestProducerInvocation in project java-chassis by ServiceComb.

the class MockHttpServerResponse method failureHandlerErrorDataWithInvocation.

@Test
public void failureHandlerErrorDataWithInvocation(@Mocked RoutingContext context, @Mocked InvocationException e) {
    RestProducerInvocation restProducerInvocation = new RestProducerInvocation();
    ErrorDataDecoderException edde = new ErrorDataDecoderException(e);
    MockHttpServerResponse response = new MockHttpServerResponse();
    new Expectations() {

        {
            context.get(RestConst.REST_PRODUCER_INVOCATION);
            result = restProducerInvocation;
            context.failure();
            returns(edde, edde);
            context.response();
            result = response;
        }
    };
    Deencapsulation.invoke(dispatcher, "failureHandler", context);
    Assert.assertSame(e, this.throwable);
    Assert.assertTrue(response.responseClosed);
}
Also used : Expectations(mockit.Expectations) RestProducerInvocation(org.apache.servicecomb.common.rest.RestProducerInvocation) ErrorDataDecoderException(io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.ErrorDataDecoderException) Test(org.junit.Test)

Example 9 with RestProducerInvocation

use of org.apache.servicecomb.common.rest.RestProducerInvocation in project java-chassis by ServiceComb.

the class MockHttpServerResponse method failureHandlerNormal.

@Test
public void failureHandlerNormal(@Mocked RoutingContext context) {
    RestProducerInvocation restProducerInvocation = new RestProducerInvocation();
    Exception e = new Exception();
    MockHttpServerResponse response = new MockHttpServerResponse();
    new Expectations() {

        {
            context.get(RestConst.REST_PRODUCER_INVOCATION);
            result = restProducerInvocation;
            context.failure();
            returns(e, e);
            context.response();
            result = response;
        }
    };
    Deencapsulation.invoke(dispatcher, "failureHandler", context);
    Assert.assertSame(e, this.throwable);
    Assert.assertTrue(response.responseClosed);
}
Also used : Expectations(mockit.Expectations) RestProducerInvocation(org.apache.servicecomb.common.rest.RestProducerInvocation) InvocationException(org.apache.servicecomb.swagger.invocation.exception.InvocationException) ErrorDataDecoderException(io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.ErrorDataDecoderException) Test(org.junit.Test)

Example 10 with RestProducerInvocation

use of org.apache.servicecomb.common.rest.RestProducerInvocation in project java-chassis by ServiceComb.

the class MockHttpServerResponse method failureHandlerErrorDataWithNormal.

@Test
public void failureHandlerErrorDataWithNormal(@Mocked RoutingContext context) {
    RestProducerInvocation restProducerInvocation = new RestProducerInvocation();
    Exception e = new Exception();
    ErrorDataDecoderException edde = new ErrorDataDecoderException(e);
    MockHttpServerResponse response = new MockHttpServerResponse();
    new Expectations() {

        {
            context.get(RestConst.REST_PRODUCER_INVOCATION);
            result = restProducerInvocation;
            context.failure();
            returns(edde, edde);
            context.response();
            result = response;
        }
    };
    Deencapsulation.invoke(dispatcher, "failureHandler", context);
    Assert.assertSame(edde, this.throwable);
    Assert.assertTrue(response.responseClosed);
}
Also used : Expectations(mockit.Expectations) RestProducerInvocation(org.apache.servicecomb.common.rest.RestProducerInvocation) InvocationException(org.apache.servicecomb.swagger.invocation.exception.InvocationException) ErrorDataDecoderException(io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.ErrorDataDecoderException) ErrorDataDecoderException(io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.ErrorDataDecoderException) Test(org.junit.Test)

Aggregations

RestProducerInvocation (org.apache.servicecomb.common.rest.RestProducerInvocation)10 Test (org.junit.Test)8 ErrorDataDecoderException (io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.ErrorDataDecoderException)6 Expectations (mockit.Expectations)6 InvocationException (org.apache.servicecomb.swagger.invocation.exception.InvocationException)4 RoutingContext (io.vertx.ext.web.RoutingContext)2 HashMap (java.util.HashMap)2 Invocation (org.apache.servicecomb.core.Invocation)2 AccessLogParam (org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam)2 HttpServletRequestEx (org.apache.servicecomb.foundation.vertx.http.HttpServletRequestEx)1 HttpServletResponseEx (org.apache.servicecomb.foundation.vertx.http.HttpServletResponseEx)1 VertxServerRequestToHttpServletRequest (org.apache.servicecomb.foundation.vertx.http.VertxServerRequestToHttpServletRequest)1 VertxServerResponseToHttpServletResponse (org.apache.servicecomb.foundation.vertx.http.VertxServerResponseToHttpServletResponse)1