Potential fix for OIO-OIO SSL echo test

This commit is contained in:
Trustin Lee 2008-11-06 15:56:05 +00:00
parent 22f33539c1
commit 7db3eacbb4
2 changed files with 29 additions and 0 deletions

View File

@ -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();

View File

@ -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;
}
}