use of org.wildfly.clustering.web.session.ImmutableSession in project wildfly by wildfly.
the class InfinispanSessionFactoryTestCase method createImmutableSession.
@Test
public void createImmutableSession() {
Map.Entry<InfinispanSessionMetaData<Object>, Object> entry = mock(Map.Entry.class);
SessionCreationMetaData creationMetaData = mock(SessionCreationMetaData.class);
SessionAccessMetaData accessMetaData = mock(SessionAccessMetaData.class);
InfinispanSessionMetaData<Object> metaDataValue = new InfinispanSessionMetaData<>(creationMetaData, accessMetaData, null);
Object attributesValue = new Object();
ImmutableSessionMetaData metaData = mock(ImmutableSessionMetaData.class);
ImmutableSessionAttributes attributes = mock(ImmutableSessionAttributes.class);
String id = "id";
when(entry.getKey()).thenReturn(metaDataValue);
when(entry.getValue()).thenReturn(attributesValue);
when(this.metaDataFactory.createImmutableSessionMetaData(id, metaDataValue)).thenReturn(metaData);
when(this.attributesFactory.createImmutableSessionAttributes(id, attributesValue)).thenReturn(attributes);
ImmutableSession result = this.factory.createImmutableSession(id, entry);
assertSame(id, result.getId());
assertSame(metaData, result.getMetaData());
assertSame(attributes, result.getAttributes());
}
use of org.wildfly.clustering.web.session.ImmutableSession in project wildfly by wildfly.
the class ConcurrentSessionManagerTestCase method readSession.
@Test
public void readSession() {
SessionManager<Void, Batch> manager = mock(SessionManager.class);
SessionManager<Void, Batch> subject = new ConcurrentSessionManager<>(manager, SimpleManager::new);
ImmutableSession expected = mock(ImmutableSession.class);
String id = "foo";
when(manager.readSession(id)).thenReturn(expected);
ImmutableSession result = subject.readSession(id);
assertSame(expected, result);
}
use of org.wildfly.clustering.web.session.ImmutableSession in project wildfly by wildfly.
the class OOBSessionTestCase method getMaxInactiveInterval.
@Test
public void getMaxInactiveInterval() {
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()::getMaxInactiveInterval);
verify(batch).close();
reset(batch);
ImmutableSession session = mock(ImmutableSession.class);
ImmutableSessionMetaData metaData = mock(ImmutableSessionMetaData.class);
Duration expected = Duration.ZERO;
when(this.manager.readSession(this.id)).thenReturn(session);
when(session.getMetaData()).thenReturn(metaData);
when(metaData.getMaxInactiveInterval()).thenReturn(expected);
Duration result = this.session.getMetaData().getMaxInactiveInterval();
Assert.assertSame(expected, result);
verify(batch).close();
}
use of org.wildfly.clustering.web.session.ImmutableSession in project wildfly by wildfly.
the class OOBSessionTestCase method getAttributeNames.
@Test
public void getAttributeNames() {
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.getAttributes()::getAttributeNames);
verify(batch).close();
reset(batch);
ImmutableSession session = mock(ImmutableSession.class);
ImmutableSessionAttributes attributes = mock(ImmutableSessionAttributes.class);
Set<String> expected = Collections.singleton("foo");
when(this.manager.readSession(this.id)).thenReturn(session);
when(session.getAttributes()).thenReturn(attributes);
when(attributes.getAttributeNames()).thenReturn(expected);
Set<String> result = this.session.getAttributes().getAttributeNames();
Assert.assertSame(expected, result);
verify(batch).close();
}
use of org.wildfly.clustering.web.session.ImmutableSession in project wildfly by wildfly.
the class OOBSessionTestCase method getLastAccessEndTime.
@Test
public void getLastAccessEndTime() {
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()::getLastAccessEndTime);
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.getLastAccessEndTime()).thenReturn(expected);
Instant result = this.session.getMetaData().getLastAccessEndTime();
Assert.assertSame(expected, result);
verify(batch).close();
}
Aggregations