Search in sources :

Example 6 with CloneByteBuffer

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

the class TestUnpacketizer method setUpImpl.

//--------------------------------------------------------------------
//	BUSINESS METHODS
//--------------------------------------------------------------------
protected void setUpImpl() {
    listener = createMock(PacketListener.class);
    listener.setDefaultBehavior("incomingPacket", new CloneByteBuffer());
    Map<String, Object> p = new HashMap<String, Object>();
    p.put(FactoryCreator.KEY_PACKET_SEPARATOR, PACKET_SEPARATOR);
    FactoryCreator creator = FactoryCreator.createFactory(null);
    PacketProcessorFactory factory = creator.createPacketProcFactory(p);
    unpacketizer = factory.createPacketProcessor("someId");
    helper = ChannelServiceFactory.bufferHelper(null);
    unpacketizer.setPacketListener((PacketListener) listener);
}
Also used : HashMap(java.util.HashMap) CloneByteBuffer(org.webpieces.nio.api.testutil.CloneByteBuffer) FactoryCreator(org.webpieces.nio.api.libs.FactoryCreator) PacketProcessorFactory(org.webpieces.nio.api.libs.PacketProcessorFactory) MockObject(biz.xsoftware.mock.MockObject) PacketListener(org.webpieces.nio.api.libs.PacketListener)

Example 7 with CloneByteBuffer

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

the class ZPerformanceSuper method setUp.

protected void setUp() throws Exception {
    HandlerForTests.setupLogging();
    LoggerFactory.getLogger("").setLevel(Level.INFO);
    //and started back up cleanly.....
    if (chanMgr == null) {
        chanMgr = getClientChanMgr();
    }
    if (echoServer == null) {
        ChannelService svrChanMgr = getServerChanMgr();
        echoServer = new EchoServer(svrChanMgr, getServerFactoryHolder());
    }
    chanMgr.start();
    svrAddr = echoServer.start();
    //this is to test EchoServer on a different machine...
    //		InetAddress tmp = InetAddress.getByName("192.168.1.102");
    //		svrAddr = new InetSocketAddress(tmp, 501);
    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);
    mockConnectOp = MockObjectFactory.createMock(OperationCallback.class);
}
Also used : OperationCallback(org.webpieces.nio.api.handlers.OperationCallback) ChannelService(org.webpieces.nio.api.deprecated.ChannelService) CloneByteBuffer(org.webpieces.nio.api.testutil.CloneByteBuffer) DataListener(org.webpieces.nio.api.handlers.DataListener) ConnectionCallback(org.webpieces.nio.api.deprecated.ConnectionCallback) EchoServer(org.webpieces.nio.test.EchoServer)

Example 8 with CloneByteBuffer

use of org.webpieces.nio.api.testutil.CloneByteBuffer 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 9 with CloneByteBuffer

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

the class TestUdpIntegration method setUpImpl.

/*
     * @see TestCase#setUp()
     */
protected void setUpImpl() throws Exception {
    if (bufFactory == null) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put(FactoryCreator.KEY_IS_DIRECT, false);
        FactoryCreator creator = FactoryCreator.createFactory(null);
        bufFactory = creator.createBufferFactory(map);
    }
    ChannelServiceFactory basic = ChannelServiceFactory.createFactory(null);
    Map<String, Object> props2 = new HashMap<String, Object>();
    props2.put(ChannelServiceFactory.KEY_IMPLEMENTATION_CLASS, ChannelServiceFactory.VAL_EXCEPTION_CHANNEL_MGR);
    props2.put(ChannelServiceFactory.KEY_CHILD_CHANNELMGR_FACTORY, basic);
    ChannelServiceFactory factory = ChannelServiceFactory.createFactory(props2);
    Map<String, Object> map = new HashMap<String, Object>();
    map.put(ChannelManagerOld.KEY_BUFFER_FACTORY, bufFactory);
    map.put(ChannelManagerOld.KEY_ID, "server+client");
    svc = factory.createChannelManager(map);
    svc.start();
    client = svc.createUDPChannel("client", null);
    server = svc.createUDPChannel("server", null);
    clientHandler = createMock(DataListener.class);
    svrHandler = createMock(DataListener.class);
    clientHandler.setDefaultBehavior("incomingData", new CloneByteBuffer());
    svrHandler.setDefaultBehavior("incomingData", new CloneByteBuffer());
}
Also used : HashMap(java.util.HashMap) CloneByteBuffer(org.webpieces.nio.api.testutil.CloneByteBuffer) FactoryCreator(org.webpieces.nio.api.libs.FactoryCreator) ChannelServiceFactory(org.webpieces.nio.api.deprecated.ChannelServiceFactory) MockObject(biz.xsoftware.mock.MockObject) DataListener(org.webpieces.nio.api.handlers.DataListener)

Example 10 with CloneByteBuffer

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

Aggregations

CloneByteBuffer (org.webpieces.nio.api.testutil.CloneByteBuffer)13 DataListener (org.webpieces.nio.api.handlers.DataListener)7 ChannelService (org.webpieces.nio.api.deprecated.ChannelService)6 FactoryCreator (org.webpieces.nio.api.libs.FactoryCreator)6 MockObject (biz.xsoftware.mock.MockObject)5 InetSocketAddress (java.net.InetSocketAddress)5 HashMap (java.util.HashMap)4 ConnectionCallback (org.webpieces.nio.api.deprecated.ConnectionCallback)4 MockNIOServer (org.webpieces.nio.api.testutil.MockNIOServer)4 CalledMethod (biz.xsoftware.mock.CalledMethod)3 ChannelServiceFactory (org.webpieces.nio.api.deprecated.ChannelServiceFactory)3 ByteBuffer (java.nio.ByteBuffer)2 SSLEngine (javax.net.ssl.SSLEngine)2 Settings (org.webpieces.nio.api.deprecated.Settings)2 OperationCallback (org.webpieces.nio.api.handlers.OperationCallback)2 AsyncSSLEngine (org.webpieces.nio.api.libs.AsyncSSLEngine)2 SSLEngineFactory (org.webpieces.nio.api.libs.SSLEngineFactory)2 MockSSLEngineFactory (org.webpieces.nio.api.testutil.MockSSLEngineFactory)2 DatagramListener (org.webpieces.nio.api.handlers.DatagramListener)1 PacketListener (org.webpieces.nio.api.libs.PacketListener)1