Use jUnit Assume to "ignore" SCTP tests on non-unix operation systems

This commit is contained in:
norman 2012-04-02 07:34:15 +02:00
parent 7dc2d8eb77
commit 73bdaa113a
13 changed files with 128 additions and 80 deletions

27
pom.xml
View File

@ -335,32 +335,5 @@
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>unix</id>
<activation>
<os>
<family>unix</family>
</os>
</activation>
<properties>
<!--
Note: Java SCTP only available for Linux and Solaris
-->
<sctp.test.skip>false</sctp.test.skip>
</properties>
</profile>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<sctp.test.skip>true</sctp.test.skip>
</properties>
</profile>
</profiles>
</project>

View File

@ -48,18 +48,6 @@
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7.2</version>
<executions>
<execution>
<id>default-test</id>
<configuration>
<skipTests>${sctp.test.skip}}</skipTests>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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 <code>true</code> 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;
}
}