Search in sources :

Example 1 with AbstractTcpClientPackage

use of org.apache.servicecomb.foundation.vertx.client.tcp.AbstractTcpClientPackage in project incubator-servicecomb-java-chassis by apache.

the class TestHighwayClient method testSend_success_decode_failed.

@Test
public void testSend_success_decode_failed(@Mocked Vertx vertx, @Mocked HighwayClientConnectionPool pool, @Mocked HighwayClientConnection tcpClient) throws Exception {
    new MockUp<HighwayClientConnection>() {

        @Mock
        void send(AbstractTcpClientPackage tcpClientPackage, TcpResponseCallback callback) {
            callback.success(null);
        }
    };
    Object result = doTestSend(vertx, pool, tcpClient, new InvocationException(Status.BAD_REQUEST, (Object) "failed"));
    Assert.assertEquals("failed", ((InvocationException) result).getErrorData());
}
Also used : TcpResponseCallback(org.apache.servicecomb.foundation.vertx.client.tcp.TcpResponseCallback) InvocationException(org.apache.servicecomb.swagger.invocation.exception.InvocationException) MockUp(mockit.MockUp) AbstractTcpClientPackage(org.apache.servicecomb.foundation.vertx.client.tcp.AbstractTcpClientPackage) Test(org.junit.Test)

Example 2 with AbstractTcpClientPackage

use of org.apache.servicecomb.foundation.vertx.client.tcp.AbstractTcpClientPackage in project incubator-servicecomb-java-chassis by apache.

the class TestHighwayClient method testSend_failed.

@Test
public void testSend_failed(@Mocked Vertx vertx, @Mocked HighwayClientConnectionPool pool, @Mocked HighwayClientConnection tcpClient) throws Exception {
    new MockUp<HighwayClientConnection>() {

        @Mock
        void send(AbstractTcpClientPackage tcpClientPackage, TcpResponseCallback callback) {
            callback.fail(new InvocationException(Status.BAD_REQUEST, (Object) "failed"));
        }
    };
    Object result = doTestSend(vertx, pool, tcpClient, null);
    Assert.assertEquals("failed", ((InvocationException) result).getErrorData());
}
Also used : TcpResponseCallback(org.apache.servicecomb.foundation.vertx.client.tcp.TcpResponseCallback) InvocationException(org.apache.servicecomb.swagger.invocation.exception.InvocationException) MockUp(mockit.MockUp) AbstractTcpClientPackage(org.apache.servicecomb.foundation.vertx.client.tcp.AbstractTcpClientPackage) Test(org.junit.Test)

Aggregations

MockUp (mockit.MockUp)2 AbstractTcpClientPackage (org.apache.servicecomb.foundation.vertx.client.tcp.AbstractTcpClientPackage)2 TcpResponseCallback (org.apache.servicecomb.foundation.vertx.client.tcp.TcpResponseCallback)2 InvocationException (org.apache.servicecomb.swagger.invocation.exception.InvocationException)2 Test (org.junit.Test)2