use of org.apache.servicecomb.serviceregistry.task.event.PullMicroserviceVersionsInstancesEvent in project incubator-servicecomb-java-chassis by apache.
the class TestRemoteServiceRegistry method onPullMicroserviceVersionsInstancesEvent.
@Test
public void onPullMicroserviceVersionsInstancesEvent(@Injectable ServiceRegistryConfig config, @Injectable MicroserviceDefinition definition, @Mocked MicroserviceVersions microserviceVersions) {
PullMicroserviceVersionsInstancesEvent event = new PullMicroserviceVersionsInstancesEvent(microserviceVersions, 1);
ScheduledThreadPoolExecutor taskPool = new MockUp<ScheduledThreadPoolExecutor>() {
@Mock
ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
Assert.assertEquals(1, delay);
throw new Error("ok");
}
}.getMockInstance();
expectedException.expect(Error.class);
expectedException.expectMessage(Matchers.is("ok"));
EventBus bus = new EventBus();
RemoteServiceRegistry remote = new TestingRemoteServiceRegistry(bus, config, definition);
bus.register(remote);
Deencapsulation.setField(remote, "taskPool", taskPool);
bus.post(event);
}
use of org.apache.servicecomb.serviceregistry.task.event.PullMicroserviceVersionsInstancesEvent in project incubator-servicecomb-java-chassis by apache.
the class TestMicroserviceVersions method onMicroserviceInstanceChangedMatch.
@Test
public void onMicroserviceInstanceChangedMatch() {
MicroserviceKey key = new MicroserviceKey();
key.setAppId(appId);
key.setServiceName(microserviceName);
MicroserviceInstanceChangedEvent event = new MicroserviceInstanceChangedEvent();
event.setKey(key);
eventBus.register(new Object() {
@Subscribe
public void onEvent(PullMicroserviceVersionsInstancesEvent pullEvent) {
pendingPullCount.incrementAndGet();
}
});
eventBus.post(event);
Assert.assertEquals(2, pendingPullCount.get());
}
use of org.apache.servicecomb.serviceregistry.task.event.PullMicroserviceVersionsInstancesEvent in project incubator-servicecomb-java-chassis by apache.
the class MicroserviceVersions method postPullInstanceEvent.
private void postPullInstanceEvent(long msTime) {
pendingPullCount.incrementAndGet();
appManager.getEventBus().post(new PullMicroserviceVersionsInstancesEvent(this, msTime));
}
Aggregations