Search in sources :

Example 1 with MockNIOServer

use of org.webpieces.nio.api.testutil.MockNIOServer in project webpieces by deanhiller.

the class TestXEvaluateNIOBehavior method setUp.

public void setUp() {
    String os = System.getProperty("os.name");
    //String osArch = System.getProperty("os.arch");
    log.info("os=" + os);
    if (os.equals("linux")) {
        log.info("RUNNING LINUX TESTS ONLY");
        isLinux = true;
    }
    try {
        if (mockServer == null) {
            ChannelServiceFactory factory = ChannelServiceFactory.createFactory(null);
            Map<String, Object> p = new HashMap<String, Object>();
            p.put(ChannelManagerOld.KEY_ID, "[server]");
            p.put(ChannelManagerOld.KEY_BUFFER_FACTORY, bufFactory);
            ChannelService chanMgr = factory.createChannelManager(p);
            mockServer = new MockNIOServer(chanMgr, null);
        }
        svrAddr = mockServer.start();
        log.info("svrPort=" + svrAddr);
    } catch (IOException e) {
        throw new RuntimeException("test failed", e);
    } catch (InterruptedException e) {
        throw new RuntimeException("test failed2", e);
    }
}
Also used : HashMap(java.util.HashMap) ChannelService(org.webpieces.nio.api.deprecated.ChannelService) ChannelServiceFactory(org.webpieces.nio.api.deprecated.ChannelServiceFactory) MockNIOServer(org.webpieces.nio.api.testutil.MockNIOServer) IOException(java.io.IOException)

Example 2 with MockNIOServer

use of org.webpieces.nio.api.testutil.MockNIOServer in project webpieces by deanhiller.

the class TestAsynchWrites method setUp.

protected void setUp() throws Exception {
    HandlerForTests.setupLogging();
    //and started back up cleanly.....		
    if (chanMgr == null) {
        chanMgr = getClientChanMgr();
    }
    if (mockServer == null) {
        ChannelService svcChanMgr = getServerChanMgr();
        mockServer = new MockNIOServer(svcChanMgr, getServerFactoryHolder());
    }
    chanMgr.start();
    svrAddr = mockServer.start();
    log.trace("server port =" + svrAddr);
//		loopBack = InetAddress.getByName("127.0.0.1");	
//		loopBackAnyPort = new InetSocketAddress(loopBack, 0);
//		
//		mockHandler = MockObjectFactory.createMock(DataHandler.class);
//		mockHandler.setCloner(new CloneByteBuffer());
//		mockConnect = MockObjectFactory.createMock(ConnectCallback.class);
//		client1 = chanMgr.createTCPChannel("ClientChannel", getClientFactoryHolder());		
}
Also used : ChannelService(org.webpieces.nio.api.deprecated.ChannelService) MockNIOServer(org.webpieces.nio.api.testutil.MockNIOServer)

Example 3 with MockNIOServer

use of org.webpieces.nio.api.testutil.MockNIOServer in project webpieces by deanhiller.

the class TestMoreSecureChanMgr method setUp.

protected void setUp() throws Exception {
    SSLEngineFactory sslEngineFactory = new MockSSLEngineFactory();
    Settings clientFactoryHolder = new Settings(sslEngineFactory, null);
    //use this engine to feed data back from server...
    SSLEngine wrappedSvr = sslEngineFactory.createEngineForServerSocket();
    sslEngine = creator.createSSLEngine("[serverAsynch] ", wrappedSvr, null);
    sslEngine.setListener((SSLListener) mockSSLListener);
    //and started back up cleanly.....		
    if (chanMgr == null) {
        chanMgr = getClientChanMgr();
    }
    if (mockServer == null) {
        ChannelService svcChanMgr = getServerChanMgr();
        mockServer = new MockNIOServer(svcChanMgr, null);
    }
    chanMgr.start();
    svrAddr = mockServer.start();
    log.trace("server port =" + svrAddr);
    loopBack = InetAddress.getByName("127.0.0.1");
    loopBackAnyPort = new InetSocketAddress(loopBack, 0);
    mockHandler.setDefaultBehavior("incomingData", new CloneByteBuffer());
    mockSSLListener.setDefaultBehavior("packetEncrypted", new CloneByteBuffer());
    client1 = chanMgr.createTCPChannel("ClientChannel", clientFactoryHolder);
}
Also used : AsyncSSLEngine(org.webpieces.nio.api.libs.AsyncSSLEngine) SSLEngine(javax.net.ssl.SSLEngine) ChannelService(org.webpieces.nio.api.deprecated.ChannelService) InetSocketAddress(java.net.InetSocketAddress) CloneByteBuffer(org.webpieces.nio.api.testutil.CloneByteBuffer) MockNIOServer(org.webpieces.nio.api.testutil.MockNIOServer) SSLEngineFactory(org.webpieces.nio.api.libs.SSLEngineFactory) MockSSLEngineFactory(org.webpieces.nio.api.testutil.MockSSLEngineFactory) Settings(org.webpieces.nio.api.deprecated.Settings) MockSSLEngineFactory(org.webpieces.nio.api.testutil.MockSSLEngineFactory)

