Search in sources :

Example 1 with MicroserviceFactory

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

the class TestMicroserviceFactory method testCreateMicroserviceFromDefinitionWithInvalidVersion.

@Test
public void testCreateMicroserviceFromDefinitionWithInvalidVersion() {
    Configuration configuration = ConfigUtil.createLocalConfig();
    configuration.setProperty(BootStrapProperties.CONFIG_SERVICE_VERSION, "x.y.x.1");
    expectedException.equals(IllegalStateException.class);
    expectedException.expectMessage("Invalid major \"x\", version \"x.y.x.1\".");
    MicroserviceFactory microserviceFactory = new MicroserviceFactory();
    microserviceFactory.create(configuration);
}
Also used : Configuration(org.apache.commons.configuration.Configuration) MicroserviceFactory(org.apache.servicecomb.registry.api.registry.MicroserviceFactory) Test(org.junit.Test)

Example 2 with MicroserviceFactory

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

the class TestMicroserviceFactory method testSetDescription.

@Test
public void testSetDescription() {
    MicroserviceFactory factory = new MicroserviceFactory();
    Configuration configuration = ConfigUtil.createLocalConfig();
    configuration.setProperty(BootStrapProperties.CONFIG_SERVICE_DESCRIPTION, new String[] { "test1", "test2" });
    Microservice microservice = factory.create(configuration);
    Assert.assertEquals("test1,test2", 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 3 with MicroserviceFactory

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

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 4 with MicroserviceFactory

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

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 5 with MicroserviceFactory

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

the class TestServiceRegistryClientImpl method testException.

@Test
public void testException() {
    ArchaiusUtils.setProperty(BootStrapProperties.CONFIG_SERVICE_APPLICATION, "app");
    ArchaiusUtils.setProperty(BootStrapProperties.CONFIG_SERVICE_NAME, "ms");
    MicroserviceFactory microserviceFactory = new MicroserviceFactory();
    Microservice microservice = microserviceFactory.create();
    Assert.assertNull(oClient.registerMicroservice(microservice));
    Assert.assertNull(oClient.registerMicroserviceInstance(microservice.getInstance()));
    oClient.init();
    Assert.assertNull(oClient.getMicroserviceId(microservice.getAppId(), microservice.getServiceName(), microservice.getVersion(), microservice.getEnvironment()));
    Assert.assertThat(oClient.getAllMicroservices().isEmpty(), is(true));
    Assert.assertNull(oClient.registerMicroservice(microservice));
    Assert.assertNull(oClient.getMicroservice("microserviceId"));
    Assert.assertNull(oClient.getMicroserviceInstance("consumerId", "providerId"));
    Assert.assertFalse(oClient.unregisterMicroserviceInstance("microserviceId", "microserviceInstanceId"));
    Assert.assertNull(oClient.heartbeat("microserviceId", "microserviceInstanceId"));
    Assert.assertNull(oClient.findServiceInstance("selfMicroserviceId", "appId", "serviceName", "versionRule"));
    Assert.assertNull(oClient.findServiceInstances("selfMicroserviceId", "appId", "serviceName", "versionRule", "0"));
    Assert.assertEquals("a", new ClientException("a").getMessage());
    ArchaiusUtils.resetConfig();
}
Also used : Microservice(org.apache.servicecomb.registry.api.registry.Microservice) ClientException(org.apache.servicecomb.serviceregistry.client.ClientException) MicroserviceFactory(org.apache.servicecomb.registry.api.registry.MicroserviceFactory) Test(org.junit.Test)

Aggregations

MicroserviceFactory (org.apache.servicecomb.registry.api.registry.MicroserviceFactory)10 Test (org.junit.Test)9 Microservice (org.apache.servicecomb.registry.api.registry.Microservice)8 Configuration (org.apache.commons.configuration.Configuration)6 ClientException (org.apache.servicecomb.serviceregistry.client.ClientException)2 Handler (io.vertx.core.Handler)1 HttpClientOptions (io.vertx.core.http.HttpClientOptions)1 Expectations (mockit.Expectations)1 MockUp (mockit.MockUp)1 IpPort (org.apache.servicecomb.foundation.common.net.IpPort)1 AsyncResultCallback (org.apache.servicecomb.foundation.vertx.AsyncResultCallback)1