Skip to content

Commit f4be029

Browse files
committed
Cleanup tests
1 parent 349b89c commit f4be029

34 files changed

+621
-653
lines changed

pom.xml

-10
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,6 @@ limitations under the License.
9797
<exclude>org/codehaus/plexus/util/FileBasedTestCase.java</exclude>
9898
<exclude>**/Test*.java</exclude>
9999
</excludes>
100-
<systemProperties>
101-
<property>
102-
<name>JAVA_HOME</name>
103-
<value>${JAVA_HOME}</value>
104-
</property>
105-
<property>
106-
<name>M2_HOME</name>
107-
<value>${M2_HOME}</value>
108-
</property>
109-
</systemProperties>
110100
</configuration>
111101
</plugin>
112102
<plugin>

src/test/java/org/codehaus/plexus/util/CollectionUtilsTest.java

+23-23
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,21 @@
3535
* @version $Id: $Id
3636
* @since 3.4.0
3737
*/
38-
public class CollectionUtilsTest {
38+
class CollectionUtilsTest {
3939
/**
4040
* <p>testMergeMaps.</p>
4141
*/
4242
@Test
43-
public void testMergeMaps() {
44-
Map<String, String> dominantMap = new HashMap<String, String>();
43+
void mergeMaps() {
44+
Map<String, String> dominantMap = new HashMap<>();
4545
dominantMap.put("a", "a");
4646
dominantMap.put("b", "b");
4747
dominantMap.put("c", "c");
4848
dominantMap.put("d", "d");
4949
dominantMap.put("e", "e");
5050
dominantMap.put("f", "f");
5151

52-
Map<String, String> recessiveMap = new HashMap<String, String>();
52+
Map<String, String> recessiveMap = new HashMap<>();
5353
recessiveMap.put("a", "invalid");
5454
recessiveMap.put("b", "invalid");
5555
recessiveMap.put("c", "invalid");
@@ -60,7 +60,7 @@ public void testMergeMaps() {
6060
Map<String, String> result = CollectionUtils.mergeMaps(dominantMap, recessiveMap);
6161

6262
// We should have 9 elements
63-
assertEquals(9, result.keySet().size());
63+
assertEquals(9, result.size());
6464

6565
// Check the elements.
6666
assertEquals("a", result.get("a"));
@@ -79,22 +79,22 @@ public void testMergeMaps() {
7979
*/
8080
@SuppressWarnings("unchecked")
8181
@Test
82-
public void testMergeMapArray() {
82+
void mergeMapArray() {
8383
// Test empty array of Maps
8484
Map<String, String> result0 = CollectionUtils.mergeMaps(new Map[] {});
8585

8686
assertNull(result0);
8787

8888
// Test with an array with a single element.
89-
Map<String, String> map1 = new HashMap<String, String>();
89+
Map<String, String> map1 = new HashMap<>();
9090
map1.put("a", "a");
9191

9292
Map<String, String> result1 = CollectionUtils.mergeMaps(new Map[] {map1});
9393

9494
assertEquals("a", result1.get("a"));
9595

9696
// Test with an array with two elements.
97-
Map<String, String> map2 = new HashMap<String, String>();
97+
Map<String, String> map2 = new HashMap<>();
9898
map2.put("a", "aa");
9999
map2.put("b", "bb");
100100

@@ -110,7 +110,7 @@ public void testMergeMapArray() {
110110
assertEquals("bb", result3.get("b"));
111111

112112
// Test with an array with three elements.
113-
Map<String, String> map3 = new HashMap<String, String>();
113+
Map<String, String> map3 = new HashMap<>();
114114
map3.put("a", "aaa");
115115
map3.put("b", "bbb");
116116
map3.put("c", "ccc");
@@ -132,8 +132,8 @@ public void testMergeMapArray() {
132132
/**
133133
* <p>testMavenPropertiesLoading.</p>
134134
*/
135-
@org.junit.jupiter.api.Test
136-
public void testMavenPropertiesLoading() {
135+
@Test
136+
void mavenPropertiesLoading() {
137137
// Mimic MavenSession properties loading. Properties listed
138138
// in dominant order.
139139
Properties systemProperties = new Properties();
@@ -175,26 +175,26 @@ public void testMavenPropertiesLoading() {
175175
});
176176

177177
// Values that should be taken from systemProperties.
178-
assertEquals("/projects/maven", (String) result.get("maven.home"));
178+
assertEquals("/projects/maven", result.get("maven.home"));
179179

180180
// Values that should be taken from userBuildProperties.
181-
assertEquals("/opt/maven/artifact", (String) result.get("maven.repo.local"));
182-
assertEquals("false", (String) result.get("maven.repo.remote.enabled"));
183-
assertEquals("jvanzyl", (String) result.get("maven.username"));
181+
assertEquals("/opt/maven/artifact", result.get("maven.repo.local"));
182+
assertEquals("false", result.get("maven.repo.remote.enabled"));
183+
assertEquals("jvanzyl", result.get("maven.username"));
184184

185185
// Values take from projectBuildProperties.
186-
assertEquals("maven", (String) result.get("maven.final.name"));
186+
assertEquals("maven", result.get("maven.final.name"));
187187

188188
// Values take from projectProperties.
189-
assertEquals(mavenRepoRemote, (String) result.get("maven.repo.remote"));
189+
assertEquals(mavenRepoRemote, result.get("maven.repo.remote"));
190190
}
191191

192192
/**
193193
* <p>testIteratorToListWithAPopulatedList.</p>
194194
*/
195-
@org.junit.jupiter.api.Test
196-
public void testIteratorToListWithAPopulatedList() {
197-
List<String> original = new ArrayList<String>();
195+
@Test
196+
void iteratorToListWithAPopulatedList() {
197+
List<String> original = new ArrayList<>();
198198

199199
original.add("en");
200200
original.add("to");
@@ -214,9 +214,9 @@ public void testIteratorToListWithAPopulatedList() {
214214
/**
215215
* <p>testIteratorToListWithAEmptyList.</p>
216216
*/
217-
@org.junit.jupiter.api.Test
218-
public void testIteratorToListWithAEmptyList() {
219-
List<String> original = new ArrayList<String>();
217+
@Test
218+
void iteratorToListWithAEmptyList() {
219+
List<String> original = new ArrayList<>();
220220

221221
List<String> copy = CollectionUtils.iteratorToList(original.iterator());
222222

src/test/java/org/codehaus/plexus/util/DirectoryScannerTest.java

+31-32
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@
4545
* @version $Id: $Id
4646
* @since 3.4.0
4747
*/
48-
public class DirectoryScannerTest extends FileBasedTestCase {
49-
private static String testDir = getTestDirectory().getPath();
48+
class DirectoryScannerTest extends FileBasedTestCase {
49+
private static final String testDir = getTestDirectory().getPath();
5050

5151
/**
5252
* <p>setUp.</p>
5353
*/
5454
@BeforeEach
55-
public void setUp() {
55+
void setUp() {
5656
try {
5757
FileUtils.deleteDirectory(testDir);
5858
} catch (IOException e) {
@@ -67,7 +67,7 @@ public void setUp() {
6767
* @throws java.net.URISyntaxException if any.
6868
*/
6969
@Test
70-
public void testCrossPlatformIncludesString() throws IOException, URISyntaxException {
70+
void crossPlatformIncludesString() throws IOException, URISyntaxException {
7171
DirectoryScanner ds = new DirectoryScanner();
7272
ds.setBasedir(new File(getTestResourcesDir() + File.separator + "directory-scanner").getCanonicalFile());
7373

@@ -93,7 +93,7 @@ public void testCrossPlatformIncludesString() throws IOException, URISyntaxExcep
9393
* @throws java.net.URISyntaxException if any.
9494
*/
9595
@Test
96-
public void testCrossPlatformExcludesString() throws IOException, URISyntaxException {
96+
void crossPlatformExcludesString() throws IOException, URISyntaxException {
9797
DirectoryScanner ds = new DirectoryScanner();
9898
ds.setBasedir(new File(getTestResourcesDir() + File.separator + "directory-scanner").getCanonicalFile());
9999
ds.setIncludes(new String[] {"**"});
@@ -156,11 +156,10 @@ private boolean checkTestFilesSymlinks() {
156156
}
157157
return true;
158158
} catch (IOException e) {
159-
System.err.println(String.format(
160-
"The unit test '%s.%s' will be skipped, reason: %s",
161-
this.getClass().getSimpleName(), getTestMethodName(), e.getMessage()));
162-
System.out.println(
163-
String.format("This test requires symlinks files in '%s' directory.", symlinksDirectory.getPath()));
159+
System.err.printf(
160+
"The unit test '%s.%s' will be skipped, reason: %s%n",
161+
this.getClass().getSimpleName(), getTestMethodName(), e.getMessage());
162+
System.out.printf("This test requires symlinks files in '%s' directory.%n", symlinksDirectory.getPath());
164163
System.out.println("On some OS (like Windows 10), files are present only if the clone/checkout is done"
165164
+ " in administrator mode, and correct (symlinks and not flat file/directory)"
166165
+ " if symlinks option are used (for git: git clone -c core.symlinks=true [url])");
@@ -174,7 +173,7 @@ private boolean checkTestFilesSymlinks() {
174173
* @throws java.io.IOException if any.
175174
*/
176175
@Test
177-
public void testGeneral() throws IOException {
176+
void general() throws IOException {
178177
this.createTestFiles();
179178

180179
String includes = "scanner1.dat,scanner2.dat,scanner3.dat,scanner4.dat,scanner5.dat";
@@ -194,7 +193,7 @@ public void testGeneral() throws IOException {
194193
* @throws java.io.IOException if any.
195194
*/
196195
@Test
197-
public void testIncludesExcludesWithWhiteSpaces() throws IOException {
196+
void includesExcludesWithWhiteSpaces() throws IOException {
198197
this.createTestFiles();
199198

200199
String includes = "scanner1.dat,\n \n,scanner2.dat \n\r, scanner3.dat\n, \tscanner4.dat,scanner5.dat\n,";
@@ -213,7 +212,7 @@ public void testIncludesExcludesWithWhiteSpaces() throws IOException {
213212
* <p>testFollowSymlinksFalse.</p>
214213
*/
215214
@Test
216-
public void testFollowSymlinksFalse() {
215+
void followSymlinksFalse() {
217216
assumeTrue(checkTestFilesSymlinks());
218217

219218
DirectoryScanner ds = new DirectoryScanner();
@@ -248,7 +247,7 @@ private void assertAlwaysIncluded(List<String> included) {
248247
* <p>testFollowSymlinks.</p>
249248
*/
250249
@Test
251-
public void testFollowSymlinks() {
250+
void followSymlinks() {
252251
assumeTrue(checkTestFilesSymlinks());
253252

254253
DirectoryScanner ds = new DirectoryScanner();
@@ -295,7 +294,7 @@ private void createTestDirectories() throws IOException {
295294
* @throws java.io.IOException if any.
296295
*/
297296
@Test
298-
public void testDirectoriesWithHyphens() throws IOException {
297+
void directoriesWithHyphens() throws IOException {
299298
this.createTestDirectories();
300299

301300
DirectoryScanner ds = new DirectoryScanner();
@@ -317,7 +316,7 @@ public void testDirectoriesWithHyphens() throws IOException {
317316
* @throws java.io.IOException if any.
318317
*/
319318
@Test
320-
public void testAntExcludesOverrideIncludes() throws IOException {
319+
void antExcludesOverrideIncludes() throws IOException {
321320
printTestHeader();
322321

323322
File dir = new File(testDir, "regex-dir");
@@ -354,8 +353,8 @@ public void testAntExcludesOverrideIncludes() throws IOException {
354353
*
355354
* @throws java.io.IOException if any.
356355
*/
357-
@org.junit.jupiter.api.Test
358-
public void testAntExcludesOverrideIncludesWithExplicitAntPrefix() throws IOException {
356+
@Test
357+
void antExcludesOverrideIncludesWithExplicitAntPrefix() throws IOException {
359358
printTestHeader();
360359

361360
File dir = new File(testDir, "regex-dir");
@@ -393,8 +392,8 @@ public void testAntExcludesOverrideIncludesWithExplicitAntPrefix() throws IOExce
393392
*
394393
* @throws java.io.IOException if any.
395394
*/
396-
@org.junit.jupiter.api.Test
397-
public void testRegexIncludeWithExcludedPrefixDirs() throws IOException {
395+
@Test
396+
void regexIncludeWithExcludedPrefixDirs() throws IOException {
398397
printTestHeader();
399398

400399
File dir = new File(testDir, "regex-dir");
@@ -427,14 +426,14 @@ public void testRegexIncludeWithExcludedPrefixDirs() throws IOException {
427426
*
428427
* @throws java.io.IOException if any.
429428
*/
430-
@org.junit.jupiter.api.Test
431-
public void testRegexExcludeWithNegativeLookahead() throws IOException {
429+
@Test
430+
void regexExcludeWithNegativeLookahead() throws IOException {
432431
printTestHeader();
433432

434433
File dir = new File(testDir, "regex-dir");
435434
try {
436435
FileUtils.deleteDirectory(dir);
437-
} catch (IOException e) {
436+
} catch (IOException ignored) {
438437
}
439438

440439
dir.mkdirs();
@@ -467,13 +466,13 @@ public void testRegexExcludeWithNegativeLookahead() throws IOException {
467466
* @throws java.io.IOException if any.
468467
*/
469468
@Test
470-
public void testRegexWithSlashInsideCharacterClass() throws IOException {
469+
void regexWithSlashInsideCharacterClass() throws IOException {
471470
printTestHeader();
472471

473472
File dir = new File(testDir, "regex-dir");
474473
try {
475474
FileUtils.deleteDirectory(dir);
476-
} catch (IOException e) {
475+
} catch (IOException ignored) {
477476
}
478477

479478
dir.mkdirs();
@@ -508,7 +507,7 @@ public void testRegexWithSlashInsideCharacterClass() throws IOException {
508507
* @throws java.io.IOException if occurs an I/O error.
509508
*/
510509
@Test
511-
public void testDoNotScanUnnecesaryDirectories() throws IOException {
510+
void doNotScanUnnecesaryDirectories() throws IOException {
512511
createTestDirectories();
513512

514513
// create additional directories 'anotherDir1', 'anotherDir2' and 'anotherDir3' with a 'file1.dat' file
@@ -547,7 +546,7 @@ public void testDoNotScanUnnecesaryDirectories() throws IOException {
547546
"directoryTest" + File.separator + "test-dir-123" + File.separator + "file1.dat"
548547
};
549548

550-
final Set<String> scannedDirSet = new HashSet<String>();
549+
final Set<String> scannedDirSet = new HashSet<>();
551550

552551
DirectoryScanner ds = new DirectoryScanner() {
553552
@Override
@@ -566,7 +565,7 @@ protected void scandir(File dir, String vpath, boolean fast) {
566565
assertInclusionsAndExclusions(ds.getIncludedFiles(), excludedPaths, includedPaths);
567566

568567
Set<String> expectedScannedDirSet =
569-
new HashSet<String>(Arrays.asList("io", "directoryTest", "testDir123", "test_dir_123", "test-dir-123"));
568+
new HashSet<>(Arrays.asList("io", "directoryTest", "testDir123", "test_dir_123", "test-dir-123"));
570569

571570
assertEquals(expectedScannedDirSet, scannedDirSet);
572571
}
@@ -577,7 +576,7 @@ protected void scandir(File dir, String vpath, boolean fast) {
577576
* @throws java.io.IOException if any.
578577
*/
579578
@Test
580-
public void testIsSymbolicLink() throws IOException {
579+
void isSymbolicLink() throws IOException {
581580
assumeTrue(checkTestFilesSymlinks());
582581

583582
final File directory = new File("src/test/resources/symlinks/src");
@@ -594,7 +593,7 @@ public void testIsSymbolicLink() throws IOException {
594593
* @throws java.io.IOException if any.
595594
*/
596595
@Test
597-
public void testIsParentSymbolicLink() throws IOException {
596+
void isParentSymbolicLink() throws IOException {
598597
assumeTrue(checkTestFilesSymlinks());
599598

600599
final File directory = new File("src/test/resources/symlinks/src");
@@ -622,7 +621,7 @@ private void assertInclusionsAndExclusions(String[] files, String[] excludedPath
622621
System.out.println(file);
623622
}
624623

625-
List<String> failedToExclude = new ArrayList<String>();
624+
List<String> failedToExclude = new ArrayList<>();
626625
for (String excludedPath : excludedPaths) {
627626
String alt = excludedPath.replace('/', '\\');
628627
System.out.println("Searching for exclusion as: " + excludedPath + "\nor: " + alt);
@@ -631,7 +630,7 @@ private void assertInclusionsAndExclusions(String[] files, String[] excludedPath
631630
}
632631
}
633632

634-
List<String> failedToInclude = new ArrayList<String>();
633+
List<String> failedToInclude = new ArrayList<>();
635634
for (String includedPath : includedPaths) {
636635
String alt = includedPath.replace('/', '\\');
637636
System.out.println("Searching for inclusion as: " + includedPath + "\nor: " + alt);

src/test/java/org/codehaus/plexus/util/DirectoryWalkerTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@
3131
* @version $Id: $Id
3232
* @since 3.4.0
3333
*/
34-
public class DirectoryWalkerTest {
34+
class DirectoryWalkerTest {
3535
/**
3636
* <p>testDirectoryWalk.</p>
3737
*/
3838
@Test
39-
public void testDirectoryWalk() {
39+
void directoryWalk() {
4040
DirectoryWalker walker = new DirectoryWalker();
4141

4242
walker.addSCMExcludes();

0 commit comments

Comments
 (0)