Search in sources :

Example 11 with Endpoint

use of org.apache.servicecomb.core.Endpoint in project incubator-servicecomb-java-chassis by apache.

the class TestHighwayVerticle method testHighwayVerticle.

@Test
public void testHighwayVerticle(@Mocked Transport transport, @Mocked Vertx vertx, @Mocked Context context, @Mocked JsonObject json) {
    URIEndpointObject endpiontObject = new URIEndpointObject("highway://127.0.0.1:9090");
    new Expectations() {

        {
            transport.parseAddress(anyString);
            result = endpiontObject;
        }
    };
    Endpoint endpoint = new Endpoint(transport, "highway://127.0.0.1:9090");
    new Expectations() {

        {
            context.config();
            result = json;
            json.getValue(anyString);
            result = endpoint;
        }
    };
    highwayVerticle.init(vertx, context);
    @SuppressWarnings("unchecked") Future<Void> startFuture = Mockito.mock(Future.class);
    highwayVerticle.startListen(startFuture);
    MockUtil.getInstance().mockHighwayConfig();
    try {
        highwayVerticle.startListen(startFuture);
        Assert.assertTrue(true);
    } catch (Exception e) {
        Assert.assertTrue(false);
    }
}
Also used : Expectations(mockit.Expectations) Endpoint(org.apache.servicecomb.core.Endpoint) URIEndpointObject(org.apache.servicecomb.foundation.common.net.URIEndpointObject) Test(org.junit.Test)

Example 12 with Endpoint

use of org.apache.servicecomb.core.Endpoint in project incubator-servicecomb-java-chassis by apache.

the class TransportManager method init.

public void init() throws Exception {
    buildTransportMap();
    for (Transport transport : transportMap.values()) {
        if (transport.init()) {
            Endpoint endpoint = transport.getPublishEndpoint();
            if (endpoint != null && endpoint.getEndpoint() != null) {
                LOGGER.info("endpoint to publish: {}", endpoint.getEndpoint());
                Microservice microservice = RegistryUtils.getMicroservice();
                microservice.getInstance().getEndpoints().add(endpoint.getEndpoint());
            }
            continue;
        }
    }
}
Also used : Microservice(org.apache.servicecomb.serviceregistry.api.registry.Microservice) Endpoint(org.apache.servicecomb.core.Endpoint) Transport(org.apache.servicecomb.core.Transport)

Example 13 with Endpoint

use of org.apache.servicecomb.core.Endpoint in project incubator-servicecomb-java-chassis by apache.

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(org.apache.servicecomb.core.Endpoint) URIEndpointObject(org.apache.servicecomb.foundation.common.net.URIEndpointObject) Test(org.junit.Test)

Example 14 with Endpoint

use of org.apache.servicecomb.core.Endpoint in project incubator-servicecomb-java-chassis by apache.

the class TestRestServerVerticle method testRestServerVerticleWithRouterSSL.

@Test
public void testRestServerVerticleWithRouterSSL(@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?sslEnabled=true");
    new Expectations() {

        {
            transport.parseAddress("http://127.0.0.1:8080?sslEnabled=true");
            result = endpointObject;
        }
    };
    Endpoint endpiont = new Endpoint(transport, "http://127.0.0.1:8080?sslEnabled=true");
    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(org.apache.servicecomb.core.Endpoint) URIEndpointObject(org.apache.servicecomb.foundation.common.net.URIEndpointObject) Test(org.junit.Test)

Aggregations

Endpoint (org.apache.servicecomb.core.Endpoint)14 Test (org.junit.Test)9 URIEndpointObject (org.apache.servicecomb.foundation.common.net.URIEndpointObject)8 Invocation (org.apache.servicecomb.core.Invocation)5 OperationMeta (org.apache.servicecomb.core.definition.OperationMeta)5 Expectations (mockit.Expectations)4 RestOperationMeta (org.apache.servicecomb.common.rest.definition.RestOperationMeta)4 AsyncResponse (org.apache.servicecomb.swagger.invocation.AsyncResponse)4 URLPathBuilder (org.apache.servicecomb.common.rest.definition.path.URLPathBuilder)3 HttpClientRequest (io.vertx.core.http.HttpClientRequest)2 HttpClientResponse (io.vertx.core.http.HttpClientResponse)2 ProduceProcessor (org.apache.servicecomb.common.rest.codec.produce.ProduceProcessor)2 Microservice (org.apache.servicecomb.serviceregistry.api.registry.Microservice)2 Context (io.vertx.core.Context)1 HttpClient (io.vertx.core.http.HttpClient)1 HttpMethod (io.vertx.core.http.HttpMethod)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1