Search in sources :

Example 61 with Microservice

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

the class TestMicroService method setUp.

@Before
public void setUp() throws Exception {
    oMicroservice = new Microservice();
    oMapProperties = new HashMap<>();
    oListSchemas = new ArrayList<>();
}
Also used : Microservice(org.apache.servicecomb.registry.api.registry.Microservice) Before(org.junit.Before)

Example 62 with Microservice

use of org.apache.servicecomb.registry.api.registry.Microservice 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)

Example 63 with Microservice

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

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 64 with Microservice

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

the class TestMicroserviceFactory method testSetDescriptionOnEmptyDescription.

@Test
public void testSetDescriptionOnEmptyDescription() {
    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 65 with Microservice

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

the class InvocationFactory method setSrcMicroservice.

public static Invocation setSrcMicroservice(Invocation invocation) {
    Microservice microservice = RegistrationManager.INSTANCE.getMicroservice();
    invocation.addContext(Const.SRC_MICROSERVICE, microservice.getServiceName());
    if (addSourceServiceId()) {
        invocation.addContext(Const.SRC_SERVICE_ID, microservice.getServiceId());
    }
    if (addSourceInstanceId()) {
        invocation.addContext(Const.SRC_INSTANCE_ID, microservice.getInstance().getInstanceId());
    }
    return invocation;
}
Also used : Microservice(org.apache.servicecomb.registry.api.registry.Microservice)

Aggregations

Microservice (org.apache.servicecomb.registry.api.registry.Microservice)86 Test (org.junit.Test)53 MicroserviceInstance (org.apache.servicecomb.registry.api.registry.MicroserviceInstance)20 Expectations (mockit.Expectations)15 ArrayList (java.util.ArrayList)14 List (java.util.List)13 GetSchemaResponse (org.apache.servicecomb.serviceregistry.api.response.GetSchemaResponse)10 Holder (org.apache.servicecomb.serviceregistry.client.http.Holder)10 HashMap (java.util.HashMap)9 MicroserviceFactory (org.apache.servicecomb.registry.api.registry.MicroserviceFactory)9 Swagger (io.swagger.models.Swagger)8 Before (org.junit.Before)8 MockUp (mockit.MockUp)6 Configuration (org.apache.commons.configuration.Configuration)6 AccessController (org.apache.servicecomb.authentication.provider.AccessController)6 Subscribe (com.google.common.eventbus.Subscribe)5 MicroserviceInstances (org.apache.servicecomb.registry.api.registry.MicroserviceInstances)5 EventBus (com.google.common.eventbus.EventBus)4 Version (org.apache.servicecomb.foundation.common.Version)4 HashSet (java.util.HashSet)3