Search in sources :

Example 1 with TapestrySessionFactory

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

the class RequestImplTest method get_session_doesnt_exist.

@Test
public void get_session_doesnt_exist() {
    HttpServletRequest sr = mockHttpServletRequest();
    TapestrySessionFactory sf = newMock(TapestrySessionFactory.class);
    expect(sf.getSession(false)).andReturn(null);
    replay();
    Request request = new RequestImpl(sr, CHARSET, sf);
    assertNull(request.getSession(false));
    verify();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) TapestrySessionFactory(org.apache.tapestry5.http.internal.services.TapestrySessionFactory) HttpServletRequest(javax.servlet.http.HttpServletRequest) Request(org.apache.tapestry5.http.services.Request) RequestImpl(org.apache.tapestry5.http.internal.services.RequestImpl) Test(org.testng.annotations.Test)

Example 2 with TapestrySessionFactory

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

the class RequestImplTest method isSessionInvalidated_is_true_when_session_is_invalid.

@Test
public void isSessionInvalidated_is_true_when_session_is_invalid() {
    HttpServletRequest sr = mockHttpServletRequest();
    Session session = mockSession();
    TapestrySessionFactory sf = newMock(TapestrySessionFactory.class);
    expect(sf.getSession(false)).andReturn(session);
    expect(session.isInvalidated()).andReturn(true);
    replay();
    Request request = new RequestImpl(sr, CHARSET, sf);
    assertTrue(request.isSessionInvalidated());
    verify();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) TapestrySessionFactory(org.apache.tapestry5.http.internal.services.TapestrySessionFactory) HttpServletRequest(javax.servlet.http.HttpServletRequest) Request(org.apache.tapestry5.http.services.Request) RequestImpl(org.apache.tapestry5.http.internal.services.RequestImpl) HttpSession(javax.servlet.http.HttpSession) Session(org.apache.tapestry5.http.services.Session) Test(org.testng.annotations.Test)

Example 3 with TapestrySessionFactory

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

the class RequestImplTest method isSessionInvalidated_is_false_when_no_session_at_all.

@Test
public void isSessionInvalidated_is_false_when_no_session_at_all() {
    HttpServletRequest sr = mockHttpServletRequest();
    TapestrySessionFactory sf = newMock(TapestrySessionFactory.class);
    expect(sf.getSession(false)).andReturn(null);
    replay();
    Request request = new RequestImpl(sr, CHARSET, sf);
    assertFalse(request.isSessionInvalidated());
    verify();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) TapestrySessionFactory(org.apache.tapestry5.http.internal.services.TapestrySessionFactory) HttpServletRequest(javax.servlet.http.HttpServletRequest) Request(org.apache.tapestry5.http.services.Request) RequestImpl(org.apache.tapestry5.http.internal.services.RequestImpl) Test(org.testng.annotations.Test)

Example 4 with TapestrySessionFactory

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

the class RequestImplTest method force_session_create.

@Test
public void force_session_create() {
    HttpServletRequest sr = mockHttpServletRequest();
    TapestrySessionFactory sf = newMock(TapestrySessionFactory.class);
    Session session = mockSession();
    expect(sf.getSession(true)).andReturn(session);
    replay();
    Request request = new RequestImpl(sr, CHARSET, sf);
    assertSame(request.getSession(true), session);
    verify();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) TapestrySessionFactory(org.apache.tapestry5.http.internal.services.TapestrySessionFactory) HttpServletRequest(javax.servlet.http.HttpServletRequest) Request(org.apache.tapestry5.http.services.Request) RequestImpl(org.apache.tapestry5.http.internal.services.RequestImpl) HttpSession(javax.servlet.http.HttpSession) Session(org.apache.tapestry5.http.services.Session) Test(org.testng.annotations.Test)

Example 5 with TapestrySessionFactory

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

the class RequestImplTest method isSessionInvalidated_is_false_when_session_exists_and_is_valid.

@Test
public void isSessionInvalidated_is_false_when_session_exists_and_is_valid() {
    HttpServletRequest sr = mockHttpServletRequest();
    Session session = mockSession();
    TapestrySessionFactory sf = newMock(TapestrySessionFactory.class);
    expect(sf.getSession(false)).andReturn(session);
    expect(session.isInvalidated()).andReturn(false);
    replay();
    Request request = new RequestImpl(sr, CHARSET, sf);
    assertFalse(request.isSessionInvalidated());
    verify();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) TapestrySessionFactory(org.apache.tapestry5.http.internal.services.TapestrySessionFactory) HttpServletRequest(javax.servlet.http.HttpServletRequest) Request(org.apache.tapestry5.http.services.Request) RequestImpl(org.apache.tapestry5.http.internal.services.RequestImpl) HttpSession(javax.servlet.http.HttpSession) Session(org.apache.tapestry5.http.services.Session) Test(org.testng.annotations.Test)

Aggregations

HttpServletRequest (javax.servlet.http.HttpServletRequest)5 RequestImpl (org.apache.tapestry5.http.internal.services.RequestImpl)5 TapestrySessionFactory (org.apache.tapestry5.http.internal.services.TapestrySessionFactory)5 Request (org.apache.tapestry5.http.services.Request)5 Test (org.testng.annotations.Test)5 HttpSession (javax.servlet.http.HttpSession)3 Session (org.apache.tapestry5.http.services.Session)3