Skip to content

Commit bcbecaa

Browse files
author
Vincent Potucek
committed
Migrate to JUnit 5 from JUnit 4
1 parent 6019307 commit bcbecaa

File tree

265 files changed

+1706
-2013
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

265 files changed

+1706
-2013
lines changed

api/maven-api-core/src/test/java/org/apache/maven/api/MonotonicClockTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class MonotonicClockTest {
3737

3838
@Test
3939
@DisplayName("MonotonicClock singleton instance should always return the same instance")
40-
void testSingletonInstance() {
40+
void singletonInstance() {
4141
MonotonicClock clock1 = MonotonicClock.get();
4242
MonotonicClock clock2 = MonotonicClock.get();
4343

@@ -46,7 +46,7 @@ void testSingletonInstance() {
4646

4747
@Test
4848
@DisplayName("MonotonicClock should always use UTC timezone")
49-
void testClockTimezone() {
49+
void clockTimezone() {
5050
MonotonicClock clock = MonotonicClock.get();
5151

5252
assertEquals(ZoneOffset.UTC, clock.getZone(), "Clock should use UTC timezone");
@@ -58,7 +58,7 @@ void testClockTimezone() {
5858

5959
@Test
6060
@DisplayName("MonotonicClock should maintain monotonic time progression")
61-
void testMonotonicBehavior() throws InterruptedException {
61+
void monotonicBehavior() throws InterruptedException {
6262
Instant first = MonotonicClock.now();
6363
Thread.sleep(10); // Small delay
6464
Instant second = MonotonicClock.now();
@@ -71,7 +71,7 @@ void testMonotonicBehavior() throws InterruptedException {
7171

7272
@Test
7373
@DisplayName("MonotonicClock elapsed time should increase")
74-
void testElapsedTime() throws InterruptedException {
74+
void elapsedTime() throws InterruptedException {
7575
Duration initial = MonotonicClock.elapsed();
7676
Thread.sleep(50); // Longer delay for more reliable measurement
7777
Duration later = MonotonicClock.elapsed();
@@ -84,7 +84,7 @@ void testElapsedTime() throws InterruptedException {
8484

8585
@Test
8686
@DisplayName("MonotonicClock start time should remain constant")
87-
void testStartTime() throws InterruptedException {
87+
void startTime() throws InterruptedException {
8888
Instant start1 = MonotonicClock.start();
8989
Thread.sleep(10);
9090
Instant start2 = MonotonicClock.start();
@@ -99,7 +99,7 @@ class TimeConsistencyTests {
9999

100100
@Test
101101
@DisplayName("Current time should be after start time")
102-
void testCurrentTimeAfterStart() {
102+
void currentTimeAfterStart() {
103103
Instant now = MonotonicClock.now();
104104
Instant start = MonotonicClock.start();
105105

@@ -108,7 +108,7 @@ void testCurrentTimeAfterStart() {
108108

109109
@Test
110110
@DisplayName("Elapsed time should match time difference")
111-
void testElapsedTimeConsistency() {
111+
void elapsedTimeConsistency() {
112112
MonotonicClock clock = MonotonicClock.get();
113113
Instant now = clock.instant();
114114
Duration elapsed = clock.elapsedTime();
@@ -123,7 +123,7 @@ void testElapsedTimeConsistency() {
123123

124124
@Test
125125
@DisplayName("MonotonicClock should handle rapid successive calls")
126-
void testRapidCalls() {
126+
void rapidCalls() {
127127
Instant[] instants = new Instant[1000];
128128
for (int i = 0; i < instants.length; i++) {
129129
instants[i] = MonotonicClock.now();
@@ -139,7 +139,7 @@ void testRapidCalls() {
139139

140140
@Test
141141
@DisplayName("MonotonicClock should maintain reasonable alignment with system time")
142-
void testSystemTimeAlignment() {
142+
void systemTimeAlignment() {
143143
Instant monotonic = MonotonicClock.now();
144144
Instant system = Instant.now();
145145

api/maven-api-core/src/test/java/org/apache/maven/api/services/RequestImplementationTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
class RequestImplementationTest {
3636

3737
@Test
38-
void testArtifactResolverRequestEquality() {
38+
void artifactResolverRequestEquality() {
3939
Session session = mock(Session.class);
4040
ArtifactCoordinates coords1 = mock(ArtifactCoordinates.class);
4141
ArtifactCoordinates coords2 = mock(ArtifactCoordinates.class);
@@ -74,7 +74,7 @@ void testArtifactResolverRequestEquality() {
7474
}
7575

7676
@Test
77-
void testRequestTraceIntegration() {
77+
void requestTraceIntegration() {
7878
Session session = mock(Session.class);
7979
RequestTrace trace = new RequestTrace("test-context", null, "test-data");
8080

@@ -86,7 +86,7 @@ void testRequestTraceIntegration() {
8686
}
8787

8888
@Test
89-
void testDependencyResolverRequestEquality() {
89+
void dependencyResolverRequestEquality() {
9090
Session session = mock(Session.class);
9191

9292
DependencyResolverRequest.DependencyResolverRequestBuilder builder = DependencyResolverRequest.builder();

api/maven-api-core/src/test/java/org/apache/maven/api/services/RequestTraceTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
class RequestTraceTest {
2828

2929
@Test
30-
void testRequestTraceCreation() {
30+
void requestTraceCreation() {
3131
RequestTrace parentTrace = new RequestTrace("parent-context", null, "parent-data");
3232
RequestTrace childTrace = new RequestTrace("child-context", parentTrace, "child-data");
3333

@@ -41,7 +41,7 @@ void testRequestTraceCreation() {
4141
}
4242

4343
@Test
44-
void testRequestTraceWithParentContextInheritance() {
44+
void requestTraceWithParentContextInheritance() {
4545
RequestTrace parentTrace = new RequestTrace("parent-context", null, "parent-data");
4646
RequestTrace childTrace = new RequestTrace(parentTrace, "child-data");
4747

@@ -51,22 +51,22 @@ void testRequestTraceWithParentContextInheritance() {
5151
}
5252

5353
@Test
54-
void testPredefinedContexts() {
54+
void predefinedContexts() {
5555
assertEquals("plugin", RequestTrace.CONTEXT_PLUGIN);
5656
assertEquals("project", RequestTrace.CONTEXT_PROJECT);
5757
assertEquals("bootstrap", RequestTrace.CONTEXT_BOOTSTRAP);
5858
}
5959

6060
@Test
61-
void testNullValues() {
61+
void nullValues() {
6262
RequestTrace trace = new RequestTrace(null, null, null);
6363
assertNull(trace.context());
6464
assertNull(trace.parent());
6565
assertNull(trace.data());
6666
}
6767

6868
@Test
69-
void testChainedTraces() {
69+
void chainedTraces() {
7070
RequestTrace root = new RequestTrace("root", null, "root-data");
7171
RequestTrace level1 = new RequestTrace("level1", root, "level1-data");
7272
RequestTrace level2 = new RequestTrace("level2", level1, "level2-data");

api/maven-api-core/src/test/java/org/apache/maven/api/services/SourcesTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class SourcesTest {
4343
Path tempDir;
4444

4545
@Test
46-
void testFromPath() {
46+
void fromPath() {
4747
Path path = Paths.get("/tmp");
4848
Source source = Sources.fromPath(path);
4949

@@ -53,7 +53,7 @@ void testFromPath() {
5353
}
5454

5555
@Test
56-
void testBuildSource() {
56+
void buildSource() {
5757
Path path = Paths.get("/tmp");
5858
ModelSource source = Sources.buildSource(path);
5959

@@ -63,7 +63,7 @@ void testBuildSource() {
6363
}
6464

6565
@Test
66-
void testResolvedSource() {
66+
void resolvedSource() {
6767
Path path = Paths.get("/tmp");
6868
String location = "custom-location";
6969
ModelSource source = Sources.resolvedSource(path, location);
@@ -75,7 +75,7 @@ void testResolvedSource() {
7575
}
7676

7777
@Test
78-
void testPathSourceFunctionality() {
78+
void pathSourceFunctionality() {
7979
// Test basic source functionality
8080
Path path = Paths.get("/tmp");
8181
Sources.PathSource source = (Sources.PathSource) Sources.fromPath(path);
@@ -89,7 +89,7 @@ void testPathSourceFunctionality() {
8989
}
9090

9191
@Test
92-
void testBuildPathSourceFunctionality() {
92+
void buildPathSourceFunctionality() {
9393
// Test build source functionality
9494
Path basePath = Paths.get("/tmp");
9595
ModelSource.ModelLocator locator = mock(ModelSource.ModelLocator.class);
@@ -107,7 +107,7 @@ void testBuildPathSourceFunctionality() {
107107
}
108108

109109
@Test
110-
void testResolvedPathSourceFunctionality() {
110+
void resolvedPathSourceFunctionality() {
111111
// Test resolved source functionality
112112
Path path = Paths.get("/tmp");
113113
String location = "custom-location";
@@ -123,7 +123,7 @@ void testResolvedPathSourceFunctionality() {
123123
}
124124

125125
@Test
126-
void testStreamReading() throws IOException {
126+
void streamReading() throws IOException {
127127
// Test stream reading functionality
128128
Path testFile = tempDir.resolve("test.txt");
129129
String content = "test content";
@@ -137,7 +137,7 @@ void testStreamReading() throws IOException {
137137
}
138138

139139
@Test
140-
void testNullHandling() {
140+
void nullHandling() {
141141
assertThrows(NullPointerException.class, () -> Sources.fromPath(null));
142142
assertThrows(NullPointerException.class, () -> Sources.buildSource(null));
143143
assertThrows(NullPointerException.class, () -> Sources.resolvedSource(null, "location"));

api/maven-api-plugin/src/test/java/org/apache/maven/api/plugin/descriptor/another/ExtendedPluginDescriptorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public ExtendedPluginDescriptor build() {
6363
}
6464

6565
@Test
66-
void testExtendedPluginDescriptor() {
66+
void extendedPluginDescriptor() {
6767
ExtendedPluginDescriptor.Builder builder = new ExtendedPluginDescriptor.Builder();
6868
// make sure to call the subclasses' builder methods first, otherwise fluent API would not work
6969
builder.additionalField("additional")

api/maven-api-settings/src/test/java/org/apache/maven/api/settings/SettingsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
class SettingsTest {
2727

2828
@Test
29-
void testSetLocalRepository() {
29+
void setLocalRepository() {
3030
Settings s = Settings.newInstance();
3131

3232
s = s.withLocalRepository("xxx");

compat/maven-artifact/src/test/java/org/apache/maven/artifact/ArtifactUtilsTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ private Artifact newArtifact(String aid) {
4141
}
4242

4343
@Test
44-
void testIsSnapshot() {
44+
void isSnapshot() {
4545
assertFalse(ArtifactUtils.isSnapshot(null));
4646
assertFalse(ArtifactUtils.isSnapshot(""));
4747
assertFalse(ArtifactUtils.isSnapshot("1.2.3"));
@@ -52,7 +52,7 @@ void testIsSnapshot() {
5252
}
5353

5454
@Test
55-
void testToSnapshotVersion() {
55+
void toSnapshotVersion() {
5656
assertEquals("1.2.3", ArtifactUtils.toSnapshotVersion("1.2.3"));
5757
assertEquals("1.2.3-SNAPSHOT", ArtifactUtils.toSnapshotVersion("1.2.3-SNAPSHOT"));
5858
assertEquals("1.2.3-SNAPSHOT", ArtifactUtils.toSnapshotVersion("1.2.3-20090413.094722-2"));
@@ -63,7 +63,7 @@ void testToSnapshotVersion() {
6363
* Tests that the ordering of the map resembles the ordering of the input collection of artifacts.
6464
*/
6565
@Test
66-
void testArtifactMapByVersionlessIdOrdering() throws Exception {
66+
void artifactMapByVersionlessIdOrdering() throws Exception {
6767
List<Artifact> list = new ArrayList<>();
6868
list.add(newArtifact("b"));
6969
list.add(newArtifact("a"));

compat/maven-artifact/src/test/java/org/apache/maven/artifact/DefaultArtifactTest.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void setUp() throws Exception {
6666
}
6767

6868
@Test
69-
void testGetVersionReturnsResolvedVersionOnSnapshot() {
69+
void getVersionReturnsResolvedVersionOnSnapshot() {
7070
assertEquals(snapshotResolvedVersion, snapshotArtifact.getVersion());
7171

7272
// this is FOUL!
@@ -76,24 +76,24 @@ void testGetVersionReturnsResolvedVersionOnSnapshot() {
7676
}
7777

7878
@Test
79-
void testGetDependencyConflictId() {
79+
void getDependencyConflictId() {
8080
assertEquals(groupId + ":" + artifactId + ":" + type + ":" + classifier, artifact.getDependencyConflictId());
8181
}
8282

8383
@Test
84-
void testGetDependencyConflictIdNullGroupId() {
84+
void getDependencyConflictIdNullGroupId() {
8585
artifact.setGroupId(null);
8686
assertEquals(null + ":" + artifactId + ":" + type + ":" + classifier, artifact.getDependencyConflictId());
8787
}
8888

8989
@Test
90-
void testGetDependencyConflictIdNullClassifier() {
90+
void getDependencyConflictIdNullClassifier() {
9191
artifact = new DefaultArtifact(groupId, artifactId, versionRange, scope, type, null, artifactHandler);
9292
assertEquals(groupId + ":" + artifactId + ":" + type, artifact.getDependencyConflictId());
9393
}
9494

9595
@Test
96-
void testGetDependencyConflictIdNullScope() {
96+
void getDependencyConflictIdNullScope() {
9797
artifact.setScope(null);
9898
assertEquals(groupId + ":" + artifactId + ":" + type + ":" + classifier, artifact.getDependencyConflictId());
9999
}
@@ -106,25 +106,25 @@ void testToString() {
106106
}
107107

108108
@Test
109-
void testToStringNullGroupId() {
109+
void toStringNullGroupId() {
110110
artifact.setGroupId(null);
111111
assertEquals(artifactId + ":" + type + ":" + classifier + ":" + version + ":" + scope, artifact.toString());
112112
}
113113

114114
@Test
115-
void testToStringNullClassifier() {
115+
void toStringNullClassifier() {
116116
artifact = new DefaultArtifact(groupId, artifactId, versionRange, scope, type, null, artifactHandler);
117117
assertEquals(groupId + ":" + artifactId + ":" + type + ":" + version + ":" + scope, artifact.toString());
118118
}
119119

120120
@Test
121-
void testToStringNullScope() {
121+
void toStringNullScope() {
122122
artifact.setScope(null);
123123
assertEquals(groupId + ":" + artifactId + ":" + type + ":" + classifier + ":" + version, artifact.toString());
124124
}
125125

126126
@Test
127-
void testComparisonByVersion() {
127+
void comparisonByVersion() {
128128
Artifact artifact1 = new DefaultArtifact(
129129
groupId, artifactId, VersionRange.createFromVersion("5.0"), scope, type, classifier, artifactHandler);
130130
Artifact artifact2 = new DefaultArtifact(
@@ -135,20 +135,20 @@ void testComparisonByVersion() {
135135

136136
Artifact artifact = new DefaultArtifact(
137137
groupId, artifactId, VersionRange.createFromVersion("5.0"), scope, type, classifier, artifactHandler);
138-
assertTrue(artifact.compareTo(artifact1) == 0);
139-
assertTrue(artifact1.compareTo(artifact) == 0);
138+
assertEquals(0, artifact.compareTo(artifact1));
139+
assertEquals(0, artifact1.compareTo(artifact));
140140
}
141141

142142
@Test
143-
void testNonResolvedVersionRangeConsistentlyYieldsNullVersions() throws Exception {
143+
void nonResolvedVersionRangeConsistentlyYieldsNullVersions() throws Exception {
144144
VersionRange vr = VersionRange.createFromVersionSpec("[1.0,2.0)");
145145
artifact = new DefaultArtifact(groupId, artifactId, vr, scope, type, null, artifactHandler);
146146
assertNull(artifact.getVersion());
147147
assertNull(artifact.getBaseVersion());
148148
}
149149

150150
@Test
151-
void testMNG7780() throws Exception {
151+
void mng7780() throws Exception {
152152
VersionRange vr = VersionRange.createFromVersionSpec("[1.0,2.0)");
153153
artifact = new DefaultArtifact(groupId, artifactId, vr, scope, type, null, artifactHandler);
154154
assertNull(artifact.getVersion());
@@ -161,7 +161,7 @@ void testMNG7780() throws Exception {
161161

162162
@ParameterizedTest
163163
@MethodSource("invalidMavenCoordinates")
164-
void testIllegalCoordinatesInConstructor(String groupId, String artifactId, String version) {
164+
void illegalCoordinatesInConstructor(String groupId, String artifactId, String version) {
165165
assertThrows(
166166
InvalidArtifactRTException.class,
167167
() -> new DefaultArtifact(

0 commit comments

Comments
 (0)