Search in sources :

Example 1 with Microservice

use of io.servicecomb.serviceregistry.api.registry.Microservice in project java-chassis by ServiceComb.

the class ConsumerSchemaFactory method findMicroservice.

protected Microservice findMicroservice(MicroserviceMeta microserviceMeta, String microserviceVersionRule) {
    String appId = microserviceMeta.getAppId();
    String microserviceName = microserviceMeta.getName();
    ServiceRegistryClient client = RegistryClientFactory.getRegistryClient();
    String microserviceId = client.getMicroserviceId(appId, microserviceMeta.getShortName(), microserviceVersionRule);
    if (StringUtils.isEmpty(microserviceId)) {
        LOGGER.error("can not get microservice id, {}:{}:{}", appId, microserviceName, microserviceVersionRule);
        return null;
    }
    Microservice microservice = client.getMicroservice(microserviceId);
    if (microservice == null) {
        LOGGER.error("can not get microservice, {}:{}:{}", appId, microserviceName, microserviceVersionRule);
        return null;
    }
    LOGGER.info("Found schema ids from service center, {}:{}:{}:{}", appId, microserviceName, microserviceVersionRule, microservice.getSchemas());
    return microservice;
}
Also used : Microservice(io.servicecomb.serviceregistry.api.registry.Microservice) ServiceRegistryClient(io.servicecomb.serviceregistry.client.ServiceRegistryClient)

Example 2 with Microservice

use of io.servicecomb.serviceregistry.api.registry.Microservice in project java-chassis by ServiceComb.

the class TestTransport method setupClass.

@BeforeClass
public static void setupClass() throws Exception {
    Microservice microservice = new Microservice();
    microservice.setAppId("app");
    microservice.setServiceName("testname");
    new MockUp<RegistryUtils>() {

        @Mock
        private Microservice createMicroserviceFromDefinition() {
            return microservice;
        }
    };
}
Also used : Microservice(io.servicecomb.serviceregistry.api.registry.Microservice) MockUp(mockit.MockUp) BeforeClass(org.junit.BeforeClass)

Example 3 with Microservice

use of io.servicecomb.serviceregistry.api.registry.Microservice in project java-chassis by ServiceComb.

the class TestSimpleLoadBalanceHandler method testHandler.

@Test
public void testHandler() {
    boolean status = false;
    mock();
    Assert.assertNotNull(simpleLoadBalanceHandler);
    try {
        final Microservice microService = new Microservice();
        new MockUp<RegistryUtils>() {

            @Mock
            private Microservice createMicroserviceFromDefinition() {
                return microService;
            }
        };
        Mockito.when(invocation.getMicroserviceName()).thenReturn(microserviceMetaManager.getName());
        Mockito.when(invocation.getMicroserviceVersionRule()).thenReturn("MicroserviceVersionRule");
        Mockito.when(invocation.getConfigTransportName()).thenReturn("TransportName");
        simpleLoadBalanceHandler.handle(invocation, asyncResp);
    } catch (Exception e) {
        status = true;
    }
    Assert.assertTrue(status);
}
Also used : Microservice(io.servicecomb.serviceregistry.api.registry.Microservice) MockUp(mockit.MockUp) Test(org.junit.Test)

Example 4 with Microservice

use of io.servicecomb.serviceregistry.api.registry.Microservice in project java-chassis by ServiceComb.

the class TestCseServerList method mockTestCases.

private void mockTestCases() {
    final Microservice microService = new Microservice();
    microService.setAppId("appId");
    new MockUp<RegistryUtils>() {

        @Mock
        public Microservice getMicroservice() {
            return microService;
        }

        @Mock
        private Microservice createMicroserviceFromDefinition() {
            return microService;
        }
    };
    new MockUp<InstanceCacheManager>() {

        @Mock
        public InstanceCache getOrCreate(String appId, String microserviceName, String microserviceVersionRule) {
            return null;
        }
    };
}
Also used : Microservice(io.servicecomb.serviceregistry.api.registry.Microservice) MockUp(mockit.MockUp)

Example 5 with Microservice

use of io.servicecomb.serviceregistry.api.registry.Microservice in project java-chassis by ServiceComb.

the class TestServerListCache method mockTestCases.

private void mockTestCases() {
    final Microservice microService = new Microservice();
    microService.setAppId("appId");
    new MockUp<RegistryUtils>() {

        @Mock
        public Microservice getMicroservice() {
            return microService;
        }

        @Mock
        private Microservice createMicroserviceFromDefinition() {
            return microService;
        }
    };
    new MockUp<InstanceCacheManager>() {

        @Mock
        public InstanceCache getOrCreate(String appId, String microserviceName, String microserviceVersionRule) {
            return null;
        }
    };
    transport = Mockito.mock(Transport.class);
}
Also used : Microservice(io.servicecomb.serviceregistry.api.registry.Microservice) MockUp(mockit.MockUp) Transport(io.servicecomb.core.Transport)

Aggregations

Microservice (io.servicecomb.serviceregistry.api.registry.Microservice)22 MockUp (mockit.MockUp)10 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)5 MicroserviceInstance (io.servicecomb.serviceregistry.api.registry.MicroserviceInstance)4 BeforeClass (org.junit.BeforeClass)4 RegistryThread (io.servicecomb.serviceregistry.RegistryThread)2 HealthCheck (io.servicecomb.serviceregistry.api.registry.HealthCheck)2 ClientException (io.servicecomb.serviceregistry.client.ClientException)2 ServiceRegistryClient (io.servicecomb.serviceregistry.client.ServiceRegistryClient)2 HashMap (java.util.HashMap)2 CseContext (io.servicecomb.core.CseContext)1 Transport (io.servicecomb.core.Transport)1 MicroserviceMeta (io.servicecomb.core.definition.MicroserviceMeta)1 MicroserviceMetaManager (io.servicecomb.core.definition.MicroserviceMetaManager)1 SchemaMeta (io.servicecomb.core.definition.SchemaMeta)1 SchemaListenerManager (io.servicecomb.core.definition.loader.SchemaListenerManager)1 SchemaLoader (io.servicecomb.core.definition.loader.SchemaLoader)1 UnitTestMeta (io.servicecomb.core.unittest.UnitTestMeta)1 IpPort (io.servicecomb.foundation.common.net.IpPort)1