use of org.atmosphere.util.SimpleBroadcaster in project atmosphere by Atmosphere.
the class BroadcasterCacheTest method testCloseExcludeCache.
@Test
public void testCloseExcludeCache() throws ExecutionException, InterruptedException, ServletException, IOException {
UUIDBroadcasterCache cache = new UUIDBroadcasterCache();
SimpleBroadcaster b = config.getBroadcasterFactory().lookup(SimpleBroadcaster.class, "uuidTest", true);
cache.configure(config);
b.getBroadcasterConfig().setBroadcasterCache(cache);
// Reset
b.removeAtmosphereResource(ar);
b.addAtmosphereResource(ar);
b.broadcast("foo").get();
ar.close();
b.removeAtmosphereResource(ar);
b.broadcast("raide").get();
assertEquals(cache.messages().isEmpty(), false);
List<Object> l = cache.retrieveFromCache(b.getID(), ar.uuid());
assertNotNull(l);
assertEquals(l.isEmpty(), false);
}
use of org.atmosphere.util.SimpleBroadcaster in project atmosphere by Atmosphere.
the class BroadcasterCacheTest method testSuspendExcludeCache.
@Test
public void testSuspendExcludeCache() throws ExecutionException, InterruptedException, ServletException, IOException {
UUIDBroadcasterCache cache = new UUIDBroadcasterCache();
SimpleBroadcaster b = config.getBroadcasterFactory().lookup(SimpleBroadcaster.class, "uuidTest", true);
cache.configure(config);
b.getBroadcasterConfig().setBroadcasterCache(cache);
// Reset
b.removeAtmosphereResource(ar);
ar.suspend();
b.removeAtmosphereResource(ar);
b.broadcast("raide").get();
// Blocked by the cache because suspend has been called.
assertEquals(cache.messages().isEmpty(), true);
}
use of org.atmosphere.util.SimpleBroadcaster in project atmosphere by Atmosphere.
the class BroadcasterCacheTest method testCloseExcludeCache.
@Test
public void testCloseExcludeCache() throws ExecutionException, InterruptedException, ServletException, IOException {
UUIDBroadcasterCache cache = new UUIDBroadcasterCache();
SimpleBroadcaster b = config.getBroadcasterFactory().lookup(SimpleBroadcaster.class, "uuidTest", true);
cache.configure(config);
b.getBroadcasterConfig().setBroadcasterCache(cache);
// Reset
b.removeAtmosphereResource(ar);
b.addAtmosphereResource(ar);
b.broadcast("foo").get();
ar.close();
b.removeAtmosphereResource(ar);
b.broadcast("raide").get();
assertEquals(cache.messages().isEmpty(), false);
List<Object> l = cache.retrieveFromCache(b.getID(), ar.uuid());
assertNotNull(l);
assertEquals(l.isEmpty(), false);
}
use of org.atmosphere.util.SimpleBroadcaster in project atmosphere by Atmosphere.
the class BroadcasterCacheTest method testSuspendExcludeCache.
@Test
public void testSuspendExcludeCache() throws ExecutionException, InterruptedException, ServletException, IOException {
UUIDBroadcasterCache cache = new UUIDBroadcasterCache();
SimpleBroadcaster b = config.getBroadcasterFactory().lookup(SimpleBroadcaster.class, "uuidTest", true);
cache.configure(config);
b.getBroadcasterConfig().setBroadcasterCache(cache);
// Reset
b.removeAtmosphereResource(ar);
ar.suspend();
b.removeAtmosphereResource(ar);
b.broadcast("raide").get();
// Blocked by the cache because suspend has been called.
assertEquals(cache.messages().isEmpty(), true);
}
Aggregations