EmbeddedEPNManager extends AbstractEPNManager { protected java.util.Map<String,java.util.List<EmbeddedChannel>> getEntryPoints() { return (_entryPoints); }  void publish(String subject, java.util.List<? extends java.io.Serializable> events); void close();  }
@Test public void testMultipleEntryPointsForSameSubject() { Network net1=new Network(); net1.setName(TEST_NETWORK); net1.setVersion(VER1); Subscription sub1=new Subscription(); sub1.setSubject(TEST_SUBJECT); sub1.setNodeName(N1); net1.getSubscriptions().add(sub1); Node n1=new Node(); n1.setName(N1); n1.setPredicate(new TestPredicate1()); n1.setEventProcessor(new TestEventProcessorB()); net1.getNodes().add(n1); Network net2=new Network(); net2.setName(TEST_NETWORK2); net2.setVersion(VER1); Subscription sub2=new Subscription(); sub2.setSubject(TEST_SUBJECT); sub2.setNodeName(N2); net2.getSubscriptions().add(sub2); Node n2=new Node(); n2.setName(N2); n2.setPredicate(new TestPredicate2()); n2.setMaxRetries(MAX_RETRIES); TestEventProcessorC tea=new TestEventProcessorC(); n2.setEventProcessor(tea); net2.getNodes().add(n2); EmbeddedEPNManager mgr=new EmbeddedEPNManager(); try { mgr.register(net1); java.util.List<EmbeddedChannel> ch1=mgr.getEntryPoints().get(TEST_SUBJECT); if (ch1 == null) { fail("Failed to get channels for test subject"); } else if (ch1.size() != 1) { fail("Number of channels for test subject should be 1: "+ch1.size()); } mgr.register(net2); if (ch1.size() != 2) { fail("Number of channels for test subject should now be 2: "+ch1.size()); } } catch(Exception e) { fail("Test failed: "+e); } }
@Test public void testEntryPointsForDifferentSubjects() { Network net1=new Network(); net1.setName(TEST_NETWORK); net1.setVersion(VER1); Subscription sub1=new Subscription(); sub1.setSubject(TEST_SUBJECT); sub1.setNodeName(N1); net1.getSubscriptions().add(sub1); Node n1=new Node(); n1.setName(N1); n1.setPredicate(new TestPredicate1()); n1.setEventProcessor(new TestEventProcessorB()); net1.getNodes().add(n1); Network net2=new Network(); net2.setName(TEST_NETWORK2); net2.setVersion(VER1); Subscription sub2=new Subscription(); sub2.setSubject(TEST_SUBJECT2); sub2.setNodeName(N2); net2.getSubscriptions().add(sub2); Node n2=new Node(); n2.setName(N2); n2.setPredicate(new TestPredicate2()); n2.setMaxRetries(MAX_RETRIES); TestEventProcessorC tea=new TestEventProcessorC(); n2.setEventProcessor(tea); net2.getNodes().add(n2); EmbeddedEPNManager mgr=new EmbeddedEPNManager(); try { mgr.register(net1); mgr.register(net2); java.util.List<EmbeddedChannel> ch1=mgr.getEntryPoints().get(TEST_SUBJECT); if (ch1 == null) { fail("Failed to get channels for test subject"); } else if (ch1.size() != 1) { fail("Number of channels for test subject should be 1: "+ch1.size()); } java.util.List<EmbeddedChannel> ch2=mgr.getEntryPoints().get(TEST_SUBJECT2); if (ch2 == null) { fail("Failed to get channels for test subject2"); } else if (ch2.size() != 1) { fail("Number of channels for test subject2 should be 1: "+ch2.size()); } } catch(Exception e) { fail("Test failed: "+e); } }
@Test public void testMultipleEntryPointsForSameSubjectRemoved() { Network net1=new Network(); net1.setName(TEST_NETWORK); net1.setVersion(VER1); Subscription sub1=new Subscription(); sub1.setSubject(TEST_SUBJECT); sub1.setNodeName(N1); net1.getSubscriptions().add(sub1); Node n1=new Node(); n1.setName(N1); n1.setPredicate(new TestPredicate1()); n1.setEventProcessor(new TestEventProcessorB()); net1.getNodes().add(n1); Network net2=new Network(); net2.setName(TEST_NETWORK2); net2.setVersion(VER1); Subscription sub2=new Subscription(); sub2.setSubject(TEST_SUBJECT); sub2.setNodeName(N2); net2.getSubscriptions().add(sub2); Node n2=new Node(); n2.setName(N2); n2.setPredicate(new TestPredicate2()); n2.setMaxRetries(MAX_RETRIES); TestEventProcessorC tea=new TestEventProcessorC(); n2.setEventProcessor(tea); net2.getNodes().add(n2); EmbeddedEPNManager mgr=new EmbeddedEPNManager(); try { mgr.register(net1); mgr.register(net2); mgr.unregister(TEST_NETWORK, null); java.util.List<EmbeddedChannel> ch1=mgr.getEntryPoints().get(TEST_SUBJECT); if (ch1 == null) { fail("Failed to get channels for test subject"); } else if (ch1.size() != 1) { fail("Number of channels for test subject should be 1: "+ch1.size()); } mgr.unregister(TEST_NETWORK2, null); java.util.List<EmbeddedChannel> ch2=mgr.getEntryPoints().get(TEST_SUBJECT); if (ch2 != null) { fail("No channels should exist for test subject"); } } catch(Exception e) { fail("Test failed: "+e); } }
@Test public void testMultipleVersionEntryPoints1() { Network net1=new Network(); net1.setName(TEST_NETWORK); net1.setVersion(VER1); Subscription sub1=new Subscription(); sub1.setSubject(TEST_SUBJECT); sub1.setNodeName(N1); net1.getSubscriptions().add(sub1); Node n1=new Node(); n1.setName(N1); n1.setPredicate(new TestPredicate1()); n1.setEventProcessor(new TestEventProcessorB()); net1.getNodes().add(n1); Network net2=new Network(); net2.setName(TEST_NETWORK); net2.setVersion(VER2); Subscription sub2=new Subscription(); sub2.setSubject(TEST_SUBJECT); sub2.setNodeName(N2); net2.getSubscriptions().add(sub2); Node n2=new Node(); n2.setName(N2); n2.setPredicate(new TestPredicate2()); n2.setMaxRetries(MAX_RETRIES); TestEventProcessorC tea=new TestEventProcessorC(); n2.setEventProcessor(tea); net2.getNodes().add(n2); EmbeddedEPNManager mgr=new EmbeddedEPNManager(); try { mgr.register(net1); java.util.List<EmbeddedChannel> ch1=mgr.getEntryPoints().get(TEST_SUBJECT); if (ch1 == null) { fail("Failed to get channels for test subject"); } else if (ch1.size() != 1) { fail("Number of channels for test subject should be 1: "+ch1.size()); } if (!ch1.get(0).getNodeName().equals(N1)) { fail("Expected N1"); } mgr.register(net2); java.util.List<EmbeddedChannel> ch2=mgr.getEntryPoints().get(TEST_SUBJECT); if (ch2 == null) { fail("Failed to get channels(2) for test subject"); } else if (ch2.size() != 1) { fail("Number of channels(2) for test subject should be 1: "+ch2.size()); } if (!ch2.get(0).getNodeName().equals(N2)) { fail("Expected N2"); } mgr.unregister(TEST_NETWORK, null); java.util.List<EmbeddedChannel> ch3=mgr.getEntryPoints().get(TEST_SUBJECT); if (ch3 == null) { fail("Failed to get channels(3) for test subject"); } else if (ch3.size() != 1) { fail("Number of channels(3) for test subject should be 1: "+ch3.size()); } if (!ch3.get(0).getNodeName().equals(N1)) { fail("Expected N1 again"); } mgr.unregister(TEST_NETWORK, null); java.util.List<EmbeddedChannel> ch4=mgr.getEntryPoints().get(TEST_SUBJECT); if (ch4 != null) { fail("Should be no channels for subject"); } } catch(Exception e) { fail("Test failed: "+e); } }
@Test public void testMultipleVersionEntryPoints2() { Network net1=new Network(); net1.setName(TEST_NETWORK); net1.setVersion(VER1); Subscription sub1=new Subscription(); sub1.setSubject(TEST_SUBJECT); sub1.setNodeName(N1); net1.getSubscriptions().add(sub1); Node n1=new Node(); n1.setName(N1); n1.setPredicate(new TestPredicate1()); n1.setEventProcessor(new TestEventProcessorB()); net1.getNodes().add(n1); Network net2=new Network(); net2.setName(TEST_NETWORK); net2.setVersion(VER2); Subscription sub2=new Subscription(); sub2.setSubject(TEST_SUBJECT); sub2.setNodeName(N2); net2.getSubscriptions().add(sub2); Node n2=new Node(); n2.setName(N2); n2.setPredicate(new TestPredicate2()); n2.setMaxRetries(MAX_RETRIES); TestEventProcessorC tea=new TestEventProcessorC(); n2.setEventProcessor(tea); net2.getNodes().add(n2); EmbeddedEPNManager mgr=new EmbeddedEPNManager(); try { mgr.register(net1); java.util.List<EmbeddedChannel> ch1=mgr.getEntryPoints().get(TEST_SUBJECT); if (ch1 == null) { fail("Failed to get channels for test subject"); } else if (ch1.size() != 1) { fail("Number of channels for test subject should be 1: "+ch1.size()); } if (!ch1.get(0).getNodeName().equals(N1)) { fail("Expected N1"); } mgr.register(net2); java.util.List<EmbeddedChannel> ch2=mgr.getEntryPoints().get(TEST_SUBJECT); if (ch2 == null) { fail("Failed to get channels(2) for test subject"); } else if (ch2.size() != 1) { fail("Number of channels(2) for test subject should be 1: "+ch2.size()); } if (!ch2.get(0).getNodeName().equals(N2)) { fail("Expected N2"); } mgr.unregister(TEST_NETWORK, VER1); java.util.List<EmbeddedChannel> ch3=mgr.getEntryPoints().get(TEST_SUBJECT); if (ch3 == null) { fail("Failed to get channels(3) for test subject"); } else if (ch3.size() != 1) { fail("Number of channels(3) for test subject should be 1: "+ch3.size()); } if (!ch3.get(0).getNodeName().equals(N2)) { fail("Expected N2 still"); } } catch(Exception e) { fail("Test failed: "+e); } }