Search in sources :

Example 6 with MicroserviceFactory

use of org.apache.servicecomb.registry.api.registry.MicroserviceFactory in project incubator-servicecomb-java-chassis by apache.

the class LocalRegistryStore method init.

public void init() {
    MicroserviceFactory microserviceFactory = new MicroserviceFactory();
    selfMicroservice = microserviceFactory.create();
    selfMicroserviceInstance = selfMicroservice.getInstance();
    microserviceMap.clear();
    microserviceInstanceMap.clear();
}
Also used : MicroserviceFactory(org.apache.servicecomb.registry.api.registry.MicroserviceFactory)

Example 7 with MicroserviceFactory

use of org.apache.servicecomb.registry.api.registry.MicroserviceFactory in project incubator-servicecomb-java-chassis by apache.

the class TestMicroserviceFactory method testSetDescriptionOnBlankDescription.

@Test
public void testSetDescriptionOnBlankDescription() {
    Configuration configuration = ConfigUtil.createLocalConfig();
    configuration.setProperty(BootStrapProperties.CONFIG_SERVICE_DESCRIPTION, new String[] { " ", " " });
    MicroserviceFactory factory = new MicroserviceFactory();
    Microservice microservice = factory.create(configuration);
    Assert.assertEquals(" , ", microservice.getDescription());
}
Also used : Microservice(org.apache.servicecomb.registry.api.registry.Microservice) Configuration(org.apache.commons.configuration.Configuration) MicroserviceFactory(org.apache.servicecomb.registry.api.registry.MicroserviceFactory) Test(org.junit.Test)

Example 8 with MicroserviceFactory

use of org.apache.servicecomb.registry.api.registry.MicroserviceFactory in project incubator-servicecomb-java-chassis by apache.

the class TestMicroserviceFactory method testInit.

@Test
public void testInit() {
    MicroserviceFactory factory = new MicroserviceFactory();
    Microservice microservice = factory.create(ConfigUtil.createLocalConfig());
    String microserviceName = "default";
    Assert.assertEquals(microserviceName, microservice.getServiceName());
}
Also used : Microservice(org.apache.servicecomb.registry.api.registry.Microservice) MicroserviceFactory(org.apache.servicecomb.registry.api.registry.MicroserviceFactory) Test(org.junit.Test)

Example 9 with MicroserviceFactory

use of org.apache.servicecomb.registry.api.registry.MicroserviceFactory in project java-chassis by ServiceComb.

the class TestServiceRegistryClientImpl method testPrivateMethodCreateHttpClientOptions.

@Test
public void testPrivateMethodCreateHttpClientOptions() {
    ArchaiusUtils.setProperty(BootStrapProperties.CONFIG_SERVICE_APPLICATION, "app");
    ArchaiusUtils.setProperty(BootStrapProperties.CONFIG_SERVICE_NAME, "ms");
    MicroserviceFactory microserviceFactory = new MicroserviceFactory();
    Microservice microservice = microserviceFactory.create();
    oClient.registerMicroservice(microservice);
    oClient.registerMicroserviceInstance(microservice.getInstance());
    try {
        oClient.init();
        HttpClientOptions httpClientOptions = Deencapsulation.invoke(oClient, "createHttpClientOptions");
        Assert.assertNotNull(httpClientOptions);
        Assert.assertEquals(80, httpClientOptions.getDefaultPort());
    } catch (Exception e) {
        Assert.assertNotNull(e);
    }
    ArchaiusUtils.resetConfig();
}
Also used : Microservice(org.apache.servicecomb.registry.api.registry.Microservice) MicroserviceFactory(org.apache.servicecomb.registry.api.registry.MicroserviceFactory) HttpClientOptions(io.vertx.core.http.HttpClientOptions) ClientException(org.apache.servicecomb.serviceregistry.client.ClientException) Test(org.junit.Test)

Example 10 with MicroserviceFactory

use of org.apache.servicecomb.registry.api.registry.MicroserviceFactory in project java-chassis by ServiceComb.

the class TestMicroserviceFactory method testSetDescriptionOnNullDescription.

@Test
public void testSetDescriptionOnNullDescription() {
    Configuration configuration = ConfigUtil.createLocalConfig();
    configuration.clearProperty(BootStrapProperties.CONFIG_SERVICE_DESCRIPTION);
    MicroserviceFactory factory = new MicroserviceFactory();
    Microservice microservice = factory.create(configuration);
    Assert.assertNull(microservice.getDescription());
    configuration.setProperty(BootStrapProperties.CONFIG_SERVICE_DESCRIPTION, new String[] {});
    microservice = factory.create(configuration);
    Assert.assertNull(microservice.getDescription());
}
Also used : Microservice(org.apache.servicecomb.registry.api.registry.Microservice) Configuration(org.apache.commons.configuration.Configuration) MicroserviceFactory(org.apache.servicecomb.registry.api.registry.MicroserviceFactory) Test(org.junit.Test)

Aggregations

MicroserviceFactory (org.apache.servicecomb.registry.api.registry.MicroserviceFactory)20 Test (org.junit.Test)18 Microservice (org.apache.servicecomb.registry.api.registry.Microservice)16 Configuration (org.apache.commons.configuration.Configuration)12 ClientException (org.apache.servicecomb.serviceregistry.client.ClientException)4 Handler (io.vertx.core.Handler)2 HttpClientOptions (io.vertx.core.http.HttpClientOptions)2 Expectations (mockit.Expectations)2 MockUp (mockit.MockUp)2 IpPort (org.apache.servicecomb.foundation.common.net.IpPort)2 AsyncResultCallback (org.apache.servicecomb.foundation.vertx.AsyncResultCallback)2