use of org.webpieces.nio.api.mocks.MockDataListener in project webpieces by deanhiller.
the class TestReading method setup.
@Before
public void setup() throws InterruptedException, ExecutionException, TimeoutException {
ChannelManagerFactory factory = ChannelManagerFactory.createFactory(mockJdk, Metrics.globalRegistry);
DirectExecutor exec = new DirectExecutor();
BackpressureConfig config = new BackpressureConfig();
config.setMaxBytes(6);
config.setStartReadingThreshold(2);
mgr = factory.createMultiThreadedChanMgr("test'n", new TwoPools("pl", new SimpleMeterRegistry()), config, exec);
listener = new MockDataListener();
channel = mgr.createTCPChannel("myid");
mockChannel.addConnectReturnValue(true);
mockJdk.setThread(Thread.currentThread());
XFuture<Void> future = channel.connect(new InetSocketAddress(4444), listener);
future.get(2, TimeUnit.SECONDS);
Assert.assertTrue(mockChannel.isRegisteredForReads());
}
use of org.webpieces.nio.api.mocks.MockDataListener in project webpieces by deanhiller.
the class TestWriting method setup.
@Before
public void setup() throws InterruptedException, ExecutionException, TimeoutException {
ChannelManagerFactory factory = ChannelManagerFactory.createFactory(mockJdk, Metrics.globalRegistry);
DirectExecutor exec = new DirectExecutor();
mgr = factory.createMultiThreadedChanMgr("test'n", new TwoPools("pl", new SimpleMeterRegistry()), new BackpressureConfig(), exec);
MockDataListener listener = new MockDataListener();
channel = mgr.createTCPChannel("myid");
mockChannel.addConnectReturnValue(true);
mockJdk.setThread(Thread.currentThread());
XFuture<Void> future = channel.connect(new InetSocketAddress(4444), listener);
future.get(2, TimeUnit.SECONDS);
Assert.assertTrue(mockChannel.isRegisteredForReads());
}
Aggregations