@SuppressWarnings("unchecked") public void testInstanceProvider() throws IOException { assertEquals(1, ServerRegistry.getInstance().getProviders().size()); ServerInstanceProvider provider = ServerRegistry.getInstance().getProviders().iterator().next(); assertTrue(provider instanceof MockInstanceProvider); MockInstanceProvider testProvider = (MockInstanceProvider) provider; testProvider.clear(); MockInstanceImplementation instance1 = MockInstanceImplementation.createInstance( testProvider, "Test server", "Test instance 1", true); // NOI18N MockInstanceImplementation instance2 = MockInstanceImplementation.createInstance( testProvider, "Test server", "Test instance 2", true); // NOI18N List<ServerInstance> step1 = new ArrayList<ServerInstance>(); Collections.addAll(step1, instance1.getServerInstance()); List<ServerInstance> step2 = new ArrayList<ServerInstance>(); Collections.addAll(step2, instance1.getServerInstance(), instance2.getServerInstance()); InstanceListener listener = new InstanceListener(step1, step2, step1, Collections.<ServerInstance>emptyList()); ServerRegistry.getInstance().addChangeListener(listener); testProvider.addInstance(instance1.getServerInstance()); testProvider.addInstance(instance2.getServerInstance()); testProvider.removeInstance(instance2.getServerInstance()); testProvider.removeInstance(instance1.getServerInstance()); }
public void testEmptyProvider() throws IOException { assertEquals(1, ServerRegistry.getInstance().getProviders().size()); ServerInstanceProvider provider = ServerRegistry.getInstance().getProviders().iterator().next(); assertTrue(provider instanceof MockInstanceProvider); ((MockInstanceProvider) provider).clear(); assertTrue(provider.getInstances().isEmpty()); }
public void stateChanged(ChangeEvent e) { final ServerRegistry registry = (ServerRegistry) e.getSource(); List<ServerInstance> current = new ArrayList<ServerInstance>(); for (ServerInstanceProvider provider : registry.getProviders()) { current.addAll(provider.getInstances()); } List<ServerInstance> expected = steps.get(stepIndex++); assertEquals(expected.size(), current.size()); for (ServerInstance instance : expected) { current.remove(instance); } assertTrue(current.isEmpty()); }