@Test public void testCleanupServiceForwarders() { JavaPluginConfig config = new JavaPluginConfig("test"); config.put("plugin.class", ServicingTestPlugin.class.getName()); config.put("test.id", "${test.id}"); JavaClusterConfig cluster = new JavaClusterConfig(); cluster.addReference("test.id"); cluster.addService("test.id"); cluster.addPlugin(config); JavaPluginConfig params = new JavaPluginConfig(); params.add("test.id", "service.test"); IClusterable service = new IClusterable() {}; context.registerService(service, "service.test"); IClusterControl control = context.newCluster(cluster, params); control.start(); assertEquals(2, context.getServices("service.test", IClusterable.class).size()); String id = context .getReference(context.getServices("service.test", IClusterable.class).get(1)) .getServiceId(); assertNotNull(context.getService(id, IClusterable.class)); assertEquals( context.getService(id, IClusterable.class), context.getServices("service.test", IClusterable.class).get(1)); control.stop(); assertEquals(1, context.getServices("service.test", IClusterable.class).size()); assertEquals(service, context.getService("service.test", IClusterable.class)); assertNull(context.getService(id, IClusterable.class)); }
@Override public void start() { IPluginContext context = getPluginContext(); JavaPluginConfig config = new JavaPluginConfig("test"); config.put("plugin.class", DummyPlugin.class.getName()); JavaClusterConfig cluster = new JavaClusterConfig(); cluster.addReference("test.id"); cluster.addService("test.id"); cluster.addPlugin(config); JavaPluginConfig params = new JavaPluginConfig(); params.add("test.id", "service.test"); IClusterControl control = context.newCluster(cluster, params); String id = control.getClusterConfig().getString("test.id"); IClusterable service = new IdService(id); context.registerService(service, id); control.start(); }