Search in sources :

Example 1 with ServiceCenterInfo

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

the class ServiceRegistryClientImpl method getServiceCenterInfo.

@Override
public ServiceCenterInfo getServiceCenterInfo() {
    Holder<ServiceCenterInfo> holder = new Holder<>();
    IpPort ipPort = ipPortManager.getAvailableAddress();
    CountDownLatch countDownLatch = new CountDownLatch(1);
    RestUtils.get(ipPort, Const.REGISTRY_API.SERVICECENTER_VERSION, new RequestParam(), syncHandler(countDownLatch, ServiceCenterInfo.class, holder));
    try {
        countDownLatch.await();
        if (holder.value != null) {
            return holder.value;
        }
    } catch (Exception e) {
        LOGGER.error("query servicecenter version info failed.", e);
    }
    return null;
}
Also used : ServiceCenterInfo(org.apache.servicecomb.serviceregistry.api.registry.ServiceCenterInfo) Holder(javax.xml.ws.Holder) IpPort(org.apache.servicecomb.foundation.common.net.IpPort) CountDownLatch(java.util.concurrent.CountDownLatch) ClientException(org.apache.servicecomb.serviceregistry.client.ClientException)

Example 2 with ServiceCenterInfo

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

the class TestServiceRegistryClientImpl method testGetServiceCenterInfoSuccess.

@Test
public void testGetServiceCenterInfoSuccess() {
    ServiceCenterInfo serviceCenterInfo = new ServiceCenterInfo();
    serviceCenterInfo.setVersion("x.x.x");
    serviceCenterInfo.setBuildTag("xxx");
    serviceCenterInfo.setRunMode("dev");
    serviceCenterInfo.setApiVersion("x.x.x");
    serviceCenterInfo.setConfig(new ServiceCenterConfig());
    new MockUp<RestUtils>() {

        @Mock
        void httpDo(RequestContext requestContext, Handler<RestResponse> responseHandler) {
            Holder<ServiceCenterInfo> holder = Deencapsulation.getField(responseHandler, "arg$4");
            holder.value = serviceCenterInfo;
        }
    };
    ServiceCenterInfo info = oClient.getServiceCenterInfo();
    Assert.assertEquals("x.x.x", info.getVersion());
    Assert.assertEquals("xxx", info.getBuildTag());
    Assert.assertEquals("dev", info.getRunMode());
    Assert.assertNotNull(info.getConfig());
}
Also used : ServiceCenterConfig(org.apache.servicecomb.serviceregistry.api.registry.ServiceCenterConfig) ServiceCenterInfo(org.apache.servicecomb.serviceregistry.api.registry.ServiceCenterInfo) Handler(io.vertx.core.Handler) MockUp(mockit.MockUp) Test(org.junit.Test)

Example 3 with ServiceCenterInfo

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

the class LocalServiceRegistryClientImplTest method testGetServiceCenterInfo.

@Test
public void testGetServiceCenterInfo() {
    ServiceCenterInfo serviceCenterInfo = registryClient.getServiceCenterInfo();
    Assert.assertEquals("1.0.0", serviceCenterInfo.getVersion());
}
Also used : ServiceCenterInfo(org.apache.servicecomb.serviceregistry.api.registry.ServiceCenterInfo) Test(org.junit.Test)

Example 4 with ServiceCenterInfo

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

the class LocalServiceRegistryClientImpl method getServiceCenterInfo.

@Override
public ServiceCenterInfo getServiceCenterInfo() {
    ServiceCenterInfo info = new ServiceCenterInfo();
    info.setVersion("1.0.0");
    info.setBuildTag("20180312");
    info.setRunMode("dev");
    info.setApiVersion("4.0.0");
    info.setConfig(new ServiceCenterConfig());
    return info;
}
Also used : ServiceCenterConfig(org.apache.servicecomb.serviceregistry.api.registry.ServiceCenterConfig) ServiceCenterInfo(org.apache.servicecomb.serviceregistry.api.registry.ServiceCenterInfo)

Example 5 with ServiceCenterInfo

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

the class LocalServiceRegistryClientImplTest method testGetServiceCenterInfo.

@Test
public void testGetServiceCenterInfo() {
    ServiceCenterInfo serviceCenterInfo = registryClient.getServiceCenterInfo();
    Assert.assertEquals("1.0.0", serviceCenterInfo.getVersion());
}
Also used : ServiceCenterInfo(org.apache.servicecomb.serviceregistry.api.registry.ServiceCenterInfo) Test(org.junit.Test)

Aggregations

ServiceCenterInfo (org.apache.servicecomb.serviceregistry.api.registry.ServiceCenterInfo)9 ServiceCenterConfig (org.apache.servicecomb.serviceregistry.api.registry.ServiceCenterConfig)4 Test (org.junit.Test)4 Handler (io.vertx.core.Handler)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 MockUp (mockit.MockUp)2 IpPort (org.apache.servicecomb.foundation.common.net.IpPort)2 ClientException (org.apache.servicecomb.serviceregistry.client.ClientException)2 IOException (java.io.IOException)1 ExecutionException (java.util.concurrent.ExecutionException)1 Holder (javax.xml.ws.Holder)1 RestTemplate (org.springframework.web.client.RestTemplate)1