Search in sources :

Example 26 with ImmutableSession

use of org.wildfly.clustering.web.session.ImmutableSession in project wildfly by wildfly.

the class UndertowHttpSessionFactoryTestCase method getId.

@Test
public void getId() {
    ImmutableSession session = mock(ImmutableSession.class);
    ServletContext context = mock(ServletContext.class);
    String expected = "session";
    when(session.getId()).thenReturn(expected);
    String result = this.factory.createHttpSession(session, context).getId();
    assertSame(expected, result);
}
Also used : ImmutableSession(org.wildfly.clustering.web.session.ImmutableSession) ServletContext(javax.servlet.ServletContext) Test(org.junit.Test)

Example 27 with ImmutableSession

use of org.wildfly.clustering.web.session.ImmutableSession in project wildfly by wildfly.

the class UndertowHttpSessionFactoryTestCase method setAttribute.

@Test
public void setAttribute() {
    ImmutableSession session = mock(ImmutableSession.class);
    ServletContext context = mock(ServletContext.class);
    this.factory.createHttpSession(session, context).setAttribute("name", "value");
    verifyNoInteractions(session);
}
Also used : ImmutableSession(org.wildfly.clustering.web.session.ImmutableSession) ServletContext(javax.servlet.ServletContext) Test(org.junit.Test)

Example 28 with ImmutableSession

use of org.wildfly.clustering.web.session.ImmutableSession in project wildfly by wildfly.

the class UndertowHttpSessionFactoryTestCase method invalidate.

@Test
public void invalidate() {
    ImmutableSession session = mock(ImmutableSession.class);
    ServletContext context = mock(ServletContext.class);
    this.factory.createHttpSession(session, context).invalidate();
    verifyNoInteractions(session);
}
Also used : ImmutableSession(org.wildfly.clustering.web.session.ImmutableSession) ServletContext(javax.servlet.ServletContext) Test(org.junit.Test)

Example 29 with ImmutableSession

use of org.wildfly.clustering.web.session.ImmutableSession in project wildfly by wildfly.

the class UndertowHttpSessionFactoryTestCase method getCreationTime.

@Test
public void getCreationTime() {
    ImmutableSession session = mock(ImmutableSession.class);
    ServletContext context = mock(ServletContext.class);
    SessionMetaData metaData = mock(SessionMetaData.class);
    Instant now = Instant.now();
    when(session.getMetaData()).thenReturn(metaData);
    when(metaData.getCreationTime()).thenReturn(now);
    long result = this.factory.createHttpSession(session, context).getCreationTime();
    assertEquals(now.toEpochMilli(), result);
}
Also used : ImmutableSession(org.wildfly.clustering.web.session.ImmutableSession) SessionMetaData(org.wildfly.clustering.web.session.SessionMetaData) Instant(java.time.Instant) ServletContext(javax.servlet.ServletContext) Test(org.junit.Test)

Example 30 with ImmutableSession

use of org.wildfly.clustering.web.session.ImmutableSession in project wildfly by wildfly.

the class UndertowHttpSessionFactoryTestCase method setMaxInactiveInterval.

@Test
public void setMaxInactiveInterval() {
    ImmutableSession session = mock(ImmutableSession.class);
    ServletContext context = mock(ServletContext.class);
    this.factory.createHttpSession(session, context).setMaxInactiveInterval(10);
    verifyNoInteractions(session);
}
Also used : ImmutableSession(org.wildfly.clustering.web.session.ImmutableSession) ServletContext(javax.servlet.ServletContext) Test(org.junit.Test)

Aggregations

ImmutableSession (org.wildfly.clustering.web.session.ImmutableSession)35 Test (org.junit.Test)27 Batch (org.wildfly.clustering.ee.Batch)13 ImmutableSessionMetaData (org.wildfly.clustering.web.session.ImmutableSessionMetaData)13 ServletContext (javax.servlet.ServletContext)12 ImmutableSessionAttributes (org.wildfly.clustering.web.session.ImmutableSessionAttributes)9 Map (java.util.Map)7 Instant (java.time.Instant)5 SessionExpirationListener (org.wildfly.clustering.web.session.SessionExpirationListener)4 SessionMetaData (org.wildfly.clustering.web.session.SessionMetaData)4 Session (io.undertow.server.session.Session)2 Duration (java.time.Duration)2 SimpleImmutableSession (org.wildfly.clustering.web.cache.session.SimpleImmutableSession)2 ValidSession (org.wildfly.clustering.web.cache.session.ValidSession)2 SessionAttributes (org.wildfly.clustering.web.session.SessionAttributes)2 SessionListener (io.undertow.server.session.SessionListener)1 SessionListeners (io.undertow.server.session.SessionListeners)1 Deployment (io.undertow.servlet.api.Deployment)1 IOException (java.io.IOException)1 ByteBuffer (java.nio.ByteBuffer)1