PeerRoutingInformationBaseManager implements ExtensionRoutingBaseManager { public PeerRoutingInformationBase peerRoutingInformationBase(String peerName) { if(StringUtils.isBlank(peerName)) throw new IllegalArgumentException("empty peer name"); PeerRoutingInformationBase result = null; boolean created = false; synchronized (peerRibs) { if(!peerRibs.containsKey(peerName)) { PeerRoutingInformationBase prib = pribProvider.get(); prib.setPeerName(peerName); peerRibs.put(peerName, prib); created = true; } result = peerRibs.get(peerName); } if(created) peerRibCreated.fire(new PeerRoutingInformationBaseCreated(peerName)); return result; }  PeerRoutingInformationBase peerRoutingInformationBase(String peerName); @Override PeerRoutingInformationBase extensionRoutingInformationBase(String extensionName, String key); void destroyPeerRoutingInformationBase(String peerName); void vistPeerRoutingBases(PeerRoutingInformationBaseVisitor visitor); void resetManager(); boolean isPeerRoutingInformationBaseAvailable(String peerName);  }
@Test(expected=IllegalArgumentException.class) public void testNullName() { manager.peerRoutingInformationBase(null); }
@Test(expected=IllegalArgumentException.class) public void testEmptyName() { manager.peerRoutingInformationBase(""); }
@Test(expected=IllegalArgumentException.class) public void testBlankName() { manager.peerRoutingInformationBase(" "); }
@Test public void testDifferentGet() { PeerRoutingInformationBase base1 = manager.peerRoutingInformationBase("foo"); PeerRoutingInformationBase base2 = manager.peerRoutingInformationBase("bar"); Assert.assertFalse(base1.equals(base2)); Assert.assertEquals(2, createCatcher.pribSize()); Assert.assertEquals(1, createCatcher.getPRIBCreatedCount("foo")); Assert.assertEquals(1, createCatcher.getPRIBCreatedCount("bar")); }
@Test public void testDuplicateGet() { PeerRoutingInformationBase base1 = manager.peerRoutingInformationBase("foo"); PeerRoutingInformationBase base2 = manager.peerRoutingInformationBase("foo"); Assert.assertEquals(base1, base2); Assert.assertEquals(1, createCatcher.pribSize()); Assert.assertEquals(1, createCatcher.getPRIBCreatedCount("foo")); }