Search in sources :

Example 21 with Microservice

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

the class TestPropertiesLoader method testMicroservicePropertiesLoader.

@Test
public void testMicroservicePropertiesLoader() throws Exception {
    Microservice microservice = LocalServiceRegistryFactory.createLocal().getMicroservice();
    Map<String, String> expectedMap = new HashMap<>();
    expectedMap.put("key1", "value1");
    expectedMap.put("key2", "value2");
    expectedMap.put("ek0", "ev0");
    Assert.assertEquals(expectedMap, microservice.getProperties());
}
Also used : Microservice(org.apache.servicecomb.registry.api.registry.Microservice) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 22 with Microservice

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

the class TestPropertiesLoader method testEmptyExtendedClass.

@Test
public void testEmptyExtendedClass() {
    Configuration configuration = ConfigUtil.createLocalConfig();
    configuration.setProperty(BootStrapProperties.CONFIG_SERVICE_NAME, "emptyExtendedClass");
    configuration.clearProperty(BootStrapProperties.CONFIG_SERVICE_PROPERTIES);
    configuration.clearProperty(BootStrapProperties.OLD_CONFIG_SERVICE_PROPERTIES);
    Microservice microservice = microserviceFactory.create(configuration);
    // microservice.yaml has 3 properties
    Assert.assertEquals(3, microservice.getProperties().size());
}
Also used : Microservice(org.apache.servicecomb.registry.api.registry.Microservice) Configuration(org.apache.commons.configuration.Configuration) Test(org.junit.Test)

Example 23 with Microservice

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

the class TestPropertiesLoader method testInstancePropertiesLoader.

@Test
public void testInstancePropertiesLoader() {
    Microservice microservice = LocalServiceRegistryFactory.createLocal().getMicroservice();
    MicroserviceInstance instance = microservice.getInstance();
    Map<String, String> expectedMap = new HashMap<>();
    expectedMap.put("key0", "value0");
    expectedMap.put("ek0", "ev0");
    Assert.assertEquals(expectedMap, instance.getProperties());
}
Also used : Microservice(org.apache.servicecomb.registry.api.registry.Microservice) HashMap(java.util.HashMap) MicroserviceInstance(org.apache.servicecomb.registry.api.registry.MicroserviceInstance) Test(org.junit.Test)

Example 24 with Microservice

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

the class TestInstanceCacheCheckerMock method registerMicroservice.

private void registerMicroservice(String appId, String microserviceName) {
    Microservice microservice = new Microservice();
    microservice.setAppId(appId);
    microservice.setServiceName(microserviceName);
    microservice.setVersion("1.0.0");
    serviceRegistry.getServiceRegistryClient().registerMicroservice(microservice);
}
Also used : Microservice(org.apache.servicecomb.registry.api.registry.Microservice)

Example 25 with Microservice

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

the class TestAbstractRegisterTask method testHeartbeatOtherFailed.

@Test
public void testHeartbeatOtherFailed(@Mocked ServiceRegistryClient srClient) {
    MicroserviceRegisterTask registerTask = new MicroserviceRegisterTask(eventBus, srClient, microservice);
    ReflectUtils.setField(registerTask, "registered", true);
    Microservice otherMicroservice = new Microservice();
    otherMicroservice.setAppId(microservice.getAppId());
    otherMicroservice.setServiceName("ms1");
    MicroserviceInstanceHeartbeatTask heartbeatTask = new MicroserviceInstanceHeartbeatTask(eventBus, srClient, otherMicroservice);
    ReflectUtils.setField(heartbeatTask, "heartbeatResult", HeartbeatResult.INSTANCE_NOT_REGISTERED);
    Assert.assertEquals(true, registerTask.isRegistered());
    eventBus.post(heartbeatTask);
    Assert.assertEquals(true, registerTask.isRegistered());
}
Also used : Microservice(org.apache.servicecomb.registry.api.registry.Microservice) Test(org.junit.Test)

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