use of org.apache.servicecomb.registry.api.registry.MicroserviceInstance in project java-chassis by ServiceComb.
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.setInstanceId("testid");
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.registry.api.registry.MicroserviceInstance in project java-chassis by ServiceComb.
the class LocalServiceRegistryClientImplTest method undateMicroserviceInstanceStatus_illegal_status.
@SuppressWarnings("deprecation")
@Test
public void undateMicroserviceInstanceStatus_illegal_status() {
List<MicroserviceInstance> m = registryClient.findServiceInstance("", "default", "ms2", DefinitionConst.VERSION_RULE_ALL);
MicroserviceInstance instance = m.get(0);
try {
registryClient.undateMicroserviceInstanceStatus(instance.getServiceId(), instance.getInstanceId(), null);
shouldThrowException();
} catch (NullPointerException e) {
Assert.assertEquals("Name is null", e.getMessage());
}
try {
registryClient.undateMicroserviceInstanceStatus(instance.getServiceId(), instance.getInstanceId(), "IllegalStatus");
shouldThrowException();
} catch (IllegalArgumentException e) {
Assert.assertEquals("Invalid status: IllegalStatus", e.getMessage());
}
}
use of org.apache.servicecomb.registry.api.registry.MicroserviceInstance in project java-chassis by ServiceComb.
the class LocalServiceRegistryClientImplTest method testLoadRegistryFile.
@Test
public void testLoadRegistryFile() {
Assert.assertNotNull(registryClient);
Assert.assertThat(registryClient.getAllMicroservices().size(), Is.is(2));
List<MicroserviceInstance> m = registryClient.findServiceInstance("", "default", "ms2", DefinitionConst.VERSION_RULE_ALL);
Assert.assertEquals(1, m.size());
MicroserviceInstances microserviceInstances = registryClient.findServiceInstances("", "default", "ms2", DefinitionConst.VERSION_RULE_ALL, null);
List<MicroserviceInstance> mi = microserviceInstances.getInstancesResponse().getInstances();
Assert.assertEquals(1, mi.size());
}
use of org.apache.servicecomb.registry.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.registry.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());
}
Aggregations