Search in sources :

Example 26 with Microservice

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

the class TestAbstractRegisterTask method setup.

@Before
public void setup() {
    eventBus = new EventBus();
    microservice = new Microservice();
    microservice.setAppId("app");
    microservice.setServiceName("ms");
    microservice.setInstance(new MicroserviceInstance());
}
Also used : Microservice(org.apache.servicecomb.serviceregistry.api.registry.Microservice) MicroserviceInstance(org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance) EventBus(com.google.common.eventbus.EventBus) Before(org.junit.Before)

Example 27 with Microservice

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

the class TestMicroserviceInstanceHeartbeatTask method setup.

@Before
public void setup() {
    eventBus = new EventBus();
    heartbeatTaskList = new ArrayList<>();
    eventBus.register(new Object() {

        @Subscribe
        public void onEvent(MicroserviceInstanceHeartbeatTask task) {
            heartbeatTaskList.add(task);
        }
    });
    microservice = new Microservice();
    microservice.setAppId("app");
    microservice.setServiceName("ms");
    microservice.setServiceId("serviceId");
    microservice.setInstance(new MicroserviceInstance());
    microservice.getInstance().setInstanceId("instanceId");
}
Also used : Microservice(org.apache.servicecomb.serviceregistry.api.registry.Microservice) MicroserviceInstance(org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance) EventBus(com.google.common.eventbus.EventBus) Subscribe(com.google.common.eventbus.Subscribe) Before(org.junit.Before)

Example 28 with Microservice

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

the class TestMicroserviceRegisterTask method testAlreadyRegisteredGetSchemaIdSetFailed.

@Test
public void testAlreadyRegisteredGetSchemaIdSetFailed(@Mocked ServiceRegistryClient srClient) {
    Microservice otherMicroservice = new Microservice();
    otherMicroservice.setAppId(microservice.getAppId());
    otherMicroservice.setServiceName("ms1");
    otherMicroservice.addSchema("s1", "");
    new Expectations() {

        {
            srClient.getMicroserviceId(anyString, anyString, anyString);
            result = "serviceId";
            srClient.getMicroservice(anyString);
            result = null;
        }
    };
    MicroserviceRegisterTask registerTask = new MicroserviceRegisterTask(eventBus, srClient, microservice);
    registerTask.run();
    Assert.assertEquals(false, registerTask.isRegistered());
    Assert.assertEquals(false, registerTask.isSchemaIdSetMatch());
    Assert.assertEquals("serviceId", microservice.getServiceId());
    Assert.assertEquals(1, taskList.size());
}
Also used : Expectations(mockit.Expectations) Microservice(org.apache.servicecomb.serviceregistry.api.registry.Microservice) Test(org.junit.Test)

Example 29 with Microservice

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

the class TestMicroserviceVersions method createMicroservice.

private void createMicroservice(String microserviceId) {
    Microservice microservice = new Microservice();
    microservice.setServiceId(microserviceId);
    microservice.setVersion(microserviceId + ".0.0");
    microservices.put(microserviceId, microservice);
}
Also used : Microservice(org.apache.servicecomb.serviceregistry.api.registry.Microservice)

Example 30 with Microservice

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

the class LocalServiceRegistryClientImplTest method getMicroserviceId_latest.

@Test
public void getMicroserviceId_latest() {
    Microservice v2 = mockRegisterMicroservice(appId, microserviceName, "2.0.0");
    mockRegisterMicroservice(appId, microserviceName, "1.0.0");
    String serviceId = registryClient.getMicroserviceId(appId, microserviceName, DefinitionConst.VERSION_RULE_LATEST);
    Assert.assertEquals(v2.getServiceId(), serviceId);
}
Also used : Microservice(org.apache.servicecomb.serviceregistry.api.registry.Microservice) Test(org.junit.Test)

Aggregations

Microservice (org.apache.servicecomb.serviceregistry.api.registry.Microservice)47 Test (org.junit.Test)24 MicroserviceInstance (org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance)15 Expectations (mockit.Expectations)11 HashMap (java.util.HashMap)6 ArrayList (java.util.ArrayList)5 EventBus (com.google.common.eventbus.EventBus)4 Before (org.junit.Before)4 Subscribe (com.google.common.eventbus.Subscribe)3 MockUp (mockit.MockUp)3 ServiceRegistry (org.apache.servicecomb.serviceregistry.ServiceRegistry)3 MicroserviceFactory (org.apache.servicecomb.serviceregistry.api.registry.MicroserviceFactory)3 MicroserviceInstances (org.apache.servicecomb.serviceregistry.client.http.MicroserviceInstances)3 Endpoint (org.apache.servicecomb.core.Endpoint)2 SchemaMeta (org.apache.servicecomb.core.definition.SchemaMeta)2 ClientException (org.apache.servicecomb.serviceregistry.client.ClientException)2 Version (org.apache.servicecomb.serviceregistry.version.Version)2 VersionRule (org.apache.servicecomb.serviceregistry.version.VersionRule)2 Handler (io.vertx.core.Handler)1 HttpClientOptions (io.vertx.core.http.HttpClientOptions)1