コード例 #1
0
  @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());
  }
コード例 #2
0
  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());
  }
コード例 #3
0
 @Override
 protected void setUp() throws Exception {
   super.setUp();
   MockInstanceProvider.registerInstanceProvider(
       "Test.instance", new MockInstanceProvider()); // NOI18N
 }