Skip to content

Commit 66e2d4a

Browse files
committed
2 parents d4113aa + 7604483 commit 66e2d4a

11 files changed

Lines changed: 64 additions & 46 deletions

build.gradle

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ dependencies {
4343
api 'org.ros.rosjava_messages:std_msgs:0.5.13'
4444

4545

46-
implementation 'com.google.guava:guava:33.0.0-jre'
46+
implementation 'com.google.guava:guava:33.5.0-jre'
4747
compileOnly 'org.slf4j:slf4j-api:1.7.30'
4848

4949
runtimeOnly 'org.apache.logging.log4j:log4j-slf4j-impl:2.20.0'
@@ -52,7 +52,8 @@ dependencies {
5252
implementation 'org.apache.commons:commons-configuration2:2.14.0'
5353

5454

55-
testImplementation 'junit:junit:4.13.2'
55+
testImplementation 'org.junit.jupiter:junit-jupiter:6.0.3'
56+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
5657
testImplementation 'org.ros.rosjava_messages:actionlib_tutorials:0.1.10'
5758
testImplementation 'org.ros.rosjava_messages:turtle_actionlib:0.1.10'
5859
testImplementation 'org.apache.camel:camel-test:3.22.4'
@@ -87,6 +88,10 @@ publishing {
8788
}
8889

8990

91+
test {
92+
useJUnitPlatform()
93+
}
94+
9095

9196
jar {
9297
manifest {

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
import org.apache.commons.lang3.exception.ExceptionUtils;
2424
import org.junit.Assert;
2525
import org.junit.Assume;
26-
import org.junit.Test;
26+
import org.junit.jupiter.api.Assertions;
27+
import org.junit.jupiter.api.Assumptions;
28+
import org.junit.jupiter.api.Test;
2729
import org.ros.namespace.GraphName;
2830
import org.ros.node.AbstractNodeMain;
2931
import org.ros.node.ConnectedNode;
@@ -82,7 +84,7 @@ public final void testAbandonedFutureCanBeGarbageCollectedAndUnregistered() {
8284
void beforeCustom(final RosExecutor rosExecutor, final Optional<String> rosMasterUri) {
8385
try {
8486
Assume.assumeNotNull(rosExecutor);
85-
Assume.assumeTrue(rosMasterUri.isPresent());
87+
Assumptions.assumeTrue(rosMasterUri.isPresent());
8688

8789
this.neverCompletingActionLibServer = new NeverCompletingActionLibServer();
8890
this.futureBasedClientNode = new FutureBasedClientNode();

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
*/
1616
package com.github.rosjava_actionlib;
1717

18-
import org.junit.Assert;
19-
import org.junit.Test;
18+
import org.junit.jupiter.api.Assertions;
19+
import org.junit.jupiter.api.Test;
2020

2121
public class ActionLibMessagesUtilsTest {
2222

@@ -48,7 +48,7 @@ public final void getterLookupReturnsSubmessage() {
4848

4949
final String result = ActionLibMessagesUtils.getSubMessageFromMessage(message, "getName");
5050

51-
Assert.assertEquals("goal", result);
51+
Assertions.assertEquals("goal", result);
5252
}
5353

5454
@Test
@@ -57,7 +57,7 @@ public final void setterLookupHandlesReferenceTypes() {
5757

5858
ActionLibMessagesUtils.setSubMessageFromMessage(message, "result", "setName");
5959

60-
Assert.assertEquals("result", message.getName());
60+
Assertions.assertEquals("result", message.getName());
6161
}
6262

6363
@Test
@@ -66,6 +66,6 @@ public final void setterLookupHandlesPrimitiveParameters() {
6666

6767
ActionLibMessagesUtils.setSubMessageFromMessage(message, Integer.valueOf(7), "setCount");
6868

69-
Assert.assertEquals(7, message.getCount());
69+
Assertions.assertEquals(7, message.getCount());
7070
}
7171
}

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
import org.apache.commons.lang3.exception.ExceptionUtils;
2525
import org.junit.Assert;
2626
import org.junit.Assume;
27-
import org.junit.Test;
27+
import org.junit.jupiter.api.Assertions;
28+
import org.junit.jupiter.api.Assumptions;
29+
import org.junit.jupiter.api.Test;
2830

2931
import java.util.Arrays;
3032
import java.util.Optional;
@@ -79,7 +81,7 @@ public final void resultUsesTrackedTerminalStatusWhenServerDoesNotPopulateItExpl
7981
final void beforeCustom(final RosExecutor rosExecutor, final Optional<String> rosMasterUri) {
8082
try {
8183
Assume.assumeNotNull(rosExecutor);
82-
Assume.assumeTrue(rosMasterUri.isPresent());
84+
Assumptions.assumeTrue(rosMasterUri.isPresent());
8385
final Stopwatch stopwatch = Stopwatch.createStarted();
8486
this.fibonacciActionLibServer = new FibonacciActionLibServer(false);
8587
this.futureBasedClientNode = new FutureBasedClientNode();
@@ -90,9 +92,9 @@ final void beforeCustom(final RosExecutor rosExecutor, final Optional<String> ro
9092

9193
rosExecutor.startNodeMain(this.futureBasedClientNode, this.futureBasedClientNode.getDefaultNodeName().toString(), rosMasterUri.get());
9294
final boolean clientStarted = this.futureBasedClientNode.waitForClientStartAndServerConnection(TIMEOUT - stopwatch.elapsed(TIME_UNIT), TIME_UNIT);
93-
Assume.assumeTrue("Client started. " + "Elapsed Time:" + stopwatch.elapsed(TIME_UNIT) + " timeout:" + TIMEOUT + " " + TIME_UNIT, clientStarted);
95+
Assumptions.assumeTrue(clientStarted,()->"Client started. " + "Elapsed Time:" + stopwatch.elapsed(TIME_UNIT) + " timeout:" + TIMEOUT + " " + TIME_UNIT);
9496
} catch (final Exception exception) {
95-
Assume.assumeNoException(exception);
97+
Assumptions.assumeTrue(false,ExceptionUtils.getStackTrace(exception));
9698
}
9799
}
98100

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
import org.apache.commons.lang3.exception.ExceptionUtils;
2424
import org.junit.Assert;
2525
import org.junit.Assume;
26-
import org.junit.Test;
26+
import org.junit.jupiter.api.Assertions;
27+
import org.junit.jupiter.api.Assumptions;
28+
import org.junit.jupiter.api.Test;
2729

2830
import java.lang.reflect.Field;
2931
import java.util.Map;
@@ -65,7 +67,7 @@ public final void terminalGoalsRemainTrackedUntilRetentionTimeoutExpires() {
6567
final void beforeCustom(final RosExecutor rosExecutor, final Optional<String> rosMasterUri) {
6668
try {
6769
Assume.assumeNotNull(rosExecutor);
68-
Assume.assumeTrue(rosMasterUri.isPresent());
70+
Assumptions.assumeTrue(rosMasterUri.isPresent());
6971
final Stopwatch stopwatch = Stopwatch.createStarted();
7072
this.fibonacciActionLibServer = new FibonacciActionLibServer(true, TERMINAL_STATUS_RETENTION_MILLIS, TimeUnit.MILLISECONDS);
7173
this.futureBasedClientNode = new FutureBasedClientNode();
@@ -76,9 +78,9 @@ final void beforeCustom(final RosExecutor rosExecutor, final Optional<String> ro
7678

7779
rosExecutor.startNodeMain(this.futureBasedClientNode, this.futureBasedClientNode.getDefaultNodeName().toString(), rosMasterUri.get());
7880
final boolean clientStarted = this.futureBasedClientNode.waitForClientStartAndServerConnection(TIMEOUT - stopwatch.elapsed(TIME_UNIT), TIME_UNIT);
79-
Assume.assumeTrue("Client started. " + "Elapsed Time:" + stopwatch.elapsed(TIME_UNIT) + " timeout:" + TIMEOUT + " " + TIME_UNIT, clientStarted);
81+
Assumptions.assumeTrue(clientStarted,()->"Client started. " + "Elapsed Time:" + stopwatch.elapsed(TIME_UNIT) + " timeout:" + TIMEOUT + " " + TIME_UNIT);
8082
} catch (final Exception exception) {
81-
Assume.assumeNoException(exception);
83+
Assumptions.assumeTrue(false, () -> ExceptionUtils.getStackTrace(exception));
8284
}
8385
}
8486

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
import actionlib_tutorials.FibonacciActionGoal;
2323
import actionlib_tutorials.FibonacciActionResult;
2424
import org.junit.Assert;
25-
import org.junit.Test;
25+
import org.junit.jupiter.api.Assertions;
26+
import org.junit.jupiter.api.Test;
2627
import org.ros.internal.message.DefaultMessageFactory;
2728
import org.ros.internal.message.Message;
2829
import org.ros.internal.message.definition.MessageDefinitionReflectionProvider;

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
import eu.test.utils.TestProperties;
2020
import org.apache.camel.test.AvailablePortFinder;
2121
import org.apache.commons.lang3.exception.ExceptionUtils;
22-
import org.junit.After;
23-
import org.junit.Assume;
24-
import org.junit.Before;
22+
import org.junit.jupiter.api.AfterEach;
23+
import org.junit.jupiter.api.Assumptions;
24+
import org.junit.jupiter.api.BeforeEach;
2525
import org.ros.RosCore;
2626
import org.slf4j.Logger;
2727
import org.slf4j.LoggerFactory;
@@ -68,10 +68,10 @@ final Optional<String> getRosMasterUri() {
6868
}
6969
}
7070

71-
@Before
72-
public void before() {
71+
@BeforeEach
72+
public void beforeEach() {
7373
try {
74-
if(!testProperties.useExternalRosMaster()) {
74+
if (!testProperties.useExternalRosMaster()) {
7575
this.rosMasterUriPort = AvailablePortFinder.getNextAvailable();
7676
this.rosExecutor = new RosExecutor(ROS_HOST_IP);
7777
this.rosCore = RosCore.newPrivate(rosMasterUriPort);
@@ -80,19 +80,19 @@ public void before() {
8080
}
8181
final Optional<String> rosMasterUri = this.getRosMasterUri();
8282
if (LOGGER.isTraceEnabled()) {
83-
LOGGER.trace("ROS Host IP:" + ROS_HOST_IP + " Current Ros Master Port:" + this.rosMasterUriPort);
83+
LOGGER.trace("ROS Host IP:{} Current Ros Master Port:{}", ROS_HOST_IP, this.rosMasterUriPort);
8484
}
85-
Assume.assumeTrue("Could not get rosMasterUri." + "ROS Host IP:" + ROS_HOST_IP + " Current Ros Master Port:" + this.rosMasterUriPort, rosMasterUri.isPresent());
85+
Assumptions.assumeTrue(rosMasterUri.isPresent(), ()->"Could not get rosMasterUri." + "ROS Host IP:" + ROS_HOST_IP + " Current Ros Master Port:" + this.rosMasterUriPort);
8686
this.beforeCustom(this.rosExecutor, this.getRosMasterUri());
8787
} catch (final Exception er3) {
88-
Assume.assumeNoException("ROS Host IP:" + ROS_HOST_IP + " Current Ros Master Port:" + this.rosMasterUriPort + "\nException:" + ExceptionUtils.getStackTrace(er3), er3);
88+
Assumptions.assumeTrue(false, ()->"ROS Host IP:" + ROS_HOST_IP + " Current Ros Master Port:" + this.rosMasterUriPort + "\nException:" + ExceptionUtils.getStackTrace(er3));
8989
}
9090

9191
}
9292

9393

94-
@After
95-
public void after() {
94+
@AfterEach
95+
public void afterEach() {
9696
try {
9797
this.afterCustom(this.rosExecutor);
9898
} catch (final Exception e) {

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import eu.test.utils.TestProperties;
2424
import org.apache.commons.lang3.exception.ExceptionUtils;
2525
import org.junit.*;
26+
import org.junit.jupiter.api.Assumptions;
2627
import org.ros.RosCore;
2728
import org.slf4j.Logger;
2829
import org.slf4j.LoggerFactory;
@@ -66,12 +67,12 @@ public final void before() {
6667
this.rosExecutor.startNodeMain(asyncGoalRunnerActionLibServer, asyncGoalRunnerActionLibServer.getDefaultNodeName().toString(), ROS_MASTER_URI);
6768
this.rosExecutor.startNodeMain(actionLibClientFeedbackListenerNode, actionLibClientFeedbackListenerNode.getDefaultNodeName().toString(), ROS_MASTER_URI);
6869
final boolean serverStarted = this.asyncGoalRunnerActionLibServer.waitForStart(10000, TimeUnit.SECONDS);
69-
Assume.assumeTrue("Could not connect", serverStarted);
70+
Assumptions.assumeTrue( serverStarted,"Could not connect");
7071
final boolean clientStarted = this.actionLibClientFeedbackListenerNode.waitForStartAndConnection(10000, TimeUnit.SECONDS);
71-
Assume.assumeTrue("Could not connect", clientStarted);
72+
Assumptions.assumeTrue( serverStarted,"Could not connect");
7273
} catch (final Exception er3) {
7374
LOGGER.error(ExceptionUtils.getStackTrace(er3));
74-
Assume.assumeNoException(er3);
75+
Assumptions.assumeTrue(false,()->ExceptionUtils.getStackTrace(er3));
7576
}
7677

7778
}

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@
1616
*/
1717
package com.github.rosjava_actionlib;
1818

19-
import org.junit.Before;
20-
import org.junit.Test;
19+
import org.junit.jupiter.api.BeforeEach;
20+
import org.junit.jupiter.api.Test;
2121

2222
import java.util.Arrays;
2323
import java.util.LinkedList;
2424
import java.util.List;
2525

2626
import static org.junit.Assert.*;
27+
import static org.junit.jupiter.api.Assertions.assertNotEquals;
28+
2729

2830
/**
2931
* Tests state machine
@@ -32,8 +34,8 @@ public class ClientStateMachineTest {
3234
private ClientStateMachine clientStateMachine;
3335
private static final ClientState INITIAL_CLIENT_STATE=ClientState.NO_GOAL;
3436
// Executes before each test.
35-
@Before
36-
public void setUp() {
37+
@BeforeEach
38+
public void beforeEach() {
3739
clientStateMachine = new ClientStateMachine(ClientState.NO_GOAL);
3840
}
3941

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
import org.apache.commons.lang3.exception.ExceptionUtils;
2727
import org.junit.Assert;
2828
import org.junit.Assume;
29-
import org.junit.Test;
29+
import org.junit.jupiter.api.Assertions;
30+
import org.junit.jupiter.api.Assumptions;
31+
import org.junit.jupiter.api.Test;
3032
import org.ros.internal.message.Message;
3133
import org.ros.message.Time;
3234
import org.ros.node.ConnectedNode;
@@ -409,7 +411,7 @@ public final void testResultForDifferentGoalIsIgnoredBeforeAnyGoalIsSent() {
409411
final void beforeCustom(final RosExecutor rosExecutor, final Optional<String> rosMasterUri) {
410412
try {
411413
Assume.assumeNotNull(rosExecutor);
412-
Assume.assumeTrue(rosMasterUri.isPresent());
414+
Assumptions.assumeTrue(rosMasterUri.isPresent());
413415
final Stopwatch stopwatch = Stopwatch.createStarted();
414416
this.fibonacciActionLibServer = new FibonacciActionLibServer();
415417
this.futureBasedClientNode = new FutureBasedClientNode();
@@ -420,7 +422,7 @@ final void beforeCustom(final RosExecutor rosExecutor, final Optional<String> ro
420422

421423
rosExecutor.startNodeMain(this.futureBasedClientNode, this.futureBasedClientNode.getDefaultNodeName().toString(), rosMasterUri.get());
422424
final boolean clientStarted = this.futureBasedClientNode.waitForClientStartAndServerConnection(TIMEOUT - stopwatch.elapsed(TIME_UNIT), TIME_UNIT);
423-
Assume.assumeTrue("Client started. " + "Elapsed Time:" + stopwatch.elapsed(TIME_UNIT) + " timeout:" + TIMEOUT+" "+TIME_UNIT, clientStarted);
425+
Assumptions.assumeTrue(clientStarted,()->"Client started. " + "Elapsed Time:" + stopwatch.elapsed(TIME_UNIT) + " timeout:" + TIMEOUT+" "+TIME_UNIT);
424426
} catch (final Exception exception) {
425427
Assume.assumeNoException(exception);
426428
}

0 commit comments

Comments
 (0)