Search in sources :

Example 6 with FakeHttpSession

use of org.atmosphere.util.FakeHttpSession in project atmosphere by Atmosphere.

the class SessionTest method basicAtmosphereResourceSessionTest.

@Test
public void basicAtmosphereResourceSessionTest() throws IOException, ServletException, ExecutionException, InterruptedException {
    AtmosphereRequest request = new AtmosphereRequestImpl.Builder().build();
    AtmosphereResponse response = new AtmosphereResponseImpl.Builder().build();
    AtmosphereConfig config = new AtmosphereFramework().getAtmosphereConfig();
    AtmosphereResource r = config.resourcesFactory().create(new AtmosphereFramework().getAtmosphereConfig(), request, response, mock(AsyncSupport.class));
    r.getAtmosphereConfig().setSupportSession(true);
    assertNull(r.session(false));
    assertNotNull(r.session());
    assertNotNull(r.session(true));
    assertNotNull(r.session());
    request = new AtmosphereRequestImpl.Builder().session(new FakeHttpSession("-1", null, System.currentTimeMillis(), -1)).build();
    response = new AtmosphereResponseImpl.Builder().build();
    r = config.resourcesFactory().create(new AtmosphereFramework().getAtmosphereConfig(), request, response, mock(AsyncSupport.class));
    r.getAtmosphereConfig().setSupportSession(true);
    assertNotNull(r.session());
    assertNotNull(r.session(true));
}
Also used : FakeHttpSession(org.atmosphere.util.FakeHttpSession) Test(org.testng.annotations.Test)

Aggregations

FakeHttpSession (org.atmosphere.util.FakeHttpSession)6 Test (org.testng.annotations.Test)4 Cookie (jakarta.servlet.http.Cookie)1 HttpServletRequest (jakarta.servlet.http.HttpServletRequest)1 HttpSession (jakarta.servlet.http.HttpSession)1 HashSet (java.util.HashSet)1 Cookie (javax.servlet.http.Cookie)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpSession (javax.servlet.http.HttpSession)1