Fixed a failing test

This commit is contained in:
Trustin Lee 2009-08-21 04:29:48 +00:00
parent c861adf6e0
commit d842533135

View File

@ -26,8 +26,8 @@ import static org.easymock.EasyMock.*;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import java.io.IOException; import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket; import java.net.Socket;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
@ -108,14 +108,16 @@ public abstract class AbstractSocketServerBootstrapTest {
@Test(timeout = 30000, expected = ChannelException.class) @Test(timeout = 30000, expected = ChannelException.class)
public void testFailedBindAttempt() throws Exception { public void testFailedBindAttempt() throws Exception {
ServerBootstrap bootstrap = new ServerBootstrap(); final ServerSocket ss = new ServerSocket(0);
bootstrap.setFactory(newServerSocketChannelFactory(executor)); final int boundPort = ss.getLocalPort();
bootstrap.setOption( try {
"localAddress", ServerBootstrap bootstrap = new ServerBootstrap();
new InetSocketAddress( bootstrap.setFactory(newServerSocketChannelFactory(executor));
InetAddress.getByAddress(new byte[] { -1, -1, -1, -1 }), bootstrap.setOption("localAddress", new InetSocketAddress(boundPort));
0)); bootstrap.bind().close().awaitUninterruptibly();
bootstrap.bind().close().awaitUninterruptibly(); } finally {
ss.close();
}
} }
@Test(timeout = 30000) @Test(timeout = 30000)