Potential fix for OIO-OIO SSL echo test
This commit is contained in:
parent
22f33539c1
commit
7db3eacbb4
@ -50,6 +50,9 @@ import org.jboss.netty.channel.ExceptionEvent;
|
||||
import org.jboss.netty.channel.MessageEvent;
|
||||
import org.jboss.netty.channel.SimpleChannelHandler;
|
||||
import org.jboss.netty.example.securechat.SecureChatSslContextFactory;
|
||||
import org.jboss.netty.handler.execution.ExecutionHandler;
|
||||
import org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
@ -92,9 +95,24 @@ public abstract class AbstractSocketSslEchoTest {
|
||||
}
|
||||
}
|
||||
|
||||
private ExecutorService extraExecutor = null;
|
||||
|
||||
protected abstract ChannelFactory newServerSocketChannelFactory(Executor executor);
|
||||
protected abstract ChannelFactory newClientSocketChannelFactory(Executor executor);
|
||||
|
||||
protected boolean isExecutorRequired() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@After
|
||||
public void shutdownExtraExecutor() {
|
||||
if (extraExecutor != null) {
|
||||
extraExecutor.shutdownNow();
|
||||
extraExecutor = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSslEcho() throws Throwable {
|
||||
ServerBootstrap sb = new ServerBootstrap(newServerSocketChannelFactory(executor));
|
||||
@ -117,6 +135,12 @@ public abstract class AbstractSocketSslEchoTest {
|
||||
cb.getPipeline().addFirst("ssl", new SslHandler(cse));
|
||||
cb.getPipeline().addLast("handler", ch);
|
||||
|
||||
if (isExecutorRequired()) {
|
||||
extraExecutor = new OrderedMemoryAwareThreadPoolExecutor(16, 0, 0);
|
||||
sb.getPipeline().addFirst("executor",new ExecutionHandler(extraExecutor));
|
||||
cb.getPipeline().addFirst("executor",new ExecutionHandler(extraExecutor));
|
||||
}
|
||||
|
||||
Channel sc = sb.bind(new InetSocketAddress(0));
|
||||
int port = ((InetSocketAddress) sc.getLocalAddress()).getPort();
|
||||
|
||||
|
@ -46,4 +46,9 @@ public class OioOioSocketSslEchoTest extends AbstractSocketSslEchoTest {
|
||||
protected ChannelFactory newServerSocketChannelFactory(Executor executor) {
|
||||
return new OioServerSocketChannelFactory(executor, executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isExecutorRequired() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user