Search in sources :

Example 1 with Settings

use of org.webpieces.nio.api.deprecated.Settings in project webpieces by deanhiller.

the class XTestDelayServer method setUp.

protected void setUp() throws Exception {
    FactoryCreator creator = FactoryCreator.createFactory(null);
    procFactory = creator.createPacketProcFactory(null);
    factoryHolder = new Settings(null, procFactory);
    HandlerForTests.setupLogging();
    LoggerFactory.getLogger("").setLevel(Level.INFO);
    //and started back up cleanly.....		
    if (chanMgr == null) {
        chanMgr = createClientChanMgr("[client]");
    }
    if (echoServer == null) {
        ChannelService svrChanMgr = createSvrChanMgr("[echoServer]");
        echoServer = new EchoServer(svrChanMgr, factoryHolder);
    }
    if (delayServer == null) {
        delayServer = new DelayServer();
    }
    chanMgr.start();
    InetSocketAddress echoSvrAddr = echoServer.start();
    log.trace("echo server port =" + echoSvrAddr);
    delaySvrAddr = delayServer.start(echoSvrAddr);
    log.trace("delay server port =" + delaySvrAddr);
    mockHandler = MockObjectFactory.createMock(DataListener.class);
    mockHandler.setDefaultBehavior("incomingData", new CloneByteBuffer());
    mockConnect = MockObjectFactory.createMock(ConnectionCallback.class);
}
Also used : ChannelService(org.webpieces.nio.api.deprecated.ChannelService) InetSocketAddress(java.net.InetSocketAddress) CloneByteBuffer(org.webpieces.nio.api.testutil.CloneByteBuffer) FactoryCreator(org.webpieces.nio.api.libs.FactoryCreator) DataListener(org.webpieces.nio.api.handlers.DataListener) ConnectionCallback(org.webpieces.nio.api.deprecated.ConnectionCallback) Settings(org.webpieces.nio.api.deprecated.Settings)

Example 2 with Settings

use of org.webpieces.nio.api.deprecated.Settings in project webpieces by deanhiller.

the class EventClient method start.

public void start() throws IOException, InterruptedException {
    ChannelService mgr = ChannelServiceFactory.createDefaultChannelMgr("EventServer");
    mgr.start();
    SSLEngineFactory sslFactory = new MockSSLEngineFactory();
    Settings h = new Settings(sslFactory, null);
    TCPChannel channel = mgr.createTCPChannel("SvrChan", h);
    InetAddress addr = InetAddress.getByName("192.168.1.102");
    InetSocketAddress sockAddr = new InetSocketAddress(addr, 801);
    log.info("Connecting to server=" + sockAddr);
    channel.oldConnect(sockAddr, this);
}
Also used : ChannelService(org.webpieces.nio.api.deprecated.ChannelService) TCPChannel(org.webpieces.nio.api.channels.TCPChannel) InetSocketAddress(java.net.InetSocketAddress) MockSSLEngineFactory(org.webpieces.nio.api.testutil.MockSSLEngineFactory) SSLEngineFactory(org.webpieces.nio.api.libs.SSLEngineFactory) InetAddress(java.net.InetAddress) Settings(org.webpieces.nio.api.deprecated.Settings) MockSSLEngineFactory(org.webpieces.nio.api.testutil.MockSSLEngineFactory)

Example 3 with Settings

use of org.webpieces.nio.api.deprecated.Settings in project webpieces by deanhiller.

the class EventServer method start.

