@Test public void traillingBroadcastTest() throws ExecutionException, InterruptedException { factory.get("/a/b"); factory.get("/b"); factory.get("/c"); assertEquals(MetaBroadcaster.getDefault().broadcastTo("/a/b", "yo").get().size(), 1); }
@Test public void exactBroadcastTest() throws ExecutionException, InterruptedException { factory.get("/a"); factory.get("/a/b"); factory.get("/c"); assertEquals(MetaBroadcaster.getDefault().broadcastTo("/a", "yo").get().get(0).getID(), "/a"); }
@Test public void chatTest() throws ExecutionException, InterruptedException { factory.get("/a/chat1"); factory.get("/a/chat2"); factory.get("/a/chat3"); assertEquals(MetaBroadcaster.getDefault().broadcastTo("/a", "yo").get().size(), 0); assertEquals(MetaBroadcaster.getDefault().broadcastTo("/a/", "yo").get().size(), 0); assertEquals(MetaBroadcaster.getDefault().broadcastTo("/a/*", "yo").get().size(), 3); }
@Test public void complexBroadcastTest() throws ExecutionException, InterruptedException { factory.get("/a/b/c/d"); factory.get("/b"); factory.get("/c"); assertEquals(MetaBroadcaster.getDefault().broadcastTo("/*", "yo").get().size(), 3); assertEquals(MetaBroadcaster.getDefault().broadcastTo("/a/b/c/d", "yo").get().size(), 1); assertEquals(MetaBroadcaster.getDefault().broadcastTo("/a", "yo").get().size(), 0); assertEquals(MetaBroadcaster.getDefault().broadcastTo("/b", "yo").get().size(), 1); }
@BeforeMethod public void setUp() throws Exception { AtmosphereConfig config = new AtmosphereFramework().getAtmosphereConfig(); DefaultBroadcasterFactory factory = new DefaultBroadcasterFactory(ExcludeSessionBroadcaster.class, "NEVER", config); broadcaster = factory.get(ExcludeSessionBroadcaster.class, "test"); atmosphereHandler = new AR(); ar = new AtmosphereResourceImpl( config, broadcaster, mock(AtmosphereRequest.class), AtmosphereResponse.create(), mock(BlockingIOCometSupport.class), atmosphereHandler); broadcaster.addAtmosphereResource(ar); }
@AfterMethod public void destroy() { factory.destroy(); }