@Before public void setup() { provider1 = new MockLocatorProvider("protocol1"); provider2 = new MockLocatorProvider("protocol2"); provider3 = new MockLocatorProvider("protocol3"); manager = new ResourceManager(); manager.addResourceLocatorProvider(provider1); manager.addResourceLocatorProvider(provider2); manager.addResourceLocatorProvider(provider3); }
@Test public void testAddAndRemove() { ResourceManager testManager = new ResourceManager(); Assert.assertTrue(testManager.addResourceLocatorProvider(provider1)); Assert.assertTrue(testManager.addResourceLocatorProvider(provider2)); Assert.assertEquals(2, testManager.getProtocols().size()); Assert.assertFalse(testManager.addResourceLocatorProvider(provider2)); // Add the same one again Assert.assertEquals(2, testManager.getProtocols().size()); Assert.assertTrue(testManager.removeResourceLocatorProvider(provider1)); Assert.assertEquals(1, testManager.getProtocols().size()); Assert.assertFalse( testManager.removeResourceLocatorProvider(provider1)); // Remove the same one again Assert.assertEquals(1, testManager.getProtocols().size()); Assert.assertTrue(testManager.removeResourceLocatorProvider(provider2)); Assert.assertEquals(0, testManager.getProtocols().size()); }