use of org.apache.servicecomb.serviceregistry.task.event.ShutdownEvent in project incubator-servicecomb-java-chassis by apache.
the class TestRemoteServiceRegistry method testLifeCycle.
@Test
public void testLifeCycle(@Injectable ServiceRegistryConfig config, @Injectable MicroserviceDefinition definition, @Injectable ServiceRegistry registry) {
ArrayList<IpPort> ipPortList = new ArrayList<>();
ipPortList.add(new IpPort("127.0.0.1", 9980));
ipPortList.add(new IpPort("127.0.0.1", 9981));
new Expectations() {
{
definition.getConfiguration();
result = ConfigUtil.createLocalConfig();
config.getIpPort();
result = ipPortList;
config.getTransport();
result = "rest";
config.isRegistryAutoDiscovery();
result = true;
config.getHeartbeatInterval();
result = 30;
config.getInstancePullInterval();
result = 30;
config.isWatch();
result = false;
}
};
ServiceRegistry oldRegistry = RegistryUtils.getServiceRegistry();
RegistryUtils.setServiceRegistry(registry);
EventBus bus = new EventBus();
RemoteServiceRegistry remote = new TestingRemoteServiceRegistry(bus, config, definition);
remote.init();
remote.run();
// includes complete tasks
Assert.assertTrue(2 <= remote.getTaskPool().getTaskCount());
bus.post(new ShutdownEvent());
remote.getTaskPool().schedule(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
}
}, 0, TimeUnit.SECONDS);
Assert.assertTrue(remote.getTaskPool().isShutdown());
RegistryUtils.setServiceRegistry(oldRegistry);
}
use of org.apache.servicecomb.serviceregistry.task.event.ShutdownEvent in project incubator-servicecomb-java-chassis by apache.
the class AbstractServiceRegistry method destroy.
public void destroy() {
eventBus.post(new ShutdownEvent());
unregisterInstance();
}
Aggregations