use of org.webpieces.nio.api.deprecated.ChannelServiceFactory 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);
}
}
use of org.webpieces.nio.api.deprecated.ChannelServiceFactory in project webpieces by deanhiller.
the class TryRealConnection method setUp.
protected void setUp() throws Exception {
if (chanMgr == null) {
Map<String, Object> factoryName = new HashMap<String, Object>();
factoryName.put(ChannelServiceFactory.KEY_IMPLEMENTATION_CLASS, ChannelServiceFactory.VAL_SECURE_CHANNEL_MGR);
ChannelServiceFactory secureFactory = ChannelServiceFactory.createFactory(factoryName);
//ChannelManagerFactory secureFactory = ChannelManagerFactory.createFactory(null);
Map<String, Object> p = new HashMap<String, Object>();
p.put(ChannelManagerOld.KEY_ID, "[client]");
chanMgr = secureFactory.createChannelManager(p);
chanMgr.start();
}
loopBack = InetAddress.getByName("192.168.1.100");
loopBackAddr = new InetSocketAddress(loopBack, 0);
}
use of org.webpieces.nio.api.deprecated.ChannelServiceFactory 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");
}
use of org.webpieces.nio.api.deprecated.ChannelServiceFactory in project webpieces by deanhiller.
the class TestMoreSecureChanMgr method getClientChanMgr.
protected ChannelService getClientChanMgr() throws Exception {
Map<String, Object> factoryName = new HashMap<String, Object>();
factoryName.put(ChannelServiceFactory.KEY_IMPLEMENTATION_CLASS, ChannelServiceFactory.VAL_SECURE_CHANNEL_MGR);
factoryName.put(ChannelServiceFactory.KEY_CHILD_CHANNELMGR_FACTORY, basicFactory);
ChannelServiceFactory secureFactory = ChannelServiceFactory.createFactory(factoryName);
Map<String, Object> p = new HashMap<String, Object>();
p.put(ChannelManagerOld.KEY_ID, "client");
p.put(ChannelManagerOld.KEY_BUFFER_FACTORY, bufFactory);
ChannelService chanMgr = secureFactory.createChannelManager(p);
return chanMgr;
}
use of org.webpieces.nio.api.deprecated.ChannelServiceFactory 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());
}
Aggregations