use of org.apache.servicecomb.registry.api.registry.Microservice in project java-chassis by ServiceComb.
the class TestMicroserviceFactory method testAllowCrossApp.
@Test
public void testAllowCrossApp() {
Microservice microservice = new Microservice();
Assert.assertFalse(microservice.allowCrossApp());
microservice.getProperties().put(CONFIG_ALLOW_CROSS_APP_KEY, "true");
Assert.assertTrue(microservice.allowCrossApp());
microservice.getProperties().put(CONFIG_ALLOW_CROSS_APP_KEY, "false");
Assert.assertFalse(microservice.allowCrossApp());
microservice.getProperties().put(CONFIG_ALLOW_CROSS_APP_KEY, "asfas");
Assert.assertFalse(microservice.allowCrossApp());
}
use of org.apache.servicecomb.registry.api.registry.Microservice in project java-chassis by ServiceComb.
the class TestRestProducerInvocation method findRestOperationNameFromRegistry.
@Test
public void findRestOperationNameFromRegistry() {
Microservice microservice = new Microservice();
microservice.setServiceName("ms");
new Expectations(ServicePathManager.class) {
{
// just make the method throw Exception
ServicePathManager.getServicePathManager(microserviceMeta);
result = null;
}
};
restProducerInvocation = new RestProducerInvocation();
initRestProducerInvocation();
expectedException.expect(Exception.class);
expectedException.expectMessage("[message=Not Found]");
restProducerInvocation.findRestOperation();
}
use of org.apache.servicecomb.registry.api.registry.Microservice in project java-chassis by ServiceComb.
the class LocalRegistryStore method findServiceInstances.
// local registry do not care about version and revision
public MicroserviceInstances findServiceInstances(String appId, String serviceName, String versionRule, String revision) {
MicroserviceInstances microserviceInstances = new MicroserviceInstances();
FindInstancesResponse findInstancesResponse = new FindInstancesResponse();
List<MicroserviceInstance> instances = new ArrayList<>();
Collectors.toList();
microserviceInstanceMap.values().forEach(allInstances -> allInstances.values().stream().filter(aInstance -> {
Microservice service = microserviceMap.get(aInstance.getServiceId());
return service.getAppId().equals(appId) && service.getServiceName().equals(serviceName);
}).forEach(item -> instances.add(item)));
if (instances.isEmpty()) {
microserviceInstances.setMicroserviceNotExist(true);
} else {
findInstancesResponse.setInstances(instances);
microserviceInstances.setMicroserviceNotExist(false);
microserviceInstances.setInstancesResponse(findInstancesResponse);
}
return microserviceInstances;
}
use of org.apache.servicecomb.registry.api.registry.Microservice in project java-chassis by ServiceComb.
the class AbstractLightweightDiscovery method onSchemaChanged.
@SuppressWarnings("unused")
@Subscribe
public void onSchemaChanged(SchemaChangedEvent event) {
Microservice microservice = event.getMicroservice();
appManager.markWaitingDelete(microservice.getAppId(), microservice.getServiceName());
}
use of org.apache.servicecomb.registry.api.registry.Microservice in project java-chassis by ServiceComb.
the class TestSwaggerLoader method loadFromResource_sameApp_dirWithoutApp.
@Test
public void loadFromResource_sameApp_dirWithoutApp() {
Swagger swagger = SwaggerGenerator.generate(Hello.class);
mockLocalResource(swagger, String.format("microservices/%s/%s.yaml", serviceName, schemaId));
RegistrationManager.INSTANCE.getSwaggerLoader().unregisterSwagger(appId, serviceName, schemaId);
Microservice microservice = appManager.getOrCreateMicroserviceVersions(appId, serviceName).getVersions().values().iterator().next().getMicroservice();
Swagger loadedSwagger = RegistrationManager.INSTANCE.getSwaggerLoader().loadSwagger(microservice, null, schemaId);
Assert.assertNotSame(swagger, loadedSwagger);
Assert.assertEquals(swagger, loadedSwagger);
}
Aggregations