@Test
public void testRefresh() {

    Provider p1 = new OrderedProvider("aaa", 2);
    Provider p2 = new UnorderedProvider("ccc");
    ProviderStack<Provider> providers = new ProviderStack<Provider>(new Provider[] {
            p2,
            new UnorderedProvider("ddd"),
            new OrderedProvider("bbb", 5),
            p1
    });
    assertNotNull(providers.hashCode());
    assertNotNull(providers.toString());
    assertEquals(4, providers.size());
    providers.refresh();
    assertEquals(4, providers.size());
    System.gc(); // should wipe the 2 without a reference
    providers.refresh();
    assertEquals(2, providers.size());
    assertEquals(p1, providers.getProvider(0));
    assertEquals(p2, providers.getProvider(1));
    p1 = null;
    System.gc(); // should wipe the p1
    providers.refresh();
    assertEquals(1, providers.size());
    assertEquals(p2, providers.getProvider(0));
    p2 = null;
    providers.clear();
    providers = null;
}