[maven-surefire] branch master updated: fixed shouldExistTmpDirectory(AbstractSurefireMojoTest) on JDK 11

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[maven-surefire] branch master updated: fixed shouldExistTmpDirectory(AbstractSurefireMojoTest) on JDK 11

Tibor Digana
This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git


The following commit(s) were added to refs/heads/master by this push:
     new d86d649  fixed shouldExistTmpDirectory(AbstractSurefireMojoTest) on JDK 11
d86d649 is described below

commit d86d649181ded89c440e0440659938f1c71c9dcc
Author: Tibor17 <[hidden email]>
AuthorDate: Wed Dec 5 05:39:38 2018 +0100

    fixed shouldExistTmpDirectory(AbstractSurefireMojoTest) on JDK 11
---
 .../org/apache/maven/plugin/surefire/AbstractSurefireMojo.java    | 8 +++++---
 .../main/java/org/apache/maven/plugin/surefire/TestClassPath.java | 6 +++---
 .../apache/maven/plugin/surefire/AbstractSurefireMojoTest.java    | 7 +++++++
 3 files changed, 15 insertions(+), 6 deletions(-)

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 @@ public abstract class AbstractSurefireMojo
             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 @@ public abstract class AbstractSurefireMojo
         }
 
         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 @@ package org.apache.maven.plugin.surefire;
  */
 
 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 @@ final class TestClassPath
     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.commons.lang3.SystemUtils.IS_OS_WINDOWS;
 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 @@ public class AbstractSurefireMojoTest
         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();