Search in sources :

Example 31 with Invocation

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

the class InvokerUtils method syncInvoke.

public static Object syncInvoke(String microserviceName, String microserviceVersion, String transport, String schemaId, String operationName, Object[] args) {
    ReferenceConfig referenceConfig = new ReferenceConfig(microserviceName, microserviceVersion, transport);
    SchemaMeta schemaMeta = referenceConfig.getMicroserviceMeta().ensureFindSchemaMeta(schemaId);
    Invocation invocation = InvocationFactory.forConsumer(referenceConfig, schemaMeta, operationName, args);
    return syncInvoke(invocation);
}
Also used : Invocation(io.servicecomb.core.Invocation) SchemaMeta(io.servicecomb.core.definition.SchemaMeta)

Example 32 with Invocation

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

the class TestVertxRestServer method testSetHttpRequestContext.

@Test
public void testSetHttpRequestContext() {
    boolean status = false;
    try {
        Invocation invocation = Mockito.mock(Invocation.class);
        RestServerRequestInternal restRequest = Mockito.mock(RestServerRequestInternal.class);
        instance.setHttpRequestContext(invocation, restRequest);
        Assert.assertNotNull(instance);
    } catch (Exception e) {
        status = true;
    }
    Assert.assertFalse(status);
}
Also used : Invocation(io.servicecomb.core.Invocation) RestServerRequestInternal(io.servicecomb.common.rest.codec.RestServerRequestInternal) Test(org.junit.Test)

Example 33 with Invocation

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

the class TestVertxRestTransport method testSendException.

@Test
public void testSendException() {
    boolean validAssert;
    Invocation invocation = Mockito.mock(Invocation.class);
    AsyncResponse asyncResp = Mockito.mock(AsyncResponse.class);
    URIEndpointObject endpoint = Mockito.mock(URIEndpointObject.class);
    Endpoint end = Mockito.mock(Endpoint.class);
    Mockito.when(invocation.getEndpoint()).thenReturn(end);
    Mockito.when(invocation.getEndpoint().getAddress()).thenReturn(endpoint);
    try {
        validAssert = true;
        instance.send(invocation, asyncResp);
    } catch (Exception e) {
        validAssert = false;
    }
    Assert.assertFalse(validAssert);
}
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)

Example 34 with Invocation

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

the class TestServletHttpRequestCreator method testCreateMockParam.

@Test
public void testCreateMockParam() {
    boolean status = true;
    try {
        HttpServletRequest httpRequest = Mockito.mock(HttpServletRequest.class);
        ProducerServletHttpRequestArgMapper servletHttpRequestCreator = new ProducerServletHttpRequestArgMapper(httpRequest);
        Invocation invocation = Mockito.mock(Invocation.class);
        servletHttpRequestCreator.createContextArg(invocation);
    } catch (Exception ex) {
        status = false;
    }
    Assert.assertTrue(status);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Invocation(io.servicecomb.core.Invocation) Test(org.junit.Test)

Example 35 with Invocation

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

the class TestServletRestServer method testSetHttpRequestContext.

@Test
public void testSetHttpRequestContext() {
    boolean status = true;
    try {
        Invocation invocation = Mockito.mock(Invocation.class);
        RestServerRequestInternal restRequest = Mockito.mock(RestServerRequestInternal.class);
        servletRestServer.setHttpRequestContext(invocation, restRequest);
    } catch (Exception exce) {
        Assert.assertNotNull(exce);
        status = false;
    }
    Assert.assertTrue(status);
}
Also used : Invocation(io.servicecomb.core.Invocation) RestServerRequestInternal(io.servicecomb.common.rest.codec.RestServerRequestInternal) Test(org.junit.Test)

Aggregations

Invocation (io.servicecomb.core.Invocation)70 Test (org.junit.Test)55 OperationMeta (io.servicecomb.core.definition.OperationMeta)29 Response (io.servicecomb.core.Response)20 AsyncResponse (io.servicecomb.core.AsyncResponse)19 RestOperationMeta (io.servicecomb.common.rest.definition.RestOperationMeta)10 HystrixCommandProperties (com.netflix.hystrix.HystrixCommandProperties)9 OperationProtobuf (io.servicecomb.codec.protobuf.definition.OperationProtobuf)9 WrapSchema (io.servicecomb.codec.protobuf.utils.WrapSchema)9 MockUp (mockit.MockUp)9 InvocationException (io.servicecomb.core.exception.InvocationException)8 Endpoint (io.servicecomb.core.Endpoint)7 IpPort (io.servicecomb.foundation.common.net.IpPort)6 HttpClientRequest (io.vertx.core.http.HttpClientRequest)6 HttpClientResponse (io.vertx.core.http.HttpClientResponse)6 URLPathBuilder (io.servicecomb.common.rest.definition.path.URLPathBuilder)5 Buffer (io.vertx.core.buffer.Buffer)5 HttpClient (io.vertx.core.http.HttpClient)4 ArrayList (java.util.ArrayList)4 ProduceProcessor (io.servicecomb.common.rest.codec.produce.ProduceProcessor)3