From 17893241076ecddda76ea372fb47edaa4130517c Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Mon, 17 Apr 2023 11:00:42 +0200 Subject: [PATCH] Switch to junit 5 --- pom.xml | 6 +- .../plexus/util/CollectionUtilsTest.java | 14 +- .../plexus/util/DirectoryScannerTest.java | 48 ++--- .../plexus/util/DirectoryWalkerTest.java | 22 +- .../plexus/util/FileBasedTestCase.java | 90 +++----- .../codehaus/plexus/util/FileUtilsTest.java | 194 +++++++++--------- .../org/codehaus/plexus/util/IOUtilTest.java | 91 +++----- .../util/InterpolationFilterReaderTest.java | 6 +- .../LineOrientedInterpolatingReaderTest.java | 18 +- .../plexus/util/MatchPatternTest.java | 8 +- .../plexus/util/MatchPatternsTest.java | 6 +- .../java/org/codehaus/plexus/util/OsTest.java | 10 +- .../codehaus/plexus/util/PathToolTest.java | 8 +- .../org/codehaus/plexus/util/PerfTest.java | 2 +- .../plexus/util/ReflectionUtilsTest.java | 6 +- .../plexus/util/SelectorUtilsTest.java | 10 +- .../plexus/util/StringInputStreamTest.java | 37 ---- .../codehaus/plexus/util/StringUtilsTest.java | 34 +-- .../codehaus/plexus/util/SweeperPoolTest.java | 46 ++--- .../plexus/util/cli/CommandLineUtilsTest.java | 10 +- .../plexus/util/cli/CommandlineTest.java | 31 ++- .../plexus/util/cli/DefaultConsumerTest.java | 2 +- .../util/cli/EnhancedStringTokenizerTest.java | 75 +++---- .../plexus/util/cli/StreamPumperTest.java | 14 +- .../util/cli/shell/BourneShellTest.java | 10 +- .../util/dag/CycleDetectedExceptionTest.java | 6 +- .../plexus/util/dag/CycleDetectorTest.java | 60 +++--- .../org/codehaus/plexus/util/dag/DAGTest.java | 8 +- .../util/dag/TopologicalSorterTest.java | 12 +- .../codehaus/plexus/util/dag/VertexTest.java | 4 +- .../ReflectionValueExtractorTest.java | 22 +- .../util/io/CachingOutputStreamTest.java | 16 +- .../plexus/util/io/CachingWriterTest.java | 14 +- .../plexus/util/reflection/ReflectorTest.java | 10 +- 34 files changed, 428 insertions(+), 522 deletions(-) delete mode 100644 src/test/java/org/codehaus/plexus/util/StringInputStreamTest.java diff --git a/pom.xml b/pom.xml index ff239a69..d922aa9f 100644 --- a/pom.xml +++ b/pom.xml @@ -62,9 +62,9 @@ limitations under the License. true - junit - junit - 4.13.2 + org.junit.jupiter + junit-jupiter + 5.9.2 test diff --git a/src/test/java/org/codehaus/plexus/util/CollectionUtilsTest.java b/src/test/java/org/codehaus/plexus/util/CollectionUtilsTest.java index 70add088..edd76231 100644 --- a/src/test/java/org/codehaus/plexus/util/CollectionUtilsTest.java +++ b/src/test/java/org/codehaus/plexus/util/CollectionUtilsTest.java @@ -16,9 +16,9 @@ * limitations under the License. */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import java.util.ArrayList; import java.util.HashMap; @@ -26,7 +26,7 @@ import java.util.Map; import java.util.Properties; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** *

CollectionUtilsTest class.

