Skip to content

Commit 4200322

Browse files
committed
task: Migrate junit -> 6.0.3
1 parent 66e2d4a commit 4200322

10 files changed

Lines changed: 289 additions & 273 deletions

src/test/java/com/github/rosjava_actionlib/ActionClientFutureLifecycleTest.java

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
import actionlib_tutorials.FibonacciActionResult;
2222
import eu.test.utils.RosExecutor;
2323
import org.apache.commons.lang3.exception.ExceptionUtils;
24-
import org.junit.Assert;
25-
import org.junit.Assume;
2624
import org.junit.jupiter.api.Assertions;
2725
import org.junit.jupiter.api.Assumptions;
2826
import org.junit.jupiter.api.Test;
@@ -64,39 +62,39 @@ public final void testAbandonedFutureCanBeGarbageCollectedAndUnregistered() {
6462
final WeakReference<ActionFuture<FibonacciActionGoal, FibonacciActionFeedback, FibonacciActionResult>> weakReference =
6563
new WeakReference<>(createdFuture);
6664

67-
Assert.assertEquals(initialResultListenerCount + 1, getListenerCount(actionClient, "callbackResultTargets"));
68-
Assert.assertEquals(initialFeedbackListenerCount + 1, getListenerCount(actionClient, "callbackFeedbackTargets"));
65+
Assertions.assertEquals(initialResultListenerCount + 1, getListenerCount(actionClient, "callbackResultTargets"));
66+
Assertions.assertEquals(initialFeedbackListenerCount + 1, getListenerCount(actionClient, "callbackFeedbackTargets"));
6967

7068
createdFuture = null;
7169
waitForGarbageCollection(weakReference);
7270

73-
Assert.assertNull("The future should be garbage collectable after user code drops it", weakReference.get());
74-
Assert.assertEquals("Result listener registrations should be removed when the future is abandoned",
75-
initialResultListenerCount, getListenerCount(actionClient, "callbackResultTargets"));
76-
Assert.assertEquals("Feedback listener registrations should be removed when the future is abandoned",
77-
initialFeedbackListenerCount, getListenerCount(actionClient, "callbackFeedbackTargets"));
71+
Assertions.assertNull(weakReference.get(), "The future should be garbage collectable after user code drops it");
72+
Assertions.assertEquals(initialResultListenerCount, getListenerCount(actionClient, "callbackResultTargets"),
73+
"Result listener registrations should be removed when the future is abandoned");
74+
Assertions.assertEquals(initialFeedbackListenerCount, getListenerCount(actionClient, "callbackFeedbackTargets"),
75+
"Feedback listener registrations should be removed when the future is abandoned");
7876
} catch (final Exception exception) {
79-
Assert.fail(ExceptionUtils.getStackTrace(exception));
77+
Assertions.fail(ExceptionUtils.getStackTrace(exception));
8078
}
8179
}
8280

8381
@Override
8482
void beforeCustom(final RosExecutor rosExecutor, final Optional<String> rosMasterUri) {
8583
try {
86-
Assume.assumeNotNull(rosExecutor);
84+
Assumptions.assumeTrue(rosExecutor != null);
8785
Assumptions.assumeTrue(rosMasterUri.isPresent());
8886

8987
this.neverCompletingActionLibServer = new NeverCompletingActionLibServer();
9088
this.futureBasedClientNode = new FutureBasedClientNode();
9189

9290
rosExecutor.startNodeMain(this.neverCompletingActionLibServer, this.neverCompletingActionLibServer.getDefaultNodeName().toString(), rosMasterUri.get());
93-
Assert.assertTrue("Server could not connect", this.neverCompletingActionLibServer.waitForStart(TIMEOUT, TIME_UNIT));
91+
Assertions.assertTrue(this.neverCompletingActionLibServer.waitForStart(TIMEOUT, TIME_UNIT), "Server could not connect");
9492

9593
rosExecutor.startNodeMain(this.futureBasedClientNode, this.futureBasedClientNode.getDefaultNodeName().toString(), rosMasterUri.get());
9694
final boolean clientStarted = this.futureBasedClientNode.waitForClientStartAndServerConnection(TIMEOUT, TIME_UNIT);
97-
Assume.assumeTrue("Client could not connect", clientStarted);
95+
Assumptions.assumeTrue(clientStarted, "Client could not connect");
9896
} catch (final Exception exception) {
99-
Assume.assumeNoException(exception);
97+
Assumptions.assumeTrue(false, ExceptionUtils.getStackTrace(exception));
10098
}
10199
}
102100

