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);
}
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);
}
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);
}
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);
}
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");
}
Aggregations