fixed shouldExistTmpDirectory(AbstractSurefireMojoTest) on JDK 11
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
index 304f449..8c03e15 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
@@ -2375,13 +2375,15 @@
File canonical = result.getCanonicalFile();
if ( !result.equals( canonical ) )
{
- logger.debug( "Canonicalized tempDir path '" + result + "' to '" + canonical + "'" );
+ getConsoleLogger()
+ .debug( "Canonicalized tempDir path '" + result + "' to '" + canonical + "'" );
}
return canonical;
}
catch ( IOException e )
{
- logger.error( "Could not canonicalize tempDir path '" + result + "'", e );
+ getConsoleLogger()
+ .error( "Could not canonicalize tempDir path '" + result + "'", e );
}
return result;
}
@@ -2517,7 +2519,7 @@
}
return new TestClassPath( classpathArtifacts, getClassesDirectory(),
- getTestClassesDirectory(), getAdditionalClasspathElements(), logger );
+ getTestClassesDirectory(), getAdditionalClasspathElements(), getConsoleLogger() );
}
/**
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/TestClassPath.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/TestClassPath.java
index 3e3a327..ee8fadb 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/TestClassPath.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/TestClassPath.java
@@ -20,8 +20,8 @@
*/
import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
import org.apache.maven.surefire.booter.Classpath;
-import org.codehaus.plexus.logging.Logger;
import java.io.File;
import java.util.ArrayList;
@@ -38,13 +38,13 @@
private final File classesDirectory;
private final File testClassesDirectory;
private final String[] additionalClasspathElements;
- private final Logger logger;
+ private final ConsoleLogger logger;
TestClassPath( Iterable<Artifact> artifacts,
File classesDirectory,
File testClassesDirectory,
String[] additionalClasspathElements,
- Logger logger )
+ ConsoleLogger logger )
{
this.artifacts = artifacts;
this.classesDirectory = classesDirectory;
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java
index 4ec49f4..a6fc708 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java
@@ -55,6 +55,7 @@
import static org.apache.maven.artifact.versioning.VersionRange.createFromVersion;
import static org.apache.maven.artifact.versioning.VersionRange.createFromVersionSpec;
import static org.fest.assertions.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.when;
@@ -326,6 +327,12 @@
new File( targetDir, tmpDir ).delete();
AbstractSurefireMojo mojo = mock( AbstractSurefireMojo.class );
+ Logger logger = mock( Logger.class );
+ when( logger.isDebugEnabled() ).thenReturn( false );
+ when( logger.isErrorEnabled() ).thenReturn( false );
+ doNothing().when( logger ).debug( anyString() );
+ doNothing().when( logger ).error( anyString(), any( Throwable.class ) );
+ when( mojo.getConsoleLogger() ).thenReturn( new PluginConsoleLogger( logger ) );
when( mojo.getTempDir() ).thenReturn( tmpDir );
when( mojo.getProjectBuildDirectory() ).thenReturn( targetDir );
when( mojo.createSurefireBootDirectoryInTemp() ).thenCallRealMethod();