@@ -135,7 +135,7 @@ public void testMergeMapArray() /** *

testMavenPropertiesLoading.

*/ - @Test + @org.junit.jupiter.api.Test public void testMavenPropertiesLoading() { // Mimic MavenSession properties loading. Properties listed @@ -195,7 +195,7 @@ public void testMavenPropertiesLoading() /** *

testIteratorToListWithAPopulatedList.

*/ - @Test + @org.junit.jupiter.api.Test public void testIteratorToListWithAPopulatedList() { List original = new ArrayList(); @@ -218,7 +218,7 @@ public void testIteratorToListWithAPopulatedList() /** *

testIteratorToListWithAEmptyList.

*/ - @Test + @org.junit.jupiter.api.Test public void testIteratorToListWithAEmptyList() { List original = new ArrayList(); diff --git a/src/test/java/org/codehaus/plexus/util/DirectoryScannerTest.java b/src/test/java/org/codehaus/plexus/util/DirectoryScannerTest.java index 86c6dd20..3901e594 100644 --- a/src/test/java/org/codehaus/plexus/util/DirectoryScannerTest.java +++ b/src/test/java/org/codehaus/plexus/util/DirectoryScannerTest.java @@ -16,11 +16,11 @@ * limitations under the License. */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.io.File; import java.io.IOException; @@ -35,10 +35,8 @@ import java.util.List; import java.util.Set; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestName; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Base class for testcases doing tests with files. @@ -50,15 +48,12 @@ public class DirectoryScannerTest extends FileBasedTestCase { - @Rule - public TestName name = new TestName(); - private static String testDir = getTestDirectory().getPath(); /** *

setUp.

*/ - @Before + @BeforeEach public void setUp() { try @@ -190,7 +185,7 @@ private boolean checkTestFilesSymlinks() catch ( IOException e ) { System.err.println( String.format( "The unit test '%s.%s' will be skipped, reason: %s", - this.getClass().getSimpleName(), name.getMethodName(), + this.getClass().getSimpleName(), getTestMethodName(), e.getMessage() ) ); System.out.println( String.format( "This test requires symlinks files in '%s' directory.", symlinksDirectory.getPath() ) ); @@ -217,11 +212,10 @@ public void testGeneral() List fileNames = FileUtils.getFiles( new File( testDir ), includes, excludes, false ); - assertEquals( "Wrong number of results.", 3, fileNames.size() ); - assertTrue( "3 not found.", fileNames.contains( new File( "scanner3.dat" ) ) ); - assertTrue( "4 not found.", fileNames.contains( new File( "scanner4.dat" ) ) ); - assertTrue( "5 not found.", fileNames.contains( new File( "scanner5.dat" ) ) ); - + assertEquals( 3, fileNames.size(), "Wrong number of results." ); + assertTrue( fileNames.contains( new File( "scanner3.dat" ) ), "3 not found." ); + assertTrue( fileNames.contains( new File( "scanner4.dat" ) ), "4 not found." ); + assertTrue( fileNames.contains( new File( "scanner5.dat" ) ), "5 not found." ); } /** @@ -241,10 +235,10 @@ public void testIncludesExcludesWithWhiteSpaces() List fileNames = FileUtils.getFiles( new File( testDir ), includes, excludes, false ); - assertEquals( "Wrong number of results.", 3, fileNames.size() ); - assertTrue( "3 not found.", fileNames.contains( new File( "scanner3.dat" ) ) ); - assertTrue( "4 not found.", fileNames.contains( new File( "scanner4.dat" ) ) ); - assertTrue( "5 not found.", fileNames.contains( new File( "scanner5.dat" ) ) ); + assertEquals( 3, fileNames.size(), "Wrong number of results." ); + assertTrue( fileNames.contains( new File( "scanner3.dat" ) ), "3 not found." ); + assertTrue( fileNames.contains( new File( "scanner4.dat" ) ), "4 not found." ); + assertTrue( fileNames.contains( new File( "scanner5.dat" ) ), "5 not found." ); } /** @@ -347,7 +341,7 @@ public void testDirectoriesWithHyphens() ds.scan(); String[] files = ds.getIncludedFiles(); - assertEquals( "Wrong number of results.", 3, files.length ); + assertEquals( 3, files.length, "Wrong number of results." ); } /** @@ -395,7 +389,7 @@ public void testAntExcludesOverrideIncludes() * * @throws java.io.IOException if any. */ - @Test + @org.junit.jupiter.api.Test public void testAntExcludesOverrideIncludesWithExplicitAntPrefix() throws IOException { @@ -436,7 +430,7 @@ public void testAntExcludesOverrideIncludesWithExplicitAntPrefix() * * @throws java.io.IOException if any. */ - @Test + @org.junit.jupiter.api.Test public void testRegexIncludeWithExcludedPrefixDirs() throws IOException { @@ -472,7 +466,7 @@ public void testRegexIncludeWithExcludedPrefixDirs() * * @throws java.io.IOException if any. */ - @Test + @org.junit.jupiter.api.Test public void testRegexExcludeWithNegativeLookahead() throws IOException { diff --git a/src/test/java/org/codehaus/plexus/util/DirectoryWalkerTest.java b/src/test/java/org/codehaus/plexus/util/DirectoryWalkerTest.java index 757ce718..da925818 100644 --- a/src/test/java/org/codehaus/plexus/util/DirectoryWalkerTest.java +++ b/src/test/java/org/codehaus/plexus/util/DirectoryWalkerTest.java @@ -16,13 +16,13 @@ * limitations under the License. */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; -import java.io.File; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.Test; +import java.io.File; /** *

DirectoryWalkerTest class.

@@ -50,11 +50,11 @@ public void testDirectoryWalk() walker.scan(); - assertEquals( "Walk Collector / Starting Count", 1, collector.startCount ); - assertNotNull( "Walk Collector / Starting Dir", collector.startingDir ); - assertEquals( "Walk Collector / Finish Count", 1, collector.finishCount ); - assertEquals( "Walk Collector / Steps Count", 4, collector.steps.size() ); - assertTrue( "Walk Collector / percentage low >= 0", collector.percentageLow >= 0 ); - assertTrue( "Walk Collector / percentage high <= 100", collector.percentageHigh <= 100 ); + assertEquals( 1, collector.startCount, "Walk Collector / Starting Count" ); + assertNotNull( collector.startingDir, "Walk Collector / Starting Dir" ); + assertEquals( 1, collector.finishCount, "Walk Collector / Finish Count" ); + assertEquals( 4, collector.steps.size(), "Walk Collector / Steps Count" ); + assertTrue( collector.percentageLow >= 0, "Walk Collector / percentage low >= 0" ); + assertTrue( collector.percentageHigh <= 100, "Walk Collector / percentage high <= 100" ); } } diff --git a/src/test/java/org/codehaus/plexus/util/FileBasedTestCase.java b/src/test/java/org/codehaus/plexus/util/FileBasedTestCase.java index 3e111b4e..ac592e66 100644 --- a/src/test/java/org/codehaus/plexus/util/FileBasedTestCase.java +++ b/src/test/java/org/codehaus/plexus/util/FileBasedTestCase.java @@ -16,7 +16,13 @@ * limitations under the License. */ -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.TestInfo; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.io.BufferedOutputStream; import java.io.ByteArrayOutputStream; @@ -27,11 +33,10 @@ import java.io.PrintStream; import java.io.PrintWriter; import java.io.Writer; +import java.lang.reflect.Method; import java.nio.file.Files; import java.util.Arrays; -import junit.framework.AssertionFailedError; - /** * Base class for testcases doing tests with files. * @@ -43,6 +48,8 @@ public abstract class FileBasedTestCase { private static File testDir; + private TestInfo testInfo; + /** *

getTestDirectory.

* @@ -186,7 +193,7 @@ protected File newFile( String filename ) protected void checkFile( final File file, final File referenceFile ) throws Exception { - assertTrue( "Check existence of output file", file.exists() ); + assertTrue( file.exists(), "Check existence of output file" ); assertEqualContent( referenceFile, file ); } @@ -205,7 +212,7 @@ protected void checkWrite( final OutputStream output ) } catch ( final Throwable t ) { - throw new AssertionFailedError( "The copy() method closed the stream " + "when it shouldn't have. " + fail( "The copy() method closed the stream " + "when it shouldn't have. " + t.getMessage() ); } } @@ -225,7 +232,7 @@ protected void checkWrite( final Writer output ) } catch ( final Throwable t ) { - throw new AssertionFailedError( "The copy() method closed the stream " + "when it shouldn't have. " + fail( "The copy() method closed the stream " + "when it shouldn't have. " + t.getMessage() ); } } @@ -241,7 +248,7 @@ protected void deleteFile( final File file ) { if ( file.exists() ) { - assertTrue( "Couldn't delete file: " + file, file.delete() ); + assertTrue( file.delete(), "Couldn't delete file: " + file ); } } @@ -258,37 +265,10 @@ private void assertEqualContent( final File f0, final File f1 ) * + " and " + f1 + " have differing file sizes (" + f0.length() + " vs " + f1.length() + ")", ( f0.length() == * f1.length() ) ); */ - final InputStream is0 = Files.newInputStream( f0.toPath() ); - try - { - final InputStream is1 = Files.newInputStream( f1.toPath() ); - try - { - final byte[] buf0 = new byte[1024]; - final byte[] buf1 = new byte[1024]; - int n0 = 0; - int n1 = 0; - - while ( -1 != n0 ) - { - n0 = is0.read( buf0 ); - n1 = is1.read( buf1 ); - assertTrue( "The files " + f0 + " and " + f1 + " have differing number of bytes available (" + n0 - + " vs " + n1 + ")", ( n0 == n1 ) ); - - assertTrue( "The files " + f0 + " and " + f1 + " have different content", - Arrays.equals( buf0, buf1 ) ); - } - } - finally - { - is1.close(); - } - } - finally - { - is0.close(); - } + byte[] buf0 = Files.readAllBytes( f0.toPath() ); + byte[] buf1 = Files.readAllBytes( f0.toPath() ); + assertArrayEquals( buf0, buf1, + "The files " + f0 + " and " + f1 + " have different content" ); } /** @@ -301,20 +281,8 @@ private void assertEqualContent( final File f0, final File f1 ) protected void assertEqualContent( final byte[] b0, final File file ) throws IOException { - final InputStream is = Files.newInputStream( file.toPath() ); - try - { - byte[] b1 = new byte[b0.length]; - int numRead = is.read( b1 ); - assertTrue( "Different number of bytes", numRead == b0.length && is.available() == 0 ); - for ( int i = 0; i < numRead; assertTrue( "Byte " + i + " differs (" + b0[i] + " != " + b1[i] + ")", - b0[i] == b1[i] ), i++ ) - ; - } - finally - { - is.close(); - } + byte[] b1 = Files.readAllBytes( file.toPath() ); + assertArrayEquals(b0, b1, "Content differs"); } /** @@ -324,9 +292,9 @@ protected void assertEqualContent( final byte[] b0, final File file ) */ protected void assertIsDirectory( File file ) { - assertTrue( "The File doesn't exists: " + file.getAbsolutePath(), file.exists() ); + assertTrue( file.exists(), "The File doesn't exists: " + file.getAbsolutePath() ); - assertTrue( "The File isn't a directory: " + file.getAbsolutePath(), file.isDirectory() ); + assertTrue( file.isDirectory(), "The File isn't a directory: " + file.getAbsolutePath() ); } /** @@ -336,8 +304,18 @@ protected void assertIsDirectory( File file ) */ protected void assertIsFile( File file ) { - assertTrue( "The File doesn't exists: " + file.getAbsolutePath(), file.exists() ); + assertTrue( file.exists(), "The File doesn't exists: " + file.getAbsolutePath() ); + + assertTrue( file.isFile(), "The File isn't a file: " + file.getAbsolutePath() ); + } - assertTrue( "The File isn't a file: " + file.getAbsolutePath(), file.isFile() ); + @BeforeEach + void init(TestInfo testInfo) { + this.testInfo = testInfo; } + + protected String getTestMethodName() { + return testInfo.getTestMethod().map(Method::getName).orElse(null); + } + } diff --git a/src/test/java/org/codehaus/plexus/util/FileUtilsTest.java b/src/test/java/org/codehaus/plexus/util/FileUtilsTest.java index 4d63957c..5c106088 100644 --- a/src/test/java/org/codehaus/plexus/util/FileUtilsTest.java +++ b/src/test/java/org/codehaus/plexus/util/FileUtilsTest.java @@ -16,12 +16,12 @@ * limitations under the License. */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.io.ByteArrayInputStream; import java.io.File; @@ -36,10 +36,8 @@ import java.nio.file.Paths; import java.util.Properties; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestName; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * This is used to test FileUtils for correctness. @@ -53,9 +51,6 @@ public final class FileUtilsTest extends FileBasedTestCase { - @Rule - public TestName name = new TestName(); - // Test data /** @@ -91,7 +86,7 @@ public FileUtilsTest() * * @throws java.lang.Exception if any. */ - @Before + @BeforeEach public void setUp() throws Exception { @@ -187,8 +182,9 @@ public void testToURLs() URL[] urls = FileUtils.toURLs( files ); - assertEquals( "The length of the generated URL's is not equals to the length of files. " + "Was " + files.length - + ", expected " + urls.length, files.length, urls.length ); + assertEquals( files.length, urls.length, + "The length of the generated URL's is not equals to the length of files. " + "Was " + files.length + + ", expected " + urls.length ); for ( int i = 0; i < urls.length; i++ ) { @@ -258,7 +254,7 @@ public void testContentEquals() throws Exception { // Non-existent files - final File file = new File( getTestDirectory(), name.getMethodName() ); + final File file = new File( getTestDirectory(), getTestMethodName() ); assertTrue( FileUtils.contentEquals( file, file ) ); // TODO Should comparing 2 directories throw an Exception instead of returning false? @@ -266,15 +262,15 @@ public void testContentEquals() assertTrue( !FileUtils.contentEquals( getTestDirectory(), getTestDirectory() ) ); // Different files - final File objFile1 = new File( getTestDirectory(), name.getMethodName() + ".object" ); + final File objFile1 = new File( getTestDirectory(), getTestMethodName() + ".object" ); objFile1.deleteOnExit(); FileUtils.copyURLToFile( getClass().getResource( "/java/lang/Object.class" ), objFile1 ); - final File objFile2 = new File( getTestDirectory(), name.getMethodName() + ".collection" ); + final File objFile2 = new File( getTestDirectory(), getTestMethodName() + ".collection" ); objFile2.deleteOnExit(); FileUtils.copyURLToFile( getClass().getResource( "/java/util/Collection.class" ), objFile2 ); - assertTrue( "Files should not be equal.", !FileUtils.contentEquals( objFile1, objFile2 ) ); + assertTrue( !FileUtils.contentEquals( objFile1, objFile2 ), "Files should not be equal." ); // Equal files file.createNewFile(); @@ -290,8 +286,8 @@ public void testContentEquals() public void testRemovePath() { final String fileName = - FileUtils.removePath( new File( getTestDirectory(), name.getMethodName() ).getAbsolutePath() ); - assertEquals( name.getMethodName(), fileName ); + FileUtils.removePath( new File( getTestDirectory(), getTestMethodName() ).getAbsolutePath() ); + assertEquals( getTestMethodName(), fileName ); } // getPath @@ -303,7 +299,7 @@ public void testRemovePath() public void testGetPath() { final String fileName = - FileUtils.getPath( new File( getTestDirectory(), name.getMethodName() ).getAbsolutePath() ); + FileUtils.getPath( new File( getTestDirectory(), getTestMethodName() ).getAbsolutePath() ); assertEquals( getTestDirectory().getAbsolutePath(), fileName ); } @@ -319,7 +315,7 @@ public void testCopyURLToFile() throws Exception { // Creates file - final File file = new File( getTestDirectory(), name.getMethodName() ); + final File file = new File( getTestDirectory(), getTestMethodName() ); file.deleteOnExit(); // Loads resource @@ -330,8 +326,8 @@ public void testCopyURLToFile() final InputStream fis = Files.newInputStream( file.toPath() ); try { - assertTrue( "Content is not equal.", - IOUtil.contentEquals( getClass().getResourceAsStream( resourceName ), fis ) ); + assertTrue( IOUtil.contentEquals( getClass().getResourceAsStream( resourceName ), fis ), + "Content is not equal."); } finally { @@ -370,10 +366,10 @@ public void testForceMkdir() FileUtils.forceMkdir( getTestDirectory() ); // Creates test file - final File testFile = new File( getTestDirectory(), name.getMethodName() ); + final File testFile = new File( getTestDirectory(), getTestMethodName() ); testFile.deleteOnExit(); testFile.createNewFile(); - assertTrue( "Test file does not exist.", testFile.exists() ); + assertTrue( testFile.exists(), "Test file does not exist." ); // Tests with existing file try @@ -389,7 +385,7 @@ public void testForceMkdir() // Tests with non-existent directory FileUtils.forceMkdir( testFile ); - assertTrue( "Directory was not created.", testFile.exists() ); + assertTrue( testFile.exists(), "Directory was not created." ); if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) { @@ -418,7 +414,7 @@ public void testForceMkdir() public void testSizeOfDirectory() throws Exception { - final File file = new File( getTestDirectory(), name.getMethodName() ); + final File file = new File( getTestDirectory(), getTestMethodName() ); // Non-existent file try @@ -448,7 +444,7 @@ public void testSizeOfDirectory() file.delete(); file.mkdir(); - assertEquals( "Unexpected directory size", TEST_DIRECTORY_SIZE, FileUtils.sizeOfDirectory( file ) ); + assertEquals( TEST_DIRECTORY_SIZE, FileUtils.sizeOfDirectory( file ), "Unexpected directory size" ); } // isFileNewer @@ -474,8 +470,8 @@ public void testCopyFile1() { final File destination = new File( getTestDirectory(), "copy1.txt" ); FileUtils.copyFile( testFile1, destination ); - assertTrue( "Check Exist", destination.exists() ); - assertTrue( "Check Full copy", destination.length() == testFile1Size ); + assertTrue( destination.exists(), "Check Exist" ); + assertTrue( destination.length() == testFile1Size, "Check Full copy" ); } /** @@ -489,8 +485,8 @@ public void testCopyFile2() { final File destination = new File( getTestDirectory(), "copy2.txt" ); FileUtils.copyFile( testFile1, destination ); - assertTrue( "Check Exist", destination.exists() ); - assertTrue( "Check Full copy", destination.length() == testFile2Size ); + assertTrue( destination.exists(), "Check Exist" ); + assertTrue( destination.length() == testFile2Size, "Check Full copy" ); } /** @@ -509,8 +505,8 @@ public void testCopyFile3() } final File destination = new File( destDirectory, "copy2.txt" ); FileUtils.copyFile( testFile1, destination ); - assertTrue( "Check Exist", destination.exists() ); - assertTrue( "Check Full copy", destination.length() == testFile2Size ); + assertTrue( destination.exists(), "Check Exist" ); + assertTrue( destination.length() == testFile2Size, "Check Full copy" ); } // linkFile @@ -525,9 +521,9 @@ public void testLinkFile1() { final File destination = new File( getTestDirectory(), "link1.txt" ); FileUtils.linkFile( testFile1, destination ); - assertTrue( "Check Exist", destination.exists() ); - assertTrue( "Check File length", destination.length() == testFile1Size ); - assertTrue( "Check is link", Files.isSymbolicLink(destination.toPath())); + assertTrue( destination.exists(), "Check Exist" ); + assertTrue( destination.length() == testFile1Size, "Check File length" ); + assertTrue( Files.isSymbolicLink(destination.toPath()), "Check is link" ); } /** @@ -541,9 +537,9 @@ public void testLinkFile2() { final File destination = new File( getTestDirectory(), "link2.txt" ); FileUtils.linkFile( testFile1, destination ); - assertTrue( "Check Exist", destination.exists() ); - assertTrue( "Check File length", destination.length() == testFile2Size ); - assertTrue( "Check is link", Files.isSymbolicLink(destination.toPath())); + assertTrue( destination.exists(), "Check Exist" ); + assertTrue( destination.length() == testFile2Size, "Check File length" ); + assertTrue( Files.isSymbolicLink(destination.toPath()), "Check is link" ); } /** @@ -562,9 +558,9 @@ public void testLinkFile3() } final File destination = new File( destDirectory, "link2.txt" ); FileUtils.linkFile( testFile1, destination ); - assertTrue( "Check Exist", destination.exists() ); - assertTrue( "Check File length", destination.length() == testFile2Size ); - assertTrue( "Check is link", Files.isSymbolicLink(destination.toPath())); + assertTrue( destination.exists(), "Check Exist" ); + assertTrue( destination.length() == testFile2Size, "Check File length" ); + assertTrue( Files.isSymbolicLink(destination.toPath()), "Check is link" ); } // copyFileIfModified @@ -593,8 +589,8 @@ public void testCopyIfModifiedWhenSourceIsNewer() source.setLastModified( System.currentTimeMillis() ); // Copy will occur when source is newer - assertTrue( "Failed copy. Target file should have been updated.", - FileUtils.copyFileIfModified( source, destination ) ); + assertTrue( FileUtils.copyFileIfModified( source, destination ), + "Failed copy. Target file should have been updated." ); } /** @@ -620,7 +616,8 @@ public void testCopyIfModifiedWhenSourceIsOlder() FileUtils.copyFile( testFile1, destination ); // Copy will occur when destination is newer - assertFalse( "Source file should not have been copied.", FileUtils.copyFileIfModified( source, destination ) ); + assertFalse( FileUtils.copyFileIfModified( source, destination ), + "Source file should not have been copied." ); } /** @@ -643,7 +640,8 @@ public void testCopyIfModifiedWhenSourceHasZeroDate() File destination = new File( getTestDirectory(), "temp/copy1.txt" ); // Should copy the source to the non existing destination. - assertTrue( "Source file should have been copied.", FileUtils.copyFileIfModified( source, destination ) ); + assertTrue( FileUtils.copyFileIfModified( source, destination ), + "Source file should have been copied." ); } // forceDelete @@ -659,9 +657,9 @@ public void testForceDeleteAFile1() { final File destination = new File( getTestDirectory(), "copy1.txt" ); destination.createNewFile(); - assertTrue( "Copy1.txt doesn't exist to delete", destination.exists() ); + assertTrue( destination.exists(), "Copy1.txt doesn't exist to delete" ); FileUtils.forceDelete( destination ); - assertTrue( "Check No Exist", !destination.exists() ); + assertTrue( !destination.exists(), "Check No Exist" ); } /** @@ -675,9 +673,9 @@ public void testForceDeleteAFile2() { final File destination = new File( getTestDirectory(), "copy2.txt" ); destination.createNewFile(); - assertTrue( "Copy2.txt doesn't exist to delete", destination.exists() ); + assertTrue( destination.exists(), "Copy2.txt doesn't exist to delete" ); FileUtils.forceDelete( destination ); - assertTrue( "Check No Exist", !destination.exists() ); + assertTrue( !destination.exists(), "Check No Exist" ); } // copyFileToDirectory @@ -698,8 +696,8 @@ public void testCopyFile1ToDir() } final File destination = new File( directory, testFile1.getName() ); FileUtils.copyFileToDirectory( testFile1, directory ); - assertTrue( "Check Exist", destination.exists() ); - assertTrue( "Check Full copy", destination.length() == testFile1Size ); + assertTrue( destination.exists(), "Check Exist" ); + assertTrue( destination.length() == testFile1Size, "Check Full copy" ); } /** @@ -718,8 +716,8 @@ public void testCopyFile2ToDir() } final File destination = new File( directory, testFile1.getName() ); FileUtils.copyFileToDirectory( testFile1, directory ); - assertTrue( "Check Exist", destination.exists() ); - assertTrue( "Check Full copy", destination.length() == testFile2Size ); + assertTrue( destination.exists(), "Check Exist" ); + assertTrue( destination.length() == testFile2Size, "Check Full copy" ); } // copyFileToDirectoryIfModified @@ -747,12 +745,12 @@ public void testCopyFile1ToDirIfModified() final File target = new File( getTestDirectory() + "/subdir", testFile1.getName() ); long timestamp = target.lastModified(); - assertTrue( "Check Exist", destination.exists() ); - assertTrue( "Check Full copy", destination.length() == testFile1Size ); + assertTrue( destination.exists(), "Check Exist" ); + assertTrue( destination.length() == testFile1Size, "Check Full copy" ); FileUtils.copyFileToDirectoryIfModified( testFile1, directory ); - assertTrue( "Timestamp was changed", timestamp == target.lastModified() ); + assertTrue( timestamp == target.lastModified(), "Timestamp was changed" ); } /** @@ -778,12 +776,12 @@ public void testCopyFile2ToDirIfModified() final File target = new File( getTestDirectory() + "/subdir", testFile2.getName() ); long timestamp = target.lastModified(); - assertTrue( "Check Exist", destination.exists() ); - assertTrue( "Check Full copy", destination.length() == testFile2Size ); + assertTrue( destination.exists(), "Check Exist" ); + assertTrue( destination.length() == testFile2Size, "Check Full copy" ); FileUtils.copyFileToDirectoryIfModified( testFile2, directory ); - assertTrue( "Timestamp was changed", timestamp == target.lastModified() ); + assertTrue( timestamp == target.lastModified(), "Timestamp was changed" ); } // forceDelete @@ -793,12 +791,12 @@ public void testCopyFile2ToDirIfModified() * * @throws java.lang.Exception if any. */ - @Test + @org.junit.jupiter.api.Test public void testForceDeleteDir() throws Exception { FileUtils.forceDelete( getTestDirectory().getParentFile() ); - assertTrue( "Check No Exist", !getTestDirectory().getParentFile().exists() ); + assertTrue( !getTestDirectory().getParentFile().exists(), "Check No Exist" ); } // resolveFile @@ -813,7 +811,7 @@ public void testResolveFileDotDot() throws Exception { final File file = FileUtils.resolveFile( getTestDirectory(), ".." ); - assertEquals( "Check .. operator", file, getTestDirectory().getParentFile() ); + assertEquals( file, getTestDirectory().getParentFile(), "Check .. operator" ); } /** @@ -826,7 +824,7 @@ public void testResolveFileDot() throws Exception { final File file = FileUtils.resolveFile( getTestDirectory(), "." ); - assertEquals( "Check . operator", file, getTestDirectory() ); + assertEquals( file, getTestDirectory(), "Check . operator" ); } // normalize @@ -847,12 +845,12 @@ public void testNormalize() final String[] dest = { "", "/", "/", "/foo", "/foo/", "/", "/foo/", "/foo/bar", "/bar", "/baz", "/baz", "/", "/bar", "/bar/", "/foo/bar", null, null }; - assertEquals( "Oops, test writer goofed", src.length, dest.length ); + assertEquals( src.length, dest.length, "Oops, test writer goofed" ); for ( int i = 0; i < src.length; i++ ) { - assertEquals( "Check if '" + src[i] + "' normalized to '" + dest[i] + "'", dest[i], - FileUtils.normalize( src[i] ) ); + assertEquals( dest[i], FileUtils.normalize( src[i] ), + "Check if '" + src[i] + "' normalized to '" + dest[i] + "'" ); } } @@ -884,32 +882,32 @@ public void testFileUtils() // Loads file from classpath final String path = "/test.txt"; final URL url = this.getClass().getResource( path ); - assertNotNull( path + " was not found.", url ); + assertNotNull( url, path + " was not found." ); final String filename = Paths.get(url.toURI()).toString(); final String filename2 = "test2.txt"; - assertTrue( "test.txt extension == \"txt\"", FileUtils.getExtension( filename ).equals( "txt" ) ); + assertTrue( FileUtils.getExtension( filename ).equals( "txt" ), "test.txt extension == \"txt\"" ); - assertTrue( "Test file does exist: " + filename, FileUtils.fileExists( filename ) ); + assertTrue( FileUtils.fileExists( filename ), "Test file does exist: " + filename ); - assertTrue( "Second test file does not exist", !FileUtils.fileExists( filename2 ) ); + assertTrue( !FileUtils.fileExists( filename2 ), "Second test file does not exist" ); FileUtils.fileWrite( filename2, filename ); - assertTrue( "Second file was written", FileUtils.fileExists( filename2 ) ); + assertTrue( FileUtils.fileExists( filename2 ), "Second file was written" ); final String file2contents = FileUtils.fileRead( filename2 ); - assertTrue( "Second file's contents correct", FileUtils.fileRead( filename2 ).equals( file2contents ) ); + assertTrue( FileUtils.fileRead( filename2 ).equals( file2contents ), "Second file's contents correct" ); FileUtils.fileAppend( filename2, filename ); - assertTrue( "Second file's contents correct", - FileUtils.fileRead( filename2 ).equals( file2contents + file2contents ) ); + assertTrue( FileUtils.fileRead( filename2 ).equals( file2contents + file2contents ), + "Second file's contents correct" ); FileUtils.fileDelete( filename2 ); - assertTrue( "Second test file does not exist", !FileUtils.fileExists( filename2 ) ); + assertTrue( !FileUtils.fileExists( filename2 ), "Second test file does not exist" ); final String contents = FileUtils.fileRead( filename ); - assertTrue( "FileUtils.fileRead()", contents.equals( "This is a test" ) ); + assertTrue( contents.equals( "This is a test" ), "FileUtils.fileRead()" ); } @@ -933,7 +931,7 @@ public void testGetExtension() /** *

testGetExtensionWithPaths.

*/ - @Test + @org.junit.jupiter.api.Test public void testGetExtensionWithPaths() { // Since the utilities are based on the separator for the platform @@ -1155,18 +1153,18 @@ public void testCopyDirectoryStructureIfModified() FileUtils.copyDirectoryStructureIfModified( from, to ); - assertTrue( "Unmodified file was overwritten", timestamps[0] == files[0].lastModified() ); - assertTrue( "Unmodified file was overwritten", timestamps[1] == files[1].lastModified() ); - assertTrue( "Unmodified file was overwritten", timestamps[2] == files[2].lastModified() ); + assertTrue( timestamps[0] == files[0].lastModified(), "Unmodified file was overwritten" ); + assertTrue( timestamps[1] == files[1].lastModified(), "Unmodified file was overwritten" ); + assertTrue( timestamps[2] == files[2].lastModified(), "Unmodified file was overwritten" ); files[1].setLastModified( f2.lastModified() - 5000L ); timestamps[1] = files[1].lastModified(); FileUtils.copyDirectoryStructureIfModified( from, to ); - assertTrue( "Unmodified file was overwritten", timestamps[0] == files[0].lastModified() ); - assertTrue( "Outdated file was not overwritten", timestamps[1] < files[1].lastModified() ); - assertTrue( "Unmodified file was overwritten", timestamps[2] == files[2].lastModified() ); + assertTrue( timestamps[0] == files[0].lastModified(), "Unmodified file was overwritten" ); + assertTrue( timestamps[1] < files[1].lastModified(), "Outdated file was not overwritten" ); + assertTrue( timestamps[2] == files[2].lastModified(), "Unmodified file was overwritten" ); } @@ -1247,7 +1245,7 @@ public Reader getReader( Reader reader ) FileUtils.fileWrite( srcFile.getAbsolutePath(), "UTF-8", "This is a test. Test ${s}\n" ); FileUtils.copyFile( srcFile, destFile, "UTF-8", wrappers1 ); - assertTrue( "Files should be equal.", FileUtils.contentEquals( compareFile, destFile ) ); + assertTrue( FileUtils.contentEquals( compareFile, destFile ), "Files should be equal." ); srcFile.delete(); destFile.delete(); @@ -1353,8 +1351,8 @@ public void testFileRead() { IOUtil.close( writer ); } - assertEquals( "testString should be equal", testString, FileUtils.fileRead( testFile ) ); - assertEquals( "testString should be equal", testString, FileUtils.fileRead( testFileName ) ); + assertEquals( testString, FileUtils.fileRead( testFile ), "testString should be equal" ); + assertEquals( testString, FileUtils.fileRead( testFileName ), "testString should be equal" ); testFile.delete(); } @@ -1383,8 +1381,8 @@ public void testFileReadWithEncoding() { IOUtil.close( writer ); } - assertEquals( "testString should be equal", testString, FileUtils.fileRead( testFile, "UTF-8" ) ); - assertEquals( "testString should be equal", testString, FileUtils.fileRead( testFileName, "UTF-8" ) ); + assertEquals( testString, FileUtils.fileRead( testFile, "UTF-8" ), "testString should be equal" ); + assertEquals( testString, FileUtils.fileRead( testFileName, "UTF-8" ), "testString should be equal" ); testFile.delete(); } @@ -1575,7 +1573,7 @@ public void testExtensions() String fileName = values[i][0].replace( '/', File.separatorChar ); String ext = values[i][1]; String computed = FileUtils.extension( fileName ); - assertEquals( "case [" + i + "]:" + fileName + " -> " + ext + ", computed : " + computed, ext, computed ); + assertEquals( ext, computed, "case [" + i + "]:" + fileName + " -> " + ext + ", computed : " + computed ); } } @@ -1634,7 +1632,7 @@ public void testDeleteDirectoryWithValidFileSymlink() */ symlink.delete(); } - assertTrue( "Failed to delete test directory", !getTestDirectory().exists() ); + assertTrue( !getTestDirectory().exists(), "Failed to delete test directory" ); } /** @@ -1661,7 +1659,7 @@ public void testDeleteDirectoryWithValidDirSymlink() */ symlink.delete(); } - assertTrue( "Failed to delete test directory", !getTestDirectory().exists() ); + assertTrue( !getTestDirectory().exists(), "Failed to delete test directory" ); } /** @@ -1687,7 +1685,7 @@ public void testDeleteDirectoryWithDanglingSymlink() */ symlink.delete(); } - assertTrue( "Failed to delete test directory", !getTestDirectory().exists() ); + assertTrue( !getTestDirectory().exists(), "Failed to delete test directory" ); } /** @@ -1745,7 +1743,7 @@ public void testCreateTempFile() for ( int i = 0; i < 10; i++ ) { File current = FileUtils.createTempFile( "unique", ".tmp", null ); - assertTrue( "No unique name: " + current.getName(), !current.getName().equals( last.getName() ) ); + assertTrue( !current.getName().equals( last.getName() ), "No unique name: " + current.getName() ); last = current; } } diff --git a/src/test/java/org/codehaus/plexus/util/IOUtilTest.java b/src/test/java/org/codehaus/plexus/util/IOUtilTest.java index 4179a20e..83d2ce6e 100644 --- a/src/test/java/org/codehaus/plexus/util/IOUtilTest.java +++ b/src/test/java/org/codehaus/plexus/util/IOUtilTest.java @@ -16,9 +16,10 @@ * limitations under the License. */ -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.io.BufferedOutputStream; import java.io.File; @@ -32,8 +33,8 @@ import java.nio.file.Files; import java.util.Arrays; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * This is used to test IOUtil for correctness. The following checks are performed: @@ -67,7 +68,7 @@ public final class IOUtilTest /** *

setUp.

*/ - @Before + @BeforeEach public void setUp() { try @@ -113,51 +114,24 @@ private void createFile( File file, long size ) /** Assert that the contents of two byte arrays are the same. */ private void assertEqualContent( byte[] b0, byte[] b1 ) { - assertTrue( "Content not equal according to java.util.Arrays#equals()", Arrays.equals( b0, b1 ) ); + assertTrue( Arrays.equals( b0, b1 ), "Content not equal according to java.util.Arrays#equals()" ); } /** Assert that the content of two files is the same. */ private void assertEqualContent( File f0, File f1 ) throws IOException { - InputStream is0 = Files.newInputStream( f0.toPath() ); - InputStream is1 = Files.newInputStream( f1.toPath() ); - byte[] buf0 = new byte[FILE_SIZE]; - byte[] buf1 = new byte[FILE_SIZE]; - int n0 = 0; - int n1 = 0; - - try - { - while ( 0 <= n0 ) - { - n0 = is0.read( buf0 ); - n1 = is1.read( buf1 ); - assertTrue( "The files " + f0 + " and " + f1 + " have differing number of bytes available (" + n0 - + " vs " + n1 + ")", ( n0 == n1 ) ); - - assertTrue( "The files " + f0 + " and " + f1 + " have different content", Arrays.equals( buf0, buf1 ) ); - } - } - finally - { - is0.close(); - is1.close(); - } + byte[] buf0 = Files.readAllBytes( f0.toPath() ); + byte[] buf1 = Files.readAllBytes( f1.toPath() ); + assertArrayEquals( buf0, buf1, "The files " + f0 + " and " + f1 + " have different content" ); } /** Assert that the content of a file is equal to that in a byte[]. */ private void assertEqualContent( byte[] b0, File file ) throws IOException { - InputStream is = Files.newInputStream( file.toPath() ); - byte[] b1 = new byte[b0.length]; - int numRead = is.read( b1 ); - assertTrue( "Different number of bytes", numRead == b0.length && is.available() == 0 ); - for ( int i = 0; i < numRead; assertTrue( "Byte " + i + " differs (" + b0[i] + " != " + b1[i] + ")", - b0[i] == b1[i] ), i++ ) - ; - is.close(); + byte[] b1 = Files.readAllBytes( file.toPath() ); + assertArrayEquals(b0, b1, "Content differs"); } /** @@ -174,7 +148,7 @@ public void testInputStreamToOutputStream() OutputStream fout = Files.newOutputStream( destination.toPath() ); IOUtil.copy( fin, fout ); - assertTrue( "Not all bytes were read", fin.available() == 0 ); + assertTrue( fin.available() == 0, "Not all bytes were read" ); fout.flush(); checkFile( destination ); @@ -189,7 +163,7 @@ public void testInputStreamToOutputStream() * * @throws java.lang.Exception if any. */ - @Test + @org.junit.jupiter.api.Test public void testInputStreamToWriter() throws Exception { @@ -199,7 +173,7 @@ public void testInputStreamToWriter() IOUtil.copy( fin, fout ); - assertTrue( "Not all bytes were read", fin.available() == 0 ); + assertTrue( fin.available() == 0, "Not all bytes were read" ); fout.flush(); checkFile( destination ); @@ -221,8 +195,8 @@ public void testInputStreamToString() InputStream fin = Files.newInputStream( testFile.toPath() ); String out = IOUtil.toString( fin ); assertNotNull( out ); - assertTrue( "Not all bytes were read", fin.available() == 0 ); - assertTrue( "Wrong output size: out.length()=" + out.length() + "!=" + FILE_SIZE, out.length() == FILE_SIZE ); + assertTrue( fin.available() == 0, "Not all bytes were read" ); + assertTrue( out.length() == FILE_SIZE, "Wrong output size: out.length()=" + out.length() + "!=" + FILE_SIZE ); fin.close(); } @@ -258,7 +232,7 @@ public void testReaderToOutputStream() * * @throws java.lang.Exception if any. */ - @Test + @org.junit.jupiter.api.Test public void testReaderToWriter() throws Exception { @@ -280,14 +254,14 @@ public void testReaderToWriter() * * @throws java.lang.Exception if any. */ - @Test + @org.junit.jupiter.api.Test public void testReaderToString() throws Exception { Reader fin = Files.newBufferedReader( testFile.toPath() ); String out = IOUtil.toString( fin ); assertNotNull( out ); - assertTrue( "Wrong output size: out.length()=" + out.length() + "!=" + FILE_SIZE, out.length() == FILE_SIZE ); + assertTrue( out.length() == FILE_SIZE, "Wrong output size: out.length()=" + out.length() + "!=" + FILE_SIZE ); fin.close(); } @@ -296,7 +270,7 @@ public void testReaderToString() * * @throws java.lang.Exception if any. */ - @Test + @org.junit.jupiter.api.Test public void testStringToOutputStream() throws Exception { @@ -325,7 +299,7 @@ public void testStringToOutputStream() * * @throws java.lang.Exception if any. */ - @Test + @org.junit.jupiter.api.Test public void testStringToWriter() throws Exception { @@ -357,8 +331,8 @@ public void testInputStreamToByteArray() InputStream fin = Files.newInputStream( testFile.toPath() ); byte[] out = IOUtil.toByteArray( fin ); assertNotNull( out ); - assertTrue( "Not all bytes were read", fin.available() == 0 ); - assertTrue( "Wrong output size: out.length=" + out.length + "!=" + FILE_SIZE, out.length == FILE_SIZE ); + assertTrue( fin.available() == 0, "Not all bytes were read" ); + assertTrue( out.length == FILE_SIZE, "Wrong output size: out.length=" + out.length + "!=" + FILE_SIZE ); assertEqualContent( out, testFile ); fin.close(); } @@ -411,7 +385,7 @@ public void testByteArrayToWriter() * * @throws java.lang.Exception if any. */ - @Test + @org.junit.jupiter.api.Test public void testByteArrayToString() throws Exception { @@ -459,7 +433,7 @@ public void testByteArrayToOutputStream() * * @throws java.lang.Exception if any. */ - @Test + @org.junit.jupiter.api.Test public void testCloseInputStream() throws Exception { @@ -477,7 +451,7 @@ public void testCloseInputStream() * * @throws java.lang.Exception if any. */ - @Test + @org.junit.jupiter.api.Test public void testCloseOutputStream() throws Exception { @@ -607,7 +581,7 @@ private File newFile( String filename ) throws Exception { File destination = new File( testDirectory, filename ); - assertTrue( filename + "Test output data file shouldn't previously exist", !destination.exists() ); + assertTrue( !destination.exists(), filename + "Test output data file shouldn't previously exist" ); return destination; } @@ -615,7 +589,7 @@ private File newFile( String filename ) private void checkFile( File file ) throws Exception { - assertTrue( "Check existence of output file", file.exists() ); + assertTrue( file.exists(), "Check existence of output file" ); assertEqualContent( testFile, file ); } @@ -650,9 +624,8 @@ private void checkWrite( Writer output ) private void deleteFile( File file ) throws Exception { - assertTrue( "Wrong output size: file.length()=" + file.length() + "!=" + FILE_SIZE + 1, - file.length() == FILE_SIZE + 1 ); + assertTrue( file.length() == FILE_SIZE + 1, "Wrong output size: file.length()=" + file.length() + "!=" + FILE_SIZE + 1 ); - assertTrue( "File would not delete", ( file.delete() || ( !file.exists() ) ) ); + assertTrue( ( file.delete() || ( !file.exists() ) ), "File would not delete" ); } } diff --git a/src/test/java/org/codehaus/plexus/util/InterpolationFilterReaderTest.java b/src/test/java/org/codehaus/plexus/util/InterpolationFilterReaderTest.java index 1d190b4d..eb821b5c 100644 --- a/src/test/java/org/codehaus/plexus/util/InterpolationFilterReaderTest.java +++ b/src/test/java/org/codehaus/plexus/util/InterpolationFilterReaderTest.java @@ -16,13 +16,13 @@ * limitations under the License. */ -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.StringReader; import java.util.HashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** *

InterpolationFilterReaderTest class.

@@ -62,7 +62,7 @@ public void testShouldNotInterpolateExpressionAtEndOfDataWithInvalidEndToken() * * @throws java.lang.Exception if any. */ - @Test + @org.junit.jupiter.api.Test public void testShouldNotInterpolateExpressionWithMissingEndToken() throws Exception { diff --git a/src/test/java/org/codehaus/plexus/util/LineOrientedInterpolatingReaderTest.java b/src/test/java/org/codehaus/plexus/util/LineOrientedInterpolatingReaderTest.java index 6ff112db..1e3a3d05 100644 --- a/src/test/java/org/codehaus/plexus/util/LineOrientedInterpolatingReaderTest.java +++ b/src/test/java/org/codehaus/plexus/util/LineOrientedInterpolatingReaderTest.java @@ -16,7 +16,9 @@ * limitations under the License. */ -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.BufferedReader; import java.io.IOException; @@ -26,8 +28,6 @@ import java.util.HashMap; import java.util.Map; -import org.junit.Test; - /** * Generated by JUnitDoclet, a tool provided by ObjectFab GmbH under LGPL. Please see www.junitdoclet.org, www.gnu.org * and www.objectfab.de for informations about the tool, the licence and the authors. @@ -46,7 +46,7 @@ public class LineOrientedInterpolatingReaderTest * * @throws java.io.IOException if any. */ - @Test + @org.junit.jupiter.api.Test public void testShouldInterpolateExpressionAtEndOfDataWithInvalidEndToken() throws IOException { @@ -96,7 +96,7 @@ private Map getStandardMap() * * @throws java.lang.Exception if any. */ - @Test + @org.junit.jupiter.api.Test public void testDefaultInterpolationWithEscapedExpression() throws Exception { @@ -118,7 +118,7 @@ public void testDefaultInterpolationWithEscapedExpression() * * @throws java.lang.Exception if any. */ - @Test + @org.junit.jupiter.api.Test public void testDefaultInterpolationWithInterpolatedValueAtEnd() throws Exception { @@ -140,7 +140,7 @@ public void testDefaultInterpolationWithInterpolatedValueAtEnd() * * @throws java.lang.Exception if any. */ - @Test + @org.junit.jupiter.api.Test public void testInterpolationWithSpecifiedBoundaryTokens() throws Exception { @@ -163,7 +163,7 @@ public void testInterpolationWithSpecifiedBoundaryTokens() * * @throws java.lang.Exception if any. */ - @Test + @org.junit.jupiter.api.Test public void testInterpolationWithSpecifiedBoundaryTokensWithNonInterpolatedValueAtEnd() throws Exception { @@ -186,7 +186,7 @@ public void testInterpolationWithSpecifiedBoundaryTokensWithNonInterpolatedValue * * @throws java.lang.Exception if any. */ - @Test + @org.junit.jupiter.api.Test public void testInterpolationWithSpecifiedBoundaryTokensWithInterpolatedValueAtEnd() throws Exception { diff --git a/src/test/java/org/codehaus/plexus/util/MatchPatternTest.java b/src/test/java/org/codehaus/plexus/util/MatchPatternTest.java index bd523457..5745b408 100644 --- a/src/test/java/org/codehaus/plexus/util/MatchPatternTest.java +++ b/src/test/java/org/codehaus/plexus/util/MatchPatternTest.java @@ -16,10 +16,10 @@ * limitations under the License. */ -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** *

MatchPatternTest class.

@@ -48,7 +48,7 @@ public void testMatchPath() * * @see Issue #63 */ - @Test + @org.junit.jupiter.api.Test public void testMatchPatternStart() { MatchPattern mp = MatchPattern.fromString( "ABC*" ); diff --git a/src/test/java/org/codehaus/plexus/util/MatchPatternsTest.java b/src/test/java/org/codehaus/plexus/util/MatchPatternsTest.java index a10e340e..202428a3 100644 --- a/src/test/java/org/codehaus/plexus/util/MatchPatternsTest.java +++ b/src/test/java/org/codehaus/plexus/util/MatchPatternsTest.java @@ -16,10 +16,10 @@ * limitations under the License. */ -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** *

MatchPatternsTest class.

diff --git a/src/test/java/org/codehaus/plexus/util/OsTest.java b/src/test/java/org/codehaus/plexus/util/OsTest.java index 572d4a56..77b781ce 100644 --- a/src/test/java/org/codehaus/plexus/util/OsTest.java +++ b/src/test/java/org/codehaus/plexus/util/OsTest.java @@ -16,13 +16,13 @@ * limitations under the License. */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Iterator; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test Case for Os @@ -92,7 +92,7 @@ public void testOs() /** *

testValidList.

*/ - @Test + @org.junit.jupiter.api.Test public void testValidList() { assertTrue( Os.isValidFamily( "dos" ) ); diff --git a/src/test/java/org/codehaus/plexus/util/PathToolTest.java b/src/test/java/org/codehaus/plexus/util/PathToolTest.java index 0a6d011e..82744cd2 100644 --- a/src/test/java/org/codehaus/plexus/util/PathToolTest.java +++ b/src/test/java/org/codehaus/plexus/util/PathToolTest.java @@ -16,9 +16,9 @@ * limitations under the License. */ -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** *

PathToolTest class.

@@ -34,7 +34,7 @@ public class PathToolTest * * @throws java.lang.Exception */ - @Test + @org.junit.jupiter.api.Test public void testGetRelativePath() throws Exception { @@ -66,7 +66,7 @@ public void testGetDirectoryComponent() * * @throws java.lang.Exception */ - @Test + @org.junit.jupiter.api.Test public void testCalculateLink() throws Exception { diff --git a/src/test/java/org/codehaus/plexus/util/PerfTest.java b/src/test/java/org/codehaus/plexus/util/PerfTest.java index 595c7272..de8164a2 100644 --- a/src/test/java/org/codehaus/plexus/util/PerfTest.java +++ b/src/test/java/org/codehaus/plexus/util/PerfTest.java @@ -16,7 +16,7 @@ * limitations under the License. */ -import org.junit.Test; +import org.junit.jupiter.api.Test; /** *

PerfTest class.

diff --git a/src/test/java/org/codehaus/plexus/util/ReflectionUtilsTest.java b/src/test/java/org/codehaus/plexus/util/ReflectionUtilsTest.java index 32699154..8ea9a314 100644 --- a/src/test/java/org/codehaus/plexus/util/ReflectionUtilsTest.java +++ b/src/test/java/org/codehaus/plexus/util/ReflectionUtilsTest.java @@ -16,11 +16,11 @@ * limitations under the License. */ -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.HashMap; @@ -53,7 +53,7 @@ public void testSimpleVariableAccess() * * @throws java.lang.IllegalAccessException if any. */ - @Test + @org.junit.jupiter.api.Test public void testComplexVariableAccess() throws IllegalAccessException { diff --git a/src/test/java/org/codehaus/plexus/util/SelectorUtilsTest.java b/src/test/java/org/codehaus/plexus/util/SelectorUtilsTest.java index 160aa16d..047e591a 100644 --- a/src/test/java/org/codehaus/plexus/util/SelectorUtilsTest.java +++ b/src/test/java/org/codehaus/plexus/util/SelectorUtilsTest.java @@ -16,12 +16,12 @@ * limitations under the License. */ -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.File; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** *

SelectorUtilsTest class.

@@ -92,7 +92,7 @@ public void testMatchPath_WindowsFileSeparator() assertTrue( SelectorUtils.matchPath( "*" + separator + "a.txt", "b" + separator + "a.txt", separator, false ) ); } - @Test + @org.junit.jupiter.api.Test public void testPatternMatchSingleWildcardPosix() { assertFalse(SelectorUtils.matchPath( @@ -119,7 +119,7 @@ public void testPatternMatchDoubleWildcardPosix() } - @Test + @org.junit.jupiter.api.Test public void testPatternMatchSingleWildcardWindows() { assertFalse(SelectorUtils.matchPath( diff --git a/src/test/java/org/codehaus/plexus/util/StringInputStreamTest.java b/src/test/java/org/codehaus/plexus/util/StringInputStreamTest.java deleted file mode 100644 index 0127c741..00000000 --- a/src/test/java/org/codehaus/plexus/util/StringInputStreamTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.codehaus.plexus.util; - -/* - * Copyright The Codehaus Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import junit.framework.TestCase; - -/** - *

StringInputStreamTest class.

- * - * @author Ben Walding - * @version $Id: $Id - * @since 3.4.0 - */ -public class StringInputStreamTest - extends TestCase -{ - /** - *

testFoo.

- */ - public void testFoo() - { - } -} diff --git a/src/test/java/org/codehaus/plexus/util/StringUtilsTest.java b/src/test/java/org/codehaus/plexus/util/StringUtilsTest.java index b7bd6d72..659aecf1 100644 --- a/src/test/java/org/codehaus/plexus/util/StringUtilsTest.java +++ b/src/test/java/org/codehaus/plexus/util/StringUtilsTest.java @@ -16,14 +16,14 @@ * limitations under the License. */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Arrays; import java.util.Locale; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test string utils. @@ -61,7 +61,7 @@ public void testIsNotEmpty() assertEquals( true, StringUtils.isNotEmpty( " foo " ) ); } - @Test + @org.junit.jupiter.api.Test public void testIsNotEmptyNegatesIsEmpty() { assertEquals( !StringUtils.isEmpty( null ), StringUtils.isNotEmpty( null ) ); @@ -123,7 +123,7 @@ public void testCapitalizeFirstLetterTurkish() /** *

testLowerCaseFirstLetter.

*/ - @Test + @org.junit.jupiter.api.Test public void testLowerCaseFirstLetter() { assertEquals( "id", StringUtils.lowercaseFirstLetter( "id" ) ); @@ -133,7 +133,7 @@ public void testLowerCaseFirstLetter() /** *

testLowerCaseFirstLetterTurkish.

*/ - @Test + @org.junit.jupiter.api.Test public void testLowerCaseFirstLetterTurkish() { Locale l = Locale.getDefault(); @@ -146,7 +146,7 @@ public void testLowerCaseFirstLetterTurkish() /** *

testRemoveAndHump.

*/ - @Test + @org.junit.jupiter.api.Test public void testRemoveAndHump() { assertEquals( "Id", StringUtils.removeAndHump( "id", "-" ) ); @@ -184,7 +184,7 @@ public void testQuote_EscapeEmbeddedSingleQuotes() /** *

testQuote_EscapeEmbeddedSingleQuotesWithPattern.

*/ - @Test + @org.junit.jupiter.api.Test public void testQuote_EscapeEmbeddedSingleQuotesWithPattern() { String src = "This \'is a\' test"; @@ -214,7 +214,7 @@ public void testQuote_EscapeEmbeddedDoubleQuotesAndSpaces() /** *

testQuote_DontQuoteIfUnneeded.

*/ - @Test + @org.junit.jupiter.api.Test public void testQuote_DontQuoteIfUnneeded() { String src = "ThisIsATest"; @@ -243,7 +243,7 @@ public void testQuote_WrapWithSingleQuotes() /** *

testQuote_PreserveExistingQuotes.

*/ - @Test + @org.junit.jupiter.api.Test public void testQuote_PreserveExistingQuotes() { String src = "\'This is a test\'"; @@ -257,7 +257,7 @@ public void testQuote_PreserveExistingQuotes() /** *

testQuote_WrapExistingQuotesWhenForceIsTrue.

*/ - @Test + @org.junit.jupiter.api.Test public void testQuote_WrapExistingQuotesWhenForceIsTrue() { String src = "\'This is a test\'"; @@ -272,7 +272,7 @@ public void testQuote_WrapExistingQuotesWhenForceIsTrue() /** *

testQuote_ShortVersion_SingleQuotesPreserved.

*/ - @Test + @org.junit.jupiter.api.Test public void testQuote_ShortVersion_SingleQuotesPreserved() { String src = "\'This is a test\'"; @@ -285,7 +285,7 @@ public void testQuote_ShortVersion_SingleQuotesPreserved() /** *

testSplit.

*/ - @Test + @org.junit.jupiter.api.Test public void testSplit() { String[] tokens; @@ -320,7 +320,7 @@ public void testSplit() * * @throws java.lang.Exception if any. */ - @Test + @org.junit.jupiter.api.Test public void testRemoveDuplicateWhitespace() throws Exception { @@ -349,11 +349,11 @@ public void testUnifyLineSeparators() try { StringUtils.unifyLineSeparators( s, "abs" ); - assertTrue( "Exception NOT catched", false ); + assertTrue( false, "Exception NOT catched" ); } catch ( IllegalArgumentException e ) { - assertTrue( "Exception catched", true ); + assertTrue( true, "Exception catched" ); } assertEquals( "this\nis\na\ntest", StringUtils.unifyLineSeparators( s, "\n" ) ); diff --git a/src/test/java/org/codehaus/plexus/util/SweeperPoolTest.java b/src/test/java/org/codehaus/plexus/util/SweeperPoolTest.java index a642b5a2..7e7d0112 100644 --- a/src/test/java/org/codehaus/plexus/util/SweeperPoolTest.java +++ b/src/test/java/org/codehaus/plexus/util/SweeperPoolTest.java @@ -16,18 +16,18 @@ * limitations under the License. */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.util.Vector; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Created on 21/06/2003 @@ -69,31 +69,31 @@ public void testMaxSize() pool = new TestObjectPool( maxSize, minSize, initialCapacity, sweepInterval, triggerSize ); Object tmp = pool.get(); - assertNull( "Expected object from pool to be null", tmp ); + assertNull( tmp, "Expected object from pool to be null" ); pool.put( o1 ); - assertEquals( "Expected pool to contain 1 object", 1, pool.getSize() ); + assertEquals( 1, pool.getSize(), "Expected pool to contain 1 object" ); tmp = pool.get(); - assertSame( "Expected returned pool object to be the same as the one put in", tmp, o1 ); + assertSame( tmp, o1, "Expected returned pool object to be the same as the one put in" ); pool.put( o1 ); pool.put( o2 ); - assertEquals( "Expected pool to contain 2 objects", 2, pool.getSize() ); + assertEquals( 2, pool.getSize(), "Expected pool to contain 2 objects" ); pool.put( o3 ); - assertEquals( "Expected pool to contain only a maximum of 2 objects.", 2, pool.getSize() ); - assertEquals( "Expected 1 disposed pool object", 1, pool.testGetDisposedObjects().size() ); + assertEquals( 2, pool.getSize(), "Expected pool to contain only a maximum of 2 objects." ); + assertEquals( 1, pool.testGetDisposedObjects().size(), "Expected 1 disposed pool object" ); tmp = pool.testGetDisposedObjects().iterator().next(); tmp = pool.get(); - assertEquals( "Expected pool size to be 1 after removing one object", 1, pool.getSize() ); + assertEquals( 1, pool.getSize(), "Expected pool size to be 1 after removing one object" ); Object tmp2 = pool.get(); - assertEquals( "Expected pool size to be 0 after removing 2 objects", 0, pool.getSize() ); - assertNotSame( "Expected returned objects to be different", tmp, tmp2 ); + assertEquals( 0, pool.getSize(), "Expected pool size to be 0 after removing 2 objects" ); + assertNotSame( tmp, tmp2, "Expected returned objects to be different" ); } /** *

testSweepAndTrim1.

*/ - @Test + @org.junit.jupiter.api.Test public void testSweepAndTrim1() { // test trigger @@ -120,8 +120,8 @@ public void testSweepAndTrim1() fail( "Unexpected exception thrown. e=" + Tracer.traceToString( e ) ); } } - assertEquals( "Expected pool to only contain 1 object", 1, pool.getSize() ); - assertEquals( "Expected 3 disposed objects", 3, pool.testGetDisposedObjects().size() ); + assertEquals( 1, pool.getSize(), "Expected pool to only contain 1 object" ); + assertEquals( 3, pool.testGetDisposedObjects().size(), "Expected 3 disposed objects" ); } @@ -130,7 +130,7 @@ public void testSweepAndTrim1() * * @throws java.lang.Exception if any. */ - @Before + @BeforeEach public void setUp() throws Exception { @@ -147,7 +147,7 @@ public void setUp() * * @throws java.lang.Exception if any. */ - @After + @AfterEach public void tearDown() throws Exception { diff --git a/src/test/java/org/codehaus/plexus/util/cli/CommandLineUtilsTest.java b/src/test/java/org/codehaus/plexus/util/cli/CommandLineUtilsTest.java index 92cdaa2d..4e19f71f 100644 --- a/src/test/java/org/codehaus/plexus/util/cli/CommandLineUtilsTest.java +++ b/src/test/java/org/codehaus/plexus/util/cli/CommandLineUtilsTest.java @@ -16,16 +16,16 @@ * limitations under the License. */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; import java.util.Arrays; import java.util.Locale; import java.util.Properties; import org.codehaus.plexus.util.Os; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** *

CommandLineUtilsTest class.

@@ -113,7 +113,7 @@ public void testGetSystemEnvVarsWindows() * * @throws java.lang.Exception if any. */ - @Test + @org.junit.jupiter.api.Test public void testTranslateCommandline() throws Exception { diff --git a/src/test/java/org/codehaus/plexus/util/cli/CommandlineTest.java b/src/test/java/org/codehaus/plexus/util/cli/CommandlineTest.java index 15cb9744..43486862 100644 --- a/src/test/java/org/codehaus/plexus/util/cli/CommandlineTest.java +++ b/src/test/java/org/codehaus/plexus/util/cli/CommandlineTest.java @@ -16,15 +16,14 @@ * limitations under the License. */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.io.File; import java.io.IOException; import java.io.Writer; import java.nio.file.Files; -import java.nio.file.Paths; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.Os; @@ -32,8 +31,8 @@ import org.codehaus.plexus.util.cli.shell.BourneShell; import org.codehaus.plexus.util.cli.shell.CmdShell; import org.codehaus.plexus.util.cli.shell.Shell; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.BeforeEach; /** *

CommandlineTest class.

@@ -51,7 +50,7 @@ public class CommandlineTest * * @throws java.lang.Exception if any. */ - @Before + @BeforeEach public void setUp() throws Exception { @@ -118,7 +117,7 @@ public void testExecuteBinaryOnPath() * * @throws java.lang.Exception if any. */ - @Test + @org.junit.jupiter.api.Test public void testExecute() throws Exception { @@ -199,7 +198,7 @@ public void testGetShellCommandLineWindows() cmd.addArguments( new String[] { "a", "b" } ); String[] shellCommandline = cmd.getShellCommandline(); - assertEquals( "Command line size", 4, shellCommandline.length ); + assertEquals( 4, shellCommandline.length, "Command line size" ); assertEquals( "cmd.exe", shellCommandline[0] ); assertEquals( "/X", shellCommandline[1] ); @@ -223,7 +222,7 @@ public void testGetShellCommandLineWindowsWithSeveralQuotes() cmd.addArguments( new String[] { "c:\\Documents and Settings\\whatever", "b" } ); String[] shellCommandline = cmd.getShellCommandline(); - assertEquals( "Command line size", 4, shellCommandline.length ); + assertEquals( 4, shellCommandline.length, "Command line size" ); assertEquals( "cmd.exe", shellCommandline[0] ); assertEquals( "/X", shellCommandline[1] ); @@ -249,7 +248,7 @@ public void testGetShellCommandLineBash() String[] shellCommandline = cmd.getShellCommandline(); - assertEquals( "Command line size", 3, shellCommandline.length ); + assertEquals( 3, shellCommandline.length, "Command line size" ); assertEquals( "/bin/sh", shellCommandline[0] ); assertEquals( "-c", shellCommandline[1] ); @@ -279,7 +278,7 @@ public void testGetShellCommandLineBash_WithWorkingDirectory() String[] shellCommandline = cmd.getShellCommandline(); - assertEquals( "Command line size", 3, shellCommandline.length ); + assertEquals( 3, shellCommandline.length, "Command line size" ); assertEquals( "/bin/sh", shellCommandline[0] ); assertEquals( "-c", shellCommandline[1] ); @@ -306,7 +305,7 @@ public void testGetShellCommandLineBash_WithSingleQuotedArg() String[] shellCommandline = cmd.getShellCommandline(); - assertEquals( "Command line size", 3, shellCommandline.length ); + assertEquals( 3, shellCommandline.length, "Command line size" ); assertEquals( "/bin/sh", shellCommandline[0] ); assertEquals( "-c", shellCommandline[1] ); @@ -332,7 +331,7 @@ public void testGetShellCommandLineNonWindows() cmd.addArguments( new String[] { "a", "b" } ); String[] shellCommandline = cmd.getShellCommandline(); - assertEquals( "Command line size", 3, shellCommandline.length ); + assertEquals( 3, shellCommandline.length, "Command line size" ); assertEquals( "/bin/sh", shellCommandline[0] ); assertEquals( "-c", shellCommandline[1] ); @@ -508,7 +507,7 @@ public void testDollarSignInArgumentPath() File dir = new File( System.getProperty( "basedir" ), "target/test" ); if ( !dir.exists() ) { - assertTrue( "Can't create dir:" + dir.getAbsolutePath(), dir.mkdirs() ); + assertTrue( dir.mkdirs(), "Can't create dir:" + dir.getAbsolutePath() ); } Writer writer = null; @@ -627,7 +626,7 @@ private static void createAndCallScript( File dir, String content ) { if ( !dir.exists() ) { - assertTrue( "Can't create dir:" + dir.getAbsolutePath(), dir.mkdirs() ); + assertTrue( dir.mkdirs(), "Can't create dir:" + dir.getAbsolutePath() ); } // Create a script file diff --git a/src/test/java/org/codehaus/plexus/util/cli/DefaultConsumerTest.java b/src/test/java/org/codehaus/plexus/util/cli/DefaultConsumerTest.java index 423d30ed..3e59e48b 100644 --- a/src/test/java/org/codehaus/plexus/util/cli/DefaultConsumerTest.java +++ b/src/test/java/org/codehaus/plexus/util/cli/DefaultConsumerTest.java @@ -16,7 +16,7 @@ * limitations under the License. */ -import org.junit.Test; +import org.junit.jupiter.api.Test; /** *

DefaultConsumerTest class.

diff --git a/src/test/java/org/codehaus/plexus/util/cli/EnhancedStringTokenizerTest.java b/src/test/java/org/codehaus/plexus/util/cli/EnhancedStringTokenizerTest.java index 05d043f5..e5d78aad 100644 --- a/src/test/java/org/codehaus/plexus/util/cli/EnhancedStringTokenizerTest.java +++ b/src/test/java/org/codehaus/plexus/util/cli/EnhancedStringTokenizerTest.java @@ -16,10 +16,11 @@ * limitations under the License. */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.fail; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** *

EnhancedStringTokenizerTest class.

@@ -33,7 +34,7 @@ public class EnhancedStringTokenizerTest /** *

test1.

*/ - @Test + @org.junit.jupiter.api.Test public void test1() { EnhancedStringTokenizer est = new EnhancedStringTokenizer( "this is a test string" ); @@ -53,59 +54,59 @@ public void test1() public void test2() { EnhancedStringTokenizer est = new EnhancedStringTokenizer( "1,,,3,,4", "," ); - assertEquals( "Token 1", "1", est.nextToken() ); - assertEquals( "Token 2", "", est.nextToken() ); - assertEquals( "Token 3", "", est.nextToken() ); - assertEquals( "Token 4", "3", est.nextToken() ); - assertEquals( "Token 5", "", est.nextToken() ); - assertEquals( "Token 6", "4", est.nextToken() ); + assertEquals( "1", est.nextToken(), "Token 1" ); + assertEquals( "", est.nextToken(), "Token 2" ); + assertEquals( "", est.nextToken(), "Token 3" ); + assertEquals( "3", est.nextToken(), "Token 4" ); + assertEquals( "", est.nextToken(), "Token 5" ); + assertEquals( "4", est.nextToken(), "Token 6" ); } /** *

test3.

*/ - @Test + @org.junit.jupiter.api.Test public void test3() { EnhancedStringTokenizer est = new EnhancedStringTokenizer( "1,,,3,,4", ",", true ); - assertEquals( "Token 1", "1", est.nextToken() ); - assertEquals( "Token 2", ",", est.nextToken() ); - assertEquals( "Token 3", "", est.nextToken() ); - assertEquals( "Token 4", ",", est.nextToken() ); - assertEquals( "Token 5", "", est.nextToken() ); - assertEquals( "Token 6", ",", est.nextToken() ); - assertEquals( "Token 7", "3", est.nextToken() ); - assertEquals( "Token 8", ",", est.nextToken() ); - assertEquals( "Token 9", "", est.nextToken() ); - assertEquals( "Token 10", ",", est.nextToken() ); - assertEquals( "Token 11", "4", est.nextToken() ); + assertEquals( "1", est.nextToken(), "Token 1" ); + assertEquals( ",", est.nextToken(), "Token 2" ); + assertEquals( "", est.nextToken(), "Token 3" ); + assertEquals( ",", est.nextToken(), "Token 4" ); + assertEquals( "", est.nextToken(), "Token 5" ); + assertEquals( ",", est.nextToken(), "Token 6" ); + assertEquals( "3", est.nextToken(), "Token 7" ); + assertEquals( ",", est.nextToken(), "Token 8" ); + assertEquals( "", est.nextToken(), "Token 9" ); + assertEquals( ",", est.nextToken(), "Token 10" ); + assertEquals( "4", est.nextToken(), "Token 11" ); } /** *

testMultipleDelim.

*/ - @Test + @org.junit.jupiter.api.Test public void testMultipleDelim() { EnhancedStringTokenizer est = new EnhancedStringTokenizer( "1 2|3|4", " |", true ); - assertEquals( "Token 1", "1", est.nextToken() ); - assertEquals( "Token 2", " ", est.nextToken() ); - assertEquals( "Token 3", "2", est.nextToken() ); - assertEquals( "Token 4", "|", est.nextToken() ); - assertEquals( "Token 5", "3", est.nextToken() ); - assertEquals( "Token 6", "|", est.nextToken() ); - assertEquals( "Token 7", "4", est.nextToken() ); - assertEquals( "est.hasMoreTokens()", false, est.hasMoreTokens() ); + assertEquals( "1", est.nextToken(), "Token 1" ); + assertEquals( " ", est.nextToken(), "Token 2" ); + assertEquals( "2", est.nextToken(), "Token 3" ); + assertEquals( "|", est.nextToken(), "Token 4" ); + assertEquals( "3", est.nextToken(), "Token 5" ); + assertEquals( "|", est.nextToken(), "Token 6" ); + assertEquals( "4", est.nextToken(), "Token 7" ); + assertFalse( est.hasMoreTokens(), "est.hasMoreTokens()" ); } /** *

testEmptyString.

*/ - @Test + @org.junit.jupiter.api.Test public void testEmptyString() { EnhancedStringTokenizer est = new EnhancedStringTokenizer( "" ); - assertEquals( "est.hasMoreTokens()", false, est.hasMoreTokens() ); + assertFalse( est.hasMoreTokens(), "est.hasMoreTokens()" ); try { est.nextToken(); @@ -119,12 +120,12 @@ public void testEmptyString() /** *

testSimpleString.

*/ - @Test + @org.junit.jupiter.api.Test public void testSimpleString() { EnhancedStringTokenizer est = new EnhancedStringTokenizer( "a " ); - assertEquals( "Token 1", "a", est.nextToken() ); - assertEquals( "Token 2", "", est.nextToken() ); - assertEquals( "est.hasMoreTokens()", false, est.hasMoreTokens() ); + assertEquals( "a", est.nextToken(), "Token 1" ); + assertEquals( "", est.nextToken(), "Token 2" ); + assertFalse( est.hasMoreTokens(), "est.hasMoreTokens()" ); } } diff --git a/src/test/java/org/codehaus/plexus/util/cli/StreamPumperTest.java b/src/test/java/org/codehaus/plexus/util/cli/StreamPumperTest.java index eec5def5..f96ebf41 100644 --- a/src/test/java/org/codehaus/plexus/util/cli/StreamPumperTest.java +++ b/src/test/java/org/codehaus/plexus/util/cli/StreamPumperTest.java @@ -52,9 +52,9 @@ * limitations under the License. */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -64,7 +64,7 @@ import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** *

StreamPumperTest class.

@@ -100,7 +100,7 @@ public void testPumping() /** *

testPumpingWithPrintWriter.

*/ - @Test + @org.junit.jupiter.api.Test public void testPumpingWithPrintWriter() { String inputString = "This a test string"; @@ -125,7 +125,7 @@ public void testPumperReadsInputStreamUntilEndEvenIfConsumerFails() GeneratorInputStream gis = new GeneratorInputStream( 1024 * 1024 * 4 ); StreamPumper pumper = new StreamPumper( gis, new FailingConsumer() ); pumper.run(); - assertEquals( "input stream was not fully consumed, producer deadlocks", gis.size, gis.read ); + assertEquals( gis.size, gis.read, "input stream was not fully consumed, producer deadlocks" ); assertTrue( gis.closed ); assertNotNull( pumper.getException() ); } @@ -237,7 +237,7 @@ public void consumeLine( String line ) /** *

testEnabled.

*/ - @Test + @org.junit.jupiter.api.Test public void testEnabled() { ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( "AB\nCE\nEF".getBytes() ); diff --git a/src/test/java/org/codehaus/plexus/util/cli/shell/BourneShellTest.java b/src/test/java/org/codehaus/plexus/util/cli/shell/BourneShellTest.java index 1480685f..d008188c 100644 --- a/src/test/java/org/codehaus/plexus/util/cli/shell/BourneShellTest.java +++ b/src/test/java/org/codehaus/plexus/util/cli/shell/BourneShellTest.java @@ -17,15 +17,15 @@ * limitations under the License. */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Arrays; import java.util.List; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.cli.Commandline; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** *

BourneShellTest class.

@@ -50,7 +50,7 @@ protected Shell newShell() /** *

testQuoteWorkingDirectoryAndExecutable.

*/ - @Test + @org.junit.jupiter.api.Test public void testQuoteWorkingDirectoryAndExecutable() { Shell sh = newShell(); @@ -82,7 +82,7 @@ public void testQuoteWorkingDirectoryAndExecutable_WDPathWithSingleQuotes() /** *

testQuoteWorkingDirectoryAndExecutable_WDPathWithSingleQuotes_BackslashFileSep.

*/ - @Test + @org.junit.jupiter.api.Test public void testQuoteWorkingDirectoryAndExecutable_WDPathWithSingleQuotes_BackslashFileSep() { Shell sh = newShell(); diff --git a/src/test/java/org/codehaus/plexus/util/dag/CycleDetectedExceptionTest.java b/src/test/java/org/codehaus/plexus/util/dag/CycleDetectedExceptionTest.java index 5c67eb3f..771bc99f 100644 --- a/src/test/java/org/codehaus/plexus/util/dag/CycleDetectedExceptionTest.java +++ b/src/test/java/org/codehaus/plexus/util/dag/CycleDetectedExceptionTest.java @@ -16,13 +16,13 @@ * limitations under the License. */ -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.ArrayList; import java.util.List; -import org.junit.Test; - /** *

CycleDetectedExceptionTest class.

* diff --git a/src/test/java/org/codehaus/plexus/util/dag/CycleDetectorTest.java b/src/test/java/org/codehaus/plexus/util/dag/CycleDetectorTest.java index 76a9c1ff..bd086e7e 100644 --- a/src/test/java/org/codehaus/plexus/util/dag/CycleDetectorTest.java +++ b/src/test/java/org/codehaus/plexus/util/dag/CycleDetectorTest.java @@ -16,15 +16,15 @@ * limitations under the License. */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; -import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; -import org.junit.Test; +import java.util.List; /** *

CycleDetectorTest class.

@@ -85,13 +85,13 @@ public void testCycyleDetection() final List cycle = e.getCycle(); - assertNotNull( "Cycle should be not null", cycle ); + assertNotNull( cycle, "Cycle should be not null" ); - assertTrue( "Cycle contains 'a'", cycle.contains( "a" ) ); + assertTrue( cycle.contains( "a" ), "Cycle contains 'a'" ); - assertTrue( "Cycle contains 'b'", cycle.contains( "b" ) ); + assertTrue( cycle.contains( "b" ), "Cycle contains 'b'" ); - assertTrue( "Cycle contains 'c'", cycle.contains( "c" ) ); + assertTrue( cycle.contains( "c" ), "Cycle contains 'c'" ); } @@ -144,15 +144,15 @@ public void testCycyleDetection() { final List cycle = e.getCycle(); - assertNotNull( "Cycle should be not null", cycle ); + assertNotNull( cycle, "Cycle should be not null" ); - assertEquals( "Cycle contains 'a'", "a", (String) cycle.get( 0 ) ); + assertEquals( "a", (String) cycle.get( 0 ), "Cycle contains 'a'" ); - assertEquals( "Cycle contains 'b'", "b", cycle.get( 1 ) ); + assertEquals( "b", cycle.get( 1 ), "Cycle contains 'b'" ); - assertEquals( "Cycle contains 'c'", "c", cycle.get( 2 ) ); + assertEquals( "c", cycle.get( 2 ), "Cycle contains 'c'" ); - assertEquals( "Cycle contains 'a'", "a", (String) cycle.get( 3 ) ); + assertEquals( "a", (String) cycle.get( 3 ), "Cycle contains 'a'" ); } // f --> g --> h @@ -191,33 +191,33 @@ public void testCycyleDetection() { final List cycle = e.getCycle(); - assertNotNull( "Cycle should be not null", cycle ); + assertNotNull( cycle, "Cycle should be not null" ); - assertEquals( "Cycle contains 5 elements", 5, cycle.size() ); + assertEquals( 5, cycle.size(), "Cycle contains 5 elements" ); - assertEquals( "Cycle contains 'b'", "b", (String) cycle.get( 0 ) ); + assertEquals( "b", (String) cycle.get( 0 ), "Cycle contains 'b'" ); - assertEquals( "Cycle contains 'c'", "c", cycle.get( 1 ) ); + assertEquals( "c", cycle.get( 1 ), "Cycle contains 'c'" ); - assertEquals( "Cycle contains 'd'", "d", cycle.get( 2 ) ); + assertEquals( "d", cycle.get( 2 ), "Cycle contains 'd'" ); - assertEquals( "Cycle contains 'e'", "e", (String) cycle.get( 3 ) ); + assertEquals( "e", (String) cycle.get( 3 ), "Cycle contains 'e'" ); - assertEquals( "Cycle contains 'b'", "b", (String) cycle.get( 4 ) ); + assertEquals( "b", (String) cycle.get( 4 ), "Cycle contains 'b'" ); - assertTrue( "Edge exists", dag5.hasEdge( "a", "b" ) ); + assertTrue( dag5.hasEdge( "a", "b" ), "Edge exists" ); - assertTrue( "Edge exists", dag5.hasEdge( "b", "c" ) ); + assertTrue( dag5.hasEdge( "b", "c" ), "Edge exists" ); - assertTrue( "Edge exists", dag5.hasEdge( "b", "f" ) ); + assertTrue( dag5.hasEdge( "b", "f" ), "Edge exists" ); - assertTrue( "Edge exists", dag5.hasEdge( "f", "g" ) ); + assertTrue( dag5.hasEdge( "f", "g" ), "Edge exists" ); - assertTrue( "Edge exists", dag5.hasEdge( "g", "h" ) ); + assertTrue( dag5.hasEdge( "g", "h" ), "Edge exists" ); - assertTrue( "Edge exists", dag5.hasEdge( "c", "d" ) ); + assertTrue( dag5.hasEdge( "c", "d" ), "Edge exists" ); - assertTrue( "Edge exists", dag5.hasEdge( "d", "e" ) ); + assertTrue( dag5.hasEdge( "d", "e" ), "Edge exists" ); assertFalse( dag5.hasEdge( "e", "b" ) ); } diff --git a/src/test/java/org/codehaus/plexus/util/dag/DAGTest.java b/src/test/java/org/codehaus/plexus/util/dag/DAGTest.java index bf0063eb..8918755a 100644 --- a/src/test/java/org/codehaus/plexus/util/dag/DAGTest.java +++ b/src/test/java/org/codehaus/plexus/util/dag/DAGTest.java @@ -16,15 +16,15 @@ * limitations under the License. */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.List; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** *

DAGTest class.

diff --git a/src/test/java/org/codehaus/plexus/util/dag/TopologicalSorterTest.java b/src/test/java/org/codehaus/plexus/util/dag/TopologicalSorterTest.java index 25ea5b54..5f6615c2 100644 --- a/src/test/java/org/codehaus/plexus/util/dag/TopologicalSorterTest.java +++ b/src/test/java/org/codehaus/plexus/util/dag/TopologicalSorterTest.java @@ -16,12 +16,12 @@ * limitations under the License. */ -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** *

TopologicalSorterTest class.

@@ -60,7 +60,7 @@ public void testDfs() final List actual1 = TopologicalSorter.sort( dag1 ); - assertEquals( "Order is different then expected", expected1, actual1 ); + assertEquals( expected1, actual1, "Order is different then expected" ); // // a <-- b <---c @@ -88,7 +88,7 @@ public void testDfs() final List actual2 = TopologicalSorter.sort( dag2 ); - assertEquals( "Order is different then expected", expected2, actual2 ); + assertEquals( expected2, actual2, "Order is different then expected" ); // // a --> b --> c --> e @@ -145,7 +145,7 @@ public void testDfs() final List actual3 = TopologicalSorter.sort( dag3 ); - assertEquals( "Order is different then expected", expected3, actual3 ); + assertEquals( expected3, actual3, "Order is different then expected" ); // // a --> b --> c --> e @@ -198,6 +198,6 @@ public void testDfs() final List actual4 = TopologicalSorter.sort( dag4 ); - assertEquals( "Order is different then expected", expected4, actual4 ); + assertEquals( expected4, actual4, "Order is different then expected" ); } } diff --git a/src/test/java/org/codehaus/plexus/util/dag/VertexTest.java b/src/test/java/org/codehaus/plexus/util/dag/VertexTest.java index db49acd2..5a911425 100644 --- a/src/test/java/org/codehaus/plexus/util/dag/VertexTest.java +++ b/src/test/java/org/codehaus/plexus/util/dag/VertexTest.java @@ -16,9 +16,9 @@ * limitations under the License. */ -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** *

VertexTest class.

diff --git a/src/test/java/org/codehaus/plexus/util/introspection/ReflectionValueExtractorTest.java b/src/test/java/org/codehaus/plexus/util/introspection/ReflectionValueExtractorTest.java index 44533bfa..a4244e34 100644 --- a/src/test/java/org/codehaus/plexus/util/introspection/ReflectionValueExtractorTest.java +++ b/src/test/java/org/codehaus/plexus/util/introspection/ReflectionValueExtractorTest.java @@ -17,18 +17,18 @@ * limitations under the License. */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** *

ReflectionValueExtractorTest class.

@@ -46,7 +46,7 @@ public class ReflectionValueExtractorTest * * @throws java.lang.Exception if any. */ - @Before + @BeforeEach public void setUp() throws Exception { @@ -180,7 +180,7 @@ public void testValueExtractorWithAInvalidExpression() * * @throws java.lang.Exception if any. */ - @Test + @org.junit.jupiter.api.Test public void testMappedDottedKey() throws Exception { @@ -228,7 +228,7 @@ public void testMappedIndexed() * * @throws java.lang.Exception if any. */ - @Test + @org.junit.jupiter.api.Test public void testMappedMissingDot() throws Exception { @@ -289,7 +289,7 @@ public void testBadIndexedSyntax() * * @throws java.lang.Exception if any. */ - @Test + @org.junit.jupiter.api.Test public void testBadMappedSyntax() throws Exception { @@ -308,7 +308,7 @@ public void testBadMappedSyntax() * * @throws java.lang.Exception if any. */ - @Test + @org.junit.jupiter.api.Test public void testIllegalIndexedType() throws Exception { diff --git a/src/test/java/org/codehaus/plexus/util/io/CachingOutputStreamTest.java b/src/test/java/org/codehaus/plexus/util/io/CachingOutputStreamTest.java index e7888ad4..c57dbf8c 100644 --- a/src/test/java/org/codehaus/plexus/util/io/CachingOutputStreamTest.java +++ b/src/test/java/org/codehaus/plexus/util/io/CachingOutputStreamTest.java @@ -24,14 +24,14 @@ import java.nio.file.attribute.FileTime; import java.util.Objects; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.BeforeEach; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class CachingOutputStreamTest { @@ -39,7 +39,7 @@ public class CachingOutputStreamTest Path tempDir; Path checkLastModified; - @Before + @BeforeEach public void setup() throws IOException { Path dir = Paths.get( "target/io" ); diff --git a/src/test/java/org/codehaus/plexus/util/io/CachingWriterTest.java b/src/test/java/org/codehaus/plexus/util/io/CachingWriterTest.java index a4ffec91..b8a8f4b1 100644 --- a/src/test/java/org/codehaus/plexus/util/io/CachingWriterTest.java +++ b/src/test/java/org/codehaus/plexus/util/io/CachingWriterTest.java @@ -24,13 +24,13 @@ import java.nio.file.attribute.FileTime; import java.util.Objects; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class CachingWriterTest { @@ -38,7 +38,7 @@ public class CachingWriterTest Path tempDir; Path checkLastModified; - @Before + @BeforeEach public void setup() throws IOException { Path dir = Paths.get( "target/io" ); diff --git a/src/test/java/org/codehaus/plexus/util/reflection/ReflectorTest.java b/src/test/java/org/codehaus/plexus/util/reflection/ReflectorTest.java index d3c0db8c..9c892b35 100644 --- a/src/test/java/org/codehaus/plexus/util/reflection/ReflectorTest.java +++ b/src/test/java/org/codehaus/plexus/util/reflection/ReflectorTest.java @@ -16,10 +16,10 @@ * limitations under the License. */ -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** *

ReflectorTest class.

@@ -39,7 +39,7 @@ public class ReflectorTest * * @throws java.lang.Exception if any. */ - @Before + @BeforeEach public void setUp() throws Exception { @@ -67,7 +67,7 @@ public void testObjectPropertyFromName() * * @throws java.lang.Exception if any. */ - @Test + @org.junit.jupiter.api.Test public void testObjectPropertyFromBean() throws Exception {