Search in sources :

Example 21 with Microservice

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

the class TestServiceRegistryClientImpl method testPrivateMehtodCreateHttpClientOptions.

@Test
public void testPrivateMehtodCreateHttpClientOptions() {
    Microservice oInstance = RegistryUtils.getMicroservice();
    oClient.registerMicroservice(oInstance);
    oClient.registerMicroserviceInstance(RegistryUtils.getMicroserviceInstance());
    new MockUp<ServiceRegistryConfig>() {

        @Mock
        public HttpVersion getHttpVersion() {
            return HttpVersion.HTTP_2;
        }

        @Mock
        public boolean isSsl() {
            return true;
        }
    };
    try {
        oClient.init();
        HttpClientOptions httpClientOptions = Deencapsulation.invoke(oClient, "createHttpClientOptions");
        Assert.assertNotNull(httpClientOptions);
        Assert.assertEquals(80, httpClientOptions.getDefaultPort());
    } catch (Exception e) {
        Assert.assertNotNull(e);
    }
}
Also used : Microservice(io.servicecomb.serviceregistry.api.registry.Microservice) MockUp(mockit.MockUp) HttpClientOptions(io.vertx.core.http.HttpClientOptions) ClientException(io.servicecomb.serviceregistry.client.ClientException) Test(org.junit.Test)

Example 22 with Microservice

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

the class CseDiscoveryClient method getServices.

@Override
public List<String> getServices() {
    ServiceRegistryClient client = RegistryClientFactory.getRegistryClient();
    List<Microservice> services = client.getAllMicroservices();
    List<String> serviceIDList = new ArrayList<String>();
    if (null != services && !services.isEmpty())
        for (Microservice service : services) {
            serviceIDList.add(service.getServiceName());
        }
    return serviceIDList;
}
Also used : Microservice(io.servicecomb.serviceregistry.api.registry.Microservice) ArrayList(java.util.ArrayList) ServiceRegistryClient(io.servicecomb.serviceregistry.client.ServiceRegistryClient)

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