Search in sources :

Example 1 with SimpleBroadcaster

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);
}
Also used : SimpleBroadcaster(org.atmosphere.util.SimpleBroadcaster) UUIDBroadcasterCache(org.atmosphere.cache.UUIDBroadcasterCache) Test(org.testng.annotations.Test)

Example 2 with SimpleBroadcaster

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);
}
Also used : SimpleBroadcaster(org.atmosphere.util.SimpleBroadcaster) UUIDBroadcasterCache(org.atmosphere.cache.UUIDBroadcasterCache) Test(org.testng.annotations.Test)

Example 3 with SimpleBroadcaster

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);
}
Also used : SimpleBroadcaster(org.atmosphere.util.SimpleBroadcaster) UUIDBroadcasterCache(org.atmosphere.cache.UUIDBroadcasterCache) Test(org.testng.annotations.Test)

Example 4 with SimpleBroadcaster

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);
}
Also used : SimpleBroadcaster(org.atmosphere.util.SimpleBroadcaster) UUIDBroadcasterCache(org.atmosphere.cache.UUIDBroadcasterCache) Test(org.testng.annotations.Test)

Aggregations

UUIDBroadcasterCache (org.atmosphere.cache.UUIDBroadcasterCache)4 SimpleBroadcaster (org.atmosphere.util.SimpleBroadcaster)4 Test (org.testng.annotations.Test)4