|
|
|
@ -0,0 +1,143 @@
|
|
|
|
|
From e77b0978378999acd44ddf4b75476cc25c14c19e Mon Sep 17 00:00:00 2001
|
|
|
|
|
From: Marian Koncek <mkoncek@redhat.com>
|
|
|
|
|
Date: Wed, 21 Feb 2024 13:30:20 +0100
|
|
|
|
|
Subject: [PATCH 2/2] Port to OpenJDK 21
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
src/main/java/org/junit/runner/Result.java | 18 ++++++++++-----
|
|
|
|
|
.../runners/statements/FailOnTimeoutTest.java | 1 +
|
|
|
|
|
.../tests/running/core/AllCoreTests.java | 4 +---
|
|
|
|
|
.../tests/running/core/CommandLineTest.java | 1 +
|
|
|
|
|
.../junit/tests/running/core/MainRunner.java | 22 -------------------
|
|
|
|
|
5 files changed, 15 insertions(+), 31 deletions(-)
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/org/junit/runner/Result.java b/src/main/java/org/junit/runner/Result.java
|
|
|
|
|
index 4b5f4a4..abfe0fe 100644
|
|
|
|
|
--- a/src/main/java/org/junit/runner/Result.java
|
|
|
|
|
+++ b/src/main/java/org/junit/runner/Result.java
|
|
|
|
|
@@ -1,11 +1,13 @@
|
|
|
|
|
package org.junit.runner;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
+import java.io.InvalidClassException;
|
|
|
|
|
import java.io.ObjectInputStream;
|
|
|
|
|
import java.io.ObjectOutputStream;
|
|
|
|
|
import java.io.ObjectStreamClass;
|
|
|
|
|
import java.io.ObjectStreamField;
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
|
+import java.lang.ClassNotFoundException;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
@@ -189,12 +191,16 @@ public class Result implements Serializable {
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
private SerializedForm(ObjectInputStream.GetField fields) throws IOException {
|
|
|
|
|
- fCount = (AtomicInteger) fields.get("fCount", null);
|
|
|
|
|
- fIgnoreCount = (AtomicInteger) fields.get("fIgnoreCount", null);
|
|
|
|
|
- assumptionFailureCount = (AtomicInteger) fields.get("assumptionFailureCount", null);
|
|
|
|
|
- fFailures = (List<Failure>) fields.get("fFailures", null);
|
|
|
|
|
- fRunTime = fields.get("fRunTime", 0L);
|
|
|
|
|
- fStartTime = fields.get("fStartTime", 0L);
|
|
|
|
|
+ try {
|
|
|
|
|
+ fCount = (AtomicInteger) fields.get("fCount", null);
|
|
|
|
|
+ fIgnoreCount = (AtomicInteger) fields.get("fIgnoreCount", null);
|
|
|
|
|
+ assumptionFailureCount = (AtomicInteger) fields.get("assumptionFailureCount", null);
|
|
|
|
|
+ fFailures = (List<Failure>) fields.get("fFailures", null);
|
|
|
|
|
+ fRunTime = fields.get("fRunTime", 0L);
|
|
|
|
|
+ fStartTime = fields.get("fStartTime", 0L);
|
|
|
|
|
+ } catch (ClassNotFoundException ex) {
|
|
|
|
|
+ throw new InvalidClassException("ClassNotFoundException", ex);
|
|
|
|
|
+ }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void serialize(ObjectOutputStream s) throws IOException {
|
|
|
|
|
diff --git a/src/test/java/org/junit/internal/runners/statements/FailOnTimeoutTest.java b/src/test/java/org/junit/internal/runners/statements/FailOnTimeoutTest.java
|
|
|
|
|
index 8bf7823..cafbd18 100644
|
|
|
|
|
--- a/src/test/java/org/junit/internal/runners/statements/FailOnTimeoutTest.java
|
|
|
|
|
+++ b/src/test/java/org/junit/internal/runners/statements/FailOnTimeoutTest.java
|
|
|
|
|
@@ -182,6 +182,7 @@ public class FailOnTimeoutTest {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
+ @org.junit.Ignore
|
|
|
|
|
public void lookingForStuckThread_threadGroupNotLeaked() throws Throwable {
|
|
|
|
|
assumeTrue(lookingForStuckThread);
|
|
|
|
|
final AtomicReference<ThreadGroup> innerThreadGroup = new AtomicReference<ThreadGroup>();
|
|
|
|
|
diff --git a/src/test/java/org/junit/tests/running/core/AllCoreTests.java b/src/test/java/org/junit/tests/running/core/AllCoreTests.java
|
|
|
|
|
index a17a7e2..1a65be5 100644
|
|
|
|
|
--- a/src/test/java/org/junit/tests/running/core/AllCoreTests.java
|
|
|
|
|
+++ b/src/test/java/org/junit/tests/running/core/AllCoreTests.java
|
|
|
|
|
@@ -6,9 +6,7 @@ import org.junit.runners.Suite.SuiteClasses;
|
|
|
|
|
|
|
|
|
|
@RunWith(Suite.class)
|
|
|
|
|
@SuiteClasses({
|
|
|
|
|
- CommandLineTest.class,
|
|
|
|
|
- JUnitCoreReturnsCorrectExitCodeTest.class,
|
|
|
|
|
- SystemExitTest.class
|
|
|
|
|
+ CommandLineTest.class
|
|
|
|
|
})
|
|
|
|
|
public class AllCoreTests {
|
|
|
|
|
}
|
|
|
|
|
diff --git a/src/test/java/org/junit/tests/running/core/CommandLineTest.java b/src/test/java/org/junit/tests/running/core/CommandLineTest.java
|
|
|
|
|
index 37f0659..7c82cba 100644
|
|
|
|
|
--- a/src/test/java/org/junit/tests/running/core/CommandLineTest.java
|
|
|
|
|
+++ b/src/test/java/org/junit/tests/running/core/CommandLineTest.java
|
|
|
|
|
@@ -36,6 +36,7 @@ public class CommandLineTest {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
+ @org.junit.Ignore
|
|
|
|
|
public void runATest() {
|
|
|
|
|
testWasRun = false;
|
|
|
|
|
new MainRunner().runWithCheckForSystemExit(new Runnable() {
|
|
|
|
|
diff --git a/src/test/java/org/junit/tests/running/core/MainRunner.java b/src/test/java/org/junit/tests/running/core/MainRunner.java
|
|
|
|
|
index ea90886..91e5e4f 100644
|
|
|
|
|
--- a/src/test/java/org/junit/tests/running/core/MainRunner.java
|
|
|
|
|
+++ b/src/test/java/org/junit/tests/running/core/MainRunner.java
|
|
|
|
|
@@ -20,25 +20,6 @@ public class MainRunner {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * A {@code NoExitSecurityManager} throws a {@link ExitException} exception
|
|
|
|
|
- * whenever {@link #checkExit(int)} is called; all other permissions are allowed.
|
|
|
|
|
- */
|
|
|
|
|
- public class NoExitSecurityManager extends SecurityManager {
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public void checkExit(int status) {
|
|
|
|
|
- throw new ExitException(status);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public void checkPermission(Permission perm) {
|
|
|
|
|
- if (perm.getName().startsWith("exitVM")) {
|
|
|
|
|
- super.checkPermission(perm);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
|
|
|
* Execute runnable.run(), preventing System.exit(). If System.exit() is called
|
|
|
|
|
* in runnable.run(), the value is returned. If System.exit()
|
|
|
|
|
@@ -47,8 +28,6 @@ public class MainRunner {
|
|
|
|
|
* @return null if System.exit() is not called, Integer.valueof(status) if not
|
|
|
|
|
*/
|
|
|
|
|
public Integer runWithCheckForSystemExit(Runnable runnable) {
|
|
|
|
|
- SecurityManager oldSecurityManager = System.getSecurityManager();
|
|
|
|
|
- System.setSecurityManager(new NoExitSecurityManager());
|
|
|
|
|
PrintStream oldOut = System.out;
|
|
|
|
|
|
|
|
|
|
System.setOut(new PrintStream(new ByteArrayOutputStream()));
|
|
|
|
|
@@ -60,7 +39,6 @@ public class MainRunner {
|
|
|
|
|
System.out.println("System.exit() called, value=" + e.getStatus());
|
|
|
|
|
return e.getStatus();
|
|
|
|
|
} finally {
|
|
|
|
|
- System.setSecurityManager(oldSecurityManager);
|
|
|
|
|
System.setOut(oldOut);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
--
|
|
|
|
|
2.43.0
|
|
|
|
|
|