Search in sources :

Example 1 with URIEndpointObject

use of io.servicecomb.foundation.common.net.URIEndpointObject in project java-chassis by ServiceComb.

the class TestTcp method testTcpServerStarter.

@Test
public void testTcpServerStarter() {
    URIEndpointObject endpiont = new URIEndpointObject("highway://127.0.0.1:9900");
    TcpServer oStarter = new TcpServer(endpiont);
    oStarter.init(Vertx.vertx(), "", null);
    Assert.assertNotNull(oStarter);
//TODO Need to find a way to Assert TcpServerStarter as this obbject does not return any values.
}
Also used : URIEndpointObject(io.servicecomb.foundation.common.net.URIEndpointObject) TcpServer(io.servicecomb.foundation.vertx.server.TcpServer) Test(org.junit.Test)

Example 2 with URIEndpointObject

use of io.servicecomb.foundation.common.net.URIEndpointObject in project java-chassis by ServiceComb.

the class TestHighwayTransport method commonHighwayMock.

private void commonHighwayMock(Invocation invocation) {
    OperationMeta operationMeta = Mockito.mock(OperationMeta.class);
    Mockito.when(invocation.getOperationMeta()).thenReturn(operationMeta);
    OperationProtobuf operationProtobuf = Mockito.mock(OperationProtobuf.class);
    Mockito.when(operationMeta.getExtData("protobuf")).thenReturn(operationProtobuf);
    Endpoint lEndpoint = Mockito.mock(Endpoint.class);
    Mockito.when(invocation.getEndpoint()).thenReturn(lEndpoint);
    WrapSchema lWrapSchema = Mockito.mock(WrapSchema.class);
    Mockito.when(operationProtobuf.getRequestSchema()).thenReturn(lWrapSchema);
    URIEndpointObject ep = Mockito.mock(URIEndpointObject.class);
    Mockito.when(lEndpoint.getAddress()).thenReturn(ep);
    Mockito.when(ep.getHostOrIp()).thenReturn("127.0.0.1");
    Mockito.when(ep.getPort()).thenReturn(80);
}
Also used : Endpoint(io.servicecomb.core.Endpoint) OperationProtobuf(io.servicecomb.codec.protobuf.definition.OperationProtobuf) OperationMeta(io.servicecomb.core.definition.OperationMeta) WrapSchema(io.servicecomb.codec.protobuf.utils.WrapSchema) URIEndpointObject(io.servicecomb.foundation.common.net.URIEndpointObject)

Example 3 with URIEndpointObject

use of io.servicecomb.foundation.common.net.URIEndpointObject in project java-chassis by ServiceComb.

the class VertxRestTransport method send.

@Override
public void send(Invocation invocation, AsyncResponse asyncResp) throws Exception {
    URIEndpointObject endpoint = (URIEndpointObject) invocation.getEndpoint().getAddress();
    RestTransportClient client = RestTransportClientManager.INSTANCE.getRestTransportClient(endpoint.isSslEnabled());
    client.send(invocation, asyncResp);
}
Also used : RestTransportClient(io.servicecomb.transport.rest.client.RestTransportClient) URIEndpointObject(io.servicecomb.foundation.common.net.URIEndpointObject)

Example 4 with URIEndpointObject

use of io.servicecomb.foundation.common.net.URIEndpointObject in project java-chassis by ServiceComb.

the class TestRestServerVerticle method testRestServerVerticleWithRouter.

@Test
public void testRestServerVerticleWithRouter(@Mocked Transport transport, @Mocked Vertx vertx, @Mocked Context context, @Mocked JsonObject jsonObject, @Mocked Future<Void> startFuture) throws Exception {
    URIEndpointObject endpointObject = new URIEndpointObject("http://127.0.0.1:8080");
    new Expectations() {

        {
            transport.parseAddress("http://127.0.0.1:8080");
            result = endpointObject;
        }
    };
    Endpoint endpiont = new Endpoint(transport, "http://127.0.0.1:8080");
    new Expectations() {

        {
            context.config();
            result = jsonObject;
            jsonObject.getValue(AbstractTransport.ENDPOINT_KEY);
            result = endpiont;
        }
    };
    RestServerVerticle server = new RestServerVerticle();
    // process stuff done by Expectations
    server.init(vertx, context);
    server.start(startFuture);
}
Also used : Expectations(mockit.Expectations) Endpoint(io.servicecomb.core.Endpoint) URIEndpointObject(io.servicecomb.foundation.common.net.URIEndpointObject) Test(org.junit.Test)

Example 5 with URIEndpointObject

use of io.servicecomb.foundation.common.net.URIEndpointObject 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)

Aggregations

URIEndpointObject (io.servicecomb.foundation.common.net.URIEndpointObject)15 Test (org.junit.Test)8 Endpoint (io.servicecomb.core.Endpoint)6 Expectations (mockit.Expectations)5 AsyncResponse (io.servicecomb.core.AsyncResponse)2 Invocation (io.servicecomb.core.Invocation)2 CacheEndpoint (io.servicecomb.serviceregistry.cache.CacheEndpoint)2 RestTransportClient (io.servicecomb.transport.rest.client.RestTransportClient)2 OperationProtobuf (io.servicecomb.codec.protobuf.definition.OperationProtobuf)1 WrapSchema (io.servicecomb.codec.protobuf.utils.WrapSchema)1 OperationMeta (io.servicecomb.core.definition.OperationMeta)1 TcpServer (io.servicecomb.foundation.vertx.server.TcpServer)1 MicroserviceInstance (io.servicecomb.serviceregistry.api.registry.MicroserviceInstance)1 ServiceRegistryClient (io.servicecomb.serviceregistry.client.ServiceRegistryClient)1 ArrayList (java.util.ArrayList)1 DefaultServiceInstance (org.springframework.cloud.client.DefaultServiceInstance)1 ServiceInstance (org.springframework.cloud.client.ServiceInstance)1