Example 4 with MockNIOServer

use of org.webpieces.nio.api.testutil.MockNIOServer in project webpieces by deanhiller.

the class ZNioFailureSuperclass method setUpImpl.

protected void setUpImpl() throws Exception {
    HandlerForTests.setupLogging();
    //and started back up cleanly.....		
    if (chanMgr == null) {
        chanMgr = getClientChanMgr();
    }
    if (mockServer == null) {
        ChannelService svcChanMgr = getServerChanMgr();
        mockServer = new MockNIOServer(svcChanMgr, getServerFactoryHolder());
    }
    chanMgr.start();
    svrAddr = mockServer.start();
    log.trace("server port =" + svrAddr);
    loopBack = InetAddress.getByName("127.0.0.1");
    loopBackAnyPort = new InetSocketAddress(loopBack, 0);
    mockHandler = createMock(DataListener.class);
    mockHandler.setDefaultBehavior("incomingData", new CloneByteBuffer());
    mockConnect = createMock(ConnectionCallback.class);
    client1 = chanMgr.createTCPChannel("ClientChannel", getClientFactoryHolder());
}
Also used : ChannelService(org.webpieces.nio.api.deprecated.ChannelService) InetSocketAddress(java.net.InetSocketAddress) CloneByteBuffer(org.webpieces.nio.api.testutil.CloneByteBuffer) DataListener(org.webpieces.nio.api.handlers.DataListener) ConnectionCallback(org.webpieces.nio.api.deprecated.ConnectionCallback) MockNIOServer(org.webpieces.nio.api.testutil.MockNIOServer)

Example 5 with MockNIOServer

use of org.webpieces.nio.api.testutil.MockNIOServer in project webpieces by deanhiller.

the class ZNioSuperclassTest method setUp.

protected void setUp() throws Exception {
    HandlerForTests.setupLogging();
    //and started back up cleanly.....		
    if (chanMgr == null) {
        chanMgr = getClientChanMgr();
    }
    if (mockServer == null) {
        ChannelService svcChanMgr = getServerChanMgr();
        mockServer = new MockNIOServer(svcChanMgr, getServerFactoryHolder());
    }
    chanMgr.start();
    svrAddr = mockServer.start();
    log.trace("server port =" + svrAddr);
    loopBack = InetAddress.getByName("127.0.0.1");
    loopBackAnyPort = new InetSocketAddress(loopBack, 0);
    mockHandler = MockObjectFactory.createMock(DataListener.class);
    mockHandler.setDefaultBehavior("incomingData", new CloneByteBuffer());
    mockConnect = MockObjectFactory.createMock(ConnectionCallback.class);
    client1 = chanMgr.createTCPChannel("ClientChannel", getClientFactoryHolder());
}
Also used : ChannelService(org.webpieces.nio.api.deprecated.ChannelService) InetSocketAddress(java.net.InetSocketAddress) CloneByteBuffer(org.webpieces.nio.api.testutil.CloneByteBuffer) DataListener(org.webpieces.nio.api.handlers.DataListener) ConnectionCallback(org.webpieces.nio.api.deprecated.ConnectionCallback) MockNIOServer(org.webpieces.nio.api.testutil.MockNIOServer)

Aggregations

ChannelService (org.webpieces.nio.api.deprecated.ChannelService)6 MockNIOServer (org.webpieces.nio.api.testutil.MockNIOServer)6 InetSocketAddress (java.net.InetSocketAddress)4 CloneByteBuffer (org.webpieces.nio.api.testutil.CloneByteBuffer)4 DataListener (org.webpieces.nio.api.handlers.DataListener)3 ConnectionCallback (org.webpieces.nio.api.deprecated.ConnectionCallback)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 SSLEngine (javax.net.ssl.SSLEngine)1 ChannelServiceFactory (org.webpieces.nio.api.deprecated.ChannelServiceFactory)1 Settings (org.webpieces.nio.api.deprecated.Settings)1 AsyncSSLEngine (org.webpieces.nio.api.libs.AsyncSSLEngine)1 SSLEngineFactory (org.webpieces.nio.api.libs.SSLEngineFactory)1 MockSSLEngineFactory (org.webpieces.nio.api.testutil.MockSSLEngineFactory)1