use of org.eclipse.scout.rt.server.IServerSession in project scout.rt by eclipse.
the class ServerSessionCacheTest method testMultipleHttpSessionsMultipleSessionIds.
/**
* If there are multiple HTTP sessions, and multiple sessionIds, the sessions should be different.
*/
@Test
public void testMultipleHttpSessionsMultipleSessionIds() {
TestHttpSession httpSession1 = new TestHttpSession();
TestHttpSession httpSession2 = new TestHttpSession();
IServerSessionLifecycleHandler handler1 = new TestServerSessionLifecycleHandler("id1");
IServerSessionLifecycleHandler handler2 = new TestServerSessionLifecycleHandler("id2");
IServerSession session1 = BEANS.get(ServerSessionCache.class).getOrCreate(handler1, httpSession1);
IServerSession session2 = BEANS.get(ServerSessionCache.class).getOrCreate(handler2, httpSession2);
assertNotSame(session1, session2);
}
use of org.eclipse.scout.rt.server.IServerSession in project scout.rt by eclipse.
the class ServerSessionCacheTest method testMultipleHttpSessions.
/**
* If there are multiple HTTP sessions (can happen, if many requests are created in parallel for the same sessionId),
* but a single sessionId, a new server session should only be created once.
*/
@Test
public void testMultipleHttpSessions() {
TestHttpSession httpSession1 = new TestHttpSession();
TestHttpSession httpSession2 = new TestHttpSession();
IServerSessionLifecycleHandler handler = new TestServerSessionLifecycleHandler();
IServerSession session1 = BEANS.get(ServerSessionCache.class).getOrCreate(handler, httpSession1);
IServerSession session2 = BEANS.get(ServerSessionCache.class).getOrCreate(handler, httpSession2);
assertSame(session1, session2);
}
use of org.eclipse.scout.rt.server.IServerSession in project scout.rt by eclipse.
the class SessionFutureFilterTest method test.
@Test
public void test() {
IServerSession session1 = mock(IServerSession.class);
IServerSession session2 = mock(IServerSession.class);
SessionFutureFilter filter = new SessionFutureFilter(session1);
// Tests a Future of a job without RunContext
assertFalse(filter.accept(Jobs.schedule(mock(IRunnable.class), Jobs.newInput())));
// Tests a Future of a job with RunContext
assertFalse(filter.accept(Jobs.schedule(mock(IRunnable.class), Jobs.newInput().withRunContext(RunContexts.empty()))));
// Tests a Future of a job with ClientRunContext without session
assertFalse(filter.accept(Jobs.schedule(mock(IRunnable.class), Jobs.newInput().withRunContext(ServerRunContexts.empty()))));
// Tests a Future of a job with ClientRunContext with correct session
assertTrue(filter.accept(Jobs.schedule(mock(IRunnable.class), Jobs.newInput().withRunContext(ServerRunContexts.empty().withSession(session1)))));
// Tests a Future of a job with ClientRunContext with wrong session
assertFalse(filter.accept(Jobs.schedule(mock(IRunnable.class), Jobs.newInput().withRunContext(ServerRunContexts.empty().withSession(session2)))));
// Test adaptable to the session
assertSame(session1, filter.getAdapter(ISession.class));
}
Aggregations