use of org.apache.servicecomb.registry.api.registry.Microservice in project java-chassis by ServiceComb.
the class TestServiceRegistryClientImpl method getAggregatedMicroservice.
@Test
public void getAggregatedMicroservice() {
String microserviceId = "msId";
new MockUp<RestClientUtil>() {
@Mock
void httpDo(RequestContext requestContext, Handler<RestResponse> responseHandler) {
Holder<GetServiceResponse> holder = Deencapsulation.getField(responseHandler, "arg$4");
holder.value = Json.decodeValue("{\"service\":{\"serviceId\":\"serviceId\",\"framework\":null" + ",\"registerBy\":null,\"environment\":null,\"appId\":\"appId\",\"serviceName\":null," + "\"alias\":null,\"version\":null,\"description\":null,\"level\":null,\"schemas\":[]," + "\"paths\":[],\"status\":\"UP\",\"properties\":{},\"intance\":null}}", GetServiceResponse.class);
RequestParam requestParam = requestContext.getParams();
Assert.assertEquals("global=true", requestParam.getQueryParams());
}
};
Microservice aggregatedMicroservice = oClient.getAggregatedMicroservice(microserviceId);
Assert.assertEquals("serviceId", aggregatedMicroservice.getServiceId());
Assert.assertEquals("appId", aggregatedMicroservice.getAppId());
}
use of org.apache.servicecomb.registry.api.registry.Microservice in project java-chassis by ServiceComb.
the class TestServiceRegistryClientImpl method testPrivateMethodCreateHttpClientOptions.
@Test
public void testPrivateMethodCreateHttpClientOptions() {
ArchaiusUtils.setProperty(BootStrapProperties.CONFIG_SERVICE_APPLICATION, "app");
ArchaiusUtils.setProperty(BootStrapProperties.CONFIG_SERVICE_NAME, "ms");
MicroserviceFactory microserviceFactory = new MicroserviceFactory();
Microservice microservice = microserviceFactory.create();
oClient.registerMicroservice(microservice);
oClient.registerMicroserviceInstance(microservice.getInstance());
try {
oClient.init();
HttpClientOptions httpClientOptions = Deencapsulation.invoke(oClient, "createHttpClientOptions");
Assert.assertNotNull(httpClientOptions);
Assert.assertEquals(80, httpClientOptions.getDefaultPort());
} catch (Exception e) {
Assert.assertNotNull(e);
}
ArchaiusUtils.resetConfig();
}
use of org.apache.servicecomb.registry.api.registry.Microservice in project java-chassis by ServiceComb.
the class LocalServiceRegistryClientImplTest method testLoadSchemaIdsFromRegistryFile.
@Test
public void testLoadSchemaIdsFromRegistryFile() {
Microservice microservice = registryClient.getMicroservice("002");
Assert.assertThat(microservice.getSchemas().size(), Is.is(1));
Assert.assertTrue(microservice.getSchemas().contains("hello"));
}
use of org.apache.servicecomb.registry.api.registry.Microservice in project java-chassis by ServiceComb.
the class LocalServiceRegistryClientImplTest method getMicroserviceId_fixVersion.
@Test
public void getMicroserviceId_fixVersion() {
Microservice v1 = mockRegisterMicroservice(appId, microserviceName, "1.0.0");
mockRegisterMicroservice(appId, microserviceName, "2.0.0");
String serviceId = registryClient.getMicroserviceId(appId, microserviceName, "1.0.0", "");
Assert.assertEquals(v1.getServiceId(), serviceId);
}
use of org.apache.servicecomb.registry.api.registry.Microservice in project java-chassis by ServiceComb.
the class TestConsumers method deleteWhenCreateMicroserviceVersion.
@Test
public void deleteWhenCreateMicroserviceVersion() {
new MockUp<DiscoveryManager>() {
@Mock
public Microservice getMicroservice(String microserviceId) {
return null;
}
};
try (LogCollector collector = new LogCollector()) {
appManager.getOrCreateMicroserviceVersionRule(appId, serviceName, versionRule);
Assert.assertEquals(0, microserviceManager.getVersionsByName().size());
Assert.assertThat(collector.getEvents().stream().filter(e -> e.getThrowableInformation() != null).map(e -> e.getThrowableInformation().getThrowable().getMessage()).toArray(), Matchers.hasItemInArray("failed to query by microserviceId '002' from ServiceCenter."));
}
}
Aggregations