use of org.webpieces.util.threading.DirectExecutor in project webpieces by deanhiller.
the class TestConnecting method setup.
@Before
public void setup() {
ChannelManagerFactory factory = ChannelManagerFactory.createFactory(mockJdk, Metrics.globalRegistry);
DirectExecutor exec = new DirectExecutor();
mgr = factory.createMultiThreadedChanMgr("test'n", new TwoPools("pl", new SimpleMeterRegistry()), new BackpressureConfig(), exec);
}
use of org.webpieces.util.threading.DirectExecutor in project webpieces by deanhiller.
the class TestSslCloseClient method createClientChannel.
public static TCPChannel createClientChannel(String name, MockJdk mockJdk) throws GeneralSecurityException, IOException {
ChannelManagerFactory factory = ChannelManagerFactory.createFactory(mockJdk, Metrics.globalRegistry);
BufferPool pool = new TwoPools("pClient", new SimpleMeterRegistry());
ChannelManager chanMgr = factory.createMultiThreadedChanMgr(name + "Mgr", pool, new BackpressureConfig(), new DirectExecutor());
MockSSLEngineFactory sslFactory = new MockSSLEngineFactory();
SSLEngine clientSsl = sslFactory.createEngineForSocket();
TCPChannel channel1 = chanMgr.createTCPChannel("client", clientSsl);
return channel1;
}
use of org.webpieces.util.threading.DirectExecutor in project webpieces by deanhiller.
the class TestSslBasicSvr method setup.
@Before
public void setup() throws GeneralSecurityException, IOException, InterruptedException, ExecutionException, TimeoutException {
System.setProperty("jdk.tls.server.protocols", "TLSv1.2");
System.setProperty("jdk.tls.client.protocols", "TLSv1.2");
SSLEngineFactoryForTestOld sslFactory = new SSLEngineFactoryForTestOld();
MeterRegistry meters = Metrics.globalRegistry;
ChannelManagerFactory factory = ChannelManagerFactory.createFactory(mockJdk, meters);
ChannelManager mgr = factory.createMultiThreadedChanMgr("test'n", new TwoPools("pl", new SimpleMeterRegistry()), new BackpressureConfig(), new DirectExecutor());
AsyncServerManager svrMgr = AsyncServerMgrFactory.createAsyncServer(mgr, meters);
server = svrMgr.createTcpServer(new AsyncConfig(), listener, sslFactory);
XFuture<Void> future = server.start(new InetSocketAddress(8443));
Assert.assertFalse(future.isDone());
mockJdk.setThread(Thread.currentThread());
mockJdk.fireSelector();
future.get(2, TimeUnit.SECONDS);
BufferPool pool = new TwoPools("p1", new SimpleMeterRegistry());
SSLEngine clientSsl = sslFactory.createEngineForSocket();
SSLMetrics sslMetrics = new SSLMetrics("", meters);
clientSslParser = AsyncSSLFactory.create("svr", clientSsl, pool, sslMetrics);
SslAction result = clientSslParser.beginHandshake();
// simulate the jdk firing the selector with a new channel...
mockSvrChannel.addNewChannel(mockChannel);
mockJdk.setThread(Thread.currentThread());
mockJdk.fireSelector();
// assert connectionOpened was called with value of isReadyForWrites=false
// (This feature is specifically so clients can start a time and timeout the connection if they do not
// receive a valid payload in a certain amount of time).
ConnectionOpen connectionOpenedInfo = listener.getConnectionOpenedInfo();
channel = connectionOpenedInfo.channel;
Assert.assertEquals(false, connectionOpenedInfo.isReadyForWrites);
mockChannel.setNumBytesToConsume(100000);
mockChannel.forceDataRead(mockJdk, result.getEncryptedData());
}
use of org.webpieces.util.threading.DirectExecutor in project webpieces by deanhiller.
the class TestSvrReading method setup.
@Before
public void setup() throws InterruptedException, ExecutionException, TimeoutException {
MeterRegistry meters = Metrics.globalRegistry;
ChannelManagerFactory factory = ChannelManagerFactory.createFactory(mockJdk, meters);
DirectExecutor exec = new DirectExecutor();
BackpressureConfig config = new BackpressureConfig();
config.setMaxBytes(6);
config.setStartReadingThreshold(2);
ChannelManager mgr = factory.createMultiThreadedChanMgr("test'n", new TwoPools("pl", new SimpleMeterRegistry()), config, exec);
AsyncServerManager svrMgr = AsyncServerMgrFactory.createAsyncServer(mgr, meters);
listener = new MockAsyncListener();
AsyncServer server = svrMgr.createTcpServer(new AsyncConfig(), listener);
XFuture<Void> future = server.start(new InetSocketAddress(4444));
Assert.assertFalse(future.isDone());
mockJdk.setThread(Thread.currentThread());
mockJdk.fireSelector();
future.get(2, TimeUnit.SECONDS);
mockSvrChannel.addNewChannel(mockChannel);
mockJdk.setThread(Thread.currentThread());
mockJdk.fireSelector();
Assert.assertEquals(1, listener.getNumTimesCalledConnectionOpen());
}
use of org.webpieces.util.threading.DirectExecutor in project webpieces by deanhiller.
the class TestAccepting method setup.
@Before
public void setup() {
MeterRegistry meters = Metrics.globalRegistry;
ChannelManagerFactory factory = ChannelManagerFactory.createFactory(mockJdk, meters);
ChannelManager mgr = factory.createMultiThreadedChanMgr("test'n", new TwoPools("pl", new SimpleMeterRegistry()), new BackpressureConfig(), new DirectExecutor());
svrMgr = AsyncServerMgrFactory.createAsyncServer(mgr, meters);
}
Aggregations