Renamed TestOptions to TestUtil

This commit is contained in:
Trustin Lee 2009-03-12 00:42:41 +00:00
parent ebdfec8ec0
commit bd184cc665
12 changed files with 31 additions and 28 deletions

View File

@ -235,7 +235,7 @@
<forkMode>never</forkMode> <forkMode>never</forkMode>
<excludes> <excludes>
<exclude>**/Abstract*</exclude> <exclude>**/Abstract*</exclude>
<exclude>**/TestOption*</exclude> <exclude>**/TestUtil*</exclude>
</excludes> </excludes>
</configuration> </configuration>
</plugin> </plugin>

View File

@ -38,7 +38,7 @@ import org.jboss.netty.channel.ChannelPipelineException;
import org.jboss.netty.channel.ChannelPipelineFactory; import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.util.DummyHandler; import org.jboss.netty.util.DummyHandler;
import org.jboss.netty.util.ExecutorUtil; import org.jboss.netty.util.ExecutorUtil;
import org.jboss.netty.util.TestOptions; import org.jboss.netty.util.TestUtil;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
@ -93,7 +93,7 @@ public abstract class AbstractSocketClientBootstrapTest {
bootstrap.setOption( bootstrap.setOption(
"remoteAddress", "remoteAddress",
new InetSocketAddress( new InetSocketAddress(
TestOptions.getLocalHost(), TestUtil.getLocalHost(),
serverSocket.socket().getLocalPort())); serverSocket.socket().getLocalPort()));
ChannelFuture future = bootstrap.connect(); ChannelFuture future = bootstrap.connect();
@ -130,7 +130,7 @@ public abstract class AbstractSocketClientBootstrapTest {
bootstrap.setOption( bootstrap.setOption(
"remoteAddress", "remoteAddress",
new InetSocketAddress( new InetSocketAddress(
TestOptions.getLocalHost(), TestUtil.getLocalHost(),
serverSocket.socket().getLocalPort())); serverSocket.socket().getLocalPort()));
bootstrap.setOption("localAddress", new InetSocketAddress(0)); bootstrap.setOption("localAddress", new InetSocketAddress(0));
@ -162,7 +162,7 @@ public abstract class AbstractSocketClientBootstrapTest {
expect(pipelineFactory.getPipeline()).andThrow(new ChannelPipelineException()); expect(pipelineFactory.getPipeline()).andThrow(new ChannelPipelineException());
replay(pipelineFactory); replay(pipelineFactory);
bootstrap.connect(new InetSocketAddress(TestOptions.getLocalHost(), 1)); bootstrap.connect(new InetSocketAddress(TestUtil.getLocalHost(), 1));
} }
@Test(expected = IllegalStateException.class) @Test(expected = IllegalStateException.class)

View File

@ -45,7 +45,7 @@ import org.jboss.netty.channel.SimpleChannelHandler;
import org.jboss.netty.channel.socket.SocketChannelConfig; import org.jboss.netty.channel.socket.SocketChannelConfig;
import org.jboss.netty.util.DummyHandler; import org.jboss.netty.util.DummyHandler;
import org.jboss.netty.util.ExecutorUtil; import org.jboss.netty.util.ExecutorUtil;
import org.jboss.netty.util.TestOptions; import org.jboss.netty.util.TestUtil;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
@ -132,7 +132,7 @@ public abstract class AbstractSocketServerBootstrapTest {
Socket socket = null; Socket socket = null;
try { try {
socket = new Socket( socket = new Socket(
TestOptions.getLocalHost(), TestUtil.getLocalHost(),
((InetSocketAddress) channel.getLocalAddress()).getPort()); ((InetSocketAddress) channel.getLocalAddress()).getPort());
// Wait until the connection is open in the server side. // Wait until the connection is open in the server side.
@ -188,7 +188,7 @@ public abstract class AbstractSocketServerBootstrapTest {
expect(pipelineFactory.getPipeline()).andThrow(new ChannelPipelineException()); expect(pipelineFactory.getPipeline()).andThrow(new ChannelPipelineException());
replay(pipelineFactory); replay(pipelineFactory);
bootstrap.connect(new InetSocketAddress(TestOptions.getLocalHost(), 1)); bootstrap.connect(new InetSocketAddress(TestUtil.getLocalHost(), 1));
} }
@Test(expected = IllegalStateException.class) @Test(expected = IllegalStateException.class)

View File

@ -46,7 +46,7 @@ import org.jboss.netty.channel.ExceptionEvent;
import org.jboss.netty.channel.MessageEvent; import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelHandler; import org.jboss.netty.channel.SimpleChannelHandler;
import org.jboss.netty.util.ExecutorUtil; import org.jboss.netty.util.ExecutorUtil;
import org.jboss.netty.util.TestOptions; import org.jboss.netty.util.TestUtil;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
@ -97,7 +97,7 @@ public abstract class AbstractSocketEchoTest {
Channel sc = sb.bind(new InetSocketAddress(0)); Channel sc = sb.bind(new InetSocketAddress(0));
int port = ((InetSocketAddress) sc.getLocalAddress()).getPort(); int port = ((InetSocketAddress) sc.getLocalAddress()).getPort();
ChannelFuture ccf = cb.connect(new InetSocketAddress(TestOptions.getLocalHost(), port)); ChannelFuture ccf = cb.connect(new InetSocketAddress(TestUtil.getLocalHost(), port));
assertTrue(ccf.awaitUninterruptibly().isSuccess()); assertTrue(ccf.awaitUninterruptibly().isSuccess());
Channel cc = ccf.getChannel(); Channel cc = ccf.getChannel();

View File

@ -33,7 +33,7 @@ import org.jboss.netty.bootstrap.ClientBootstrap;
import org.jboss.netty.channel.ChannelFuture; import org.jboss.netty.channel.ChannelFuture;
import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory; import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
import org.jboss.netty.util.DummyHandler; import org.jboss.netty.util.DummyHandler;
import org.jboss.netty.util.TestOptions; import org.jboss.netty.util.TestUtil;
import org.junit.Test; import org.junit.Test;
@ -48,7 +48,7 @@ public class NioClientSocketShutdownTimeTest {
@Test @Test
public void testShutdownTime() throws Throwable { public void testShutdownTime() throws Throwable {
if (!TestOptions.isTimingTestEnabled()) { if (!TestUtil.isTimingTestEnabled()) {
return; return;
} }
@ -68,7 +68,7 @@ public class NioClientSocketShutdownTimeTest {
serverSocket.configureBlocking(false); serverSocket.configureBlocking(false);
ChannelFuture f = b.connect(new InetSocketAddress( ChannelFuture f = b.connect(new InetSocketAddress(
TestOptions.getLocalHost(), TestUtil.getLocalHost(),
serverSocket.socket().getLocalPort())); serverSocket.socket().getLocalPort()));
serverSocket.accept(); serverSocket.accept();

View File

@ -36,7 +36,7 @@ import org.jboss.netty.channel.ChannelPipelineCoverage;
import org.jboss.netty.channel.ChannelStateEvent; import org.jboss.netty.channel.ChannelStateEvent;
import org.jboss.netty.channel.SimpleChannelHandler; import org.jboss.netty.channel.SimpleChannelHandler;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory; import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
import org.jboss.netty.util.TestOptions; import org.jboss.netty.util.TestUtil;
import org.junit.Test; import org.junit.Test;
@ -51,7 +51,7 @@ public class NioServerSocketShutdownTimeTest {
@Test(timeout = 10000) @Test(timeout = 10000)
public void testSuccessfulBindAttempt() throws Exception { public void testSuccessfulBindAttempt() throws Exception {
if (!TestOptions.isTimingTestEnabled()) { if (!TestUtil.isTimingTestEnabled()) {
return; return;
} }
@ -74,7 +74,7 @@ public class NioServerSocketShutdownTimeTest {
Socket socket = null; Socket socket = null;
try { try {
socket = new Socket( socket = new Socket(
TestOptions.getLocalHost(), TestUtil.getLocalHost(),
((InetSocketAddress) channel.getLocalAddress()).getPort()); ((InetSocketAddress) channel.getLocalAddress()).getPort());
while (!handler.connected) { while (!handler.connected) {

View File

@ -46,7 +46,7 @@ import org.jboss.netty.channel.ExceptionEvent;
import org.jboss.netty.channel.MessageEvent; import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelHandler; import org.jboss.netty.channel.SimpleChannelHandler;
import org.jboss.netty.util.ExecutorUtil; import org.jboss.netty.util.ExecutorUtil;
import org.jboss.netty.util.TestOptions; import org.jboss.netty.util.TestUtil;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
@ -99,7 +99,7 @@ public abstract class AbstractSocketFixedLengthEchoTest {
Channel sc = sb.bind(new InetSocketAddress(0)); Channel sc = sb.bind(new InetSocketAddress(0));
int port = ((InetSocketAddress) sc.getLocalAddress()).getPort(); int port = ((InetSocketAddress) sc.getLocalAddress()).getPort();
ChannelFuture ccf = cb.connect(new InetSocketAddress(TestOptions.getLocalHost(), port)); ChannelFuture ccf = cb.connect(new InetSocketAddress(TestUtil.getLocalHost(), port));
assertTrue(ccf.awaitUninterruptibly().isSuccess()); assertTrue(ccf.awaitUninterruptibly().isSuccess());
Channel cc = ccf.getChannel(); Channel cc = ccf.getChannel();

View File

@ -44,7 +44,7 @@ import org.jboss.netty.channel.ExceptionEvent;
import org.jboss.netty.channel.MessageEvent; import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelHandler; import org.jboss.netty.channel.SimpleChannelHandler;
import org.jboss.netty.util.ExecutorUtil; import org.jboss.netty.util.ExecutorUtil;
import org.jboss.netty.util.TestOptions; import org.jboss.netty.util.TestUtil;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
@ -108,7 +108,7 @@ public abstract class AbstractSocketCompatibleObjectStreamEchoTest {
Channel sc = sb.bind(new InetSocketAddress(0)); Channel sc = sb.bind(new InetSocketAddress(0));
int port = ((InetSocketAddress) sc.getLocalAddress()).getPort(); int port = ((InetSocketAddress) sc.getLocalAddress()).getPort();
ChannelFuture ccf = cb.connect(new InetSocketAddress(TestOptions.getLocalHost(), port)); ChannelFuture ccf = cb.connect(new InetSocketAddress(TestUtil.getLocalHost(), port));
assertTrue(ccf.awaitUninterruptibly().isSuccess()); assertTrue(ccf.awaitUninterruptibly().isSuccess());
Channel cc = ccf.getChannel(); Channel cc = ccf.getChannel();

View File

@ -44,7 +44,7 @@ import org.jboss.netty.channel.ExceptionEvent;
import org.jboss.netty.channel.MessageEvent; import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelHandler; import org.jboss.netty.channel.SimpleChannelHandler;
import org.jboss.netty.util.ExecutorUtil; import org.jboss.netty.util.ExecutorUtil;
import org.jboss.netty.util.TestOptions; import org.jboss.netty.util.TestUtil;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
@ -108,7 +108,7 @@ public abstract class AbstractSocketObjectStreamEchoTest {
Channel sc = sb.bind(new InetSocketAddress(0)); Channel sc = sb.bind(new InetSocketAddress(0));
int port = ((InetSocketAddress) sc.getLocalAddress()).getPort(); int port = ((InetSocketAddress) sc.getLocalAddress()).getPort();
ChannelFuture ccf = cb.connect(new InetSocketAddress(TestOptions.getLocalHost(), port)); ChannelFuture ccf = cb.connect(new InetSocketAddress(TestUtil.getLocalHost(), port));
assertTrue(ccf.awaitUninterruptibly().isSuccess()); assertTrue(ccf.awaitUninterruptibly().isSuccess());
Channel cc = ccf.getChannel(); Channel cc = ccf.getChannel();

View File

@ -46,7 +46,7 @@ import org.jboss.netty.channel.SimpleChannelHandler;
import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder; import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder;
import org.jboss.netty.handler.codec.frame.Delimiters; import org.jboss.netty.handler.codec.frame.Delimiters;
import org.jboss.netty.util.ExecutorUtil; import org.jboss.netty.util.ExecutorUtil;
import org.jboss.netty.util.TestOptions; import org.jboss.netty.util.TestUtil;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
@ -112,7 +112,7 @@ public abstract class AbstractSocketStringEchoTest {
Channel sc = sb.bind(new InetSocketAddress(0)); Channel sc = sb.bind(new InetSocketAddress(0));
int port = ((InetSocketAddress) sc.getLocalAddress()).getPort(); int port = ((InetSocketAddress) sc.getLocalAddress()).getPort();
ChannelFuture ccf = cb.connect(new InetSocketAddress(TestOptions.getLocalHost(), port)); ChannelFuture ccf = cb.connect(new InetSocketAddress(TestUtil.getLocalHost(), port));
assertTrue(ccf.awaitUninterruptibly().isSuccess()); assertTrue(ccf.awaitUninterruptibly().isSuccess());
Channel cc = ccf.getChannel(); Channel cc = ccf.getChannel();

View File

@ -53,7 +53,7 @@ import org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor;
import org.jboss.netty.logging.InternalLogger; import org.jboss.netty.logging.InternalLogger;
import org.jboss.netty.logging.InternalLoggerFactory; import org.jboss.netty.logging.InternalLoggerFactory;
import org.jboss.netty.util.ExecutorUtil; import org.jboss.netty.util.ExecutorUtil;
import org.jboss.netty.util.TestOptions; import org.jboss.netty.util.TestUtil;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
@ -128,7 +128,7 @@ public abstract class AbstractSocketSslEchoTest {
Channel sc = sb.bind(new InetSocketAddress(0)); Channel sc = sb.bind(new InetSocketAddress(0));
int port = ((InetSocketAddress) sc.getLocalAddress()).getPort(); int port = ((InetSocketAddress) sc.getLocalAddress()).getPort();
ChannelFuture ccf = cb.connect(new InetSocketAddress(TestOptions.getLocalHost(), port)); ChannelFuture ccf = cb.connect(new InetSocketAddress(TestUtil.getLocalHost(), port));
ccf.awaitUninterruptibly(); ccf.awaitUninterruptibly();
if (!ccf.isSuccess()) { if (!ccf.isSuccess()) {
logger.error("Connection attempt failed", ccf.getCause()); logger.error("Connection attempt failed", ccf.getCause());

View File

@ -32,7 +32,7 @@ import java.net.UnknownHostException;
* @version $Rev$, $Date$ * @version $Rev$, $Date$
*/ */
@org.junit.Ignore @org.junit.Ignore
public final class TestOptions { public final class TestUtil {
private static final boolean ENABLED; private static final boolean ENABLED;
private static final InetAddress LOCALHOST; private static final InetAddress LOCALHOST;
@ -72,10 +72,13 @@ public final class TestOptions {
} }
public static InetAddress getLocalHost() { public static InetAddress getLocalHost() {
// We cache this because some machine takes almost forever to return
// from InetAddress.getLocalHost(). I think it's due to the incorrect
// /etc/hosts or /etc/resolve.conf.
return LOCALHOST; return LOCALHOST;
} }
private TestOptions() { private TestUtil() {
// Unused // Unused
} }
} }