/** Test getProviders method */
  @Test
  public void testGetProvider() {

    // Register 3 providers, mixed data types
    TestProvider1 testProvider1 = new TestProvider1(ITmfEvent.class);
    TestProvider2 testProvider2 = new TestProvider2(ITmfEvent.class);
    TestProvider3 testProvider3 = new TestProvider3(TmfEvent3.class);

    TmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, null);
    assertEquals("getProviders", 2, providers.length);
    if (providers[0] == testProvider1) {
      assertEquals("getProviders", testProvider2, providers[1]);
    } else {
      assertEquals("getProviders", testProvider2, providers[0]);
      assertEquals("getProviders", testProvider1, providers[1]);
    }

    providers = TmfProviderManager.getProviders(TmfEvent3.class, null);
    assertEquals("getProviders", 1, providers.length);
    assertEquals("getProviders", testProvider3, providers[0]);

    // Remove the providers
    testProvider1.dispose();
    testProvider2.dispose();
    testProvider3.dispose();
  }
  /** Test unregistering */
  @Test
  public void testRegister_Unregister_3() {

    // Register 3 providers, mixed data types
    TestProvider1 testProvider1 = new TestProvider1(ITmfEvent.class);
    TestProvider2 testProvider2 = new TestProvider2(ITmfEvent.class);
    TestProvider3 testProvider3 = new TestProvider3(TmfEvent3.class);

    TmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class);
    assertEquals("getProviders", 2, providers.length);
    if (providers[0] == testProvider1) {
      assertEquals("getProviders", testProvider2, providers[1]);
    } else {
      assertEquals("getProviders", testProvider2, providers[0]);
      assertEquals("getProviders", testProvider1, providers[1]);
    }

    TmfEventProvider[] providers3 = TmfProviderManager.getProviders(TmfEvent3.class);
    assertEquals("getProviders", 1, providers3.length);
    assertEquals("getProviders", testProvider3, providers3[0]);

    providers = TmfProviderManager.getProviders(ITmfEvent.class, TestProvider1.class);
    assertEquals("getProviders", 1, providers.length);
    assertEquals("getProviders", testProvider1, providers[0]);

    providers = TmfProviderManager.getProviders(ITmfEvent.class, TestProvider2.class);
    assertEquals("getProviders", 1, providers.length);
    assertEquals("getProviders", testProvider2, providers[0]);

    providers3 = TmfProviderManager.getProviders(TmfEvent3.class, TestProvider3.class);
    assertEquals("getProviders", 1, providers3.length);
    assertEquals("getProviders", testProvider3, providers3[0]);

    // Remove one
    testProvider1.dispose();

    providers = TmfProviderManager.getProviders(ITmfEvent.class);
    assertEquals("getProviders", 1, providers.length);
    assertEquals("getProviders", testProvider2, providers[0]);

    providers = TmfProviderManager.getProviders(ITmfEvent.class, TestProvider1.class);
    assertEquals("getProviders", 0, providers.length);

    providers = TmfProviderManager.getProviders(ITmfEvent.class, TestProvider2.class);
    assertEquals("getProviders", 1, providers.length);
    assertEquals("getProviders", testProvider2, providers[0]);

    providers3 = TmfProviderManager.getProviders(TmfEvent3.class);
    assertEquals("getProviders", 1, providers3.length);
    assertEquals("getProviders", testProvider3, providers3[0]);

    providers3 = TmfProviderManager.getProviders(TmfEvent3.class, TestProvider3.class);
    assertEquals("getProviders", 1, providers3.length);
    assertEquals("getProviders", testProvider3, providers3[0]);

    // Remove another one
    testProvider2.dispose();

    providers = TmfProviderManager.getProviders(ITmfEvent.class);
    assertEquals("getProviders", 0, providers.length);

    providers = TmfProviderManager.getProviders(ITmfEvent.class, TestProvider1.class);
    assertEquals("getProviders", 0, providers.length);

    providers = TmfProviderManager.getProviders(ITmfEvent.class, TestProvider2.class);
    assertEquals("getProviders", 0, providers.length);

    providers3 = TmfProviderManager.getProviders(TmfEvent3.class);
    assertTrue(providers3.length == 1);
    assertTrue(providers3[0] == testProvider3);

    providers3 = TmfProviderManager.getProviders(TmfEvent3.class, TestProvider3.class);
    assertEquals("getProviders", 1, providers3.length);
    assertEquals("getProviders", testProvider3, providers3[0]);

    // Remove the last one
    testProvider3.dispose();

    providers = TmfProviderManager.getProviders(ITmfEvent.class);
    assertEquals("getProviders", 0, providers.length);

    providers = TmfProviderManager.getProviders(ITmfEvent.class, TestProvider1.class);
    assertEquals("getProviders", 0, providers.length);

    providers = TmfProviderManager.getProviders(ITmfEvent.class, TestProvider2.class);
    assertEquals("getProviders", 0, providers.length);

    providers3 = TmfProviderManager.getProviders(TmfEvent3.class);
    assertEquals("getProviders", 0, providers.length);

    providers3 = TmfProviderManager.getProviders(TmfEvent3.class, TestProvider3.class);
    assertEquals("getProviders", 0, providers.length);
  }