Skip to content

Commit 240bdfe

Browse files
JUnit Jupiter best practices (#329)
Co-authored-by: Moderne <[email protected]>
1 parent 5bde4da commit 240bdfe

File tree

2 files changed

+33
-34
lines changed

2 files changed

+33
-34
lines changed

src/test/java/org/apache/maven/shared/archiver/MavenArchiverTest.java

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,18 @@ void setup() {
108108
"123.at.start.is.invalid",
109109
"digit.at.123start.is.invalid"
110110
})
111-
void testInvalidModuleNames(String value) {
111+
void invalidModuleNames(String value) {
112112
assertThat(MavenArchiver.isValidModuleName(value)).isFalse();
113113
}
114114

115115
@ParameterizedTest
116116
@ValueSource(strings = {"a", "a.b", "a_b", "trailing0.digits123.are456.ok789", "UTF8.chars.are.okay.äëïöüẍ", "ℤ€ℕ"})
117-
void testValidModuleNames(String value) {
117+
void validModuleNames(String value) {
118118
assertThat(MavenArchiver.isValidModuleName(value)).isTrue();
119119
}
120120

121121
@Test
122-
void testMultiClassPath() throws Exception {
122+
void multiClassPath() throws Exception {
123123
final File tempFile = File.createTempFile("maven-archiver-test-", ".jar");
124124

125125
try {
@@ -153,7 +153,7 @@ void testMultiClassPath() throws Exception {
153153
}
154154

155155
@Test
156-
void testRecreation() throws Exception {
156+
void recreation() throws Exception {
157157
File jarFile = new File("target/test/dummy.jar");
158158
JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
159159

@@ -193,7 +193,7 @@ void testRecreation() throws Exception {
193193
}
194194

195195
@Test
196-
void testNotGenerateImplementationVersionForMANIFESTMF() throws Exception {
196+
void notGenerateImplementationVersionForMANIFESTMF() throws Exception {
197197
File jarFile = new File("target/test/dummy.jar");
198198
JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
199199

@@ -214,7 +214,7 @@ void testNotGenerateImplementationVersionForMANIFESTMF() throws Exception {
214214
}
215215

216216
@Test
217-
void testGenerateImplementationVersionForMANIFESTMF() throws Exception {
217+
void generateImplementationVersionForMANIFESTMF() throws Exception {
218218
File jarFile = new File("target/test/dummy.jar");
219219
JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
220220

@@ -246,7 +246,7 @@ private MavenArchiver getMavenArchiver(JarArchiver jarArchiver) {
246246
}
247247

248248
@Test
249-
void testDashesInClassPathMSHARED134() {
249+
void dashesInClassPathMSHARED134() {
250250
File jarFile = new File("target/test/dummyWithDashes.jar");
251251
JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
252252

@@ -272,7 +272,7 @@ void testDashesInClassPathMSHARED134() {
272272
}
273273

274274
@Test
275-
void testDashesInClassPathMSHARED182() throws IOException {
275+
void dashesInClassPathMSHARED182() throws Exception {
276276
File jarFile = new File("target/test/dummy.jar");
277277
JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
278278
MavenArchiver archiver = getMavenArchiver(jarArchiver);
@@ -300,7 +300,7 @@ void testDashesInClassPathMSHARED182() throws IOException {
300300
}
301301

302302
@Test
303-
void testCarriageReturnInManifestEntry() throws Exception {
303+
void carriageReturnInManifestEntry() throws Exception {
304304
File jarFile = new File("target/test/dummy.jar");
305305
JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
306306

@@ -329,7 +329,7 @@ void testCarriageReturnInManifestEntry() throws Exception {
329329
}
330330

331331
@Test
332-
void testDeprecatedCreateArchiveAPI() throws Exception {
332+
void deprecatedCreateArchiveAPI() throws Exception {
333333
File jarFile = new File("target/test/dummy.jar");
334334
JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
335335

@@ -359,7 +359,7 @@ void testDeprecatedCreateArchiveAPI() throws Exception {
359359
}
360360

361361
@Test
362-
void testMinimalManifestEntries() throws Exception {
362+
void minimalManifestEntries() throws Exception {
363363
File jarFile = new File("target/test/dummy.jar");
364364
JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
365365

@@ -381,7 +381,7 @@ void testMinimalManifestEntries() throws Exception {
381381
}
382382

383383
@Test
384-
void testManifestEntries() throws Exception {
384+
void manifestEntries() throws Exception {
385385
File jarFile = new File("target/test/dummy.jar");
386386
JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
387387

@@ -454,7 +454,7 @@ void testManifestEntries() throws Exception {
454454
}
455455

456456
@Test
457-
void testManifestWithInvalidAutomaticModuleNameThrowsOnCreateArchive() throws Exception {
457+
void manifestWithInvalidAutomaticModuleNameThrowsOnCreateArchive() throws Exception {
458458
File jarFile = new File("target/test/dummy.jar");
459459
JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
460460

@@ -479,7 +479,7 @@ void testManifestWithInvalidAutomaticModuleNameThrowsOnCreateArchive() throws Ex
479479
* Automatic-Module-Name attribute at all, but that the archive will be created.
480480
*/
481481
@Test
482-
void testManifestWithEmptyAutomaticModuleName() throws Exception {
482+
void manifestWithEmptyAutomaticModuleName() throws Exception {
483483
File jarFile = new File("target/test/dummy.jar");
484484
JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
485485

@@ -505,7 +505,7 @@ void testManifestWithEmptyAutomaticModuleName() throws Exception {
505505
// Test to make sure that manifest sections are present in the manifest prior to the archive has been created.
506506
//
507507
@Test
508-
void testManifestSections() throws Exception {
508+
void manifestSections() throws Exception {
509509
MavenArchiver archiver = new MavenArchiver();
510510

511511
Project project = getDummyProject();
@@ -534,7 +534,7 @@ void testManifestSections() throws Exception {
534534
}
535535

536536
@Test
537-
void testDefaultClassPathValue() throws Exception {
537+
void defaultClassPathValue() throws Exception {
538538
Project project = getDummyProject();
539539
File jarFile = new File("target/test/dummy.jar");
540540
JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
@@ -561,7 +561,7 @@ void testDefaultClassPathValue() throws Exception {
561561
}
562562

563563
@Test
564-
void testDefaultClassPathValueWithSnapshot() throws Exception {
564+
void defaultClassPathValueWithSnapshot() throws Exception {
565565
Project project = getDummyProjectWithSnapshot();
566566
File jarFile = new File("target/test/dummy.jar");
567567
JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
@@ -589,7 +589,7 @@ void testDefaultClassPathValueWithSnapshot() throws Exception {
589589
}
590590

591591
@Test
592-
void testMavenRepoClassPathValue() throws Exception {
592+
void mavenRepoClassPathValue() throws Exception {
593593
Project project = getDummyProject();
594594
File jarFile = new File("target/test/dummy.jar");
595595
JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
@@ -831,7 +831,7 @@ void shouldCreateArchiveWithSimpleClassPathLayoutUsingDefaults() throws Exceptio
831831
}
832832

833833
@Test
834-
void testMavenRepoClassPathValueWithSnapshot() throws Exception {
834+
void mavenRepoClassPathValueWithSnapshot() throws Exception {
835835
Project project = getDummyProjectWithSnapshot();
836836
File jarFile = new File("target/test/dummy.jar");
837837
JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
@@ -867,7 +867,7 @@ void testMavenRepoClassPathValueWithSnapshot() throws Exception {
867867
}
868868

869869
@Test
870-
void testCustomClassPathValue() throws Exception {
870+
void customClassPathValue() throws Exception {
871871
Project project = getDummyProject();
872872
File jarFile = new File("target/test/dummy.jar");
873873
JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
@@ -906,7 +906,7 @@ void testCustomClassPathValue() throws Exception {
906906
}
907907

908908
@Test
909-
void testCustomClassPathValueWithSnapshotResolvedVersion() throws Exception {
909+
void customClassPathValueWithSnapshotResolvedVersion() throws Exception {
910910
Project project = getDummyProjectWithSnapshot();
911911
File jarFile = new File("target/test/dummy.jar");
912912
JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
@@ -944,7 +944,7 @@ void testCustomClassPathValueWithSnapshotResolvedVersion() throws Exception {
944944
}
945945

946946
@Test
947-
void testCustomClassPathValueWithSnapshotForcingBaseVersion() throws Exception {
947+
void customClassPathValueWithSnapshotForcingBaseVersion() throws Exception {
948948
Project project = getDummyProjectWithSnapshot();
949949
File jarFile = new File("target/test/dummy.jar");
950950
JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
@@ -980,7 +980,7 @@ void testCustomClassPathValueWithSnapshotForcingBaseVersion() throws Exception {
980980
}
981981

982982
@Test
983-
void testDefaultPomProperties() throws Exception {
983+
void defaultPomProperties() throws Exception {
984984
Project project = getDummyProject();
985985
File jarFile = new File("target/test/dummy.jar");
986986
JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
@@ -1013,7 +1013,7 @@ void testDefaultPomProperties() throws Exception {
10131013
}
10141014

10151015
@Test
1016-
void testCustomPomProperties() throws Exception {
1016+
void customPomProperties() throws Exception {
10171017
Project project = getDummyProject();
10181018
File jarFile = new File("target/test/dummy.jar");
10191019
JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
@@ -1235,7 +1235,7 @@ private Manifest getJarFileManifest(File jarFile) throws IOException {
12351235
}
12361236

12371237
@Test
1238-
void testParseOutputTimestamp() {
1238+
void parseOutputTimestamp() {
12391239
assertThat(MavenArchiver.parseBuildOutputTimestamp(null)).isEmpty();
12401240
assertThat(MavenArchiver.parseBuildOutputTimestamp("")).isEmpty();
12411241
assertThat(MavenArchiver.parseBuildOutputTimestamp(".")).isEmpty();
@@ -1275,7 +1275,7 @@ void testParseOutputTimestamp() {
12751275
@ParameterizedTest
12761276
@NullAndEmptySource
12771277
@ValueSource(strings = {".", " ", "_", "-", "T", "/", "!", "!", "*", "ñ"})
1278-
void testEmptyParseOutputTimestampInstant(String value) {
1278+
void emptyParseOutputTimestampInstant(String value) {
12791279
// Empty optional if null or 1 char
12801280
assertThat(MavenArchiver.parseBuildOutputTimestamp(value)).isEmpty();
12811281
}
@@ -1292,7 +1292,7 @@ void testEmptyParseOutputTimestampInstant(String value) {
12921292
"1980-01-01T00:00:02Z,315532802",
12931293
"2099-12-31T23:59:59Z,4102444799"
12941294
})
1295-
void testParseOutputTimestampInstant(String value, long expected) {
1295+
void parseOutputTimestampInstant(String value, long expected) {
12961296
assertThat(MavenArchiver.parseBuildOutputTimestamp(value)).contains(Instant.ofEpochSecond(expected));
12971297
}
12981298

@@ -1307,7 +1307,7 @@ void testParseOutputTimestampInstant(String value, long expected) {
13071307
"Tue, 3 Jun 2008 11:05:30 GMT",
13081308
"2011-12-03T10:15:30+01:00[Europe/Paris]"
13091309
})
1310-
void testThrownParseOutputTimestampInstant(String outputTimestamp) {
1310+
void thrownParseOutputTimestampInstant(String outputTimestamp) {
13111311
// Invalid parsing
13121312
assertThatExceptionOfType(IllegalArgumentException.class)
13131313
.isThrownBy(() -> MavenArchiver.parseBuildOutputTimestamp(outputTimestamp))
@@ -1322,7 +1322,7 @@ void testThrownParseOutputTimestampInstant(String outputTimestamp) {
13221322
"1988-02-22T20:37:42+06,572539062"
13231323
})
13241324
@EnabledForJreRange(min = JRE.JAVA_9)
1325-
void testShortOffset(String value, long expected) {
1325+
void shortOffset(String value, long expected) {
13261326
assertThat(MavenArchiver.parseBuildOutputTimestamp(value)).contains(Instant.ofEpochSecond(expected));
13271327
}
13281328

@@ -1411,7 +1411,7 @@ private long testReproducibleJarEntryTime(String name, String timestamp) throws
14111411
* @throws Exception
14121412
*/
14131413
@Test
1414-
void testReproducibleJar19700101() throws Exception {
1414+
void reproducibleJar19700101() throws Exception {
14151415
long entryTime = testReproducibleJarEntryTime("1970", "10");
14161416
assertThat(entryTime).isGreaterThanOrEqualTo(0);
14171417
}

src/test/java/org/apache/maven/shared/archiver/PomPropertiesUtilTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
*/
1919
package org.apache.maven.shared.archiver;
2020

21-
import java.io.IOException;
2221
import java.io.Writer;
2322
import java.nio.charset.StandardCharsets;
2423
import java.nio.file.Files;
@@ -41,7 +40,7 @@ class PomPropertiesUtilTest {
4140
Path tempDirectory;
4241

4342
@Test
44-
void testCreatePomProperties() throws IOException {
43+
void createPomProperties() throws Exception {
4544
Path pomPropertiesFile = tempDirectory.resolve("bar.properties");
4645
util.createPomProperties("org.foo", "bar", "2.1.5", new JarArchiver(), null, pomPropertiesFile);
4746

@@ -61,7 +60,7 @@ void testCreatePomProperties() throws IOException {
6160
}
6261

6362
@Test
64-
void testUnicodeEscape() throws IOException {
63+
void unicodeEscape() throws Exception {
6564
Path pomPropertiesFile = tempDirectory.resolve("bar.properties");
6665
util.createPomProperties("org.foo", "こんにちは", "2.1.5", new JarArchiver(), null, pomPropertiesFile);
6766

@@ -81,7 +80,7 @@ void testUnicodeEscape() throws IOException {
8180
}
8281

8382
@Test
84-
void testWhitespaceEscape() throws IOException {
83+
void whitespaceEscape() throws Exception {
8584
Path pomPropertiesFile = tempDirectory.resolve("bar.properties");
8685
Path customPomPropertiesFile = tempDirectory.resolve("custom.properties");
8786
try (Writer out = Files.newBufferedWriter(customPomPropertiesFile, StandardCharsets.ISO_8859_1)) {

0 commit comments

Comments
 (0)