use of org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance in project incubator-servicecomb-java-chassis by apache.
the class TestMicroserviceRegisterTask method setup.
@Before
public void setup() {
eventBus = new EventBus();
taskList = new ArrayList<>();
eventBus.register(new Object() {
@Subscribe
public void onEvent(MicroserviceRegisterTask task) {
taskList.add(task);
}
});
microservice = new Microservice();
microservice.setAppId("app");
microservice.setServiceName("ms");
microservice.setInstance(new MicroserviceInstance());
}
use of org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance in project incubator-servicecomb-java-chassis by apache.
the class TestMicroserviceVersionRule method setInstances.
@Test
public void setInstances() {
MicroserviceVersion v1 = MicroserviceVersionTestUtils.createMicroserviceVersion("1", "0.0.1");
microserviceVersionRule.addMicroserviceVersion(v1);
MicroserviceVersion v2 = MicroserviceVersionTestUtils.createMicroserviceVersion("2", "2.0.0");
microserviceVersionRule.addMicroserviceVersion(v2);
MicroserviceInstance instance1 = new MicroserviceInstance();
instance1.setServiceId("1");
instance1.setInstanceId("i1");
MicroserviceInstance instance2 = new MicroserviceInstance();
instance2.setServiceId("2");
instance2.setInstanceId("i2");
MicroserviceInstance instance3 = new MicroserviceInstance();
instance3.setServiceId("3");
instance3.setInstanceId("i3");
InstanceCache orgCache = microserviceVersionRule.getInstanceCache();
microserviceVersionRule.setInstances(Arrays.asList(instance1, instance2, instance3));
Assert.assertThat(microserviceVersionRule.getInstances().values(), Matchers.contains(instance2));
Assert.assertNotSame(orgCache, microserviceVersionRule.getInstanceCache());
Assert.assertSame(microserviceVersionRule.getInstances(), microserviceVersionRule.getInstanceCache().getInstanceMap());
Assert.assertSame(microserviceVersionRule.getInstances(), microserviceVersionRule.getVersionedCache().data());
}
use of org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance in project incubator-servicecomb-java-chassis by apache.
the class TestMicroserviceVersions method createInstance.
private void createInstance(String microserviceId) {
MicroserviceInstance instance = new MicroserviceInstance();
instance.setInstanceId("i" + microserviceId);
instance.setServiceId(microserviceId);
instances.add(instance);
}
use of org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance in project incubator-servicecomb-java-chassis by apache.
the class TestAbstractTransportDiscoveryFilter method createDiscoveryTree_ignoreInvalid.
@Test
public void createDiscoveryTree_ignoreInvalid() {
MicroserviceInstance instance1 = createInstance("a", "b");
MicroserviceInstance instance2 = createInstance("");
Map<String, MicroserviceInstance> instances = createMicroserviceInstances("name", instance1, instance2);
parent.data(instances);
result = filter.createDiscoveryTreeNode("", context, parent);
Assert.assertEquals("parent/", result.name());
Assert.assertThat(result.collectionData(), Matchers.contains(instance1.getEndpoints().toArray()));
}
use of org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance in project incubator-servicecomb-java-chassis by apache.
the class TestAbstractTransportDiscoveryFilter method createDiscoveryTree_allTransport.
@Test
public void createDiscoveryTree_allTransport() {
MicroserviceInstance instance1 = createInstance("a", "b");
MicroserviceInstance instance2 = createInstance("b");
Map<String, MicroserviceInstance> instances = createMicroserviceInstances("name", instance1, instance2);
parent.data(instances);
result = filter.createDiscoveryTreeNode("", context, parent);
Assert.assertEquals("parent/", result.name());
List<String> expect = new ArrayList<>();
expect.addAll(instance1.getEndpoints());
expect.addAll(instance2.getEndpoints());
Assert.assertThat(result.collectionData(), Matchers.contains(expect.toArray()));
}
Aggregations