Search in sources :

Example 11 with SessionAttributes

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

the class DistributableSessionTestCase method removeAttribute.

@Test
public void removeAttribute() {
    String name = "name";
    this.validate(session -> session.removeAttribute(name));
    SessionManager<LocalSessionContext, Batch> manager = mock(SessionManager.class);
    Batcher<Batch> batcher = mock(Batcher.class);
    BatchContext context = mock(BatchContext.class);
    SessionAttributes attributes = mock(SessionAttributes.class);
    SessionListener listener = mock(SessionListener.class);
    SessionListeners listeners = new SessionListeners();
    listeners.addSessionListener(listener);
    Object expected = new Object();
    when(this.session.getAttributes()).thenReturn(attributes);
    when(attributes.removeAttribute(name)).thenReturn(expected);
    when(this.manager.getSessionListeners()).thenReturn(listeners);
    when(this.manager.getSessionManager()).thenReturn(manager);
    when(manager.getBatcher()).thenReturn(batcher);
    when(batcher.resumeBatch(this.batch)).thenReturn(context);
    Object result = this.adapter.removeAttribute(name);
    assertSame(expected, result);
    verify(listener).attributeRemoved(this.adapter, name, expected);
    verify(context).close();
}
Also used : Batch(org.wildfly.clustering.ee.Batch) SessionListeners(io.undertow.server.session.SessionListeners) SessionAttributes(org.wildfly.clustering.web.session.SessionAttributes) BatchContext(org.wildfly.clustering.ee.BatchContext) SessionListener(io.undertow.server.session.SessionListener) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)11 Batch (org.wildfly.clustering.ee.Batch)11 BatchContext (org.wildfly.clustering.ee.BatchContext)11 SessionAttributes (org.wildfly.clustering.web.session.SessionAttributes)11 SessionListener (io.undertow.server.session.SessionListener)7 SessionListeners (io.undertow.server.session.SessionListeners)7 AuthenticatedSession (io.undertow.security.api.AuthenticatedSessionManager.AuthenticatedSession)3 Account (io.undertow.security.idm.Account)2 CachedAuthenticatedSessionHandler (io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler)2 HttpServerExchange (io.undertow.server.HttpServerExchange)1 SessionConfig (io.undertow.server.session.SessionConfig)1 Duration (java.time.Duration)1 Instant (java.time.Instant)1 SessionMetaData (org.wildfly.clustering.web.session.SessionMetaData)1