Skip to content

Commit

Permalink
Remove the last references to JUnit 4 (netty#12442)
Browse files Browse the repository at this point in the history
Motivation:
This completes our migration to JUnit 5.

Modification:
Remove all JUnit 4 dependencies.
Replace or remove the last references to JUnit 4 types in the code.
Add a revapi exception because a public TestUtils method was exposing JUnit 4 types and had to be removed.

Result:
No more JUnit 4 in our project.

Fixes netty#10757
  • Loading branch information
chrisvest authored Jun 3, 2022
1 parent 56f7c50 commit c42a207
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,6 @@

<dependencies>
<!-- Testing frameworks and related dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
Expand Down
10 changes: 0 additions & 10 deletions microbench/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,6 @@
<artifactId>junit-jupiter-engine</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
Expand Down
28 changes: 6 additions & 22 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -886,18 +886,6 @@
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-build-common</artifactId>
Expand Down Expand Up @@ -1030,16 +1018,6 @@
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-build-common</artifactId>
Expand Down Expand Up @@ -1148,6 +1126,12 @@
<classQualifiedName>io.netty.util.internal.InternalThreadLocalMap</classQualifiedName>
<justification>Ignore cache padding.</justification>
</item>
<item>
<ignore>true</ignore>
<code>java.method.removed</code>
<old>method java.lang.String io.netty.testsuite.util.TestUtils::testMethodName(org.junit.rules.TestName)</old>
<justification>This should be test-only, and we're removing support for JUnit 4.</justification>
</item>
</differences>
</revapi.differences>
</analysisConfiguration>
Expand Down
8 changes: 0 additions & 8 deletions testsuite-native/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependencies>
<profiles>
<profile>
Expand Down
8 changes: 0 additions & 8 deletions testsuite-shading/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,6 @@
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependencies>
<profiles>
<profile>
Expand Down
10 changes: 0 additions & 10 deletions testsuite/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,6 @@
<artifactId>junit-jupiter-params</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import io.netty.channel.socket.InternetProtocolFamily;
import io.netty.util.internal.PlatformDependent;
import io.netty.util.internal.SuppressJava6Requirement;
import org.junit.AssumptionViolatedException;
import org.junit.jupiter.api.BeforeAll;
import org.opentest4j.TestAbortedException;

import java.io.IOException;
import java.net.StandardProtocolFamily;
Expand All @@ -38,7 +38,7 @@ public static void assumeIpv6Supported() {
Channel channel = SelectorProvider.provider().openDatagramChannel(StandardProtocolFamily.INET6);
channel.close();
} catch (UnsupportedOperationException e) {
throw new AssumptionViolatedException("IPv6 not supported", e);
throw new TestAbortedException("IPv6 not supported", e);
} catch (IOException ignore) {
// Ignore
}
Expand Down
12 changes: 0 additions & 12 deletions testsuite/src/main/java/io/netty/testsuite/util/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
import org.junit.jupiter.api.TestInfo;
import org.junit.rules.TestName;
import org.tukaani.xz.LZMA2Options;
import org.tukaani.xz.XZOutputStream;

Expand Down Expand Up @@ -120,17 +119,6 @@ public String apply(Method method) {
return testMethodName;
}

/**
* 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;
}

public static void dump(String filenamePrefix) throws IOException {

ObjectUtil.checkNotNull(filenamePrefix, "filenamePrefix");
Expand Down
10 changes: 0 additions & 10 deletions transport-native-unix-common-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,5 @@
<artifactId>junit-jupiter-engine</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

import io.netty.channel.unix.Buffer;
import io.netty.channel.unix.Socket;
import org.junit.AssumptionViolatedException;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.opentest4j.TestAbortedException;

import java.io.IOException;
import java.nio.ByteBuffer;
Expand Down Expand Up @@ -127,10 +127,10 @@ public void testRawOpt() throws IOException {
}

protected int level() {
throw new AssumptionViolatedException("Not supported");
throw new TestAbortedException("Not supported");
}

protected int optname() {
throw new AssumptionViolatedException("Not supported");
throw new TestAbortedException("Not supported");
}
}

0 comments on commit c42a207

Please sign in to comment.