@Test
public void testAddProvider() {

    // preload
    ProviderStack<Provider> providers = new ProviderStack<Provider>(new Provider[] {
            new UnorderedProvider("ccc"),
            new UnorderedProvider("ddd"),
            new OrderedProvider("bbb", 5),
            new OrderedProvider("aaa", 2)
    });
    assertNotNull(providers.hashCode());
    assertNotNull(providers.toString());
    assertEquals(4, providers.size());
    // check the order
    List<Provider> l = providers.getProviders();
    assertEquals("aaa", l.get(0).getPrefix());
    assertEquals("bbb", l.get(1).getPrefix());
    assertEquals("ccc", l.get(2).getPrefix());
    assertEquals("ddd", l.get(3).getPrefix());
    // now do some adds
    // unordered should go to the end
    Provider p5 = new UnorderedProvider("eee");
    providers.addProvider( p5 );
    assertEquals(5, providers.size());
    l = providers.getProviders();
    assertEquals("aaa", l.get(0).getPrefix());
    assertEquals("bbb", l.get(1).getPrefix());
    assertEquals("ccc", l.get(2).getPrefix());
    assertEquals("ddd", l.get(3).getPrefix());
    assertEquals("eee", l.get(4).getPrefix());
    // ordered should go in order
    Provider p6 = new OrderedProvider("ab6", 3);
    providers.addProvider( p6 );
    assertEquals(6, providers.size());
    l = providers.getProviders();
    assertEquals("aaa", l.get(0).getPrefix());
    assertEquals("ab6", l.get(1).getPrefix());
    assertEquals("bbb", l.get(2).getPrefix());
    assertEquals("ccc", l.get(3).getPrefix());
    assertEquals("ddd", l.get(4).getPrefix());
    assertEquals("eee", l.get(5).getPrefix());
    Provider p7 = new OrderedProvider("bc7", 6);
    providers.addProvider( p7 );
    assertEquals(7, providers.size());
    l = providers.getProviders();
    assertEquals("aaa", l.get(0).getPrefix());
    assertEquals("ab6", l.get(1).getPrefix());
    assertEquals("bbb", l.get(2).getPrefix());
    assertEquals("bc7", l.get(3).getPrefix());
    assertEquals("ccc", l.get(4).getPrefix());
    assertEquals("ddd", l.get(5).getPrefix());
    assertEquals("eee", l.get(6).getPrefix());
    l = null;
    p5 = p6 = p7 = null;
    providers.clear();
    providers = null;
}