public void start() throws IOException, InterruptedException {
    log.info("Attempting to start server");
    ChannelService mgr = ChannelServiceFactory.createDefaultChannelMgr("EventServer");
    mgr.start();
    SSLEngineFactory sslFactory = new MockSSLEngineFactory();
    Settings h = new Settings(sslFactory, null);
    TCPServerChannel svrChannel = mgr.createTCPServerChannel("SvrChan", h);
    InetAddress addr = InetAddress.getByName("192.168.1.101");
    InetSocketAddress sockAddr = new InetSocketAddress(addr, 801);
    log.info("binding");
    svrChannel.bind(sockAddr);
    log.info("bound to=" + svrChannel.getLocalAddress());
    svrChannel.registerServerSocketChannel(this);
    log.info(svrChannel + "Server started");
}
Also used : ChannelService(org.webpieces.nio.api.deprecated.ChannelService) InetSocketAddress(java.net.InetSocketAddress) TCPServerChannel(org.webpieces.nio.api.channels.TCPServerChannel) MockSSLEngineFactory(org.webpieces.nio.api.testutil.MockSSLEngineFactory) SSLEngineFactory(org.webpieces.nio.api.libs.SSLEngineFactory) InetAddress(java.net.InetAddress) Settings(org.webpieces.nio.api.deprecated.Settings) MockSSLEngineFactory(org.webpieces.nio.api.testutil.MockSSLEngineFactory)

Example 4 with Settings

use of org.webpieces.nio.api.deprecated.Settings in project webpieces by deanhiller.

the class TryRealConnection method xxxtestRealConnection.

public void xxxtestRealConnection() throws Exception {
    MockObject mockConnect = MockObjectFactory.createMock(ConnectionCallback.class);
    Settings h = new Settings(new MockSSLEngineFactory(), null);
    TCPChannel channel = chanMgr.createTCPChannel("testId", h);
    channel.bind(loopBackAddr);
    log.trace("aaaaa");
    MockObject handler = new MockDataHandler();
    channel.registerForReads((DataListener) handler);
    //		InetAddress host = InetAddress.getByName("shell.sourceforge.net");
    InetAddress host = InetAddress.getByName("www.xsoftware.biz");
    InetSocketAddress addr = new InetSocketAddress(host, 22);
    channel.oldConnect(addr, (ConnectionCallback) mockConnect);
    mockConnect.expect("connected");
    handler.addIgnore("getBuffer");
    //CalledMethod method = 
    handler.expect("incomingData");
//		ByteBuffer b = (ByteBuffer)method.getAllParams()[1];
}
Also used : TCPChannel(org.webpieces.nio.api.channels.TCPChannel) MockDataHandler(org.webpieces.nio.api.testutil.MockDataHandler) InetSocketAddress(java.net.InetSocketAddress) InetAddress(java.net.InetAddress) MockObject(biz.xsoftware.mock.MockObject) Settings(org.webpieces.nio.api.deprecated.Settings) MockSSLEngineFactory(org.webpieces.nio.api.testutil.MockSSLEngineFactory)

Example 5 with Settings

use of org.webpieces.nio.api.deprecated.Settings 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)

Aggregations

InetSocketAddress (java.net.InetSocketAddress)5 Settings (org.webpieces.nio.api.deprecated.Settings)5 ChannelService (org.webpieces.nio.api.deprecated.ChannelService)4 MockSSLEngineFactory (org.webpieces.nio.api.testutil.MockSSLEngineFactory)4 InetAddress (java.net.InetAddress)3 SSLEngineFactory (org.webpieces.nio.api.libs.SSLEngineFactory)3 TCPChannel (org.webpieces.nio.api.channels.TCPChannel)2 CloneByteBuffer (org.webpieces.nio.api.testutil.CloneByteBuffer)2 MockObject (biz.xsoftware.mock.MockObject)1 SSLEngine (javax.net.ssl.SSLEngine)1 TCPServerChannel (org.webpieces.nio.api.channels.TCPServerChannel)1 ConnectionCallback (org.webpieces.nio.api.deprecated.ConnectionCallback)1 DataListener (org.webpieces.nio.api.handlers.DataListener)1 AsyncSSLEngine (org.webpieces.nio.api.libs.AsyncSSLEngine)1 FactoryCreator (org.webpieces.nio.api.libs.FactoryCreator)1 MockDataHandler (org.webpieces.nio.api.testutil.MockDataHandler)1 MockNIOServer (org.webpieces.nio.api.testutil.MockNIOServer)1