diff --git a/pom.xml b/pom.xml
index 5ba5774..58d07e3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -72,6 +72,18 @@ under the License.
2022-04-05T18:45:23Z
+
+
+
+ org.junit
+ junit-bom
+ 5.9.1
+ pom
+ import
+
+
+
+
org.apache.maven.shared
@@ -84,9 +96,8 @@ under the License.
1
- junit
- junit
- 4.13.2
+ org.junit.jupiter
+ junit-jupiter
test
diff --git a/src/test/java/org/apache/maven/shared/invoker/DefaultInvokerTest.java b/src/test/java/org/apache/maven/shared/invoker/DefaultInvokerTest.java
index 8f59e2a..2f4c518 100644
--- a/src/test/java/org/apache/maven/shared/invoker/DefaultInvokerTest.java
+++ b/src/test/java/org/apache/maven/shared/invoker/DefaultInvokerTest.java
@@ -20,7 +20,6 @@
*/
import java.io.File;
-import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
@@ -30,9 +29,9 @@
import org.apache.maven.shared.utils.Os;
import org.apache.maven.shared.utils.StringUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class DefaultInvokerTest
{
@@ -121,7 +120,7 @@ public void testSpacePom()
request.setDebug( true );
request.setGoals( Collections.singletonList( "clean" ) );
request.setProperties( getProperties() );
-
+
InvocationResult result = invoker.execute( request );
assertEquals( 0, result.getExitCode() );
@@ -344,7 +343,7 @@ private void logTestStart()
System.out.println( "Starting: " + element.getMethodName() );
}
-
+
private Properties getProperties()
{
Properties properties = new Properties();
@@ -353,7 +352,7 @@ private Properties getProperties()
properties.put( "maven.compiler.source", "1.7" );
properties.put( "maven.compiler.target", "1.7" );
}
-
+
String httpProtocols = System.getProperty( "https.protocols" );
if ( httpProtocols != null )
{
diff --git a/src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java b/src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java
index 7a6c7dc..f0dc319 100644
--- a/src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java
+++ b/src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java
@@ -22,42 +22,42 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
+import java.util.Objects;
import java.util.Properties;
import java.util.Set;
import org.apache.maven.shared.utils.Os;
import org.apache.maven.shared.utils.cli.Commandline;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertArrayEquals;
-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.assumeThat;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+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.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
public class MavenCommandLineBuilderTest
{
- @Rule
- public TemporaryFolder temporaryFolder = new TemporaryFolder();
+ @TempDir
+ public Path temporaryFolder;
private Properties sysProps;
private File lrd;
private MavenCommandLineBuilder mclb = new MavenCommandLineBuilder();
private Commandline cli = new Commandline();
- @Before
+ @BeforeEach
public void setUp() throws IOException
{
sysProps = System.getProperties();
@@ -65,11 +65,11 @@ public void setUp() throws IOException
System.setProperties( p );
- lrd = temporaryFolder.newFile();
+ lrd = Files.createTempFile( temporaryFolder, "", "" ).toFile();
}
- @After
+ @AfterEach
public void tearDown()
{
System.setProperties( sysProps );
@@ -109,7 +109,7 @@ public void testShouldFailToSetLocalRepoLocationFromRequestWhenItIsAFile()
@Test
public void testShouldSetLocalRepoLocationGlobally() throws IOException
{
- File lrd = temporaryFolder.newFolder( "workdir" ).getCanonicalFile();
+ File lrd = Files.createDirectory( temporaryFolder.resolve( "workdir" )).toFile().getCanonicalFile();
mclb.setLocalRepositoryDirectory( lrd );
mclb.setLocalRepository( newRequest(), cli );
@@ -120,7 +120,7 @@ public void testShouldSetLocalRepoLocationGlobally() throws IOException
public void testShouldSetLocalRepoLocationFromRequest()
throws Exception
{
- File lrd = temporaryFolder.newFolder( "workdir" ).getCanonicalFile();
+ File lrd = Files.createDirectory( temporaryFolder.resolve( "workdir" ) ).toFile().getCanonicalFile();
mclb.setLocalRepository( newRequest().setLocalRepositoryDirectory( lrd ), cli );
assertArgumentsPresentInOrder( cli, "-D", "maven.repo.local=" + lrd.getPath() );
@@ -130,8 +130,8 @@ public void testShouldSetLocalRepoLocationFromRequest()
public void testRequestProvidedLocalRepoLocationShouldOverrideGlobal()
throws Exception
{
- File lrd = temporaryFolder.newFolder( "workdir" ).getCanonicalFile();
- File glrd = temporaryFolder.newFolder( "global-workdir" ).getCanonicalFile();
+ File lrd = Files.createDirectory( temporaryFolder.resolve( "workdir" ) ).toFile().getCanonicalFile();
+ File glrd = Files.createDirectory( temporaryFolder.resolve( "global-workdir" ) ).toFile().getCanonicalFile();
mclb.setLocalRepositoryDirectory( glrd );
mclb.setLocalRepository( newRequest().setLocalRepositoryDirectory( lrd ), cli );
@@ -143,7 +143,7 @@ public void testRequestProvidedLocalRepoLocationShouldOverrideGlobal()
public void testShouldSetWorkingDirectoryGlobally()
throws Exception
{
- File wd = temporaryFolder.newFolder( "workdir" );
+ File wd = Files.createDirectory( temporaryFolder.resolve( "workdir" ) ).toFile();
mclb.setBaseDirectory( wd );
Commandline commandline = mclb.build( newRequest() );
@@ -155,7 +155,7 @@ public void testShouldSetWorkingDirectoryGlobally()
public void testShouldSetWorkingDirectoryFromRequest()
throws Exception
{
- File wd = temporaryFolder.newFolder( "workdir" );
+ File wd = Files.createDirectory( temporaryFolder.resolve( "workdir" ) ).toFile();
InvocationRequest req = newRequest();
req.setBaseDirectory( wd );
@@ -169,8 +169,8 @@ public void testShouldSetWorkingDirectoryFromRequest()
public void testRequestProvidedWorkingDirectoryShouldOverrideGlobal()
throws Exception
{
- File wd = temporaryFolder.newFolder( "workdir" );
- File gwd = temporaryFolder.newFolder( "global-workdir" );
+ File wd = Files.createDirectory( temporaryFolder.resolve( "workdir" ) ).toFile();
+ File gwd = Files.createDirectory( temporaryFolder.resolve( "global-workdir" ) ).toFile();
mclb.setBaseDirectory( gwd );
@@ -200,7 +200,7 @@ private File setupTempMavenHomeIfMissing( boolean forceDummy )
if ( forceDummy || ( mavenHome == null ) || !new File( mavenHome ).exists() )
{
- appDir = temporaryFolder.newFolder( "invoker-tests", "maven-home" );
+ appDir = Files.createDirectories( temporaryFolder.resolve( "invoker-tests" ).resolve( "maven-home" ) ).toFile();
File binDir = new File( appDir, "bin" );
binDir.mkdirs();
@@ -246,7 +246,8 @@ public void testShouldFailIfLoggerSetToNull()
public void testShouldFindDummyMavenExecutable()
throws Exception
{
- File dummyMavenHomeBin = temporaryFolder.newFolder( "invoker-tests", "dummy-maven-home", "bin" );
+ File dummyMavenHomeBin = Files.createDirectories( temporaryFolder.resolve( "invoker-tests" )
+ .resolve( "dummy-maven-home" ).resolve( "bin" ) ).toFile();
File check;
if ( Os.isFamily( Os.FAMILY_WINDOWS ) )
@@ -268,7 +269,8 @@ public void testShouldFindDummyMavenExecutable()
public void testShouldFindDummyPS1MavenExecutable()
throws Exception
{
- File dummyMavenHomeBin = temporaryFolder.newFolder( "invoker-tests", "dummy-maven-home", "bin" );
+ File dummyMavenHomeBin = Files.createDirectories( temporaryFolder.resolve( "invoker-tests" )
+ .resolve( "dummy-maven-home" ).resolve( "bin" ) ).toFile();
File check;
if ( Os.isFamily( Os.FAMILY_WINDOWS ) )
@@ -285,7 +287,8 @@ public void testShouldFindDummyPS1MavenExecutable()
public void testShouldFindDummyMavenExecutableWithMavenHomeFromRequest()
throws Exception
{
- File dummyMavenHomeBin = temporaryFolder.newFolder( "invoker-tests", "dummy-maven-home", "bin" );
+ File dummyMavenHomeBin = Files.createDirectories( temporaryFolder.resolve( "invoker-tests" )
+ .resolve( "dummy-maven-home" ).resolve( "bin" ) ).toFile();
File check;
if ( Os.isFamily( Os.FAMILY_WINDOWS ) )
@@ -531,7 +534,8 @@ public void testShouldSetNoTransferProgressFlagFromRequest()
public void testShouldSpecifyFileOptionUsingNonStandardPomFileLocation()
throws Exception
{
- File projectDir = temporaryFolder.newFolder( "invoker-tests", "file-option-nonstd-pom-file-location" );
+ File projectDir = Files.createDirectories( temporaryFolder.resolve( "invoker-tests" )
+ .resolve( "file-option-nonstd-pom-file-location" ) ).toFile();
File pomFile = createDummyFile( projectDir, "non-standard-pom.xml" ).getCanonicalFile();
@@ -553,7 +557,8 @@ public void testShouldSpecifyFileOptionUsingNonStandardPomFileLocation()
public void testShouldNotSpecifyFileOptionUsingStandardPomFileLocation()
throws Exception
{
- File projectDir = temporaryFolder.newFolder( "invoker-tests", "std-pom-file-location" );
+ File projectDir = Files.createDirectories( temporaryFolder.resolve( "invoker-tests" )
+ .resolve( "std-pom-file-location" ) ).toFile();
File pomFile = createDummyFile( projectDir, "pom.xml" ).getCanonicalFile();
@@ -575,9 +580,10 @@ public void testShouldNotSpecifyFileOptionUsingStandardPomFileLocation()
public void testShouldSetPomForOutsideWorkspace()
throws Exception
{
- File projectDir = temporaryFolder.newFolder( "invoker-tests", "std-pom-file-location" );
+ File projectDir = Files.createDirectories( temporaryFolder.resolve( "invoker-tests" )
+ .resolve( "std-pom-file-location" ) ).toFile();
- File outsidePom = temporaryFolder.newFile( "pom.xml" );
+ File outsidePom = Files.createFile( temporaryFolder.resolve( "pom.xml" ) ).toFile();
InvocationRequest req = newRequest()
@@ -599,7 +605,8 @@ public void testShouldSetPomForOutsideWorkspace()
public void testShouldNotSpecifyFileOptionUsingStandardPomInBasedir()
throws Exception
{
- File projectDir = temporaryFolder.newFolder( "invoker-tests", "std-basedir-is-pom-file" );
+ File projectDir = Files.createDirectories( temporaryFolder.resolve( "invoker-tests" )
+ .resolve( "std-basedir-is-pom-file" ) ).toFile();
File basedir = createDummyFile( projectDir, "pom.xml" ).getCanonicalFile();
@@ -621,7 +628,8 @@ public void testShouldNotSpecifyFileOptionUsingStandardPomInBasedir()
public void testShouldUseDefaultPomFileWhenBasedirSpecifiedWithoutPomFileName()
throws Exception
{
- File projectDir = temporaryFolder.newFolder( "invoker-tests", "std-basedir-no-pom-filename" );
+ File projectDir = Files.createDirectories( temporaryFolder.resolve( "invoker-tests" )
+ .resolve( "std-basedir-no-pom-filename" ) ).toFile();
InvocationRequest req = newRequest().setBaseDirectory( projectDir );
@@ -641,7 +649,8 @@ public void testShouldUseDefaultPomFileWhenBasedirSpecifiedWithoutPomFileName()
public void testShouldSpecifyPomFileWhenBasedirSpecifiedWithPomFileName()
throws Exception
{
- File projectDir = temporaryFolder.newFolder( "invoker-tests", "std-basedir-with-pom-filename" );
+ File projectDir = Files.createDirectories( temporaryFolder.resolve( "invoker-tests" )
+ .resolve( "std-basedir-with-pom-filename" ) ).toFile();
InvocationRequest req = newRequest().setBaseDirectory( projectDir ).setPomFileName( "non-standard-pom.xml" );
@@ -660,7 +669,8 @@ public void testShouldSpecifyPomFileWhenBasedirSpecifiedWithPomFileName()
public void testShouldSpecifyCustomUserSettingsLocationFromRequest()
throws Exception
{
- File projectDir = temporaryFolder.newFolder( "invoker-tests", "custom-settings" );
+ File projectDir = Files.createDirectories( temporaryFolder.resolve( "invoker-tests" )
+ .resolve( "custom-settings" ) ).toFile();
File settingsFile = createDummyFile( projectDir, "settings.xml" );
@@ -678,7 +688,8 @@ public void testShouldSpecifyCustomUserSettingsLocationFromRequest()
public void testShouldSpecifyCustomGlobalSettingsLocationFromRequest()
throws Exception
{
- File projectDir = temporaryFolder.newFolder( "invoker-tests", "custom-settings" ).getCanonicalFile();
+ File projectDir = Files.createDirectories( temporaryFolder.resolve( "invoker-tests" )
+ .resolve( "custom-settings" ) ).toFile().getCanonicalFile();
File settingsFile = createDummyFile( projectDir, "settings.xml" );
@@ -696,7 +707,8 @@ public void testShouldSpecifyCustomGlobalSettingsLocationFromRequest()
public void testShouldSpecifyCustomToolchainsLocationFromRequest()
throws Exception
{
- File projectDir = temporaryFolder.newFolder( "invoker-tests", "custom-toolchains" );
+ File projectDir = Files.createDirectories( temporaryFolder.resolve( "invoker-tests" )
+ .resolve( "custom-toolchains" ) ).toFile();
File toolchainsFile = createDummyFile( projectDir, "toolchains.xml" );
@@ -787,7 +799,8 @@ public void testBuildTypicalMavenInvocationEndToEnd()
InvocationRequest request = newRequest();
- File projectDir = temporaryFolder.newFolder( "invoker-tests", "typical-end-to-end-cli-build" );
+ File projectDir = Files.createDirectories( temporaryFolder.resolve( "invoker-tests" )
+ .resolve( "typical-end-to-end-cli-build" ) ).toFile();
request.setBaseDirectory( projectDir );
@@ -857,46 +870,43 @@ public void testShouldInsertActivatedProfiles()
public void testMvnExecutableFromInvoker()
throws Exception
{
- assumeThat( "Test only works when maven.home is set",
- System.getProperty( "maven.home" ), is(notNullValue()));
+ assumeTrue( Objects.nonNull( System.getProperty( "maven.home" ) ), "Test only works when maven.home is set" );
File mavenExecutable = new File( "mvnDebug" );
mclb.setMavenExecutable( mavenExecutable );
mclb.build( newRequest() );
- assertTrue( "Expected executable to exist", mclb.getMavenExecutable().exists() );
- assertTrue( "Expected executable to be absolute", mclb.getMavenExecutable().isAbsolute() );
- assertTrue( "Expected mvnDebug as command mvnDebug", mclb.getMavenExecutable().getName().contains( "mvnDebug" ) );
+ assertTrue( mclb.getMavenExecutable().exists(), "Expected executable to exist" );
+ assertTrue( mclb.getMavenExecutable().isAbsolute(), "Expected executable to be absolute" );
+ assertTrue( mclb.getMavenExecutable().getName().contains( "mvnDebug" ), "Expected mvnDebug as command mvnDebug" );
}
@Test
public void testMvnExecutableFormRequest()
throws Exception
{
- assumeThat( "Test only works when maven.home is set",
- System.getProperty( "maven.home" ), is(notNullValue()));
+ assumeTrue( Objects.nonNull( System.getProperty( "maven.home" ) ), "Test only works when maven.home is set" );
File mavenExecutable = new File( "mvnDebug" );
mclb.build( newRequest().setMavenExecutable( mavenExecutable ) );
- assertTrue( "Expected executable to exist", mclb.getMavenExecutable().exists() );
- assertTrue( "Expected executable to be absolute", mclb.getMavenExecutable().isAbsolute() );
- assertTrue( "Expected mvnDebug as command", mclb.getMavenExecutable().getName().contains( "mvnDebug" ) );
+ assertTrue( mclb.getMavenExecutable().exists(), "Expected executable to exist" );
+ assertTrue( mclb.getMavenExecutable().isAbsolute(), "Expected executable to be absolute" );
+ assertTrue( mclb.getMavenExecutable().getName().contains( "mvnDebug" ), "Expected mvnDebug as command" );
}
@Test
public void testDefaultMavenCommand()
throws Exception
{
- assumeThat( "Test only works when maven.home is set",
- System.getProperty( "maven.home" ), is(notNullValue()));
+ assumeTrue(Objects.nonNull( System.getProperty( "maven.home" ) ), "Test only works when maven.home is set" );
mclb.build( newRequest() );
- assertTrue( "Expected executable to exist", mclb.getMavenExecutable().exists() );
- assertTrue( "Expected executable to be absolute", mclb.getMavenExecutable().isAbsolute() );
+ assertTrue( mclb.getMavenExecutable().exists(), "Expected executable to exist" );
+ assertTrue( mclb.getMavenExecutable().isAbsolute(), "Expected executable to be absolute" );
}
@Test
@@ -928,8 +938,8 @@ private void assertEnvironmentVariablePresent( Commandline cli, String varName,
String expectedDeclaration = varName + "=" + varValue;
- assertTrue( "Environment variable setting: '" + expectedDeclaration + "' is mssing in "
- + environmentVariables, environmentVariables.contains( expectedDeclaration ) );
+ assertTrue( environmentVariables.contains( expectedDeclaration ), "Environment variable setting: '"
+ + expectedDeclaration + "' is missing in " + environmentVariables );
}
private void assertArgumentsPresentInOrder( Commandline cli, String... expected )
@@ -951,8 +961,8 @@ private void assertArgumentsPresentInOrder( Commandline cli, List expect
}
}
- assertEquals( "Arguments: " + expected + " were not found or are in the wrong order: "
- + Arrays.asList( arguments ), expected.size(), expectedCounter );
+ assertEquals( expected.size(), expectedCounter, "Arguments: " + expected + " were not found or are in the wrong order: "
+ + Arrays.asList( arguments ) );
}
private void assertArgumentsPresent( Commandline cli, Set requiredArgs )
@@ -962,7 +972,7 @@ private void assertArgumentsPresent( Commandline cli, Set requiredArgs )
for ( String arg : requiredArgs )
{
- assertTrue( "Command-line argument: '" + arg + "' is missing in " + args, args.contains( arg ) );
+ assertTrue( args.contains( arg ), "Command-line argument: '" + arg + "' is missing in " + args );
}
}
@@ -973,7 +983,7 @@ private void assertArgumentsNotPresent( Commandline cli, Set bannedArgs
for ( String arg : bannedArgs )
{
- assertFalse( "Command-line argument: '" + arg + "' should not be present.", args.contains( arg ) );
+ assertFalse( args.contains( arg ), "Command-line argument: '" + arg + "' should not be present." );
}
}
diff --git a/src/test/java/org/apache/maven/shared/invoker/SystemOutHandlerTest.java b/src/test/java/org/apache/maven/shared/invoker/SystemOutHandlerTest.java
index 3870955..ddc5e72 100644
--- a/src/test/java/org/apache/maven/shared/invoker/SystemOutHandlerTest.java
+++ b/src/test/java/org/apache/maven/shared/invoker/SystemOutHandlerTest.java
@@ -19,7 +19,7 @@
* under the License.
*/
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class SystemOutHandlerTest
{
diff --git a/src/test/java/org/apache/maven/shared/invoker/SystemOutLoggerTest.java b/src/test/java/org/apache/maven/shared/invoker/SystemOutLoggerTest.java
index f936ba9..1238843 100644
--- a/src/test/java/org/apache/maven/shared/invoker/SystemOutLoggerTest.java
+++ b/src/test/java/org/apache/maven/shared/invoker/SystemOutLoggerTest.java
@@ -19,13 +19,13 @@
* under the License.
*/
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import org.junit.jupiter.api.Test;
import java.net.MalformedURLException;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class SystemOutLoggerTest
{