Skip to content

Commit 17a9fee

Browse files
JUnit Jupiter best practices (#214)
Co-authored-by: Moderne <[email protected]>
1 parent 86901d1 commit 17a9fee

File tree

8 files changed

+66
-69
lines changed

8 files changed

+66
-69
lines changed

plexus-java/src/test/java/org/codehaus/plexus/languages/java/jpms/AbstractFilenameModuleNameExtractorTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,26 @@ public abstract class AbstractFilenameModuleNameExtractorTest {
3030
protected abstract ModuleNameExtractor getExtractor();
3131

3232
@Test
33-
void testJarWithoutManifest() throws Exception {
33+
void jarWithoutManifest() throws Exception {
3434
String name = getExtractor().extract(Paths.get("src/test/test-data/jar.empty/plexus-java-1.0.0-SNAPSHOT.jar"));
3535
assertEquals("plexus.java", name);
3636
}
3737

3838
@Test
39-
void testJarWithManifest() throws Exception {
39+
void jarWithManifest() throws Exception {
4040
String name = getExtractor()
4141
.extract(Paths.get("src/test/test-data/jar.manifest.with/plexus-java-1.0.0-SNAPSHOT.jar"));
4242
assertEquals("org.codehaus.plexus.languages.java", name);
4343
}
4444

4545
@Test
46-
void testJarUnsupported() throws Exception {
46+
void jarUnsupported() throws Exception {
4747
String name = getExtractor().extract(Paths.get("src/test/test-data/jar.unsupported/jdom-1.0.jar"));
4848
assertNull(name);
4949
}
5050

5151
@Test
52-
void testJarWithSpacesInPath() throws Exception {
52+
void jarWithSpacesInPath() throws Exception {
5353
String name = getExtractor()
5454
.extract(Paths.get("src/test/test-data/jar with spaces in path/plexus-java-1.0.0-SNAPSHOT.jar"));
5555
assertEquals("org.codehaus.plexus.languages.java", name);

plexus-java/src/test/java/org/codehaus/plexus/languages/java/jpms/BinaryModuleInfoParserTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class BinaryModuleInfoParserTest {
4747
private final BinaryModuleInfoParser parser = new BinaryModuleInfoParser();
4848

4949
@Test
50-
void testJarDescriptor() throws Exception {
50+
void jarDescriptor() throws Exception {
5151
JavaModuleDescriptor descriptor =
5252
parser.getModuleDescriptor(Paths.get("src/test/test-data/jar.descriptor/asm-6.0_BETA.jar"));
5353

@@ -67,7 +67,7 @@ void testJarDescriptor() throws Exception {
6767
}
6868

6969
@Test
70-
void testMultiReleaseJarDescriptor() throws Exception {
70+
void multiReleaseJarDescriptor() throws Exception {
7171
JavaModuleDescriptor descriptor = parser.getModuleDescriptor(
7272
Paths.get("src/test/test-data/jar.mr.descriptor/jloadr-1.0-SNAPSHOT.jar"), JavaVersion.parse("17"));
7373

@@ -77,7 +77,7 @@ void testMultiReleaseJarDescriptor() throws Exception {
7777
}
7878

7979
@Test
80-
void testIncompleteMultiReleaseJarDescriptor() throws Exception {
80+
void incompleteMultiReleaseJarDescriptor() throws Exception {
8181
// this jar is missing the Multi-Release: true entry in the Manifest
8282
JavaModuleDescriptor descriptor = parser.getModuleDescriptor(
8383
Paths.get("src/test/test-data/jar.mr.incomplete.descriptor/jloadr-1.0-SNAPSHOT.jar"));
@@ -86,15 +86,15 @@ void testIncompleteMultiReleaseJarDescriptor() throws Exception {
8686
}
8787

8888
@Test
89-
void testClassicJar() throws Exception {
89+
void classicJar() throws Exception {
9090
JavaModuleDescriptor descriptor =
9191
parser.getModuleDescriptor(Paths.get("src/test/test-data/jar.empty/plexus-java-1.0.0-SNAPSHOT.jar"));
9292

9393
assertNull(descriptor);
9494
}
9595

9696
@Test
97-
void testOutputDirectoryDescriptor() throws Exception {
97+
void outputDirectoryDescriptor() throws Exception {
9898
JavaModuleDescriptor descriptor =
9999
parser.getModuleDescriptor(Paths.get("src/test/test-data/dir.descriptor/out"));
100100

@@ -115,14 +115,14 @@ void testOutputDirectoryDescriptor() throws Exception {
115115
}
116116

117117
@Test
118-
void testClassicOutputDirectory() {
118+
void classicOutputDirectory() {
119119
assertThrows(
120120
NoSuchFileException.class,
121121
() -> parser.getModuleDescriptor(Paths.get("src/test/test-data/dir.empty/out")));
122122
}
123123

124124
@Test
125-
void testJModDescriptor() throws Exception {
125+
void jModDescriptor() throws Exception {
126126
JavaModuleDescriptor descriptor = parser.getModuleDescriptor(
127127
Paths.get("src/test/test-data/jmod.descriptor/first-jmod-1.0-SNAPSHOT.jmod"));
128128

@@ -139,13 +139,13 @@ void testJModDescriptor() throws Exception {
139139
}
140140

141141
@Test
142-
void testInvalidFile() {
142+
void invalidFile() {
143143
assertThrows(
144144
IOException.class, () -> parser.getModuleDescriptor(Paths.get("src/test/test-data/nonjar/pom.xml")));
145145
}
146146

147147
@Test
148-
void testUses() throws Exception {
148+
void uses() throws Exception {
149149
try (InputStream is =
150150
Files.newInputStream(Paths.get("src/test/test-data/dir.descriptor.uses/out/module-info.class"))) {
151151
JavaModuleDescriptor descriptor = parser.parse(is);
@@ -161,7 +161,7 @@ void testUses() throws Exception {
161161
}
162162

163163
@Test
164-
void testProvides() throws Exception {
164+
void provides() throws Exception {
165165
JavaModuleDescriptor descriptor =
166166
parser.getModuleDescriptor(Paths.get("src/test/test-data/jar.service/threeten-extra-1.4.jar"));
167167

@@ -186,7 +186,7 @@ void testProvides() throws Exception {
186186
}
187187

188188
@Test
189-
void testRequires() throws Exception {
189+
void requires() throws Exception {
190190
try (InputStream is =
191191
Files.newInputStream(Paths.get("src/test/test-data/dir.descriptor.requires/out/module-info.class"))) {
192192
JavaModuleDescriptor descriptor = parser.parse(is);

plexus-java/src/test/java/org/codehaus/plexus/languages/java/jpms/CmdModuleNameExtractorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
class CmdModuleNameExtractorTest {
2929
@Test
30-
void testMethodCount() throws Exception {
30+
void methodCount() throws Exception {
3131
// ensure that both implementations are in sync
3232
assertThat(CmdModuleNameExtractor.class.getDeclaredMethods()).hasSize(2);
3333

plexus-java/src/test/java/org/codehaus/plexus/languages/java/jpms/LocationManagerIT.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ ModuleInfoParser getBinaryModuleInfoParser(Path jdkHome) {
6666
}
6767

6868
@Test
69-
void testManifestWithoutReflectRequires() throws Exception {
69+
void manifestWithoutReflectRequires() throws Exception {
7070
Path abc = Paths.get("src/test/test-data/manifest.without/out");
7171
JavaModuleDescriptor descriptor =
7272
JavaModuleDescriptor.newModule("base").requires("any").build();
@@ -84,7 +84,7 @@ void testManifestWithoutReflectRequires() throws Exception {
8484
}
8585

8686
@Test
87-
void testEmptyWithReflectRequires() throws Exception {
87+
void emptyWithReflectRequires() throws Exception {
8888
Path abc = Paths.get("src/test/test-data/empty/out");
8989
JavaModuleDescriptor descriptor =
9090
JavaModuleDescriptor.newModule("base").requires("a.b.c").build();
@@ -102,17 +102,14 @@ void testEmptyWithReflectRequires() throws Exception {
102102
}
103103

104104
@Test
105-
void testResolvePathWithException() {
106-
assertThrows(RuntimeException.class, () -> {
107-
Path p = Paths.get("src/test/test-data/jar.empty.invalid.name/101-1.0.0-SNAPSHOT.jar");
108-
ResolvePathRequest<Path> request = ResolvePathRequest.ofPath(p);
109-
110-
locationManager.resolvePath(request);
111-
});
105+
void resolvePathWithException() {
106+
Path p = Paths.get("src/test/test-data/jar.empty.invalid.name/101-1.0.0-SNAPSHOT.jar");
107+
ResolvePathRequest<Path> request = ResolvePathRequest.ofPath(p);
108+
assertThrows(RuntimeException.class, () -> locationManager.resolvePath(request));
112109
}
113110

114111
@Test
115-
void testClassicJarNameStartsWithNumber() throws Exception {
112+
void classicJarNameStartsWithNumber() throws Exception {
116113
Path p = Paths.get("src/test/test-data/jar.empty.invalid.name/101-1.0.0-SNAPSHOT.jar");
117114
ResolvePathsRequest<Path> request =
118115
ResolvePathsRequest.ofPaths(Collections.singletonList(p)).setMainModuleDescriptor(mockModuleInfoJava);

plexus-java/src/test/java/org/codehaus/plexus/languages/java/jpms/LocationManagerTest.java

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ ModuleInfoParser getBinaryModuleInfoParser(Path jdkHome) {
5757
}
5858

5959
@Test
60-
void testNoPaths() throws Exception {
60+
void noPaths() throws Exception {
6161
ResolvePathsResult<File> result =
6262
locationManager.resolvePaths(ResolvePathsRequest.ofFiles(Collections.emptyList()));
6363
assertThat(result.getMainModuleDescriptor()).isNull();
@@ -68,7 +68,7 @@ void testNoPaths() throws Exception {
6868
}
6969

7070
@Test
71-
void testWithUnknownRequires() throws Exception {
71+
void withUnknownRequires() throws Exception {
7272
JavaModuleDescriptor descriptor = JavaModuleDescriptor.newModule("base")
7373
.requires("java.base")
7474
.requires("jdk.net")
@@ -87,7 +87,7 @@ void testWithUnknownRequires() throws Exception {
8787
}
8888

8989
@Test
90-
void testManifestWithReflectRequires() throws Exception {
90+
void manifestWithReflectRequires() throws Exception {
9191
Path abc = Paths.get("src/test/test-data/dir.manifest.with/out");
9292
JavaModuleDescriptor descriptor = JavaModuleDescriptor.newModule("base")
9393
.requires("auto.by.manifest")
@@ -107,7 +107,7 @@ void testManifestWithReflectRequires() throws Exception {
107107
}
108108

109109
@Test
110-
void testDirDescriptorWithReflectRequires() throws Exception {
110+
void dirDescriptorWithReflectRequires() throws Exception {
111111
Path abc = Paths.get("src/test/test-data/dir.descriptor/out");
112112
JavaModuleDescriptor descriptor = JavaModuleDescriptor.newModule("base")
113113
.requires("dir.descriptor")
@@ -130,7 +130,7 @@ void testDirDescriptorWithReflectRequires() throws Exception {
130130
}
131131

132132
@Test
133-
void testJarWithAsmRequires() throws Exception {
133+
void jarWithAsmRequires() throws Exception {
134134
Path abc = Paths.get("src/test/test-data/jar.descriptor/asm-6.0_BETA.jar");
135135
JavaModuleDescriptor descriptor = JavaModuleDescriptor.newModule("base")
136136
.requires("org.objectweb.asm")
@@ -152,7 +152,7 @@ void testJarWithAsmRequires() throws Exception {
152152
}
153153

154154
@Test
155-
void testIdenticalModuleNames() throws Exception {
155+
void identicalModuleNames() throws Exception {
156156
Path pj1 = Paths.get("src/test/test-data/jar.empty/plexus-java-1.0.0-SNAPSHOT.jar");
157157
Path pj2 = Paths.get("src/test/test-data/jar.empty.2/plexus-java-2.0.0-SNAPSHOT.jar");
158158
JavaModuleDescriptor descriptor =
@@ -182,7 +182,7 @@ void testIdenticalModuleNames() throws Exception {
182182
}
183183

184184
@Test
185-
public void testIdenticalAutomaticModuleNames() throws Exception {
185+
void identicalAutomaticModuleNames() throws Exception {
186186
Path pj1 = Paths.get("src/test/test-data/jar.empty/plexus-java-1.0.0-SNAPSHOT.jar");
187187
Path pj2 = Paths.get("src/test/test-data/jar.empty.2/plexus-java-2.0.0-SNAPSHOT.jar");
188188
JavaModuleDescriptor descriptor =
@@ -212,7 +212,7 @@ public void testIdenticalAutomaticModuleNames() throws Exception {
212212
}
213213

214214
@Test
215-
public void testMainJarModuleAndTestJarAutomatic() throws Exception {
215+
void mainJarModuleAndTestJarAutomatic() throws Exception {
216216
Path pj1 = Paths.get("src/test/test-data/jar.tests/plexus-java-1.0.0-SNAPSHOT.jar");
217217
Path pj2 = Paths.get("src/test/test-data/jar.tests/plexus-java-1.0.0-SNAPSHOT-tests.jar");
218218
JavaModuleDescriptor descriptor =
@@ -242,7 +242,7 @@ public void testMainJarModuleAndTestJarAutomatic() throws Exception {
242242
}
243243

244244
@Test
245-
void testNonJar() throws Exception {
245+
void nonJar() throws Exception {
246246
Path p = Paths.get("src/test/test-data/nonjar/pom.xml");
247247

248248
ResolvePathsRequest<Path> request =
@@ -254,7 +254,7 @@ void testNonJar() throws Exception {
254254
}
255255

256256
@Test
257-
void testAdditionalModules() throws Exception {
257+
void additionalModules() throws Exception {
258258
Path p = Paths.get("src/test/test-data/mock/jar0.jar");
259259

260260
JavaModuleDescriptor descriptor = JavaModuleDescriptor.newModule("base").build();
@@ -276,7 +276,7 @@ void testAdditionalModules() throws Exception {
276276
}
277277

278278
@Test
279-
void testResolvePath() throws Exception {
279+
void resolvePath() throws Exception {
280280
Path abc = Paths.get("src/test/test-data/mock/jar0.jar");
281281
ResolvePathRequest<Path> request = ResolvePathRequest.ofPath(abc);
282282

@@ -291,7 +291,7 @@ void testResolvePath() throws Exception {
291291
}
292292

293293
@Test
294-
void testNoMatchingProviders() throws Exception {
294+
void noMatchingProviders() throws Exception {
295295
Path abc = Paths.get("src/test/test-data/mock/module-info.java"); // some file called module-info.java
296296
Path def = Paths.get("src/test/test-data/mock/jar0.jar"); // any existing file
297297
ResolvePathsRequest<Path> request =
@@ -312,7 +312,7 @@ void testNoMatchingProviders() throws Exception {
312312
}
313313

314314
@Test
315-
void testMainModuleDescriptorWithProviders() throws Exception {
315+
void mainModuleDescriptorWithProviders() throws Exception {
316316
Path abc = Paths.get("src/test/test-data/mock/module-info.java"); // some file called module-info.java
317317
Path def = Paths.get("src/test/test-data/mock/jar0.jar"); // any existing file
318318
ResolvePathsRequest<Path> request =
@@ -333,7 +333,7 @@ void testMainModuleDescriptorWithProviders() throws Exception {
333333
}
334334

335335
@Test
336-
void testMainModuleDescriptorWithProvidersDontIncludeProviders() throws Exception {
336+
void mainModuleDescriptorWithProvidersDontIncludeProviders() throws Exception {
337337
Path abc = Paths.get("src/test/test-data/mock/module-info.java"); // some file called module-info.java
338338
Path def = Paths.get("src/test/test-data/mock/jar0.jar"); // any existing file
339339
ResolvePathsRequest<Path> request = ResolvePathsRequest.ofPaths(def).setMainModuleDescriptor(abc);
@@ -353,7 +353,7 @@ void testMainModuleDescriptorWithProvidersDontIncludeProviders() throws Exceptio
353353
}
354354

355355
@Test
356-
void testTransitiveProviders() throws Exception {
356+
void transitiveProviders() throws Exception {
357357
Path abc = Paths.get("src/test/test-data/mock/module-info.java"); // some file called module-info.java
358358
Path def = Paths.get("src/test/test-data/mock/jar0.jar"); // any existing file
359359
Path ghi = Paths.get("src/test/test-data/mock/jar1.jar"); // any existing file
@@ -379,7 +379,7 @@ void testTransitiveProviders() throws Exception {
379379
}
380380

381381
@Test
382-
void testDontIncludeProviders() throws Exception {
382+
void dontIncludeProviders() throws Exception {
383383
Path abc = Paths.get("src/test/test-data/mock/module-info.java"); // some file called module-info.java
384384
Path def = Paths.get("src/test/test-data/mock/jar0.jar"); // any existing file
385385
Path ghi = Paths.get("src/test/test-data/mock/jar1.jar"); // any existing file
@@ -404,7 +404,7 @@ void testDontIncludeProviders() throws Exception {
404404
}
405405

406406
@Test
407-
void testAllowAdditionalModulesWithoutMainDescriptor() throws Exception {
407+
void allowAdditionalModulesWithoutMainDescriptor() throws Exception {
408408
Path def = Paths.get("src/test/test-data/mock/jar0.jar"); // any existing file
409409
Path ghi = Paths.get("src/test/test-data/mock/jar1.jar"); // any existing file
410410
ResolvePathsRequest<Path> request =
@@ -423,7 +423,7 @@ void testAllowAdditionalModulesWithoutMainDescriptor() throws Exception {
423423
}
424424

425425
@Test
426-
void testReuseModuleDescriptor() throws Exception {
426+
void reuseModuleDescriptor() throws Exception {
427427
Path def = Paths.get("src/test/test-data/mock/jar0.jar");
428428

429429
ResolvePathRequest<Path> request1 = ResolvePathRequest.ofPath(def);
@@ -441,7 +441,7 @@ void testReuseModuleDescriptor() throws Exception {
441441
}
442442

443443
@Test
444-
void testParseModuleDescriptor() throws Exception {
444+
void parseModuleDescriptor() throws Exception {
445445
Path descriptorPath = Paths.get("src/test/test-data/src.dir/module-info.java");
446446
when(qdoxParser.fromSourcePath(descriptorPath))
447447
.thenReturn(JavaModuleDescriptor.newModule("a.b.c").build());
@@ -460,7 +460,7 @@ void testParseModuleDescriptor() throws Exception {
460460
}
461461

462462
@Test
463-
void testTransitiveStatic() throws Exception {
463+
void transitiveStatic() throws Exception {
464464
Path moduleA = Paths.get("src/test/test-data/mock/module-info.java"); // some file called module-info.java
465465
Path moduleB = Paths.get("src/test/test-data/mock/jar0.jar"); // any existing file
466466
Path moduleC = Paths.get("src/test/test-data/mock/jar1.jar"); // any existing file
@@ -486,7 +486,7 @@ void testTransitiveStatic() throws Exception {
486486
}
487487

488488
@Test
489-
void testDirectStatic() throws Exception {
489+
void directStatic() throws Exception {
490490
Path moduleA = Paths.get("src/test/test-data/mock/module-info.java"); // some file called module-info.java
491491
Path moduleB = Paths.get("src/test/test-data/mock/jar0.jar"); // any existing file
492492
Path moduleC = Paths.get("src/test/test-data/mock/jar1.jar"); // any existing file
@@ -517,7 +517,7 @@ void testDirectStatic() throws Exception {
517517
}
518518

519519
@Test
520-
void testDuplicateModule() throws Exception {
520+
void duplicateModule() throws Exception {
521521
Path moduleA = Paths.get("src/test/test-data/mock/module-info.java"); // some file called module-info.java
522522
Path moduleB = Paths.get("src/test/test-data/mock/jar0.jar"); // any existing file
523523
Path moduleC = Paths.get("src/test/test-data/mock/jar1.jar"); // any existing file
@@ -547,7 +547,7 @@ void testDuplicateModule() throws Exception {
547547
}
548548

549549
@Test
550-
void testStaticTransitive() throws Exception {
550+
void staticTransitive() throws Exception {
551551
Path moduleA = Paths.get("src/test/test-data/mock/module-info.java"); // some file called module-info.java
552552
Path moduleB = Paths.get("src/test/test-data/mock/jar0.jar"); // any existing file
553553
Path moduleC = Paths.get("src/test/test-data/mock/jar1.jar"); // any existing file

0 commit comments

Comments
 (0)