You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2021/10/08 11:40:10 UTC

[maven-javadoc-plugin] 01/01: Use test constructor instead of conditional setup

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

rfscholte pushed a commit to branch stabilize
in repository https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git

commit 664f37bb35cf4b4f12cf166002a7e586445dbb78
Author: rfscholte <rf...@apache.org>
AuthorDate: Fri Oct 8 13:39:58 2021 +0200

    Use test constructor instead of conditional setup
---
 .../maven/plugins/javadoc/JavadocReportTest.java   | 37 ++++------------------
 1 file changed, 6 insertions(+), 31 deletions(-)

diff --git a/src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java b/src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java
index 3dc5ffd..5b00634 100644
--- a/src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java
+++ b/src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java
@@ -43,6 +43,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.stream.Collectors;
 
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.model.Plugin;
@@ -80,22 +81,14 @@ public class JavadocReportTest
 
     public static final String OPTIONS_UMLAUT_ENCODING = "Options Umlaut Encoding ö ä ü ß";
 
-    /** flag to copy repo only one time */
-    private static boolean TEST_REPO_CREATED = false;
+    private final Path unit;
 
-    private Path unit;
-
-    private File localRepo;
+    private final File localRepo;
 
     private static final Logger LOGGER = LoggerFactory.getLogger( JavadocReportTest.class );
-
-    /** {@inheritDoc} */
-    @Override
-    protected void setUp()
-        throws Exception
+    
+    public JavadocReportTest() throws Exception
     {
-        super.setUp();
-
         unit = new File( getBasedir(), "src/test/resources/unit" ).toPath();
 
         localRepo = new File( getBasedir(), "target/local-repo/" );
@@ -103,7 +96,6 @@ public class JavadocReportTest
         createTestRepo();
     }
 
-
     private JavadocReport lookupMojo( Path testPom )
         throws Exception
     {
@@ -130,11 +122,6 @@ public class JavadocReportTest
     private void createTestRepo()
         throws IOException
     {
-        if ( TEST_REPO_CREATED )
-        {
-            return;
-        }
-
         localRepo.mkdirs();
 
         // ----------------------------------------------------------------------
@@ -195,15 +182,12 @@ public class JavadocReportTest
                 file.delete();
             }
         }
-
-        TEST_REPO_CREATED = true;
     }
 
     /**
      * Convenience method that reads the contents of the specified file object into a string with a
      * <code>space</code> as line separator.
      *
-     * @see #LINE_SEPARATOR
      * @param file the file to be read
      * @return a String object that contains the contents of the file
      * @throws IOException if any
@@ -218,7 +202,6 @@ public class JavadocReportTest
      * Convenience method that reads the contents of the specified file object into a string with a
      * <code>space</code> as line separator.
      *
-     * @see #LINE_SEPARATOR
      * @param file the file to be read
      * @param cs charset to use
      * @return a String object that contains the contents of the file
@@ -227,15 +210,7 @@ public class JavadocReportTest
     private static String readFile( Path file, Charset cs )
             throws IOException
     {
-        StringBuilder str = new StringBuilder( (int) Files.size( file ) );
-
-        for ( String strTmp : Files.readAllLines( file, cs ) )
-        {
-            str.append( LINE_SEPARATOR);
-            str.append( strTmp );
-        }
-
-        return str.toString();
+        return Files.readAllLines( file, cs ).stream().collect( Collectors.joining( " " ) );
     }
 
     /**