use of org.xnio.channels.Configurable in project wildfly by wildfly.
the class DistributableSessionTestCase method changeSessionIdResponseCommitted.
public void changeSessionIdResponseCommitted() {
when(this.session.getMetaData()).thenReturn(this.metaData);
when(this.metaData.isNew()).thenReturn(false);
when(this.session.isValid()).thenReturn(true);
io.undertow.server.session.Session session = new DistributableSession(this.manager, this.session, this.config, this.batch, this.closeTask);
// Ugh - all this, just to get HttpServerExchange.isResponseStarted() to return true
Configurable configurable = mock(Configurable.class);
StreamSourceConduit sourceConduit = mock(StreamSourceConduit.class);
ConduitStreamSourceChannel sourceChannel = new ConduitStreamSourceChannel(configurable, sourceConduit);
StreamSinkConduit sinkConduit = mock(StreamSinkConduit.class);
ConduitStreamSinkChannel sinkChannel = new ConduitStreamSinkChannel(configurable, sinkConduit);
StreamConnection stream = mock(StreamConnection.class);
when(stream.getSourceChannel()).thenReturn(sourceChannel);
when(stream.getSinkChannel()).thenReturn(sinkChannel);
ByteBufferPool bufferPool = mock(ByteBufferPool.class);
HttpHandler handler = mock(HttpHandler.class);
HttpServerConnection connection = new HttpServerConnection(stream, bufferPool, handler, OptionMap.create(UndertowOptions.ALWAYS_SET_DATE, false), 0, null);
HttpServerExchange exchange = new HttpServerExchange(connection);
exchange.setProtocol(Protocols.HTTP_1_1);
exchange.getResponseChannel();
SessionConfig config = mock(SessionConfig.class);
Assert.assertThrows(IllegalStateException.class, () -> session.changeSessionId(exchange, config));
}
use of org.xnio.channels.Configurable in project wildfly by wildfly.
the class DistributableSessionManagerTestCase method createSessionResponseCommitted.
@Test
public void createSessionResponseCommitted() {
// Ugh - all this, just to get HttpServerExchange.isResponseStarted() to return true
Configurable configurable = mock(Configurable.class);
StreamSourceConduit sourceConduit = mock(StreamSourceConduit.class);
ConduitStreamSourceChannel sourceChannel = new ConduitStreamSourceChannel(configurable, sourceConduit);
StreamSinkConduit sinkConduit = mock(StreamSinkConduit.class);
ConduitStreamSinkChannel sinkChannel = new ConduitStreamSinkChannel(configurable, sinkConduit);
StreamConnection stream = mock(StreamConnection.class);
when(stream.getSourceChannel()).thenReturn(sourceChannel);
when(stream.getSinkChannel()).thenReturn(sinkChannel);
ByteBufferPool bufferPool = mock(ByteBufferPool.class);
HttpHandler handler = mock(HttpHandler.class);
HttpServerConnection connection = new HttpServerConnection(stream, bufferPool, handler, OptionMap.create(UndertowOptions.ALWAYS_SET_DATE, false), 0, null);
HttpServerExchange exchange = new HttpServerExchange(connection);
exchange.setProtocol(Protocols.HTTP_1_1);
exchange.getResponseChannel();
SessionConfig config = mock(SessionConfig.class);
Assert.assertThrows(IllegalStateException.class, () -> this.adapter.createSession(exchange, config));
}
Aggregations