use of org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance in project incubator-servicecomb-java-chassis by apache.
the class TestAbstractTransportDiscoveryFilter method createDiscoveryTree_oneTransport.
@Test
public void createDiscoveryTree_oneTransport() {
MicroserviceInstance instance1 = createInstance("a", "b");
MicroserviceInstance instance2 = createInstance("b");
Map<String, MicroserviceInstance> instances = createMicroserviceInstances("name", instance1, instance2);
parent.data(instances);
result = filter.createDiscoveryTreeNode("a", context, parent);
Assert.assertEquals("parent/a", result.name());
Assert.assertThat(result.collectionData(), Matchers.contains(instance1.getEndpoints().get(0)));
}
use of org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance in project incubator-servicecomb-java-chassis by apache.
the class TestAbstractTransportDiscoveryFilter method createEndpointNull.
@Test
public void createEndpointNull() {
disableCreate = true;
MicroserviceInstance instance1 = createInstance("a", "b");
Map<String, MicroserviceInstance> instances = createMicroserviceInstances("name", instance1);
parent.data(instances);
result = filter.createDiscoveryTreeNode("", context, parent);
Assert.assertEquals("parent/", result.name());
Assert.assertThat(result.collectionData(), Matchers.empty());
}
use of org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance in project incubator-servicecomb-java-chassis by apache.
the class TestAbstractTransportDiscoveryFilter method createInstance.
private MicroserviceInstance createInstance(String... schemas) {
String id = UUID.randomUUID().toString();
MicroserviceInstance instance = new MicroserviceInstance();
instance.setInstanceId(id);
for (int idx = 0; idx < schemas.length; idx++) {
String schema = schemas[idx];
instance.getEndpoints().add(String.format("%s://%s:%d", schema, id, 8080 + idx));
}
return instance;
}
use of org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance in project incubator-servicecomb-java-chassis by apache.
the class LocalServiceRegistryClientImplTest method findServiceInstance_twoSelectOne.
@Test
public void findServiceInstance_twoSelectOne() {
Microservice v1 = mockRegisterMicroservice(appId, microserviceName, "1.0.0");
mockRegisterMicroservice(appId, microserviceName, "2.0.0");
MicroserviceInstance instance = new MicroserviceInstance();
instance.setServiceId(v1.getServiceId());
registryClient.registerMicroserviceInstance(instance);
List<MicroserviceInstance> result = registryClient.findServiceInstance("self", appId, microserviceName, "1.0.0");
Assert.assertThat(result, Matchers.contains(instance));
MicroserviceInstances microserviceInstances = registryClient.findServiceInstances("self", appId, microserviceName, "1.0.0", "0");
List<MicroserviceInstance> results = microserviceInstances.getInstancesResponse().getInstances();
Assert.assertThat(results, Matchers.contains(instance));
}
use of org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance in project incubator-servicecomb-java-chassis by apache.
the class LocalServiceRegistryClientImplTest method testFindServiceInstance.
@Test
public void testFindServiceInstance() {
Microservice microservice = mockRegisterMicroservice(appId, microserviceName, "1.0.0");
MicroserviceInstance instance = new MicroserviceInstance();
instance.setServiceId(microservice.getServiceId());
String instanceId = registryClient.registerMicroserviceInstance(instance);
Assert.assertNotNull(registryClient.findServiceInstance(microservice.getServiceId(), instanceId));
}
Aggregations