@@ -168,4 +166,4 @@ public boolean waitForStart(final long timeout, final TimeUnit timeUnit) throws
168166
return this.startCountDownLatch.await(timeout, timeUnit);
169167
}
170168
}
171-
}
169+
}

src/test/java/com/github/rosjava_actionlib/ActionServerResultStatusCompatibilityTest.java

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
import com.google.common.base.Stopwatch;
2323
import eu.test.utils.RosExecutor;
2424
import org.apache.commons.lang3.exception.ExceptionUtils;
25-
import org.junit.Assert;
26-
import org.junit.Assume;
2725
import org.junit.jupiter.api.Assertions;
2826
import org.junit.jupiter.api.Assumptions;
2927
import org.junit.jupiter.api.Test;
@@ -59,42 +57,42 @@ public final void resultUsesTrackedTerminalStatusWhenServerDoesNotPopulateItExpl
5957

6058
try {
6159
final boolean serverStarted = this.futureBasedClientNode.waitForClientStartAndServerConnection(TIMEOUT, TIME_UNIT);
62-
Assert.assertTrue("Was not connected. Elapsed Time:" + stopwatch.elapsed(TIME_UNIT) + " timeout:" + TIMEOUT, serverStarted);
60+
Assertions.assertTrue(serverStarted, "Was not connected. Elapsed Time:" + stopwatch.elapsed(TIME_UNIT) + " timeout:" + TIMEOUT);
6361

6462
final ActionFuture<FibonacciActionGoal, FibonacciActionFeedback, FibonacciActionResult> resultFuture =
6563
this.futureBasedClientNode.invoke(TestInputs.TEST_INPUT);
6664

6765
final FibonacciActionResult result = resultFuture.get(TIMEOUT - stopwatch.elapsed(TIME_UNIT), TIME_UNIT);
68-
Assert.assertNotNull("Null Result", result);
69-
Assert.assertTrue("Result was wrong", Arrays.equals(result.getResult().getSequence(), TestInputs.TEST_CORRECT_OUTPUT));
70-
Assert.assertEquals("Result should inherit tracked SUCCEEDED status", GoalStatus.SUCCEEDED, result.getStatus().getStatus());
66+
Assertions.assertNotNull(result, "Null Result");
67+
Assertions.assertTrue(Arrays.equals(result.getResult().getSequence(), TestInputs.TEST_CORRECT_OUTPUT), "Result was wrong");
68+
Assertions.assertEquals(GoalStatus.SUCCEEDED, result.getStatus().getStatus(), "Result should inherit tracked SUCCEEDED status");
7169

7270
final boolean statusReceived = terminalStatusReceived.await(TIMEOUT - stopwatch.elapsed(TIME_UNIT), TIME_UNIT);
73-
Assert.assertTrue("Expected a terminal /status publication after the result", statusReceived);
74-
Assert.assertEquals("Expected SUCCEEDED terminal status", Byte.valueOf(GoalStatus.SUCCEEDED), terminalStatus.get());
71+
Assertions.assertTrue(statusReceived, "Expected a terminal /status publication after the result");
72+
Assertions.assertEquals(Byte.valueOf(GoalStatus.SUCCEEDED), terminalStatus.get(), "Expected SUCCEEDED terminal status");
7573
} catch (final Exception exception) {
76-
Assert.fail(ExceptionUtils.getStackTrace(exception));
74+
Assertions.fail(ExceptionUtils.getStackTrace(exception));
7775
}
7876
}
7977

