Search in sources :

Example 1 with FactoryCreator

use of org.webpieces.nio.api.libs.FactoryCreator in project webpieces by deanhiller.

the class TestNewAsynchSSLEngine2 method setUp.

@Override
protected void setUp() throws Exception {
    HandlerForTests.setupLogging();
    serverList.setDefaultBehavior("packetEncrypted", new CloneByteBuffer());
    clientList.setDefaultBehavior("packetEncrypted", new CloneByteBuffer());
    SSLEngineFactory sslEngineFactory = new MockSSLEngineFactory();
    FactoryCreator creator = FactoryCreator.createFactory(null);
    SSLEngine wrappedSvr = sslEngineFactory.createEngineForServerSocket();
    serverEngine = creator.createSSLEngine("[serverAsynch] ", wrappedSvr, null);
    serverEngine.setListener((SSLListener) serverList);
    SSLEngine wrappedClient = sslEngineFactory.createEngineForSocket();
    clientEngine = creator.createSSLEngine("[clientEngine] ", wrappedClient, null);
    clientEngine.setListener((SSLListener) clientList);
}
Also used : CloneByteBuffer(org.webpieces.nio.api.testutil.CloneByteBuffer) AsyncSSLEngine(org.webpieces.nio.api.libs.AsyncSSLEngine) SSLEngine(javax.net.ssl.SSLEngine) FactoryCreator(org.webpieces.nio.api.libs.FactoryCreator) MockSSLEngineFactory(org.webpieces.nio.api.testutil.MockSSLEngineFactory) SSLEngineFactory(org.webpieces.nio.api.libs.SSLEngineFactory) MockSSLEngineFactory(org.webpieces.nio.api.testutil.MockSSLEngineFactory)

Example 2 with FactoryCreator

use of org.webpieces.nio.api.libs.FactoryCreator 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 3 with FactoryCreator

use of org.webpieces.nio.api.libs.FactoryCreator in project webpieces by deanhiller.

the class TestNewAsynchSSLEngine method setUp.

@Override
protected void setUp() throws Exception {
    HandlerForTests.setupLogging();
    SSLEngineFactory sslEngineFactory = new MockSSLEngineFactory();
    FactoryCreator creator = FactoryCreator.createFactory(null);
    SSLEngine wrappedSvr = sslEngineFactory.createEngineForServerSocket();
    serverEngine = creator.createSSLEngine("[serverAsynch] ", wrappedSvr, null);
    serverEngine.setListener((SSLListener) serverList);
    SSLEngine wrappedClient = sslEngineFactory.createEngineForSocket();
    clientEngine = creator.createSSLEngine("[clientEngine] ", wrappedClient, null);
    clientEngine.setListener((SSLListener) clientList);
}
Also used : AsyncSSLEngine(org.webpieces.nio.api.libs.AsyncSSLEngine) SSLEngine(javax.net.ssl.SSLEngine) FactoryCreator(org.webpieces.nio.api.libs.FactoryCreator) MockSSLEngineFactory(org.webpieces.nio.api.testutil.MockSSLEngineFactory) SSLEngineFactory(org.webpieces.nio.api.libs.SSLEngineFactory) MockSSLEngineFactory(org.webpieces.nio.api.testutil.MockSSLEngineFactory)

Example 4 with FactoryCreator

use of org.webpieces.nio.api.libs.FactoryCreator 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 5 with FactoryCreator

use of org.webpieces.nio.api.libs.FactoryCreator in project webpieces by deanhiller.

the class TestWrites method setUp.

protected void setUp() throws Exception {
    HandlerForTests.setupLogging();
    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);
    }
    mockSunsChannel = MockObjectFactory.createMock(SocketChannel.class);
    mockSunsChannel.addIgnore("isBlocking");
    mockSunsChannel.addIgnore("getSelectableChannel");
    mockSunsChannel.setDefaultReturnValue("isBlocking", false);
    mockSunsChannel.addReturnValue("connect", true);
    mockSelect = MockObjectFactory.createMock(Select.class);
    mockSelect.addIgnore("isRunning");
    mockSelect.addIgnore("getThread");
    mockSelect.addIgnore("setRunning");
    mockSelect.setDefaultReturnValue("isRunning", true);
    mockSelect.setDefaultReturnValue("isWantShutdown", false);
    mockWriteHandler = MockObjectFactory.createMock(OperationCallback.class);
    mockRegListener = MockObjectFactory.createMock(ChannelRegistrationListener.class);
    MockObject mockChannels = MockObjectFactory.createMock(ChannelsFactory.class);
    MockObject mockSelectorProv = MockObjectFactory.createMock(SelectorProviderFactory.class);
    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);
    factory = ChannelServiceFactory.createFactory(props2);
    Map<String, Object> p = new HashMap<String, Object>();
    p.put(ChannelManagerOld.KEY_ID, "[client]");
    p.put(ChannelManagerOld.KEY_BUFFER_FACTORY, bufFactory);
    p.put("mock.channelsFactory", mockChannels);
    p.put("mock.selectorProvider", mockSelectorProv);
    chanMgr = factory.createChannelManager(p);
    mockSelectorProv.addReturnValue("provider", mockSelect);
    chanMgr.start();
    CalledMethod m = mockSelect.expect("startPollingThread");
    listener = (SelectorListener) m.getAllParams()[0];
    mockHandler = MockObjectFactory.createMock(DataListener.class);
    mockHandler.setDefaultBehavior("incomingData", new CloneByteBuffer());
    // mockConnect = MockObjectFactory.createMock(ConnectCallback.class);
    mockChannels.addReturnValue("open", mockSunsChannel);
    client1 = chanMgr.createTCPChannel("ClientChannel", null);
    mockSunsChannel.expect("configureBlocking");
}
Also used : SocketChannel(org.webpieces.nio.api.testutil.chanapi.SocketChannel) 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) CalledMethod(biz.xsoftware.mock.CalledMethod) ChannelRegistrationListener(org.webpieces.nio.api.testutil.nioapi.ChannelRegistrationListener) OperationCallback(org.webpieces.nio.api.handlers.OperationCallback) Select(org.webpieces.nio.api.testutil.nioapi.Select) MockObject(biz.xsoftware.mock.MockObject) DataListener(org.webpieces.nio.api.handlers.DataListener) MockObject(biz.xsoftware.mock.MockObject)

Aggregations

FactoryCreator (org.webpieces.nio.api.libs.FactoryCreator)7 CloneByteBuffer (org.webpieces.nio.api.testutil.CloneByteBuffer)6 MockObject (biz.xsoftware.mock.MockObject)4 HashMap (java.util.HashMap)4 ChannelServiceFactory (org.webpieces.nio.api.deprecated.ChannelServiceFactory)3 DataListener (org.webpieces.nio.api.handlers.DataListener)3 SSLEngine (javax.net.ssl.SSLEngine)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 CalledMethod (biz.xsoftware.mock.CalledMethod)1 InetSocketAddress (java.net.InetSocketAddress)1 ChannelService (org.webpieces.nio.api.deprecated.ChannelService)1 ConnectionCallback (org.webpieces.nio.api.deprecated.ConnectionCallback)1 Settings (org.webpieces.nio.api.deprecated.Settings)1 DatagramListener (org.webpieces.nio.api.handlers.DatagramListener)1 OperationCallback (org.webpieces.nio.api.handlers.OperationCallback)1 PacketListener (org.webpieces.nio.api.libs.PacketListener)1 PacketProcessorFactory (org.webpieces.nio.api.libs.PacketProcessorFactory)1 SocketChannel (org.webpieces.nio.api.testutil.chanapi.SocketChannel)1