diff --git a/testsuite/pom.xml b/testsuite/pom.xml
index 207272749b..4b47d0e1a5 100644
--- a/testsuite/pom.xml
+++ b/testsuite/pom.xml
@@ -32,27 +32,22 @@
junit
junit
- compile
org.easymock
easymock
- compile
org.easymock
easymockclassextension
- compile
org.jmock
jmock-junit4
- compile
ch.qos.logback
logback-classic
- compile
${project.groupId}
@@ -79,10 +74,16 @@
- maven-deploy-plugin
-
- true
-
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 2.4
+
+
+
+ test-jar
+
+
+
diff --git a/testsuite/src/test/java/io/netty/testsuite/transport/AbstractComboTestsuiteTest.java b/testsuite/src/test/java/io/netty/testsuite/transport/AbstractComboTestsuiteTest.java
new file mode 100644
index 0000000000..938c6388f7
--- /dev/null
+++ b/testsuite/src/test/java/io/netty/testsuite/transport/AbstractComboTestsuiteTest.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2014 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.transport;
+
+import io.netty.bootstrap.AbstractBootstrap;
+import io.netty.buffer.ByteBufAllocator;
+import io.netty.testsuite.util.TestUtils;
+import io.netty.util.internal.StringUtil;
+import io.netty.util.internal.logging.InternalLogger;
+import io.netty.util.internal.logging.InternalLoggerFactory;
+import org.junit.Rule;
+import org.junit.rules.TestName;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.List;
+
+public abstract class AbstractComboTestsuiteTest,
+ CB extends AbstractBootstrap, ?>> {
+ private final Class sbClazz;
+ private final Class cbClazz;
+ protected final InternalLogger logger = InternalLoggerFactory.getInstance(getClass());
+ protected volatile CB cb;
+ protected volatile SB sb;
+
+ protected AbstractComboTestsuiteTest(Class sbClazz, Class cbClazz) {
+ this.sbClazz = sbClazz;
+ this.cbClazz = cbClazz;
+ }
+
+ protected abstract List> newFactories();
+
+ protected List newAllocators() {
+ return TestsuitePermutation.allocator();
+ }
+
+ @Rule
+ public final TestName testName = new TestName();
+
+ protected void run() throws Throwable {
+ List> combos = newFactories();
+ for (ByteBufAllocator allocator: newAllocators()) {
+ int i = 0;
+ for (TestsuitePermutation.BootstrapComboFactory e: combos) {
+ sb = e.newServerInstance();
+ cb = e.newClientInstance();
+ configure(sb, cb, allocator);
+ logger.info(String.format(
+ "Running: %s %d of %d (%s + %s) with %s",
+ testName.getMethodName(), ++ i, combos.size(), sb, cb, StringUtil.simpleClassName(allocator)));
+ try {
+ Method m = getClass().getMethod(
+ TestUtils.testMethodName(testName), sbClazz, cbClazz);
+ m.invoke(this, sb, cb);
+ } catch (InvocationTargetException ex) {
+ throw ex.getCause();
+ }
+ }
+ }
+ }
+
+ protected abstract void configure(SB sb, CB cb, ByteBufAllocator allocator);
+}
diff --git a/testsuite/src/test/java/io/netty/testsuite/transport/AbstractTestsuiteTest.java b/testsuite/src/test/java/io/netty/testsuite/transport/AbstractTestsuiteTest.java
new file mode 100644
index 0000000000..5ec58109df
--- /dev/null
+++ b/testsuite/src/test/java/io/netty/testsuite/transport/AbstractTestsuiteTest.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2014 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.transport;
+
+import io.netty.bootstrap.AbstractBootstrap;
+import io.netty.buffer.ByteBufAllocator;
+import io.netty.testsuite.util.TestUtils;
+import io.netty.util.internal.StringUtil;
+import io.netty.util.internal.logging.InternalLogger;
+import io.netty.util.internal.logging.InternalLoggerFactory;
+import org.junit.Rule;
+import org.junit.rules.TestName;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.List;
+
+public abstract class AbstractTestsuiteTest> {
+ private final Class clazz;
+ protected final InternalLogger logger = InternalLoggerFactory.getInstance(getClass());
+ protected volatile T cb;
+
+ protected AbstractTestsuiteTest(Class clazz) {
+ this.clazz = clazz;
+ }
+
+ protected abstract List> newFactories();
+
+ protected List newAllocators() {
+ return TestsuitePermutation.allocator();
+ }
+
+ @Rule
+ public final TestName testName = new TestName();
+
+ protected void run() throws Throwable {
+ List> combos = newFactories();
+ for (ByteBufAllocator allocator: newAllocators()) {
+ int i = 0;
+ for (TestsuitePermutation.BootstrapFactory e: combos) {
+ cb = e.newInstance();
+ configure(cb, allocator);
+ logger.info(String.format(
+ "Running: %s %d of %d with %s",
+ testName.getMethodName(), ++ i, combos.size(), StringUtil.simpleClassName(allocator)));
+ try {
+ Method m = getClass().getDeclaredMethod(
+ TestUtils.testMethodName(testName), clazz);
+ m.invoke(this, cb);
+ } catch (InvocationTargetException ex) {
+ throw ex.getCause();
+ }
+ }
+ }
+ }
+
+ protected abstract void configure(T bootstrap, ByteBufAllocator allocator);
+}
diff --git a/testsuite/src/test/java/io/netty/testsuite/transport/TestsuitePermutation.java b/testsuite/src/test/java/io/netty/testsuite/transport/TestsuitePermutation.java
new file mode 100644
index 0000000000..ee2cd7166c
--- /dev/null
+++ b/testsuite/src/test/java/io/netty/testsuite/transport/TestsuitePermutation.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2014 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.transport;
+
+import io.netty.bootstrap.AbstractBootstrap;
+import io.netty.buffer.ByteBufAllocator;
+import io.netty.buffer.PooledByteBufAllocator;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public final class TestsuitePermutation {
+
+ public static List allocator() {
+ List allocators = new ArrayList();
+ allocators.add(UnpooledByteBufAllocator.DEFAULT);
+ allocators.add(PooledByteBufAllocator.DEFAULT);
+ return allocators;
+ }
+
+ private TestsuitePermutation() { }
+
+ public interface BootstrapFactory> {
+ CB newInstance();
+ }
+
+ public interface BootstrapComboFactory, CB extends AbstractBootstrap, ?>> {
+ SB newServerInstance();
+ CB newClientInstance();
+ }
+}
diff --git a/testsuite/src/test/java/io/netty/testsuite/transport/sctp/AbstractSctpTest.java b/testsuite/src/test/java/io/netty/testsuite/transport/sctp/AbstractSctpTest.java
index 51a09ef963..71e0aa3bae 100644
--- a/testsuite/src/test/java/io/netty/testsuite/transport/sctp/AbstractSctpTest.java
+++ b/testsuite/src/test/java/io/netty/testsuite/transport/sctp/AbstractSctpTest.java
@@ -19,61 +19,33 @@ import io.netty.bootstrap.Bootstrap;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.buffer.ByteBufAllocator;
import io.netty.channel.ChannelOption;
-import io.netty.testsuite.transport.sctp.SctpTestPermutation.Factory;
+import io.netty.testsuite.transport.AbstractComboTestsuiteTest;
+import io.netty.testsuite.transport.TestsuitePermutation;
import io.netty.testsuite.util.TestUtils;
import io.netty.util.NetUtil;
-import io.netty.util.internal.StringUtil;
-import io.netty.util.internal.logging.InternalLogger;
-import io.netty.util.internal.logging.InternalLoggerFactory;
-import org.junit.Rule;
-import org.junit.rules.TestName;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.net.InetSocketAddress;
import java.util.List;
-import java.util.Map.Entry;
-public abstract class AbstractSctpTest {
-
- private static final List, Factory>> COMBO =
- SctpTestPermutation.sctpChannel();
- private static final List ALLOCATORS = SctpTestPermutation.allocator();
-
- @Rule
- public final TestName testName = new TestName();
-
- protected final InternalLogger logger = InternalLoggerFactory.getInstance(getClass());
-
- protected volatile ServerBootstrap sb;
- protected volatile Bootstrap cb;
+public abstract class AbstractSctpTest extends AbstractComboTestsuiteTest {
protected volatile InetSocketAddress addr;
- protected volatile Factory currentBootstrap;
- protected void run() throws Throwable {
- for (ByteBufAllocator allocator: ALLOCATORS) {
- int i = 0;
- for (Entry, Factory> e: COMBO) {
- currentBootstrap = e.getValue();
- sb = e.getKey().newInstance();
- cb = e.getValue().newInstance();
- addr = new InetSocketAddress(NetUtil.LOCALHOST, TestUtils.getFreePort());
- sb.localAddress(addr);
- sb.option(ChannelOption.ALLOCATOR, allocator);
- sb.childOption(ChannelOption.ALLOCATOR, allocator);
- cb.remoteAddress(addr);
- cb.option(ChannelOption.ALLOCATOR, allocator);
- logger.info(String.format(
- "Running: %s %d of %d (%s + %s) with %s",
- testName.getMethodName(), ++ i, COMBO.size(), sb, cb, StringUtil.simpleClassName(allocator)));
- try {
- Method m = getClass().getDeclaredMethod(
- TestUtils.testMethodName(testName), ServerBootstrap.class, Bootstrap.class);
- m.invoke(this, sb, cb);
- } catch (InvocationTargetException ex) {
- throw ex.getCause();
- }
- }
- }
+ protected AbstractSctpTest() {
+ super(ServerBootstrap.class, Bootstrap.class);
+ }
+
+ @Override
+ protected List> newFactories() {
+ return SctpTestPermutation.sctpChannel();
+ }
+
+ @Override
+ protected void configure(ServerBootstrap serverBootstrap, Bootstrap bootstrap, ByteBufAllocator allocator) {
+ addr = new InetSocketAddress(NetUtil.LOCALHOST, TestUtils.getFreePort());
+ serverBootstrap.localAddress(addr);
+ serverBootstrap.option(ChannelOption.ALLOCATOR, allocator);
+ serverBootstrap.childOption(ChannelOption.ALLOCATOR, allocator);
+ bootstrap.remoteAddress(addr);
+ bootstrap.option(ChannelOption.ALLOCATOR, allocator);
}
}
diff --git a/testsuite/src/test/java/io/netty/testsuite/transport/sctp/SctpTestPermutation.java b/testsuite/src/test/java/io/netty/testsuite/transport/sctp/SctpTestPermutation.java
index 8c2e54f016..bc5ab90dca 100644
--- a/testsuite/src/test/java/io/netty/testsuite/transport/sctp/SctpTestPermutation.java
+++ b/testsuite/src/test/java/io/netty/testsuite/transport/sctp/SctpTestPermutation.java
@@ -17,9 +17,6 @@ package io.netty.testsuite.transport.sctp;
import io.netty.bootstrap.Bootstrap;
import io.netty.bootstrap.ServerBootstrap;
-import io.netty.buffer.ByteBufAllocator;
-import io.netty.buffer.PooledByteBufAllocator;
-import io.netty.buffer.UnpooledByteBufAllocator;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.oio.OioEventLoopGroup;
@@ -28,12 +25,13 @@ import io.netty.channel.sctp.nio.NioSctpServerChannel;
import io.netty.channel.sctp.oio.OioSctpChannel;
import io.netty.channel.sctp.oio.OioSctpServerChannel;
import io.netty.testsuite.util.TestUtils;
+import io.netty.testsuite.transport.TestsuitePermutation.BootstrapComboFactory;
+import io.netty.testsuite.transport.TestsuitePermutation.BootstrapFactory;
import io.netty.util.concurrent.DefaultThreadFactory;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.Map;
public final class SctpTestPermutation {
@@ -48,14 +46,14 @@ public final class SctpTestPermutation {
private static final EventLoopGroup oioWorkerGroup =
new OioEventLoopGroup(Integer.MAX_VALUE, new DefaultThreadFactory("testsuite-sctp-oio-worker", true));
- static List> sctpServerChannel() {
+ static List> sctpServerChannel() {
if (!TestUtils.isSctpSupported()) {
return Collections.emptyList();
}
- List> list = new ArrayList>();
+ List> list = new ArrayList>();
// Make the list of ServerBootstrap factories.
- list.add(new Factory() {
+ list.add(new BootstrapFactory() {
@Override
public ServerBootstrap newInstance() {
return new ServerBootstrap().
@@ -63,7 +61,7 @@ public final class SctpTestPermutation {
channel(NioSctpServerChannel.class);
}
});
- list.add(new Factory() {
+ list.add(new BootstrapFactory() {
@Override
public ServerBootstrap newInstance() {
return new ServerBootstrap().
@@ -75,19 +73,19 @@ public final class SctpTestPermutation {
return list;
}
- static List> sctpClientChannel() {
+ static List> sctpClientChannel() {
if (!TestUtils.isSctpSupported()) {
return Collections.emptyList();
}
- List> list = new ArrayList>();
- list.add(new Factory() {
+ List> list = new ArrayList>();
+ list.add(new BootstrapFactory() {
@Override
public Bootstrap newInstance() {
return new Bootstrap().group(nioWorkerGroup).channel(NioSctpChannel.class);
}
});
- list.add(new Factory() {
+ list.add(new BootstrapFactory() {
@Override
public Bootstrap newInstance() {
return new Bootstrap().group(oioWorkerGroup).channel(OioSctpChannel.class);
@@ -96,35 +94,30 @@ public final class SctpTestPermutation {
return list;
}
- static List, Factory>> sctpChannel() {
- List, Factory>> list =
- new ArrayList, Factory>>();
+ static List> sctpChannel() {
+ List> list =
+ new ArrayList>();
// Make the list of SCTP ServerBootstrap factories.
- List> sbfs = sctpServerChannel();
+ List> sbfs = sctpServerChannel();
// Make the list of SCTP Bootstrap factories.
- List> cbfs = sctpClientChannel();
+ List> cbfs = sctpClientChannel();
// Populate the combinations
- for (Factory sbf: sbfs) {
- for (Factory cbf: cbfs) {
- final Factory sbf0 = sbf;
- final Factory cbf0 = cbf;
- list.add(new Map.Entry, Factory>() {
+ for (BootstrapFactory sbf: sbfs) {
+ for (BootstrapFactory cbf: cbfs) {
+ final BootstrapFactory sbf0 = sbf;
+ final BootstrapFactory cbf0 = cbf;
+ list.add(new BootstrapComboFactory() {
@Override
- public Factory getKey() {
- return sbf0;
+ public ServerBootstrap newServerInstance() {
+ return sbf0.newInstance();
}
@Override
- public Factory getValue() {
- return cbf0;
- }
-
- @Override
- public Factory setValue(Factory value) {
- throw new UnsupportedOperationException();
+ public Bootstrap newClientInstance() {
+ return cbf0.newInstance();
}
});
}
@@ -133,16 +126,5 @@ public final class SctpTestPermutation {
return list;
}
- static List allocator() {
- List allocators = new ArrayList();
- allocators.add(UnpooledByteBufAllocator.DEFAULT);
- allocators.add(PooledByteBufAllocator.DEFAULT);
- return allocators;
- }
-
private SctpTestPermutation() { }
-
- interface Factory {
- T newInstance();
- }
}
diff --git a/testsuite/src/test/java/io/netty/testsuite/transport/socket/AbstractClientSocketTest.java b/testsuite/src/test/java/io/netty/testsuite/transport/socket/AbstractClientSocketTest.java
index 32b311912a..f6fde17047 100644
--- a/testsuite/src/test/java/io/netty/testsuite/transport/socket/AbstractClientSocketTest.java
+++ b/testsuite/src/test/java/io/netty/testsuite/transport/socket/AbstractClientSocketTest.java
@@ -18,51 +18,31 @@ package io.netty.testsuite.transport.socket;
import io.netty.bootstrap.Bootstrap;
import io.netty.buffer.ByteBufAllocator;
import io.netty.channel.ChannelOption;
-import io.netty.testsuite.transport.socket.SocketTestPermutation.Factory;
+import io.netty.testsuite.transport.AbstractTestsuiteTest;
+import io.netty.testsuite.transport.TestsuitePermutation;
import io.netty.testsuite.util.TestUtils;
import io.netty.util.NetUtil;
-import io.netty.util.internal.StringUtil;
-import io.netty.util.internal.logging.InternalLogger;
-import io.netty.util.internal.logging.InternalLoggerFactory;
-import org.junit.Rule;
-import org.junit.rules.TestName;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.net.InetSocketAddress;
import java.util.List;
-public abstract class AbstractClientSocketTest {
+public abstract class AbstractClientSocketTest extends AbstractTestsuiteTest {
- private static final List> COMBO = SocketTestPermutation.clientSocket();
- private static final List ALLOCATORS = SocketTestPermutation.allocator();
-
- @Rule
- public final TestName testName = new TestName();
-
- protected final InternalLogger logger = InternalLoggerFactory.getInstance(getClass());
-
- protected volatile Bootstrap cb;
protected volatile InetSocketAddress addr;
- protected void run() throws Throwable {
- for (ByteBufAllocator allocator: ALLOCATORS) {
- int i = 0;
- for (Factory e: COMBO) {
- cb = e.newInstance();
- addr = new InetSocketAddress(NetUtil.LOCALHOST, TestUtils.getFreePort());
- cb.remoteAddress(addr);
- cb.option(ChannelOption.ALLOCATOR, allocator);
- logger.info(String.format(
- "Running: %s %d of %d with %s",
- testName.getMethodName(), ++ i, COMBO.size(), StringUtil.simpleClassName(allocator)));
- try {
- Method m = getClass().getDeclaredMethod(TestUtils.testMethodName(testName), Bootstrap.class);
- m.invoke(this, cb);
- } catch (InvocationTargetException ex) {
- throw ex.getCause();
- }
- }
- }
+ protected AbstractClientSocketTest() {
+ super(Bootstrap.class);
+ }
+
+ @Override
+ protected List> newFactories() {
+ return SocketTestPermutation.clientSocket();
+ }
+
+ @Override
+ protected void configure(Bootstrap bootstrap, ByteBufAllocator allocator) {
+ addr = new InetSocketAddress(NetUtil.LOCALHOST, TestUtils.getFreePort());
+ bootstrap.remoteAddress(addr);
+ bootstrap.option(ChannelOption.ALLOCATOR, allocator);
}
}
diff --git a/testsuite/src/test/java/io/netty/testsuite/transport/socket/AbstractDatagramTest.java b/testsuite/src/test/java/io/netty/testsuite/transport/socket/AbstractDatagramTest.java
index 7c35b6ba3c..e8b1b9a638 100644
--- a/testsuite/src/test/java/io/netty/testsuite/transport/socket/AbstractDatagramTest.java
+++ b/testsuite/src/test/java/io/netty/testsuite/transport/socket/AbstractDatagramTest.java
@@ -18,57 +18,34 @@ package io.netty.testsuite.transport.socket;
import io.netty.bootstrap.Bootstrap;
import io.netty.buffer.ByteBufAllocator;
import io.netty.channel.ChannelOption;
-import io.netty.testsuite.transport.socket.SocketTestPermutation.Factory;
+import io.netty.testsuite.transport.AbstractComboTestsuiteTest;
+import io.netty.testsuite.transport.TestsuitePermutation;
import io.netty.testsuite.util.TestUtils;
import io.netty.util.NetUtil;
-import io.netty.util.internal.StringUtil;
-import io.netty.util.internal.logging.InternalLogger;
-import io.netty.util.internal.logging.InternalLoggerFactory;
-import org.junit.Rule;
-import org.junit.rules.TestName;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.net.InetSocketAddress;
import java.util.List;
-import java.util.Map.Entry;
-public abstract class AbstractDatagramTest {
+public abstract class AbstractDatagramTest extends AbstractComboTestsuiteTest {
- private static final List, Factory>> COMBO = SocketTestPermutation.datagram();
- private static final List ALLOCATORS = SocketTestPermutation.allocator();
-
- @Rule
- public final TestName testName = new TestName();
-
- protected final InternalLogger logger = InternalLoggerFactory.getInstance(getClass());
-
- protected volatile Bootstrap sb;
- protected volatile Bootstrap cb;
protected volatile InetSocketAddress addr;
- protected void run() throws Throwable {
- for (ByteBufAllocator allocator: ALLOCATORS) {
- int i = 0;
- for (Entry, Factory> e: COMBO) {
- sb = e.getKey().newInstance();
- cb = e.getValue().newInstance();
- addr = new InetSocketAddress(NetUtil.LOCALHOST4, TestUtils.getFreePort());
- sb.localAddress(addr);
- sb.option(ChannelOption.ALLOCATOR, allocator);
- cb.localAddress(0).remoteAddress(addr);
- cb.option(ChannelOption.ALLOCATOR, allocator);
- logger.info(String.format(
- "Running: %s %d of %d (%s + %s) with %s",
- testName.getMethodName(), ++ i, COMBO.size(), sb, cb, StringUtil.simpleClassName(allocator)));
- try {
- Method m = getClass().getDeclaredMethod(
- TestUtils.testMethodName(testName), Bootstrap.class, Bootstrap.class);
- m.invoke(this, sb, cb);
- } catch (InvocationTargetException ex) {
- throw ex.getCause();
- }
- }
- }
+ protected AbstractDatagramTest() {
+ super(Bootstrap.class, Bootstrap.class);
+ }
+
+ @Override
+ protected List> newFactories() {
+ return SocketTestPermutation.datagram();
+ }
+
+ @Override
+ protected void configure(Bootstrap bootstrap, Bootstrap bootstrap2, ByteBufAllocator allocator) {
+ addr = new InetSocketAddress(
+ NetUtil.LOCALHOST4, TestUtils.getFreePort());
+ bootstrap.localAddress(addr);
+ bootstrap.option(ChannelOption.ALLOCATOR, allocator);
+ bootstrap2.localAddress(0).remoteAddress(addr);
+ bootstrap2.option(ChannelOption.ALLOCATOR, allocator);
}
}
diff --git a/testsuite/src/test/java/io/netty/testsuite/transport/socket/AbstractServerSocketTest.java b/testsuite/src/test/java/io/netty/testsuite/transport/socket/AbstractServerSocketTest.java
index 54ca4e0e4b..fb634556de 100644
--- a/testsuite/src/test/java/io/netty/testsuite/transport/socket/AbstractServerSocketTest.java
+++ b/testsuite/src/test/java/io/netty/testsuite/transport/socket/AbstractServerSocketTest.java
@@ -18,53 +18,33 @@ package io.netty.testsuite.transport.socket;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.buffer.ByteBufAllocator;
import io.netty.channel.ChannelOption;
-import io.netty.testsuite.transport.socket.SocketTestPermutation.Factory;
+import io.netty.testsuite.transport.AbstractTestsuiteTest;
+import io.netty.testsuite.transport.TestsuitePermutation;
import io.netty.testsuite.util.TestUtils;
import io.netty.util.NetUtil;
-import io.netty.util.internal.StringUtil;
-import io.netty.util.internal.logging.InternalLogger;
-import io.netty.util.internal.logging.InternalLoggerFactory;
-import org.junit.Rule;
-import org.junit.rules.TestName;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.net.InetSocketAddress;
import java.util.List;
-public abstract class AbstractServerSocketTest {
+public abstract class AbstractServerSocketTest extends AbstractTestsuiteTest {
- private static final List> COMBO = SocketTestPermutation.serverSocket();
- private static final List ALLOCATORS = SocketTestPermutation.allocator();
-
- @Rule
- public final TestName testName = new TestName();
-
- protected final InternalLogger logger = InternalLoggerFactory.getInstance(getClass());
-
- protected volatile ServerBootstrap sb;
protected volatile InetSocketAddress addr;
- protected void run() throws Throwable {
- for (ByteBufAllocator allocator: ALLOCATORS) {
- int i = 0;
- for (Factory e: COMBO) {
- sb = e.newInstance();
- addr = new InetSocketAddress(NetUtil.LOCALHOST, TestUtils.getFreePort());
- sb.localAddress(addr);
- sb.option(ChannelOption.ALLOCATOR, allocator);
- sb.childOption(ChannelOption.ALLOCATOR, allocator);
+ protected AbstractServerSocketTest() {
+ super(ServerBootstrap.class);
+ }
- logger.info(String.format(
- "Running: %s %d of %d (%s) with %s",
- testName.getMethodName(), ++ i, COMBO.size(), sb, StringUtil.simpleClassName(allocator)));
- try {
- Method m = getClass().getDeclaredMethod(TestUtils.testMethodName(testName), ServerBootstrap.class);
- m.invoke(this, sb);
- } catch (InvocationTargetException ex) {
- throw ex.getCause();
- }
- }
- }
+ @Override
+ protected List> newFactories() {
+ return SocketTestPermutation.serverSocket();
+ }
+
+ @Override
+ protected void configure(ServerBootstrap bootstrap, ByteBufAllocator allocator) {
+ addr = new InetSocketAddress(
+ NetUtil.LOCALHOST, TestUtils.getFreePort());
+ bootstrap.localAddress(addr);
+ bootstrap.option(ChannelOption.ALLOCATOR, allocator);
+ bootstrap.childOption(ChannelOption.ALLOCATOR, allocator);
}
}
diff --git a/testsuite/src/test/java/io/netty/testsuite/transport/socket/AbstractSocketTest.java b/testsuite/src/test/java/io/netty/testsuite/transport/socket/AbstractSocketTest.java
index b9883de6eb..10e7321a54 100644
--- a/testsuite/src/test/java/io/netty/testsuite/transport/socket/AbstractSocketTest.java
+++ b/testsuite/src/test/java/io/netty/testsuite/transport/socket/AbstractSocketTest.java
@@ -19,63 +19,35 @@ import io.netty.bootstrap.Bootstrap;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.buffer.ByteBufAllocator;
import io.netty.channel.ChannelOption;
-import io.netty.testsuite.transport.socket.SocketTestPermutation.Factory;
+import io.netty.testsuite.transport.AbstractComboTestsuiteTest;
+import io.netty.testsuite.transport.TestsuitePermutation;
import io.netty.testsuite.util.TestUtils;
import io.netty.util.NetUtil;
-import io.netty.util.internal.StringUtil;
-import io.netty.util.internal.logging.InternalLogger;
-import io.netty.util.internal.logging.InternalLoggerFactory;
-import org.junit.Rule;
-import org.junit.rules.TestName;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.net.InetSocketAddress;
import java.util.List;
-import java.util.Map.Entry;
-public abstract class AbstractSocketTest {
+public abstract class AbstractSocketTest extends AbstractComboTestsuiteTest {
- private static final List, Factory>> COMBO =
- SocketTestPermutation.socket();
-
- private static final List ALLOCATORS = SocketTestPermutation.allocator();
-
- @Rule
- public final TestName testName = new TestName();
-
- protected final InternalLogger logger = InternalLoggerFactory.getInstance(getClass());
-
- protected volatile ServerBootstrap sb;
- protected volatile Bootstrap cb;
protected volatile InetSocketAddress addr;
- protected volatile Factory currentBootstrap;
- protected void run() throws Throwable {
- for (ByteBufAllocator allocator: ALLOCATORS) {
- int i = 0;
- for (Entry, Factory> e: COMBO) {
- currentBootstrap = e.getValue();
- sb = e.getKey().newInstance();
- cb = e.getValue().newInstance();
- addr = new InetSocketAddress(NetUtil.LOCALHOST, TestUtils.getFreePort());
- sb.localAddress(addr);
- sb.option(ChannelOption.ALLOCATOR, allocator);
- sb.childOption(ChannelOption.ALLOCATOR, allocator);
- cb.remoteAddress(addr);
- cb.option(ChannelOption.ALLOCATOR, allocator);
+ protected AbstractSocketTest() {
+ super(ServerBootstrap.class, Bootstrap.class);
+ }
- logger.info(String.format(
- "Running: %s %d of %d (%s + %s) with %s",
- testName.getMethodName(), ++ i, COMBO.size(), sb, cb, StringUtil.simpleClassName(allocator)));
- try {
- Method m = getClass().getDeclaredMethod(
- TestUtils.testMethodName(testName), ServerBootstrap.class, Bootstrap.class);
- m.invoke(this, sb, cb);
- } catch (InvocationTargetException ex) {
- throw ex.getCause();
- }
- }
- }
+ @Override
+ protected List> newFactories() {
+ return SocketTestPermutation.socket();
+ }
+
+ @Override
+ protected void configure(ServerBootstrap bootstrap, Bootstrap bootstrap2, ByteBufAllocator allocator) {
+ addr = new InetSocketAddress(
+ NetUtil.LOCALHOST, TestUtils.getFreePort());
+ bootstrap.localAddress(addr);
+ bootstrap.option(ChannelOption.ALLOCATOR, allocator);
+ bootstrap.childOption(ChannelOption.ALLOCATOR, allocator);
+ bootstrap2.remoteAddress(addr);
+ bootstrap2.option(ChannelOption.ALLOCATOR, allocator);
}
}
diff --git a/testsuite/src/test/java/io/netty/testsuite/transport/socket/SocketTestPermutation.java b/testsuite/src/test/java/io/netty/testsuite/transport/socket/SocketTestPermutation.java
index fff25ea9ea..05dd6d4008 100644
--- a/testsuite/src/test/java/io/netty/testsuite/transport/socket/SocketTestPermutation.java
+++ b/testsuite/src/test/java/io/netty/testsuite/transport/socket/SocketTestPermutation.java
@@ -18,9 +18,6 @@ package io.netty.testsuite.transport.socket;
import io.netty.bootstrap.Bootstrap;
import io.netty.bootstrap.ChannelFactory;
import io.netty.bootstrap.ServerBootstrap;
-import io.netty.buffer.ByteBufAllocator;
-import io.netty.buffer.PooledByteBufAllocator;
-import io.netty.buffer.UnpooledByteBufAllocator;
import io.netty.channel.Channel;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
@@ -32,13 +29,18 @@ import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.channel.socket.oio.OioDatagramChannel;
import io.netty.channel.socket.oio.OioServerSocketChannel;
import io.netty.channel.socket.oio.OioSocketChannel;
+import io.netty.testsuite.transport.TestsuitePermutation.BootstrapComboFactory;
+import io.netty.testsuite.transport.TestsuitePermutation.BootstrapFactory;
import io.netty.util.concurrent.DefaultThreadFactory;
import java.util.ArrayList;
import java.util.List;
-import java.util.Map.Entry;
-final class SocketTestPermutation {
+public final class SocketTestPermutation {
+ private SocketTestPermutation() {
+ // utility
+ }
+
private static final int BOSSES = 2;
private static final int WORKERS = 3;
private static final EventLoopGroup nioBossGroup =
@@ -50,35 +52,30 @@ final class SocketTestPermutation {
private static final EventLoopGroup oioWorkerGroup =
new OioEventLoopGroup(Integer.MAX_VALUE, new DefaultThreadFactory("testsuite-oio-worker", true));
- static List, Factory>> socket() {
- List, Factory>> list =
- new ArrayList, Factory>>();
+ static List> socket() {
+ List> list =
+ new ArrayList>();
// Make the list of ServerBootstrap factories.
- List> sbfs = serverSocket();
+ List> sbfs = serverSocket();
// Make the list of Bootstrap factories.
- List> cbfs = clientSocket();
+ List> cbfs = clientSocket();
// Populate the combinations
- for (Factory sbf: sbfs) {
- for (Factory cbf: cbfs) {
- final Factory sbf0 = sbf;
- final Factory cbf0 = cbf;
- list.add(new Entry, Factory>() {
+ for (BootstrapFactory sbf: sbfs) {
+ for (BootstrapFactory cbf: cbfs) {
+ final BootstrapFactory sbf0 = sbf;
+ final BootstrapFactory cbf0 = cbf;
+ list.add(new BootstrapComboFactory() {
@Override
- public Factory getKey() {
- return sbf0;
+ public ServerBootstrap newServerInstance() {
+ return sbf0.newInstance();
}
@Override
- public Factory getValue() {
- return cbf0;
- }
-
- @Override
- public Factory setValue(Factory value) {
- throw new UnsupportedOperationException();
+ public Bootstrap newClientInstance() {
+ return cbf0.newInstance();
}
});
}
@@ -90,14 +87,14 @@ final class SocketTestPermutation {
return list;
}
- static List, Factory>> datagram() {
- List, Factory>> list =
- new ArrayList, Factory>>();
+ static List> datagram() {
+ List> list =
+ new ArrayList>();
// Make the list of Bootstrap factories.
- List> bfs =
- new ArrayList>();
- bfs.add(new Factory() {
+ List> bfs =
+ new ArrayList>();
+ bfs.add(new BootstrapFactory() {
@Override
public Bootstrap newInstance() {
return new Bootstrap().group(nioWorkerGroup).channelFactory(new ChannelFactory() {
@@ -113,7 +110,7 @@ final class SocketTestPermutation {
});
}
});
- bfs.add(new Factory() {
+ bfs.add(new BootstrapFactory() {
@Override
public Bootstrap newInstance() {
return new Bootstrap().group(oioWorkerGroup).channel(OioDatagramChannel.class);
@@ -121,24 +118,19 @@ final class SocketTestPermutation {
});
// Populate the combinations
- for (Factory sbf: bfs) {
- for (Factory cbf: bfs) {
- final Factory sbf0 = sbf;
- final Factory cbf0 = cbf;
- list.add(new Entry, Factory>() {
+ for (BootstrapFactory sbf: bfs) {
+ for (BootstrapFactory cbf: bfs) {
+ final BootstrapFactory sbf0 = sbf;
+ final BootstrapFactory cbf0 = cbf;
+ list.add(new BootstrapComboFactory() {
@Override
- public Factory getKey() {
- return sbf0;
+ public Bootstrap newServerInstance() {
+ return sbf0.newInstance();
}
@Override
- public Factory getValue() {
- return cbf0;
- }
-
- @Override
- public Factory setValue(Factory value) {
- throw new UnsupportedOperationException();
+ public Bootstrap newClientInstance() {
+ return cbf0.newInstance();
}
});
}
@@ -147,18 +139,18 @@ final class SocketTestPermutation {
return list;
}
- static List> serverSocket() {
- List> list = new ArrayList>();
+ static List> serverSocket() {
+ List> list = new ArrayList>();
// Make the list of ServerBootstrap factories.
- list.add(new Factory() {
+ list.add(new BootstrapFactory() {
@Override
public ServerBootstrap newInstance() {
return new ServerBootstrap().group(nioBossGroup, nioWorkerGroup)
.channel(NioServerSocketChannel.class);
}
});
- list.add(new Factory() {
+ list.add(new BootstrapFactory() {
@Override
public ServerBootstrap newInstance() {
return new ServerBootstrap().group(oioBossGroup, oioWorkerGroup)
@@ -169,15 +161,15 @@ final class SocketTestPermutation {
return list;
}
- static List> clientSocket() {
- List> list = new ArrayList>();
- list.add(new Factory() {
+ static List> clientSocket() {
+ List> list = new ArrayList>();
+ list.add(new BootstrapFactory() {
@Override
public Bootstrap newInstance() {
return new Bootstrap().group(nioWorkerGroup).channel(NioSocketChannel.class);
}
});
- list.add(new Factory() {
+ list.add(new BootstrapFactory() {
@Override
public Bootstrap newInstance() {
return new Bootstrap().group(oioWorkerGroup).channel(OioSocketChannel.class);
@@ -186,16 +178,4 @@ final class SocketTestPermutation {
return list;
}
- static List allocator() {
- List allocators = new ArrayList();
- allocators.add(UnpooledByteBufAllocator.DEFAULT);
- allocators.add(PooledByteBufAllocator.DEFAULT);
- return allocators;
- }
-
- private SocketTestPermutation() { }
-
- interface Factory {
- T newInstance();
- }
}