AbstractEPNManager implements EPNManager { public void register(Network network) throws Exception { LOG.info(MessageFormat.format(java.util.PropertyResourceBundle.getBundle( "epn-core.Messages").getString("EPN-CORE-13"), network.getName(), network.getVersion())); network.init(getContainer()); if (!EPNValidator.validate(network, getValidationListener())) { network.close(); throw new Exception(MessageFormat.format(java.util.PropertyResourceBundle.getBundle( "epn-core.Messages").getString("EPN-CORE-12"), network.getName(), network.getVersion())); } synchronized (_networkMap) { NetworkList nl=_networkMap.get(network.getName()); if (nl == null) { nl = new NetworkList(); _networkMap.put(network.getName(), nl); } Network oldnet=nl.getCurrent(); nl.add(network); if (nl.getCurrent() == network) { currentNetworkChanged(oldnet, network); } } synchronized (_networkListeners) { for (int i=0; i < _networkListeners.size(); i++) { _networkListeners.get(i).registered(network); } } } AbstractEPNManager(); void init(); void register(Network network); void unregister(String networkName, String version); void addNotificationListener(String subject, NotificationListener l); void removeNotificationListener(String subject, NotificationListener l); void addNetworkListener(NetworkListener l); void removeNetworkListener(NetworkListener l); void close();  }
@Test public void testRegisterNetworkIncorrectRootNodeName() { Network net=new Network(); net.setName(TEST_NETWORK); Subscription sub=new Subscription(); sub.setNodeName(N2); sub.setSubject(TEST_SUBJECT1); net.getSubscriptions().add(sub); Node n1=new Node(); n1.setName(N1); n1.setEventProcessor(new TestEventProcessorA()); net.getNodes().add(n1); AbstractEPNManager mgr=getManager(); try { mgr.register(net); fail("Network registration should fail due to missing or incorrect root node"); } catch(Exception e) { } }
@Test public void testRegisterInvalidNetwork() { Network net=new Network(); AbstractEPNManager mgr=getManager(); try { mgr.register(net); fail("Network registration should fail due to validation issues"); } catch(Exception e) { } }
@Test public void testRegisterNetworkNodeNoEventProcessor() { Network net=new Network(); net.setName(TEST_NETWORK); Node n1=new Node(); n1.setName(N1); net.getNodes().add(n1); AbstractEPNManager mgr=getManager(); try { mgr.register(net); fail("Network registration should fail due to node with missing event processor"); } catch(Exception e) { } }