Search in sources :

Example 1 with Configurable

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));
}
Also used : ByteBufferPool(io.undertow.connector.ByteBufferPool) HttpHandler(io.undertow.server.HttpHandler) HttpServerConnection(io.undertow.server.protocol.http.HttpServerConnection) SessionConfig(io.undertow.server.session.SessionConfig) Configurable(org.xnio.channels.Configurable) StreamConnection(org.xnio.StreamConnection) StreamSourceConduit(org.xnio.conduits.StreamSourceConduit) HttpServerExchange(io.undertow.server.HttpServerExchange) StreamSinkConduit(org.xnio.conduits.StreamSinkConduit) ConduitStreamSourceChannel(org.xnio.conduits.ConduitStreamSourceChannel) ConduitStreamSinkChannel(org.xnio.conduits.ConduitStreamSinkChannel)

Example 2 with Configurable

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));
}
Also used : ByteBufferPool(io.undertow.connector.ByteBufferPool) HttpServerExchange(io.undertow.server.HttpServerExchange) HttpHandler(io.undertow.server.HttpHandler) HttpServerConnection(io.undertow.server.protocol.http.HttpServerConnection) StreamSinkConduit(org.xnio.conduits.StreamSinkConduit) SessionConfig(io.undertow.server.session.SessionConfig) Configurable(org.xnio.channels.Configurable) ConduitStreamSourceChannel(org.xnio.conduits.ConduitStreamSourceChannel) StreamConnection(org.xnio.StreamConnection) StreamSourceConduit(org.xnio.conduits.StreamSourceConduit) ConduitStreamSinkChannel(org.xnio.conduits.ConduitStreamSinkChannel) Test(org.junit.Test)

Aggregations

ByteBufferPool (io.undertow.connector.ByteBufferPool)2 HttpHandler (io.undertow.server.HttpHandler)2 HttpServerExchange (io.undertow.server.HttpServerExchange)2 HttpServerConnection (io.undertow.server.protocol.http.HttpServerConnection)2 SessionConfig (io.undertow.server.session.SessionConfig)2 StreamConnection (org.xnio.StreamConnection)2 Configurable (org.xnio.channels.Configurable)2 ConduitStreamSinkChannel (org.xnio.conduits.ConduitStreamSinkChannel)2 ConduitStreamSourceChannel (org.xnio.conduits.ConduitStreamSourceChannel)2 StreamSinkConduit (org.xnio.conduits.StreamSinkConduit)2 StreamSourceConduit (org.xnio.conduits.StreamSourceConduit)2 Test (org.junit.Test)1