Search in sources :

Example 66 with AtmosphereRequest

use of org.atmosphere.runtime.AtmosphereRequest in project atmosphere by Atmosphere.

the class PathTest method testSingletonAtmosphereHandler.

@Test
public void testSingletonAtmosphereHandler() throws IOException, ServletException {
    instanceCount = 0;
    AtmosphereRequest request = new AtmosphereRequestImpl.Builder().pathInfo("/singleton/atmospherehandler/yes").method("GET").build();
    framework.doCometSupport(request, AtmosphereResponseImpl.newInstance());
    assertEquals(instanceCount, 0);
    assertNotNull(r.get());
    assertEquals(r.get(), "/singleton/atmospherehandler/yes");
}
Also used : AtmosphereRequestImpl(org.atmosphere.runtime.AtmosphereRequestImpl) AtmosphereRequest(org.atmosphere.runtime.AtmosphereRequest) Test(org.testng.annotations.Test)

Example 67 with AtmosphereRequest

use of org.atmosphere.runtime.AtmosphereRequest in project atmosphere by Atmosphere.

the class PathTest method testAtmosphereHandlerPath.

@Test
public void testAtmosphereHandlerPath() throws IOException, ServletException {
    instanceCount = 0;
    AtmosphereRequest request = new AtmosphereRequestImpl.Builder().pathInfo("/ah/test2").method("GET").build();
    framework.doCometSupport(request, AtmosphereResponseImpl.newInstance());
    assertEquals(instanceCount, 1);
    assertNotNull(r.get());
    assertEquals(r.get(), "/ah/test2");
}
Also used : AtmosphereRequestImpl(org.atmosphere.runtime.AtmosphereRequestImpl) AtmosphereRequest(org.atmosphere.runtime.AtmosphereRequest) Test(org.testng.annotations.Test)

Example 68 with AtmosphereRequest

use of org.atmosphere.runtime.AtmosphereRequest in project atmosphere by Atmosphere.

the class PathTest method testMeteorPath.

@Test
public void testMeteorPath() throws IOException, ServletException {
    instanceCount = 0;
    AtmosphereRequest request = new AtmosphereRequestImpl.Builder().pathInfo("/a/b/test2").method("GET").build();
    framework.doCometSupport(request, AtmosphereResponseImpl.newInstance());
    assertEquals(instanceCount, 1);
    assertNotNull(r.get());
    assertEquals(r.get(), "/a/b/test2");
}
Also used : AtmosphereRequestImpl(org.atmosphere.runtime.AtmosphereRequestImpl) AtmosphereRequest(org.atmosphere.runtime.AtmosphereRequest) Test(org.testng.annotations.Test)

Example 69 with AtmosphereRequest

use of org.atmosphere.runtime.AtmosphereRequest in project atmosphere by Atmosphere.

the class PathTest method testManagedWebSocketPathMessage.

@Test
public void testManagedWebSocketPathMessage() throws IOException, ServletException {
    instanceCount = 0;
    ByteArrayOutputStream b = new ByteArrayOutputStream();
    final WebSocket w = new ArrayBaseWebSocket(b);
    final WebSocketProcessor processor = WebSocketProcessorFactory.getDefault().getWebSocketProcessor(framework);
    AtmosphereRequest request = new AtmosphereRequestImpl.Builder().pathInfo("/ws/bar").method("GET").build();
    processor.open(w, request, AtmosphereResponseImpl.newInstance(framework.getAtmosphereConfig(), request, w));
    assertEquals(instanceCount, 1);
    assertNotNull(r.get());
    assertEquals(r.get(), "/ws/bar");
}
Also used : AtmosphereRequestImpl(org.atmosphere.runtime.AtmosphereRequestImpl) AtmosphereRequest(org.atmosphere.runtime.AtmosphereRequest) WebSocketProcessor(org.atmosphere.websocket.WebSocketProcessor) ByteArrayOutputStream(java.io.ByteArrayOutputStream) WebSocket(org.atmosphere.websocket.WebSocket) Test(org.testng.annotations.Test)

Example 70 with AtmosphereRequest

use of org.atmosphere.runtime.AtmosphereRequest in project atmosphere by Atmosphere.

the class ManagedAtmosphereHandlerTest method testPostConstruct.

@Test
public void testPostConstruct() throws IOException, ServletException {
    AtmosphereRequest request = new AtmosphereRequestImpl.Builder().pathInfo("/postConstruct").method("GET").build();
    framework.doCometSupport(request, AtmosphereResponseImpl.newInstance());
    assertNotNull(r.get());
    r.get().resume();
    assertNotNull(message.get());
    assertEquals(message.get(), "postConstructmessage");
}
Also used : AtmosphereRequestImpl(org.atmosphere.runtime.AtmosphereRequestImpl) AtmosphereRequest(org.atmosphere.runtime.AtmosphereRequest) Test(org.testng.annotations.Test)

Aggregations

AtmosphereRequest (org.atmosphere.runtime.AtmosphereRequest)76 Test (org.testng.annotations.Test)39 AtmosphereRequestImpl (org.atmosphere.runtime.AtmosphereRequestImpl)38 IOException (java.io.IOException)23 AtmosphereResourceImpl (org.atmosphere.runtime.AtmosphereResourceImpl)20 AtmosphereResponse (org.atmosphere.runtime.AtmosphereResponse)18 ServletException (javax.servlet.ServletException)10 AsynchronousProcessor (org.atmosphere.runtime.AsynchronousProcessor)8 AtmosphereFramework (org.atmosphere.runtime.AtmosphereFramework)7 AtmosphereResource (org.atmosphere.runtime.AtmosphereResource)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 AsyncIOWriter (org.atmosphere.runtime.AsyncIOWriter)6 SimpleBroadcaster (org.atmosphere.util.SimpleBroadcaster)6 BeforeMethod (org.testng.annotations.BeforeMethod)6 ArrayList (java.util.ArrayList)5 AtmosphereInterceptorWriter (org.atmosphere.runtime.AtmosphereInterceptorWriter)5 AtmosphereResourceEvent (org.atmosphere.runtime.AtmosphereResourceEvent)5 Reader (java.io.Reader)4 Enumeration (java.util.Enumeration)4 ServletConfig (javax.servlet.ServletConfig)4