Search in sources :

Example 1 with SessionImpl

use of org.apache.tapestry5.http.internal.services.SessionImpl in project tapestry-5 by apache.

the class SessionImplTest method http_session_invalidate.

@Test
public void http_session_invalidate() {
    HttpSession hs = mockHttpSession();
    HttpServletRequest hsr = mockHttpServletRequest();
    SessionLock lock = mockLock();
    train_getSession(hsr, false, hs);
    replay();
    Session session = new SessionImpl(hsr, hs, lock);
    assertFalse(session.isInvalidated());
    verify();
    train_getSession(hsr, false, null);
    replay();
    assertTrue(session.isInvalidated());
    verify();
    train_getSession(hsr, false, mockHttpSession());
    replay();
    assertTrue(session.isInvalidated());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpSession(javax.servlet.http.HttpSession) SessionImpl(org.apache.tapestry5.http.internal.services.SessionImpl) ClusteredSessionImpl(org.apache.tapestry5.http.internal.services.ClusteredSessionImpl) SessionLock(org.apache.tapestry5.http.internal.services.SessionLock) HttpSession(javax.servlet.http.HttpSession) Session(org.apache.tapestry5.http.services.Session) Test(org.testng.annotations.Test)

Example 2 with SessionImpl

use of org.apache.tapestry5.http.internal.services.SessionImpl in project tapestry-5 by apache.

the class SessionImplTest method get_max_inactive.

@Test
public void get_max_inactive() {
    HttpSession hs = mockHttpSession();
    int seconds = 999;
    expect(hs.getMaxInactiveInterval()).andReturn(seconds);
    replay();
    Session session = new SessionImpl(null, hs, null);
    assertEquals(session.getMaxInactiveInterval(), seconds);
    verify();
}
Also used : HttpSession(javax.servlet.http.HttpSession) SessionImpl(org.apache.tapestry5.http.internal.services.SessionImpl) ClusteredSessionImpl(org.apache.tapestry5.http.internal.services.ClusteredSessionImpl) HttpSession(javax.servlet.http.HttpSession) Session(org.apache.tapestry5.http.services.Session) Test(org.testng.annotations.Test)

Example 3 with SessionImpl

use of org.apache.tapestry5.http.internal.services.SessionImpl in project tapestry-5 by apache.

the class SessionImplTest method get_attribute_names.

@Test
public void get_attribute_names() {
    Enumeration e = Collections.enumeration(Arrays.asList("fred", "barney"));
    HttpSession hs = mockHttpSession();
    SessionLock lock = mockLock();
    lock.acquireReadLock();
    expect(hs.getAttributeNames()).andReturn(e);
    replay();
    Session session = new SessionImpl(null, hs, lock);
    assertEquals(session.getAttributeNames(), Arrays.asList("barney", "fred"));
    verify();
}
Also used : Enumeration(java.util.Enumeration) HttpSession(javax.servlet.http.HttpSession) SessionImpl(org.apache.tapestry5.http.internal.services.SessionImpl) ClusteredSessionImpl(org.apache.tapestry5.http.internal.services.ClusteredSessionImpl) SessionLock(org.apache.tapestry5.http.internal.services.SessionLock) HttpSession(javax.servlet.http.HttpSession) Session(org.apache.tapestry5.http.services.Session) Test(org.testng.annotations.Test)

Example 4 with SessionImpl

use of org.apache.tapestry5.http.internal.services.SessionImpl in project tapestry-5 by apache.

the class SessionImplTest method invalidate.

@Test
public void invalidate() {
    HttpSession hs = mockHttpSession();
    SessionLock lock = mockLock();
    hs.invalidate();
    replay();
    Session session = new SessionImpl(null, hs, lock);
    session.invalidate();
    verify();
}
Also used : HttpSession(javax.servlet.http.HttpSession) SessionImpl(org.apache.tapestry5.http.internal.services.SessionImpl) ClusteredSessionImpl(org.apache.tapestry5.http.internal.services.ClusteredSessionImpl) SessionLock(org.apache.tapestry5.http.internal.services.SessionLock) HttpSession(javax.servlet.http.HttpSession) Session(org.apache.tapestry5.http.services.Session) Test(org.testng.annotations.Test)

Example 5 with SessionImpl

use of org.apache.tapestry5.http.internal.services.SessionImpl in project tapestry-5 by apache.

the class SessionImplTest method get_attribute_names_by_prefix.

@Test
public void get_attribute_names_by_prefix() {
    Enumeration e = Collections.enumeration(Arrays.asList("fred", "barney", "fanny"));
    HttpSession hs = mockHttpSession();
    SessionLock lock = mockLock();
    lock.acquireReadLock();
    expect(hs.getAttributeNames()).andReturn(e);
    replay();
    Session session = new SessionImpl(null, hs, lock);
    assertEquals(session.getAttributeNames("f"), Arrays.asList("fanny", "fred"));
    verify();
}
Also used : Enumeration(java.util.Enumeration) HttpSession(javax.servlet.http.HttpSession) SessionImpl(org.apache.tapestry5.http.internal.services.SessionImpl) ClusteredSessionImpl(org.apache.tapestry5.http.internal.services.ClusteredSessionImpl) SessionLock(org.apache.tapestry5.http.internal.services.SessionLock) HttpSession(javax.servlet.http.HttpSession) Session(org.apache.tapestry5.http.services.Session) Test(org.testng.annotations.Test)

Aggregations

HttpSession (javax.servlet.http.HttpSession)6 ClusteredSessionImpl (org.apache.tapestry5.http.internal.services.ClusteredSessionImpl)6 SessionImpl (org.apache.tapestry5.http.internal.services.SessionImpl)6 Session (org.apache.tapestry5.http.services.Session)6 Test (org.testng.annotations.Test)6 SessionLock (org.apache.tapestry5.http.internal.services.SessionLock)4 Enumeration (java.util.Enumeration)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)1