8078
@Override
8179
final void beforeCustom(final RosExecutor rosExecutor, final Optional<String> rosMasterUri) {
8280
try {
83-
Assume.assumeNotNull(rosExecutor);
81+
Assumptions.assumeTrue(rosExecutor != null);
8482
Assumptions.assumeTrue(rosMasterUri.isPresent());
8583
final Stopwatch stopwatch = Stopwatch.createStarted();
8684
this.fibonacciActionLibServer = new FibonacciActionLibServer(false);
8785
this.futureBasedClientNode = new FutureBasedClientNode();
8886

8987
rosExecutor.startNodeMain(this.fibonacciActionLibServer, this.fibonacciActionLibServer.getDefaultNodeName().toString(), rosMasterUri.get());
9088
final boolean serverStarted = this.fibonacciActionLibServer.waitForStart(TIMEOUT - stopwatch.elapsed(TIME_UNIT), TIME_UNIT);
91-
Assert.assertTrue("Server Could not connect", serverStarted);
89+
Assertions.assertTrue(serverStarted, "Server Could not connect");
9290

9391
rosExecutor.startNodeMain(this.futureBasedClientNode, this.futureBasedClientNode.getDefaultNodeName().toString(), rosMasterUri.get());
9492
final boolean clientStarted = this.futureBasedClientNode.waitForClientStartAndServerConnection(TIMEOUT - stopwatch.elapsed(TIME_UNIT), TIME_UNIT);
95-
Assumptions.assumeTrue(clientStarted,()->"Client started. " + "Elapsed Time:" + stopwatch.elapsed(TIME_UNIT) + " timeout:" + TIMEOUT + " " + TIME_UNIT);
93+
Assumptions.assumeTrue(clientStarted, () -> "Client started. " + "Elapsed Time:" + stopwatch.elapsed(TIME_UNIT) + " timeout:" + TIMEOUT + " " + TIME_UNIT);
9694
} catch (final Exception exception) {
97-
Assumptions.assumeTrue(false,ExceptionUtils.getStackTrace(exception));
95+
Assumptions.assumeTrue(false, ExceptionUtils.getStackTrace(exception));
9896
}
9997
}
10098

@@ -111,4 +109,4 @@ final void afterCustom(final RosExecutor rosExecutor) {
111109
this.futureBasedClientNode = null;
112110
this.fibonacciActionLibServer = null;
113111
}
114-
}
112+
}

