use of org.wildfly.clustering.web.session.ImmutableSession in project wildfly by wildfly.
the class UndertowHttpSessionFactoryTestCase method getLastAccessedTime.
@Test
public void getLastAccessedTime() {
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.getLastAccessStartTime()).thenReturn(now);
long result = this.factory.createHttpSession(session, context).getLastAccessedTime();
assertEquals(now.toEpochMilli(), result);
}
use of org.wildfly.clustering.web.session.ImmutableSession in project wildfly by wildfly.
the class UndertowHttpSessionFactoryTestCase method removeAttribute.
@Test
public void removeAttribute() {
ImmutableSession session = mock(ImmutableSession.class);
ServletContext context = mock(ServletContext.class);
this.factory.createHttpSession(session, context).removeAttribute("name");
verifyNoInteractions(session);
}
use of org.wildfly.clustering.web.session.ImmutableSession in project wildfly by wildfly.
the class OOBSessionTestCase method isNew.
@Test
public void isNew() {
Batcher<Batch> batcher = mock(Batcher.class);
Batch batch = mock(Batch.class);
when(this.manager.getBatcher()).thenReturn(batcher);
when(batcher.createBatch()).thenReturn(batch);
when(this.manager.readSession(this.id)).thenReturn(null);
Assert.assertThrows(IllegalStateException.class, this.session.getMetaData()::isNew);
verify(batch).close();
reset(batch);
ImmutableSession session = mock(ImmutableSession.class);
ImmutableSessionMetaData metaData = mock(ImmutableSessionMetaData.class);
boolean expected = true;
when(this.manager.readSession(this.id)).thenReturn(session);
when(session.getMetaData()).thenReturn(metaData);
when(metaData.isNew()).thenReturn(expected);
boolean result = this.session.getMetaData().isNew();
Assert.assertEquals(expected, result);
verify(batch).close();
}
use of org.wildfly.clustering.web.session.ImmutableSession in project wildfly by wildfly.
the class OOBSessionTestCase method getCreationTime.
@Test
public void getCreationTime() {
Batcher<Batch> batcher = mock(Batcher.class);
Batch batch = mock(Batch.class);
when(this.manager.getBatcher()).thenReturn(batcher);
when(batcher.createBatch()).thenReturn(batch);
when(this.manager.readSession(this.id)).thenReturn(null);
Assert.assertThrows(IllegalStateException.class, this.session.getMetaData()::getCreationTime);
verify(batch).close();
reset(batch);
ImmutableSession session = mock(ImmutableSession.class);
ImmutableSessionMetaData metaData = mock(ImmutableSessionMetaData.class);
Instant expected = Instant.now();
when(this.manager.readSession(this.id)).thenReturn(session);
when(session.getMetaData()).thenReturn(metaData);
when(metaData.getCreationTime()).thenReturn(expected);
Instant result = this.session.getMetaData().getCreationTime();
Assert.assertSame(expected, result);
verify(batch).close();
}
use of org.wildfly.clustering.web.session.ImmutableSession in project wildfly by wildfly.
the class OOBSessionTestCase method getLastAccessStartTime.
@Test
public void getLastAccessStartTime() {
Batcher<Batch> batcher = mock(Batcher.class);
Batch batch = mock(Batch.class);
when(this.manager.getBatcher()).thenReturn(batcher);
when(batcher.createBatch()).thenReturn(batch);
when(this.manager.readSession(this.id)).thenReturn(null);
Assert.assertThrows(IllegalStateException.class, this.session.getMetaData()::getLastAccessStartTime);
verify(batch).close();
reset(batch);
ImmutableSession session = mock(ImmutableSession.class);
ImmutableSessionMetaData metaData = mock(ImmutableSessionMetaData.class);
Instant expected = Instant.now();
when(this.manager.readSession(this.id)).thenReturn(session);
when(session.getMetaData()).thenReturn(metaData);
when(metaData.getLastAccessStartTime()).thenReturn(expected);
Instant result = this.session.getMetaData().getLastAccessStartTime();
Assert.assertSame(expected, result);
verify(batch).close();
}
Aggregations