diff --git a/pom.xml b/pom.xml index 436b1b1867..f69676e699 100644 --- a/pom.xml +++ b/pom.xml @@ -335,32 +335,5 @@ - - - - unix - - - unix - - - - - false - - - - - default - - true - - - true - - - diff --git a/transport-sctp/pom.xml b/transport-sctp/pom.xml index 011e80f2b0..1803e2fa45 100644 --- a/transport-sctp/pom.xml +++ b/transport-sctp/pom.xml @@ -48,18 +48,6 @@ - - maven-surefire-plugin - 2.7.2 - - - default-test - - ${sctp.test.skip}} - - - - maven-jar-plugin diff --git a/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketClientBootstrapTest.java b/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketClientBootstrapTest.java index 509a35398b..abf305d99d 100644 --- a/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketClientBootstrapTest.java +++ b/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketClientBootstrapTest.java @@ -24,10 +24,11 @@ import io.netty.channel.ChannelPipelineFactory; import io.netty.channel.sctp.codec.SctpFrameDecoder; import io.netty.channel.sctp.codec.SctpFrameEncoder; import io.netty.testsuite.util.DummyHandler; -import io.netty.testsuite.util.SctpSocketAddresses; +import io.netty.testsuite.util.SctpTestUtil; import io.netty.util.internal.ExecutorUtil; import org.easymock.EasyMock; import org.junit.AfterClass; +import org.junit.Assume; import org.junit.BeforeClass; import org.junit.Test; @@ -64,6 +65,8 @@ public abstract class AbstractSocketClientBootstrapTest { @Test(timeout = 10000) public void testFailedConnectionAttempt() throws Exception { + Assume.assumeTrue(SctpTestUtil.isSctpSupported()); + ClientBootstrap bootstrap = new ClientBootstrap(); bootstrap.setFactory(newClientSocketChannelFactory(executor)); bootstrap.getPipeline().addLast("sctp-decoder", new SctpFrameDecoder()); @@ -78,8 +81,10 @@ public abstract class AbstractSocketClientBootstrapTest { @Test(timeout = 10000) public void testSuccessfulConnectionAttempt() throws Throwable { + Assume.assumeTrue(SctpTestUtil.isSctpSupported()); + SctpServerChannel serverChannel = SctpServerChannel.open(); - serverChannel.bind(new InetSocketAddress(SctpSocketAddresses.LOOP_BACK, 0)); + serverChannel.bind(new InetSocketAddress(SctpTestUtil.LOOP_BACK, 0)); try { serverChannel.configureBlocking(false); @@ -97,7 +102,7 @@ public abstract class AbstractSocketClientBootstrapTest { bootstrap.setOption( "remoteAddress", new InetSocketAddress( - SctpSocketAddresses.LOOP_BACK, + SctpTestUtil.LOOP_BACK, serverPort)); ChannelFuture future = bootstrap.connect(); @@ -121,11 +126,13 @@ public abstract class AbstractSocketClientBootstrapTest { @Test(timeout = 10000) public void testSuccessfulConnectionAttemptWithLocalAddress() throws Throwable { + Assume.assumeTrue(SctpTestUtil.isSctpSupported()); + SctpServerChannel serverChannel = SctpServerChannel.open(); try { serverChannel.configureBlocking(false); - serverChannel = serverChannel.bind(new InetSocketAddress(SctpSocketAddresses.LOOP_BACK, 0)); + serverChannel = serverChannel.bind(new InetSocketAddress(SctpTestUtil.LOOP_BACK, 0)); final Iterator serverAddresses = serverChannel.getAllLocalAddresses().iterator(); InetSocketAddress serverAddress = (InetSocketAddress) serverAddresses.next(); @@ -137,9 +144,9 @@ public abstract class AbstractSocketClientBootstrapTest { bootstrap.setOption( "remoteAddress", new InetSocketAddress( - SctpSocketAddresses.LOOP_BACK, + SctpTestUtil.LOOP_BACK, serverPort)); - bootstrap.setOption("localAddress", new InetSocketAddress(SctpSocketAddresses.LOOP_BACK, 0)); + bootstrap.setOption("localAddress", new InetSocketAddress(SctpTestUtil.LOOP_BACK, 0)); ChannelFuture future = bootstrap.connect(); serverChannel.accept(); @@ -162,6 +169,8 @@ public abstract class AbstractSocketClientBootstrapTest { @Test(expected = ChannelPipelineException.class) public void testFailedPipelineInitialization() throws Exception { + Assume.assumeTrue(SctpTestUtil.isSctpSupported()); + ClientBootstrap bootstrap = new ClientBootstrap(EasyMock.createMock(ChannelFactory.class)); ChannelPipelineFactory pipelineFactory = EasyMock.createMock(ChannelPipelineFactory.class); bootstrap.setPipelineFactory(pipelineFactory); @@ -169,22 +178,28 @@ public abstract class AbstractSocketClientBootstrapTest { EasyMock.expect(pipelineFactory.getPipeline()).andThrow(new ChannelPipelineException()); EasyMock.replay(pipelineFactory); - bootstrap.connect(new InetSocketAddress(SctpSocketAddresses.LOOP_BACK, 1)); + bootstrap.connect(new InetSocketAddress(SctpTestUtil.LOOP_BACK, 1)); } @Test(expected = IllegalStateException.class) public void shouldHaveRemoteAddressOption() { + Assume.assumeTrue(SctpTestUtil.isSctpSupported()); + new ClientBootstrap(EasyMock.createMock(ChannelFactory.class)).connect(); } @Test(expected = NullPointerException.class) public void shouldDisallowNullRemoteAddressParameter1() { + Assume.assumeTrue(SctpTestUtil.isSctpSupported()); + new ClientBootstrap(EasyMock.createMock(ChannelFactory.class)).connect(null); } @Test(expected = NullPointerException.class) public void shouldDisallowNullRemoteAddressParameter2() { + Assume.assumeTrue(SctpTestUtil.isSctpSupported()); + new ClientBootstrap(EasyMock.createMock(ChannelFactory.class)).connect(null, null); } } diff --git a/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketCompatibleObjectStreamEchoTest.java b/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketCompatibleObjectStreamEchoTest.java index eb2f2d424d..5afc90a58f 100644 --- a/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketCompatibleObjectStreamEchoTest.java +++ b/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketCompatibleObjectStreamEchoTest.java @@ -22,9 +22,10 @@ import io.netty.channel.sctp.codec.SctpFrameDecoder; import io.netty.channel.sctp.codec.SctpFrameEncoder; import io.netty.handler.codec.serialization.CompatibleObjectDecoder; import io.netty.handler.codec.serialization.CompatibleObjectEncoder; -import io.netty.testsuite.util.SctpSocketAddresses; +import io.netty.testsuite.util.SctpTestUtil; import io.netty.util.internal.ExecutorUtil; import org.junit.AfterClass; +import org.junit.Assume; import org.junit.BeforeClass; import org.junit.Test; @@ -74,6 +75,8 @@ public abstract class AbstractSocketCompatibleObjectStreamEchoTest { @Test @SuppressWarnings("deprecation") public void testCompatibleObjectEcho() throws Throwable { + Assume.assumeTrue(SctpTestUtil.isSctpSupported()); + ServerBootstrap sb = new ServerBootstrap(newServerSocketChannelFactory(executor)); ClientBootstrap cb = new ClientBootstrap(newClientSocketChannelFactory(executor)); @@ -92,10 +95,10 @@ public abstract class AbstractSocketCompatibleObjectStreamEchoTest { cb.getPipeline().addLast("encoder", new CompatibleObjectEncoder()); cb.getPipeline().addLast("handler", ch); - Channel sc = sb.bind(new InetSocketAddress(SctpSocketAddresses.LOOP_BACK, 0)); + Channel sc = sb.bind(new InetSocketAddress(SctpTestUtil.LOOP_BACK, 0)); int port = ((InetSocketAddress) sc.getLocalAddress()).getPort(); - ChannelFuture ccf = cb.connect(new InetSocketAddress(SctpSocketAddresses.LOOP_BACK, port)); + ChannelFuture ccf = cb.connect(new InetSocketAddress(SctpTestUtil.LOOP_BACK, port)); assertTrue(ccf.awaitUninterruptibly().isSuccess()); Channel cc = ccf.getChannel(); diff --git a/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketEchoTest.java b/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketEchoTest.java index 90821601e1..a307435771 100644 --- a/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketEchoTest.java +++ b/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketEchoTest.java @@ -22,9 +22,10 @@ import io.netty.buffer.ChannelBuffers; import io.netty.channel.*; import io.netty.channel.sctp.codec.SctpFrameDecoder; import io.netty.channel.sctp.codec.SctpFrameEncoder; -import io.netty.testsuite.util.SctpSocketAddresses; +import io.netty.testsuite.util.SctpTestUtil; import io.netty.util.internal.ExecutorUtil; import org.junit.AfterClass; +import org.junit.Assume; import org.junit.BeforeClass; import org.junit.Test; @@ -65,6 +66,8 @@ public abstract class AbstractSocketEchoTest { @Test public void testSimpleEcho() throws Throwable { + Assume.assumeTrue(SctpTestUtil.isSctpSupported()); + ServerBootstrap sb = new ServerBootstrap(newServerSocketChannelFactory(executor)); ClientBootstrap cb = new ClientBootstrap(newClientSocketChannelFactory(executor)); @@ -81,10 +84,10 @@ public abstract class AbstractSocketEchoTest { cb.getPipeline().addLast("sctp-encoder", new SctpFrameEncoder()); cb.getPipeline().addLast("handler", ch); - Channel sc = sb.bind(new InetSocketAddress(SctpSocketAddresses.LOOP_BACK, 0)); + Channel sc = sb.bind(new InetSocketAddress(SctpTestUtil.LOOP_BACK, 0)); int port = ((InetSocketAddress) sc.getLocalAddress()).getPort(); - ChannelFuture ccf = cb.connect(new InetSocketAddress(SctpSocketAddresses.LOOP_BACK, port)); + ChannelFuture ccf = cb.connect(new InetSocketAddress(SctpTestUtil.LOOP_BACK, port)); assertTrue(ccf.awaitUninterruptibly().isSuccess()); Channel cc = ccf.getChannel(); diff --git a/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketFixedLengthEchoTest.java b/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketFixedLengthEchoTest.java index 697d694bb1..6dacb5f44f 100644 --- a/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketFixedLengthEchoTest.java +++ b/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketFixedLengthEchoTest.java @@ -23,9 +23,10 @@ import io.netty.channel.*; import io.netty.channel.sctp.codec.SctpFrameDecoder; import io.netty.channel.sctp.codec.SctpFrameEncoder; import io.netty.handler.codec.frame.FixedLengthFrameDecoder; -import io.netty.testsuite.util.SctpSocketAddresses; +import io.netty.testsuite.util.SctpTestUtil; import io.netty.util.internal.ExecutorUtil; import org.junit.AfterClass; +import org.junit.Assume; import org.junit.BeforeClass; import org.junit.Test; @@ -66,6 +67,8 @@ public abstract class AbstractSocketFixedLengthEchoTest { @Test public void testFixedLengthEcho() throws Throwable { + Assume.assumeTrue(SctpTestUtil.isSctpSupported()); + ServerBootstrap sb = new ServerBootstrap(newServerSocketChannelFactory(executor)); ClientBootstrap cb = new ClientBootstrap(newClientSocketChannelFactory(executor)); @@ -86,7 +89,7 @@ public abstract class AbstractSocketFixedLengthEchoTest { Channel sc = sb.bind(new InetSocketAddress(0)); int port = ((InetSocketAddress) sc.getLocalAddress()).getPort(); - ChannelFuture ccf = cb.connect(new InetSocketAddress(SctpSocketAddresses.LOOP_BACK, port)); + ChannelFuture ccf = cb.connect(new InetSocketAddress(SctpTestUtil.LOOP_BACK, port)); assertTrue(ccf.awaitUninterruptibly().isSuccess()); Channel cc = ccf.getChannel(); diff --git a/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketObjectStreamEchoTest.java b/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketObjectStreamEchoTest.java index 26b97f1efb..92d38165f7 100644 --- a/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketObjectStreamEchoTest.java +++ b/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketObjectStreamEchoTest.java @@ -31,7 +31,7 @@ import io.netty.channel.sctp.codec.SctpFrameEncoder; import io.netty.handler.codec.serialization.ClassResolvers; import io.netty.handler.codec.serialization.ObjectDecoder; import io.netty.handler.codec.serialization.ObjectEncoder; -import io.netty.testsuite.util.SctpSocketAddresses; +import io.netty.testsuite.util.SctpTestUtil; import io.netty.util.internal.ExecutorUtil; import java.io.IOException; @@ -43,6 +43,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicReference; import org.junit.AfterClass; +import org.junit.Assume; import org.junit.BeforeClass; import org.junit.Test; @@ -80,6 +81,8 @@ public abstract class AbstractSocketObjectStreamEchoTest { @Test public void testObjectEcho() throws Throwable { + Assume.assumeTrue(SctpTestUtil.isSctpSupported()); + ServerBootstrap sb = new ServerBootstrap(newServerSocketChannelFactory(executor)); ClientBootstrap cb = new ClientBootstrap(newClientSocketChannelFactory(executor)); @@ -100,10 +103,10 @@ public abstract class AbstractSocketObjectStreamEchoTest { cb.getPipeline().addLast("encoder", new ObjectEncoder()); cb.getPipeline().addLast("handler", ch); - Channel sc = sb.bind(new InetSocketAddress(SctpSocketAddresses.LOOP_BACK, 0)); + Channel sc = sb.bind(new InetSocketAddress(SctpTestUtil.LOOP_BACK, 0)); int port = ((InetSocketAddress) sc.getLocalAddress()).getPort(); - ChannelFuture ccf = cb.connect(new InetSocketAddress(SctpSocketAddresses.LOOP_BACK, port)); + ChannelFuture ccf = cb.connect(new InetSocketAddress(SctpTestUtil.LOOP_BACK, port)); assertTrue(ccf.awaitUninterruptibly().isSuccess()); Channel cc = ccf.getChannel(); diff --git a/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketServerBootstrapTest.java b/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketServerBootstrapTest.java index 28709c363d..242c02feb5 100644 --- a/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketServerBootstrapTest.java +++ b/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketServerBootstrapTest.java @@ -23,10 +23,11 @@ import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.*; import io.netty.channel.sctp.SctpChannelConfig; import io.netty.testsuite.util.DummyHandler; -import io.netty.testsuite.util.SctpSocketAddresses; +import io.netty.testsuite.util.SctpTestUtil; import io.netty.util.internal.ExecutorUtil; import org.easymock.EasyMock; import org.junit.AfterClass; +import org.junit.Assume; import org.junit.BeforeClass; import org.junit.Test; @@ -87,8 +88,10 @@ public abstract class AbstractSocketServerBootstrapTest { @Test(timeout = 30000, expected = ChannelException.class) public void testFailedBindAttempt() throws Exception { + Assume.assumeTrue(SctpTestUtil.isSctpSupported()); + SctpServerChannel serverChannel = SctpServerChannel.open(); - serverChannel.bind(new InetSocketAddress(SctpSocketAddresses.LOOP_BACK, 0)); + serverChannel.bind(new InetSocketAddress(SctpTestUtil.LOOP_BACK, 0)); try { final Iterator serverAddresses = serverChannel.getAllLocalAddresses().iterator(); @@ -96,7 +99,7 @@ public abstract class AbstractSocketServerBootstrapTest { final int boundPort = serverAddress.getPort(); ServerBootstrap bootstrap = new ServerBootstrap(); bootstrap.setFactory(newServerSocketChannelFactory(executor)); - bootstrap.setOption("localAddress", new InetSocketAddress(SctpSocketAddresses.LOOP_BACK, boundPort)); + bootstrap.setOption("localAddress", new InetSocketAddress(SctpTestUtil.LOOP_BACK, boundPort)); bootstrap.bind().close().awaitUninterruptibly(); } finally { serverChannel.close(); @@ -105,11 +108,13 @@ public abstract class AbstractSocketServerBootstrapTest { @Test(timeout = 30000) public void testSuccessfulBindAttempt() throws Exception { + Assume.assumeTrue(SctpTestUtil.isSctpSupported()); + ServerBootstrap bootstrap = new ServerBootstrap( newServerSocketChannelFactory(executor)); bootstrap.setParentHandler(new ParentChannelHandler()); - bootstrap.setOption("localAddress", new InetSocketAddress(SctpSocketAddresses.LOOP_BACK, 0)); + bootstrap.setOption("localAddress", new InetSocketAddress(SctpTestUtil.LOOP_BACK, 0)); bootstrap.setOption("child.receiveBufferSize", 9753); bootstrap.setOption("child.sendBufferSize", 8642); @@ -123,7 +128,7 @@ public abstract class AbstractSocketServerBootstrapTest { try { sctpChannel.connect( new InetSocketAddress( - SctpSocketAddresses.LOOP_BACK, + SctpTestUtil.LOOP_BACK, ((InetSocketAddress) channel.getLocalAddress()).getPort())); // Wait until the connection is open in the server side. @@ -172,6 +177,8 @@ public abstract class AbstractSocketServerBootstrapTest { @Test(expected = ChannelPipelineException.class) public void testFailedPipelineInitialization() throws Exception { + Assume.assumeTrue(SctpTestUtil.isSctpSupported()); + ClientBootstrap bootstrap = new ClientBootstrap(EasyMock.createMock(ChannelFactory.class)); ChannelPipelineFactory pipelineFactory = EasyMock.createMock(ChannelPipelineFactory.class); bootstrap.setPipelineFactory(pipelineFactory); @@ -179,17 +186,21 @@ public abstract class AbstractSocketServerBootstrapTest { EasyMock.expect(pipelineFactory.getPipeline()).andThrow(new ChannelPipelineException()); EasyMock.replay(pipelineFactory); - bootstrap.connect(new InetSocketAddress(SctpSocketAddresses.LOOP_BACK, 1)); + bootstrap.connect(new InetSocketAddress(SctpTestUtil.LOOP_BACK, 1)); } @Test(expected = IllegalStateException.class) public void shouldHaveLocalAddressOption() { + Assume.assumeTrue(SctpTestUtil.isSctpSupported()); + new ServerBootstrap(EasyMock.createMock(ServerChannelFactory.class)).bind(); } @Test(expected = NullPointerException.class) public void shouldDisallowNullLocalAddressParameter() { + Assume.assumeTrue(SctpTestUtil.isSctpSupported()); + new ServerBootstrap(EasyMock.createMock(ServerChannelFactory.class)).bind(null); } diff --git a/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketSslEchoTest.java b/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketSslEchoTest.java index b169ef6d43..12996df3e0 100644 --- a/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketSslEchoTest.java +++ b/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketSslEchoTest.java @@ -27,9 +27,10 @@ import io.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor; import io.netty.handler.ssl.SslHandler; import io.netty.logging.InternalLogger; import io.netty.logging.InternalLoggerFactory; -import io.netty.testsuite.util.SctpSocketAddresses; +import io.netty.testsuite.util.SctpTestUtil; import io.netty.util.internal.ExecutorUtil; import org.junit.AfterClass; +import org.junit.Assume; import org.junit.BeforeClass; import org.junit.Test; @@ -87,6 +88,8 @@ public abstract class AbstractSocketSslEchoTest { @Test public void testSslEcho() throws Throwable { + Assume.assumeTrue(SctpTestUtil.isSctpSupported()); + ServerBootstrap sb = new ServerBootstrap(newServerSocketChannelFactory(executor)); ClientBootstrap cb = new ClientBootstrap(newClientSocketChannelFactory(executor)); @@ -114,10 +117,10 @@ public abstract class AbstractSocketSslEchoTest { cb.getPipeline().addFirst("executor", new ExecutionHandler(eventExecutor)); } - Channel sc = sb.bind(new InetSocketAddress(SctpSocketAddresses.LOOP_BACK, 0)); + Channel sc = sb.bind(new InetSocketAddress(SctpTestUtil.LOOP_BACK, 0)); int port = ((InetSocketAddress) sc.getLocalAddress()).getPort(); - ChannelFuture ccf = cb.connect(new InetSocketAddress(SctpSocketAddresses.LOOP_BACK, port)); + ChannelFuture ccf = cb.connect(new InetSocketAddress(SctpTestUtil.LOOP_BACK, port)); ccf.awaitUninterruptibly(); if (!ccf.isSuccess()) { logger.error("Connection attempt failed", ccf.getCause()); diff --git a/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketStringEchoTest.java b/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketStringEchoTest.java index 9163d99e32..0c6196af54 100644 --- a/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketStringEchoTest.java +++ b/transport-sctp/src/test/java/io/netty/testsuite/transport/AbstractSocketStringEchoTest.java @@ -24,10 +24,11 @@ import io.netty.handler.codec.frame.DelimiterBasedFrameDecoder; import io.netty.handler.codec.frame.Delimiters; import io.netty.handler.codec.string.StringDecoder; import io.netty.handler.codec.string.StringEncoder; -import io.netty.testsuite.util.SctpSocketAddresses; +import io.netty.testsuite.util.SctpTestUtil; import io.netty.util.CharsetUtil; import io.netty.util.internal.ExecutorUtil; import org.junit.AfterClass; +import org.junit.Assume; import org.junit.BeforeClass; import org.junit.Test; @@ -76,6 +77,8 @@ public abstract class AbstractSocketStringEchoTest { @Test public void testStringEcho() throws Throwable { + Assume.assumeTrue(SctpTestUtil.isSctpSupported()); + ServerBootstrap sb = new ServerBootstrap(newServerSocketChannelFactory(executor)); ClientBootstrap cb = new ClientBootstrap(newClientSocketChannelFactory(executor)); @@ -96,10 +99,10 @@ public abstract class AbstractSocketStringEchoTest { cb.getPipeline().addLast("encoder", new StringEncoder(CharsetUtil.ISO_8859_1)); cb.getPipeline().addLast("handler", ch); - Channel sc = sb.bind(new InetSocketAddress(SctpSocketAddresses.LOOP_BACK, 0)); + Channel sc = sb.bind(new InetSocketAddress(SctpTestUtil.LOOP_BACK, 0)); int port = ((InetSocketAddress) sc.getLocalAddress()).getPort(); - ChannelFuture ccf = cb.connect(new InetSocketAddress(SctpSocketAddresses.LOOP_BACK, port)); + ChannelFuture ccf = cb.connect(new InetSocketAddress(SctpTestUtil.LOOP_BACK, port)); assertTrue(ccf.awaitUninterruptibly().isSuccess()); Channel cc = ccf.getChannel(); diff --git a/transport-sctp/src/test/java/io/netty/testsuite/transport/sctp/SctpMultiHomingEchoTest.java b/transport-sctp/src/test/java/io/netty/testsuite/transport/sctp/SctpMultiHomingEchoTest.java index 12e153a8ed..ed5cc560de 100644 --- a/transport-sctp/src/test/java/io/netty/testsuite/transport/sctp/SctpMultiHomingEchoTest.java +++ b/transport-sctp/src/test/java/io/netty/testsuite/transport/sctp/SctpMultiHomingEchoTest.java @@ -35,7 +35,7 @@ import io.netty.channel.sctp.SctpServerSocketChannelFactory; import io.netty.channel.sctp.codec.SctpFrameDecoder; import io.netty.channel.sctp.codec.SctpFrameEncoder; import io.netty.channel.sctp.handler.SimpleSctpChannelHandler; -import io.netty.testsuite.util.SctpSocketAddresses; +import io.netty.testsuite.util.SctpTestUtil; import io.netty.util.internal.ExecutorUtil; import java.io.IOException; @@ -48,6 +48,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicReference; import org.junit.AfterClass; +import org.junit.Assume; import org.junit.BeforeClass; import org.junit.Test; @@ -81,6 +82,8 @@ public class SctpMultiHomingEchoTest { @Test(timeout = 15000) public void testSimpleEcho() throws Throwable { + Assume.assumeTrue(SctpTestUtil.isSctpSupported()); + ServerBootstrap sb = new ServerBootstrap(newServerSocketChannelFactory(executor)); ClientBootstrap cb = new ClientBootstrap(newClientSocketChannelFactory(executor)); @@ -97,22 +100,22 @@ public class SctpMultiHomingEchoTest { cb.getPipeline().addLast("sctp-encoder", new SctpFrameEncoder()); cb.getPipeline().addLast("handler", ch); - SctpServerChannel serverChannel = (SctpServerChannel) sb.bind(new InetSocketAddress(SctpSocketAddresses.LOOP_BACK, 0)); + SctpServerChannel serverChannel = (SctpServerChannel) sb.bind(new InetSocketAddress(SctpTestUtil.LOOP_BACK, 0)); int port = serverChannel.getLocalAddress().getPort(); - ChannelFuture multiHomingServerBindFuture = serverChannel.bindAddress(InetAddress.getByName(SctpSocketAddresses.LOOP_BACK2)); + ChannelFuture multiHomingServerBindFuture = serverChannel.bindAddress(InetAddress.getByName(SctpTestUtil.LOOP_BACK2)); assertTrue(multiHomingServerBindFuture.awaitUninterruptibly().isSuccess()); - ChannelFuture bindFuture = cb.bind(new InetSocketAddress(SctpSocketAddresses.LOOP_BACK, 0)); + ChannelFuture bindFuture = cb.bind(new InetSocketAddress(SctpTestUtil.LOOP_BACK, 0)); assertTrue(bindFuture.awaitUninterruptibly().isSuccess()); SctpChannel clientChannel = (SctpChannel) bindFuture.getChannel(); //adding a muti-homing address to client channel - ChannelFuture multiHomingBindFuture = clientChannel.bindAddress(InetAddress.getByName(SctpSocketAddresses.LOOP_BACK2)); + ChannelFuture multiHomingBindFuture = clientChannel.bindAddress(InetAddress.getByName(SctpTestUtil.LOOP_BACK2)); assertTrue(multiHomingBindFuture.awaitUninterruptibly().isSuccess()); - ChannelFuture connectFuture = clientChannel.connect(new InetSocketAddress(SctpSocketAddresses.LOOP_BACK, port)); + ChannelFuture connectFuture = clientChannel.connect(new InetSocketAddress(SctpTestUtil.LOOP_BACK, port)); assertTrue(connectFuture.awaitUninterruptibly().isSuccess()); assertEquals("Client local addresses count should be 2", 2, clientChannel.getAllLocalAddresses().size()); @@ -157,10 +160,10 @@ public class SctpMultiHomingEchoTest { } //removing already added muti-homing address from client channel - ChannelFuture multiHomingUnbindFuture = clientChannel.unbindAddress(InetAddress.getByName(SctpSocketAddresses.LOOP_BACK2)); + ChannelFuture multiHomingUnbindFuture = clientChannel.unbindAddress(InetAddress.getByName(SctpTestUtil.LOOP_BACK2)); assertTrue(multiHomingUnbindFuture.awaitUninterruptibly().isSuccess()); - ChannelFuture multiHomingServerUnbindFuture = serverChannel.unbindAddress(InetAddress.getByName(SctpSocketAddresses.LOOP_BACK2)); + ChannelFuture multiHomingServerUnbindFuture = serverChannel.unbindAddress(InetAddress.getByName(SctpTestUtil.LOOP_BACK2)); assertTrue(multiHomingServerUnbindFuture.awaitUninterruptibly().isSuccess()); diff --git a/transport-sctp/src/test/java/io/netty/testsuite/transport/sctp/SctpMultiStreamingEchoTest.java b/transport-sctp/src/test/java/io/netty/testsuite/transport/sctp/SctpMultiStreamingEchoTest.java index 952e759ad8..c77934c505 100644 --- a/transport-sctp/src/test/java/io/netty/testsuite/transport/sctp/SctpMultiStreamingEchoTest.java +++ b/transport-sctp/src/test/java/io/netty/testsuite/transport/sctp/SctpMultiStreamingEchoTest.java @@ -23,9 +23,10 @@ import io.netty.channel.*; import io.netty.channel.sctp.SctpClientSocketChannelFactory; import io.netty.channel.sctp.SctpFrame; import io.netty.channel.sctp.SctpServerSocketChannelFactory; -import io.netty.testsuite.util.SctpSocketAddresses; +import io.netty.testsuite.util.SctpTestUtil; import io.netty.util.internal.ExecutorUtil; import org.junit.AfterClass; +import org.junit.Assume; import org.junit.BeforeClass; import org.junit.Test; @@ -81,6 +82,8 @@ public class SctpMultiStreamingEchoTest { @Test(timeout = 10000) public void testMultiStreamingEcho() throws Throwable { + Assume.assumeTrue(SctpTestUtil.isSctpSupported()); + ServerBootstrap sb = new ServerBootstrap(newServerSocketChannelFactory(executor)); ClientBootstrap cb = new ClientBootstrap(newClientSocketChannelFactory(executor)); @@ -93,10 +96,10 @@ public class SctpMultiStreamingEchoTest { cb.getPipeline().addLast("handler", ch); - Channel sc = sb.bind(new InetSocketAddress(SctpSocketAddresses.LOOP_BACK, 0)); + Channel sc = sb.bind(new InetSocketAddress(SctpTestUtil.LOOP_BACK, 0)); int port = ((InetSocketAddress) sc.getLocalAddress()).getPort(); - ChannelFuture ccf = cb.connect(new InetSocketAddress(SctpSocketAddresses.LOOP_BACK, port)); + ChannelFuture ccf = cb.connect(new InetSocketAddress(SctpTestUtil.LOOP_BACK, port)); assertTrue(ccf.awaitUninterruptibly().isSuccess()); Channel cc = ccf.getChannel(); diff --git a/transport-sctp/src/test/java/io/netty/testsuite/util/SctpTestUtil.java b/transport-sctp/src/test/java/io/netty/testsuite/util/SctpTestUtil.java new file mode 100644 index 0000000000..5a3b3abd63 --- /dev/null +++ b/transport-sctp/src/test/java/io/netty/testsuite/util/SctpTestUtil.java @@ -0,0 +1,37 @@ +/* + * Copyright 2011 The Netty Project + * + * The Netty Project licenses this file to you under the Apache License, + * version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package io.netty.testsuite.util; + +import java.util.Locale; + +public class SctpTestUtil { + //io.netty.util.SocketAddresses.LOCALHOST interface has MTU SIZE issues with SCTP, we have to use local loop back interface for testing + public final static String LOOP_BACK = "127.0.0.1"; + public final static String LOOP_BACK2 = "127.0.0.2"; + + /** + * Return true if SCTP is supported by the running os. + * + */ + public static boolean isSctpSupported() { + String os = System.getProperty("os.name").toLowerCase(Locale.UK); + if (os.equals("unix") || os.equals("linux") || os.equals("sun") || os.equals("solaris")) { + return true; + } + return false; + } + +}