Skip to content

Commit

Permalink
Move the reusable classes in netty-testsuite to main/java/src and dep…
Browse files Browse the repository at this point in the history
…loy them
  • Loading branch information
trustin committed Jan 9, 2014
1 parent f05a200 commit 2338bc5
Show file tree
Hide file tree
Showing 16 changed files with 124 additions and 34 deletions.
37 changes: 32 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,38 @@
<version>2.2.0</version>
</dependency>

<!-- Common test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>3.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymockclassextension</artifactId>
<version>3.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jmock</groupId>
<artifactId>jmock-junit4</artifactId>
<version>2.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.13</version>
<scope>test</scope>
</dependency>

<!-- Test dependencies for jboss marshalling encoder/decoder -->
<dependency>
<groupId>org.jboss.marshalling</groupId>
Expand Down Expand Up @@ -250,31 +282,26 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>3.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymockclassextension</artifactId>
<version>3.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jmock</groupId>
<artifactId>jmock-junit4</artifactId>
<version>2.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.13</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
37 changes: 28 additions & 9 deletions testsuite/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,31 @@
<name>Netty/Testsuite</name>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymockclassextension</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jmock</groupId>
<artifactId>jmock-junit4</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-sctp</artifactId>
Expand All @@ -45,20 +70,14 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-udt</artifactId>
<version>${project.version}</version>
<groupId>io.netty</groupId>
<artifactId>netty-transport-udt</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<!--
<plugin>
<groupId>me.normanmaurer.maven.autobahntestsuite</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ protected void run() throws Throwable {
currentBootstrap = e.getValue();
sb = e.getKey().newInstance();
cb = e.getValue().newInstance();
addr = new InetSocketAddress(
NetUtil.LOCALHOST, TestUtils.getFreePort());
addr = new InetSocketAddress(NetUtil.LOCALHOST, TestUtils.getFreePort());
sb.localAddress(addr);
sb.option(ChannelOption.ALLOCATOR, allocator);
sb.childOption(ChannelOption.ALLOCATOR, allocator);
Expand All @@ -69,7 +68,7 @@ protected void run() throws Throwable {
testName.getMethodName(), ++ i, COMBO.size(), sb, cb, StringUtil.simpleClassName(allocator)));
try {
Method m = getClass().getDeclaredMethod(
testName.getMethodName(), ServerBootstrap.class, Bootstrap.class);
TestUtils.testMethodName(testName), ServerBootstrap.class, Bootstrap.class);
m.invoke(this, sb, cb);
} catch (InvocationTargetException ex) {
throw ex.getCause();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright 2012 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.
*/

/**
* Reusable classes that help testing the code that uses SCTP transport.
*/
package io.netty.testsuite.transport.sctp;
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ protected void run() throws Throwable {
"Running: %s %d of %d with %s",
testName.getMethodName(), ++ i, COMBO.size(), StringUtil.simpleClassName(allocator)));
try {
Method m = getClass().getDeclaredMethod(
testName.getMethodName(), Bootstrap.class);
Method m = getClass().getDeclaredMethod(TestUtils.testMethodName(testName), Bootstrap.class);
m.invoke(this, cb);
} catch (InvocationTargetException ex) {
throw ex.getCause();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ protected void run() throws Throwable {
for (Entry<Factory<Bootstrap>, Factory<Bootstrap>> e: COMBO) {
sb = e.getKey().newInstance();
cb = e.getValue().newInstance();
addr = new InetSocketAddress(
NetUtil.LOCALHOST4, TestUtils.getFreePort());
addr = new InetSocketAddress(NetUtil.LOCALHOST4, TestUtils.getFreePort());
sb.localAddress(addr);
sb.option(ChannelOption.ALLOCATOR, allocator);
cb.localAddress(0).remoteAddress(addr);
Expand All @@ -64,7 +63,7 @@ protected void run() throws Throwable {
testName.getMethodName(), ++ i, COMBO.size(), sb, cb, StringUtil.simpleClassName(allocator)));
try {
Method m = getClass().getDeclaredMethod(
testName.getMethodName(), Bootstrap.class, Bootstrap.class);
TestUtils.testMethodName(testName), Bootstrap.class, Bootstrap.class);
m.invoke(this, sb, cb);
} catch (InvocationTargetException ex) {
throw ex.getCause();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ protected void run() throws Throwable {
int i = 0;
for (Factory<ServerBootstrap> e: COMBO) {
sb = e.newInstance();
addr = new InetSocketAddress(
NetUtil.LOCALHOST, TestUtils.getFreePort());
addr = new InetSocketAddress(NetUtil.LOCALHOST, TestUtils.getFreePort());
sb.localAddress(addr);
sb.option(ChannelOption.ALLOCATOR, allocator);
sb.childOption(ChannelOption.ALLOCATOR, allocator);
Expand All @@ -60,8 +59,7 @@ protected void run() throws Throwable {
"Running: %s %d of %d (%s) with %s",
testName.getMethodName(), ++ i, COMBO.size(), sb, StringUtil.simpleClassName(allocator)));
try {
Method m = getClass().getDeclaredMethod(
testName.getMethodName(), ServerBootstrap.class);
Method m = getClass().getDeclaredMethod(TestUtils.testMethodName(testName), ServerBootstrap.class);
m.invoke(this, sb);
} catch (InvocationTargetException ex) {
throw ex.getCause();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ protected void run() throws Throwable {
currentBootstrap = e.getValue();
sb = e.getKey().newInstance();
cb = e.getValue().newInstance();
addr = new InetSocketAddress(
NetUtil.LOCALHOST, TestUtils.getFreePort());
addr = new InetSocketAddress(NetUtil.LOCALHOST, TestUtils.getFreePort());
sb.localAddress(addr);
sb.option(ChannelOption.ALLOCATOR, allocator);
sb.childOption(ChannelOption.ALLOCATOR, allocator);
Expand All @@ -70,11 +69,8 @@ protected void run() throws Throwable {
"Running: %s %d of %d (%s + %s) with %s",
testName.getMethodName(), ++ i, COMBO.size(), sb, cb, StringUtil.simpleClassName(allocator)));
try {
String testMethodName = testName.getMethodName();
if (testMethodName.contains("[")) {
testMethodName = testMethodName.substring(0, testMethodName.indexOf('['));
}
Method m = getClass().getDeclaredMethod(testMethodName, ServerBootstrap.class, Bootstrap.class);
Method m = getClass().getDeclaredMethod(
TestUtils.testMethodName(testName), ServerBootstrap.class, Bootstrap.class);
m.invoke(this, sb, cb);
} catch (InvocationTargetException ex) {
throw ex.getCause();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright 2012 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.
*/

/**
* Reusable classes that help testing the code that uses socket and datagram transport.
*/
package io.netty.testsuite.transport.socket;
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
package io.netty.testsuite.util;

import io.netty.util.NetUtil;
import org.junit.rules.TestName;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
Expand Down Expand Up @@ -111,5 +113,16 @@ public static boolean isSctpSupported() {
return false;
}

/**
* Returns the method name of the current test.
*/
public static String testMethodName(TestName testName) {
String testMethodName = testName.getMethodName();
if (testMethodName.contains("[")) {
testMethodName = testMethodName.substring(0, testMethodName.indexOf('['));
}
return testMethodName;
}

private TestUtils() { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
*/

/**
* Util Test suite classes
* Utility classes that help testing a network application.
*/
package io.netty.testsuite.util;

0 comments on commit 2338bc5

Please sign in to comment.