Search in sources :

Example 1 with SimpleJsonObject

use of org.apache.servicecomb.foundation.vertx.SimpleJsonObject in project incubator-servicecomb-java-chassis by apache.

the class VertxRestTransport method init.

@Override
public boolean init() throws Exception {
    restClient = RestTransportClientManager.INSTANCE.getRestClient();
    // 部署transport server
    DeploymentOptions options = new DeploymentOptions().setInstances(TransportConfig.getThreadCount());
    SimpleJsonObject json = new SimpleJsonObject();
    json.put(ENDPOINT_KEY, getEndpoint());
    options.setConfig(json);
    return VertxUtils.blockDeploy(transportVertx, RestServerVerticle.class, options);
}
Also used : DeploymentOptions(io.vertx.core.DeploymentOptions) SimpleJsonObject(org.apache.servicecomb.foundation.vertx.SimpleJsonObject)

Example 2 with SimpleJsonObject

use of org.apache.servicecomb.foundation.vertx.SimpleJsonObject in project incubator-servicecomb-java-chassis by apache.

the class TestClientVerticle method start.

@Test
public void start(@Mocked Context context) throws Exception {
    AtomicInteger count = new AtomicInteger();
    ClientPoolManager<HttpClientWithContext> clientMgr = new MockUp<ClientPoolManager<HttpClientWithContext>>() {

        @Mock
        HttpClientWithContext createClientPool() {
            count.incrementAndGet();
            return null;
        }
    }.getMockInstance();
    clientVerticle.init(null, context);
    JsonObject config = new SimpleJsonObject();
    config.put(ClientVerticle.CLIENT_MGR, clientMgr);
    new Expectations() {

        {
            context.config();
            result = config;
        }
    };
    clientVerticle.start();
    Assert.assertEquals(1, count.get());
}
Also used : Expectations(mockit.Expectations) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HttpClientWithContext(org.apache.servicecomb.foundation.vertx.client.http.HttpClientWithContext) SimpleJsonObject(org.apache.servicecomb.foundation.vertx.SimpleJsonObject) JsonObject(io.vertx.core.json.JsonObject) SimpleJsonObject(org.apache.servicecomb.foundation.vertx.SimpleJsonObject) Mock(mockit.Mock) Test(org.junit.Test)

Example 3 with SimpleJsonObject

use of org.apache.servicecomb.foundation.vertx.SimpleJsonObject in project incubator-servicecomb-java-chassis by apache.

the class HighwayTransport method init.

public boolean init() throws Exception {
    highwayClient.init(transportVertx);
    DeploymentOptions deployOptions = new DeploymentOptions().setInstances(HighwayConfig.getServerThreadCount());
    setListenAddressWithoutSchema(HighwayConfig.getAddress(), Collections.singletonMap(TcpConst.LOGIN, "true"));
    SimpleJsonObject json = new SimpleJsonObject();
    json.put(ENDPOINT_KEY, getEndpoint());
    deployOptions.setConfig(json);
    return VertxUtils.blockDeploy(transportVertx, HighwayServerVerticle.class, deployOptions);
}
Also used : DeploymentOptions(io.vertx.core.DeploymentOptions) SimpleJsonObject(org.apache.servicecomb.foundation.vertx.SimpleJsonObject)

Example 4 with SimpleJsonObject

use of org.apache.servicecomb.foundation.vertx.SimpleJsonObject in project java-chassis by ServiceComb.

the class TestClientVerticle method start.

@Test
public void start(@Mocked Context context) throws Exception {
    AtomicInteger count = new AtomicInteger();
    ClientPoolManager<HttpClientWithContext> clientMgr = new MockUp<ClientPoolManager<HttpClientWithContext>>() {

        @Mock
        HttpClientWithContext createClientPool(Context context) {
            count.incrementAndGet();
            return null;
        }
    }.getMockInstance();
    clientVerticle.init(null, context);
    JsonObject config = new SimpleJsonObject();
    config.put(ClientVerticle.CLIENT_MGR, clientMgr);
    new Expectations() {

        {
            context.config();
            result = config;
        }
    };
    clientVerticle.start();
    Assert.assertEquals(1, count.get());
}
Also used : HttpClientWithContext(org.apache.servicecomb.foundation.vertx.client.http.HttpClientWithContext) Context(io.vertx.core.Context) Expectations(mockit.Expectations) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HttpClientWithContext(org.apache.servicecomb.foundation.vertx.client.http.HttpClientWithContext) SimpleJsonObject(org.apache.servicecomb.foundation.vertx.SimpleJsonObject) JsonObject(io.vertx.core.json.JsonObject) SimpleJsonObject(org.apache.servicecomb.foundation.vertx.SimpleJsonObject) Mock(mockit.Mock) Test(org.junit.Test)

Example 5 with SimpleJsonObject

use of org.apache.servicecomb.foundation.vertx.SimpleJsonObject in project java-chassis by ServiceComb.

the class HighwayTransport method init.

@Override
public boolean init() throws Exception {
    highwayClient.init(transportVertx);
    DeploymentOptions deployOptions = new DeploymentOptions().setInstances(HighwayConfig.getServerThreadCount());
    setListenAddressWithoutSchema(HighwayConfig.getAddress(), Collections.singletonMap(TcpConst.LOGIN, "true"));
    SimpleJsonObject json = new SimpleJsonObject();
    json.put(ENDPOINT_KEY, getEndpoint());
    deployOptions.setConfig(json);
    deployOptions.setWorkerPoolName("pool-worker-transport-highway");
    return VertxUtils.blockDeploy(transportVertx, HighwayServerVerticle.class, deployOptions);
}
Also used : DeploymentOptions(io.vertx.core.DeploymentOptions) SimpleJsonObject(org.apache.servicecomb.foundation.vertx.SimpleJsonObject)

Aggregations

SimpleJsonObject (org.apache.servicecomb.foundation.vertx.SimpleJsonObject)6 DeploymentOptions (io.vertx.core.DeploymentOptions)4 JsonObject (io.vertx.core.json.JsonObject)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Expectations (mockit.Expectations)2 Mock (mockit.Mock)2 HttpClientWithContext (org.apache.servicecomb.foundation.vertx.client.http.HttpClientWithContext)2 Test (org.junit.Test)2 Context (io.vertx.core.Context)1 RestTransportClient (org.apache.servicecomb.transport.rest.client.RestTransportClient)1