Search in sources :

Example 21 with AsyncResponse

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

the class TestVertxPostMethod method testVertxPostMethod.

@Test
public void testVertxPostMethod() {
    Invocation invocation = Mockito.mock(Invocation.class);
    HttpClient client = Mockito.mock(HttpClient.class);
    IpPort ipPort = Mockito.mock(IpPort.class);
    RestOperationMeta operation = Mockito.mock(RestOperationMeta.class);
    AsyncResponse asyncResp = Mockito.mock(AsyncResponse.class);
    Mockito.when(ipPort.getPort()).thenReturn(23);
    assertEquals(23, ipPort.getPort());
    Mockito.when(ipPort.getHostOrIp()).thenReturn("testCall");
    assertNotNull("testCall", ipPort.getHostOrIp());
    HttpClientRequest obj = VertxPostMethod.INSTANCE.createRequest(client, invocation, ipPort, "test", operation, asyncResp);
    Assert.assertNull(obj);
}
Also used : HttpClientRequest(io.vertx.core.http.HttpClientRequest) Invocation(io.servicecomb.core.Invocation) RestOperationMeta(io.servicecomb.common.rest.definition.RestOperationMeta) HttpClient(io.vertx.core.http.HttpClient) IpPort(io.servicecomb.foundation.common.net.IpPort) AsyncResponse(io.servicecomb.core.AsyncResponse) Test(org.junit.Test)

Example 22 with AsyncResponse

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

the class TestServletRestTransport method testSendException.

@Test
public void testSendException() {
    boolean status = true;
    Invocation invocation = Mockito.mock(Invocation.class);
    AsyncResponse asyncResp = Mockito.mock(AsyncResponse.class);
    URIEndpointObject endpoint = Mockito.mock(URIEndpointObject.class);
    Endpoint endpoint1 = Mockito.mock(Endpoint.class);
    Mockito.when(invocation.getEndpoint()).thenReturn(endpoint1);
    Mockito.when(invocation.getEndpoint().getAddress()).thenReturn(endpoint);
    try {
        transport.send(invocation, asyncResp);
    } catch (Exception exce) {
        Assert.assertNotNull(exce);
        status = false;
    }
    Assert.assertFalse(status);
}
Also used : Invocation(io.servicecomb.core.Invocation) Endpoint(io.servicecomb.core.Endpoint) URIEndpointObject(io.servicecomb.foundation.common.net.URIEndpointObject) AsyncResponse(io.servicecomb.core.AsyncResponse) Test(org.junit.Test)

Aggregations

AsyncResponse (io.servicecomb.core.AsyncResponse)22 Invocation (io.servicecomb.core.Invocation)18 Test (org.junit.Test)16 RestOperationMeta (io.servicecomb.common.rest.definition.RestOperationMeta)6 Response (io.servicecomb.core.Response)6 IpPort (io.servicecomb.foundation.common.net.IpPort)6 Endpoint (io.servicecomb.core.Endpoint)5 OperationMeta (io.servicecomb.core.definition.OperationMeta)5 HttpClientRequest (io.vertx.core.http.HttpClientRequest)5 MockUp (mockit.MockUp)5 HttpClient (io.vertx.core.http.HttpClient)4 OperationProtobuf (io.servicecomb.codec.protobuf.definition.OperationProtobuf)3 HttpClientWithContext (io.servicecomb.foundation.vertx.client.http.HttpClientWithContext)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 ExecutionListener (com.netflix.loadbalancer.reactive.ExecutionListener)2 ProduceProcessor (io.servicecomb.common.rest.codec.produce.ProduceProcessor)2 URLPathBuilder (io.servicecomb.common.rest.definition.path.URLPathBuilder)2 InvocationException (io.servicecomb.core.exception.InvocationException)2 SyncResponseExecutor (io.servicecomb.core.provider.consumer.SyncResponseExecutor)2 URIEndpointObject (io.servicecomb.foundation.common.net.URIEndpointObject)2