src/test/java/com/github/rosjava_actionlib/ActionServerTerminalStatusRetentionTest.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
import com.google.common.base.Stopwatch;
2222
import eu.test.utils.RosExecutor;
2323
import org.apache.commons.lang3.exception.ExceptionUtils;
24-
import org.junit.Assert;
25-
import org.junit.Assume;
2624
import org.junit.jupiter.api.Assertions;
2725
import org.junit.jupiter.api.Assumptions;
2826
import org.junit.jupiter.api.Test;
@@ -45,40 +43,40 @@ public final void terminalGoalsRemainTrackedUntilRetentionTimeoutExpires() {
4543
final Stopwatch stopwatch = Stopwatch.createStarted();
4644
try {
4745
final boolean serverStarted = this.futureBasedClientNode.waitForClientStartAndServerConnection(TIMEOUT, TIME_UNIT);
48-
Assert.assertTrue("Was not connected. Elapsed Time:" + stopwatch.elapsed(TIME_UNIT) + " timeout:" + TIMEOUT, serverStarted);
46+
Assertions.assertTrue(serverStarted, "Was not connected. Elapsed Time:" + stopwatch.elapsed(TIME_UNIT) + " timeout:" + TIMEOUT);
4947

5048
final ActionFuture<FibonacciActionGoal, FibonacciActionFeedback, FibonacciActionResult> resultFuture =
5149
this.futureBasedClientNode.invoke(TestInputs.TEST_INPUT);
5250

5351
final FibonacciActionResult result = resultFuture.get(TIMEOUT - stopwatch.elapsed(TIME_UNIT), TIME_UNIT);
54-
Assert.assertNotNull("Null Result", result);
52+
Assertions.assertNotNull(result, "Null Result");
5553
final String goalId = result.getStatus().getGoalId().getId();
5654
final Map<?, ?> trackedGoals = this.getTrackedGoalsMap();
5755

58-
Assert.assertTrue("Terminal goal should remain tracked for additional status heartbeats", trackedGoals.containsKey(goalId));
56+
Assertions.assertTrue(trackedGoals.containsKey(goalId), "Terminal goal should remain tracked for additional status heartbeats");
5957
this.waitUntil(() -> !trackedGoals.containsKey(goalId), TERMINAL_STATUS_RETENTION_MILLIS + 2000);
60-
Assert.assertFalse("Terminal goal should be evicted after the retention timeout", trackedGoals.containsKey(goalId));
58+
Assertions.assertFalse(trackedGoals.containsKey(goalId), "Terminal goal should be evicted after the retention timeout");
6159
} catch (final Exception exception) {
62-
Assert.fail(ExceptionUtils.getStackTrace(exception));
60+
Assertions.fail(ExceptionUtils.getStackTrace(exception));
6361
}
6462
}
6563

6664
@Override
6765
final void beforeCustom(final RosExecutor rosExecutor, final Optional<String> rosMasterUri) {
6866
try {
69-
Assume.assumeNotNull(rosExecutor);
67+
Assumptions.assumeTrue(rosExecutor != null);
7068
Assumptions.assumeTrue(rosMasterUri.isPresent());
7169
final Stopwatch stopwatch = Stopwatch.createStarted();
7270
this.fibonacciActionLibServer = new FibonacciActionLibServer(true, TERMINAL_STATUS_RETENTION_MILLIS, TimeUnit.MILLISECONDS);
7371
this.futureBasedClientNode = new FutureBasedClientNode();
7472

7573
rosExecutor.startNodeMain(this.fibonacciActionLibServer, this.fibonacciActionLibServer.getDefaultNodeName().toString(), rosMasterUri.get());
7674
final boolean serverStarted = this.fibonacciActionLibServer.waitForStart(TIMEOUT - stopwatch.elapsed(TIME_UNIT), TIME_UNIT);
77-
Assert.assertTrue("Server Could not connect", serverStarted);
75+
Assertions.assertTrue(serverStarted, "Server Could not connect");
7876

7977
rosExecutor.startNodeMain(this.futureBasedClientNode, this.futureBasedClientNode.getDefaultNodeName().toString(), rosMasterUri.get());
8078
final boolean clientStarted = this.futureBasedClientNode.waitForClientStartAndServerConnection(TIMEOUT - stopwatch.elapsed(TIME_UNIT), TIME_UNIT);
81-
Assumptions.assumeTrue(clientStarted,()->"Client started. " + "Elapsed Time:" + stopwatch.elapsed(TIME_UNIT) + " timeout:" + TIMEOUT + " " + TIME_UNIT);
79+
Assumptions.assumeTrue(clientStarted, () -> "Client started. " + "Elapsed Time:" + stopwatch.elapsed(TIME_UNIT) + " timeout:" + TIMEOUT + " " + TIME_UNIT);
8280
} catch (final Exception exception) {
8381
Assumptions.assumeTrue(false, () -> ExceptionUtils.getStackTrace(exception));
8482
}
@@ -123,4 +121,4 @@ private void waitUntil(final CheckedCondition condition, final long timeoutMilli
123121
private interface CheckedCondition {
124122
boolean evaluate() throws Exception;
125123
}
126-
}
124+
}

0 commit comments

Comments
 (0)