Search in sources :

Example 1 with ConnectionListener

use of org.webpieces.nio.api.handlers.ConnectionListener in project webpieces by deanhiller.

the class TestNewChannelManager method setUp.

protected void setUp() throws Exception {
    HandlerForTests.setupLogging();
    server = ChannelManagerFactory.createChannelManager("server", null);
    client = ChannelManagerFactory.createChannelManager("client", null);
    loopBack = InetAddress.getByName("127.0.0.1");
    loopBackAnyPort = new InetSocketAddress(loopBack, 0);
    serverAccept = MockObjectFactory.createMock(ConnectionListener.class);
    srvrChannel = server.createTCPServerChannel("jmxServer");
    srvrChannel.setReuseAddress(true);
    srvrChannel.bind(loopBackAnyPort);
    srvrChannel.registerServerSocketChannel((ConnectionListener) serverAccept);
    clientHandler = MockObjectFactory.createMock(DataListener.class);
    clientConnect = MockObjectFactory.createMock(OperationCallback.class);
    client1 = client.createTCPChannel("ClientChannel");
}
Also used : OperationCallback(org.webpieces.nio.api.handlers.OperationCallback) InetSocketAddress(java.net.InetSocketAddress) DataListener(org.webpieces.nio.api.handlers.DataListener) ConnectionListener(org.webpieces.nio.api.handlers.ConnectionListener)

Example 2 with ConnectionListener

use of org.webpieces.nio.api.handlers.ConnectionListener in project webpieces by deanhiller.

the class TestS3InitialHttpConnections method setUp.

@Before
public void setUp() throws InterruptedException, ExecutionException, TimeoutException {
    MockTcpServerChannel svrChannel = new MockTcpServerChannel();
    mockChanMgr.addTCPSvrChannelToReturn(svrChannel);
    mockTcpChannel.setIncomingFrameDefaultReturnValue(CompletableFuture.completedFuture(mockTcpChannel));
    mockListener.setDefaultRetVal(mockStreamWriter);
    mockStreamWriter.setDefaultRetValToThis();
    Http2Config config = new Http2Config();
    config.setLocalSettings(localSettings);
    InjectionConfig injConfig = new InjectionConfig(mockTime, config);
    FrontendConfig frontendConfig = new FrontendConfig("http", new InetSocketAddress("me", 8080));
    HttpFrontendManager manager = HttpFrontendFactory.createFrontEnd(mockChanMgr, mockTimer, injConfig);
    HttpServer httpServer = manager.createHttpServer(frontendConfig, mockListener);
    httpServer.start();
    ConnectionListener listener = mockChanMgr.getSingleConnectionListener();
    CompletableFuture<DataListener> futureList = listener.connected(mockTcpChannel, true);
    DataListener dataListener = futureList.get(3, TimeUnit.SECONDS);
    mockChannel.setDataListener(dataListener);
}
Also used : FrontendConfig(org.webpieces.frontend2.api.FrontendConfig) HttpFrontendManager(org.webpieces.frontend2.api.HttpFrontendManager) InetSocketAddress(java.net.InetSocketAddress) Http2Config(com.webpieces.http2engine.api.client.Http2Config) HttpServer(org.webpieces.frontend2.api.HttpServer) InjectionConfig(com.webpieces.http2engine.api.client.InjectionConfig) DataListener(org.webpieces.nio.api.handlers.DataListener) ConnectionListener(org.webpieces.nio.api.handlers.ConnectionListener) MockTcpServerChannel(org.webpieces.httpfrontend2.api.mock2.MockTcpServerChannel) Before(org.junit.Before)

Example 3 with ConnectionListener

use of org.webpieces.nio.api.handlers.ConnectionListener in project webpieces by deanhiller.

the class AbstractHttp2Test method simulateClientConnecting.

private void simulateClientConnecting() throws InterruptedException, ExecutionException, TimeoutException {
    ConnectionListener listener = mockChanMgr.getSingleConnectionListener();
    CompletableFuture<DataListener> futureList = listener.connected(mockTcpChannel, true);
    DataListener dataListener = futureList.get(3, TimeUnit.SECONDS);
    mockChannel.setDataListener(dataListener);
}
Also used : DataListener(org.webpieces.nio.api.handlers.DataListener) ConnectionListener(org.webpieces.nio.api.handlers.ConnectionListener)

Example 4 with ConnectionListener

use of org.webpieces.nio.api.handlers.ConnectionListener in project webpieces by deanhiller.

the class AbstractHttp1Test method simulateClientConnecting.

private void simulateClientConnecting() throws InterruptedException, ExecutionException, TimeoutException {
    ConnectionListener listener = mockChanMgr.getSingleConnectionListener();
    CompletableFuture<DataListener> futureList = listener.connected(mockChannel, true);
    DataListener dataListener = futureList.get(3, TimeUnit.SECONDS);
    mockChannel.setDataListener(dataListener);
}
Also used : DataListener(org.webpieces.nio.api.handlers.DataListener) ConnectionListener(org.webpieces.nio.api.handlers.ConnectionListener)

Example 5 with ConnectionListener

use of org.webpieces.nio.api.handlers.ConnectionListener in project webpieces by deanhiller.

the class Http11ClientSimulator method openHttp.

public Http11Socket openHttp() {
    ConnectionListener listener = mgr.getHttpConnection();
    MockTcpChannel channel = new MockTcpChannel(parser);
    CompletableFuture<DataListener> connected = listener.connected(channel, true);
    try {
        DataListener dataListener = connected.get(2, TimeUnit.SECONDS);
        return new Http11Socket(dataListener, channel, parser);
    } catch (Throwable e) {
        throw new RuntimeException(e);
    }
}
Also used : DataListener(org.webpieces.nio.api.handlers.DataListener) ConnectionListener(org.webpieces.nio.api.handlers.ConnectionListener)

Aggregations

ConnectionListener (org.webpieces.nio.api.handlers.ConnectionListener)6 DataListener (org.webpieces.nio.api.handlers.DataListener)6 InetSocketAddress (java.net.InetSocketAddress)2 Http2Config (com.webpieces.http2engine.api.client.Http2Config)1 InjectionConfig (com.webpieces.http2engine.api.client.InjectionConfig)1 Before (org.junit.Before)1 FrontendConfig (org.webpieces.frontend2.api.FrontendConfig)1 HttpFrontendManager (org.webpieces.frontend2.api.HttpFrontendManager)1 HttpServer (org.webpieces.frontend2.api.HttpServer)1 MockTcpServerChannel (org.webpieces.httpfrontend2.api.mock2.MockTcpServerChannel)1 OperationCallback (org.webpieces.nio.api.handlers.OperationCallback)1