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

elharo pushed a commit to branch xml2
in repository https://gitbox.apache.org/repos/asf/maven-shared-utils.git

commit 662c9eea3b8f47a34e015c8614e32e6efde623a5
Author: Elliotte Rusty Harold <elh...@ibiblio.org>
AuthorDate: Sun Feb 23 11:22:42 2020 -0500

    fix a number of small warnings and formatting issues
---
 .../apache/maven/shared/utils/io/FileUtils.java    |  8 ----
 .../maven/shared/utils/reflection/Reflector.java   |  8 ++--
 .../org/apache/maven/shared/utils/xml/Xpp3Dom.java |  9 ----
 .../org/apache/maven/shared/utils/ExpandTest.java  | 20 ++++----
 .../maven/shared/utils/XmlStreamReaderTest.java    | 54 ++++++++--------------
 .../shared/utils/cli/CommandLineUtilsTest.java     | 27 ++++++-----
 .../shared/utils/io/DirectoryScannerTest.java      |  1 -
 .../maven/shared/utils/io/SymlinkTestSetup.java    | 15 +++---
 8 files changed, 55 insertions(+), 87 deletions(-)

diff --git a/src/main/java/org/apache/maven/shared/utils/io/FileUtils.java 
b/src/main/java/org/apache/maven/shared/utils/io/FileUtils.java
index 63a5aa3..e5264b2 100644
--- a/src/main/java/org/apache/maven/shared/utils/io/FileUtils.java
+++ b/src/main/java/org/apache/maven/shared/utils/io/FileUtils.java
@@ -107,11 +107,6 @@ public class FileUtils
     private static final int ONE_MB = ONE_KB * ONE_KB;
 
     /**
-     * The number of bytes in a gigabyte.
-     */
-    private static final int ONE_GB = ONE_KB * ONE_MB;
-
-    /**
      * The file copy buffer size (30 MB)
      */
     private static final long FILE_COPY_BUFFER_SIZE = ONE_MB * 30;
@@ -497,9 +492,6 @@ public class FileUtils
     /**
      * Given a directory and an array of extensions return an array of 
compliant files.
      * <p/>
-     * TODO Should an ignore list be passed in?
-     * TODO Should a recurse flag be passed in?
-     * <p/>
      * The given extensions should be like "java" and not like ".java"
      *
      * @param directory  The path of the directory.
diff --git 
a/src/main/java/org/apache/maven/shared/utils/reflection/Reflector.java 
b/src/main/java/org/apache/maven/shared/utils/reflection/Reflector.java
index c4cb3b7..49cbef0 100644
--- a/src/main/java/org/apache/maven/shared/utils/reflection/Reflector.java
+++ b/src/main/java/org/apache/maven/shared/utils/reflection/Reflector.java
@@ -422,12 +422,12 @@ final class Reflector
     }
 
     /**
-     * Return the method, checking the cache first and storing in cache if not 
already there..
+     * Return the method, checking the cache first and storing in cache if not 
already there.
      * 
-     * @param targetClass The class to get the method from
-     * @param params The classes of the parameters which the method should 
match.
+     * @param targetClass the class to get the method from
+     * @param params the classes of the parameters which the method should 
match.
      * @return the Method object that matches, never {@code null}
-     * @throws ReflectorException In case we can't retrieve the proper method.
+     * @throws ReflectorException if we can't retrieve the proper method
      */
     public Method getMethod( Class<?> targetClass, String methodName, 
Class<?>... params )
         throws ReflectorException
diff --git a/src/main/java/org/apache/maven/shared/utils/xml/Xpp3Dom.java 
b/src/main/java/org/apache/maven/shared/utils/xml/Xpp3Dom.java
index 5efa8fc..1b2f1b6 100644
--- a/src/main/java/org/apache/maven/shared/utils/xml/Xpp3Dom.java
+++ b/src/main/java/org/apache/maven/shared/utils/xml/Xpp3Dom.java
@@ -311,15 +311,6 @@ public class Xpp3Dom
        this.parent = parent;
     }
 
-    // Todo: Support writing to serializer (>1.0)
-  //  public void writeToSerializer( String namespace, XmlSerializer 
serializer )
-    //        throws IOException
-
-    private static Xpp3Dom merge( Xpp3Dom dominant, Xpp3Dom recessive, Boolean 
childMergeOverride )
-    {
-        return Xpp3DomUtils.merge( dominant, recessive, childMergeOverride );
-    }
-
     /**
      * @param dominant The dominant part.
      * @param recessive The recessive part.
diff --git a/src/test/java/org/apache/maven/shared/utils/ExpandTest.java 
b/src/test/java/org/apache/maven/shared/utils/ExpandTest.java
index 6718c83..d0d877e 100644
--- a/src/test/java/org/apache/maven/shared/utils/ExpandTest.java
+++ b/src/test/java/org/apache/maven/shared/utils/ExpandTest.java
@@ -29,17 +29,17 @@ import org.junit.rules.TemporaryFolder;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.net.URL;
+import java.util.Scanner;
 
 import static org.hamcrest.CoreMatchers.*;
 
 /**
- * This will test the plexus utility class {@link Expand}.
+ * This tests the utility class {@link Expand}.
  *
- * Most of this stuff will be obsolete because java-1.4.2
+ * Most of this stuff is obsolete because java-1.4.2
  * introduced a java.util.zip package which works like a charm.
  *
- * We of course need to implement this class due to compatibility
- * reasons.
+ * We  need to implement this class for compatibility reasons.
  *
  * @author <a href="mailto:strub...@yahoo.de";>Mark Struberg</a>
  */
@@ -326,11 +326,11 @@ public class ExpandTest
 
         assertNotNull( expandedFile );
 
-        java.util.Scanner scanner = new java.util.Scanner( expandedFile 
).useDelimiter( "\n" );
-        String text = scanner.next();
-
-        assertThat( "expanded file content must match"
-                  , text
-                  , is( expectedContent ) );
+        try (Scanner base = new Scanner( expandedFile );
+             Scanner scanner = base.useDelimiter( "\n" ) ) 
+        {
+            String text = scanner.next();
+            assertThat( "expanded file content must match", text, is( 
expectedContent ) );
+        }
     }
 }
diff --git 
a/src/test/java/org/apache/maven/shared/utils/XmlStreamReaderTest.java 
b/src/test/java/org/apache/maven/shared/utils/XmlStreamReaderTest.java
index 05715c1..3ffb98d 100644
--- a/src/test/java/org/apache/maven/shared/utils/XmlStreamReaderTest.java
+++ b/src/test/java/org/apache/maven/shared/utils/XmlStreamReaderTest.java
@@ -55,8 +55,6 @@ public class XmlStreamReaderTest
     private static final byte[] BOM_UTF8 = { (byte)0xEF, (byte)0xBB, 
(byte)0xBF };
     private static final byte[] BOM_UTF16BE = { (byte)0xFE, (byte)0xFF };
     private static final byte[] BOM_UTF16LE = { (byte)0xFF, (byte)0xFE };
-    private static final byte[] BOM_UTF32BE = { (byte)0x00, (byte)0x00, 
(byte)0xFF, (byte)0xFE };
-    private static final byte[] BOM_UTF32LE = { (byte)0xFF, (byte)0xFE, 
(byte)0x00, (byte)0x00 };
 
     private static String createXmlContent( String text, String encoding )
     {
@@ -74,8 +72,7 @@ public class XmlStreamReaderTest
         checkXmlContent( xml, encoding, null );
     }
 
-    private static void checkXmlContent( String xml, String encoding, byte[] 
bom )
-    throws IOException
+    private static void checkXmlContent( String xml, String encoding, byte[] 
bom ) throws IOException
     {
         byte[] xmlContent = xml.getBytes( encoding );
         InputStream in = new ByteArrayInputStream( xmlContent );
@@ -92,104 +89,90 @@ public class XmlStreamReaderTest
     }
 
     private static void checkXmlStreamReader( String text, String encoding, 
String effectiveEncoding )
-    throws IOException
+        throws IOException
     {
         checkXmlStreamReader( text, encoding, effectiveEncoding, null );
     }
 
-    private static void checkXmlStreamReader( String text, String encoding )
-    throws IOException
+    private static void checkXmlStreamReader( String text, String encoding ) 
throws IOException
     {
         checkXmlStreamReader( text, encoding, encoding, null );
     }
 
-    private static void checkXmlStreamReader( String text, String encoding, 
byte[] bom )
-    throws IOException
+    private static void checkXmlStreamReader( String text, String encoding, 
byte[] bom ) throws IOException
     {
         checkXmlStreamReader( text, encoding, encoding, bom );
     }
 
     private static void checkXmlStreamReader( String text, String encoding, 
String effectiveEncoding, byte[] bom )
-    throws IOException
+        throws IOException
     {
         String xml = createXmlContent( text, encoding );
         checkXmlContent( xml, effectiveEncoding, bom );
     }
 
-    public void testNoXmlHeader()
-    throws IOException
+    public void testNoXmlHeader() throws IOException
     {
         String xml = "<text>text with no XML header</text>";
         checkXmlContent( xml, "UTF-8" );
         checkXmlContent( xml, "UTF-8", BOM_UTF8 );
     }
 
-    public void testDefaultEncoding()
-    throws IOException
+    public void testDefaultEncoding() throws IOException
     {
         checkXmlStreamReader( TEXT_UNICODE, null, "UTF-8" );
         checkXmlStreamReader( TEXT_UNICODE, null, "UTF-8", BOM_UTF8 );
     }
 
-    public void testUTF8Encoding()
-    throws IOException
+    public void testUTF8Encoding()  throws IOException
     {
         checkXmlStreamReader( TEXT_UNICODE, "UTF-8" );
         checkXmlStreamReader( TEXT_UNICODE, "UTF-8", BOM_UTF8 );
     }
 
-    public void testUTF16Encoding()
-    throws IOException
+    public void testUTF16Encoding() throws IOException
     {
         checkXmlStreamReader( TEXT_UNICODE, "UTF-16", "UTF-16BE", null );
         checkXmlStreamReader( TEXT_UNICODE, "UTF-16", "UTF-16LE", BOM_UTF16LE 
);
         checkXmlStreamReader( TEXT_UNICODE, "UTF-16", "UTF-16BE", BOM_UTF16BE 
);
     }
 
-    public void testUTF16BEEncoding()
-    throws IOException
+    public void testUTF16BEEncoding() throws IOException
     {
         checkXmlStreamReader( TEXT_UNICODE, "UTF-16BE" );
     }
 
-    public void testUTF16LEEncoding()
-    throws IOException
+    public void testUTF16LEEncoding() throws IOException
     {
         checkXmlStreamReader( TEXT_UNICODE, "UTF-16LE" );
     }
 
-    public void testLatin1Encoding()
-    throws IOException
+    public void testLatin1Encoding() throws IOException
     {
         checkXmlStreamReader( TEXT_LATIN1, "ISO-8859-1" );
     }
 
-    public void testLatin7Encoding()
-    throws IOException
+    public void testLatin7Encoding() throws IOException
     {
         checkXmlStreamReader( TEXT_LATIN7, "ISO-8859-7" );
     }
 
-    public void testLatin15Encoding()
-    throws IOException
+    public void testLatin15Encoding() throws IOException
     {
         checkXmlStreamReader( TEXT_LATIN15, "ISO-8859-15" );
     }
 
-    public void testEUC_JPEncoding()
-    throws IOException
+    public void testEUC_JPEncoding() throws IOException
     {
         checkXmlStreamReader( TEXT_EUC_JP, "EUC-JP" );
     }
 
-    public void testEBCDICEncoding()
-    throws IOException
+    public void testEBCDICEncoding() throws IOException
     {
         checkXmlStreamReader( "simple text in EBCDIC", "CP1047" );
     }
 
-    public void testInappropriateEncoding()
-    throws IOException
+    public void testInappropriateEncoding() throws IOException
     {
         try
         {
@@ -202,8 +185,7 @@ public class XmlStreamReaderTest
         }
     }
 
-    public void testEncodingAttribute()
-    throws IOException
+    public void testEncodingAttribute() throws IOException
     {
         String xml = "<?xml version='1.0' encoding='US-ASCII'?><element 
encoding='attribute value'/>";
         checkXmlContent( xml, "US-ASCII" );
diff --git 
a/src/test/java/org/apache/maven/shared/utils/cli/CommandLineUtilsTest.java 
b/src/test/java/org/apache/maven/shared/utils/cli/CommandLineUtilsTest.java
index 5b5ec2a..50d9336 100644
--- a/src/test/java/org/apache/maven/shared/utils/cli/CommandLineUtilsTest.java
+++ b/src/test/java/org/apache/maven/shared/utils/cli/CommandLineUtilsTest.java
@@ -19,7 +19,6 @@ package org.apache.maven.shared.utils.cli;
  * under the License.
  */
 
-import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -128,33 +127,37 @@ public class CommandLineUtilsTest
     }
 
     @Test
-    public void 
givenASingleQuoteMarkInArgument_whenTranslatingToCmdLineArgs_thenTheQuotationMarkIsNotEscaped()
 throws Exception
+    public void 
givenASingleQuoteMarkInArgument_whenTranslatingToCmdLineArgs_thenTheQuotationMarkIsNotEscaped()
+        throws Exception
     {
         final String command = "echo \"let's go\"";
-        final String[] expected = new String[]{"echo", "let's go"};
-        assertCmdLineArgs(expected, command);
+        final String[] expected = new String[] { "echo", "let's go" };
+        assertCmdLineArgs( expected, command );
     }
 
     @Test
-    public void 
givenAnEscapedDoubleQuoteMarkInArgument_whenTranslatingToCmdLineArgs_thenTheQuotationMarkRemainsEscaped()
 throws Exception
+    public void 
givenAnEscapedDoubleQuoteMarkInArgument_whenTranslatingToCmdLineArgs_thenTheQuotationMarkRemainsEscaped()
+        throws Exception
     {
         final String command = "echo \"let\\\"s go\"";
-        final String[] expected = new String[]{"echo", "let\\\"s go"};
-        assertCmdLineArgs(expected, command);
+        final String[] expected = new String[] { "echo", "let\\\"s go" };
+        assertCmdLineArgs( expected, command );
     }
 
     @Test
-    public void 
givenAnEscapedSingleQuoteMarkInArgument_whenTranslatingToCmdLineArgs_thenTheQuotationMarkRemainsEscaped()
 throws Exception
+    public void 
givenAnEscapedSingleQuoteMarkInArgument_whenTranslatingToCmdLineArgs_thenTheQuotationMarkRemainsEscaped()
+        throws Exception
     {
         final String command = "echo \"let\\\'s go\"";
-        final String[] expected = new String[]{"echo", "let\\\'s go"};
-        assertCmdLineArgs(expected, command);
+        final String[] expected = new String[] { "echo", "let\\\'s go" };
+        assertCmdLineArgs( expected, command );
     }
 
     @Test
-    public void 
givenAnEscapedDoubleQuoteMarkInArgument_whenTranslatingToCmdLineArgs_thenNoExceptionIsThrown()
 throws Exception
+    public void 
givenAnEscapedDoubleQuoteMarkInArgument_whenTranslatingToCmdLineArgs_thenNoExceptionIsThrown()
+        throws Exception
     {
-        new Commandline("echo \"let\\\"s go\"").execute();
+        new Commandline( "echo \"let\\\"s go\"" ).execute();
     }
 
     private void assertCmdLineArgs( final String[] expected, final String 
cmdLine )
diff --git 
a/src/test/java/org/apache/maven/shared/utils/io/DirectoryScannerTest.java 
b/src/test/java/org/apache/maven/shared/utils/io/DirectoryScannerTest.java
index e331db9..f25e0a8 100644
--- a/src/test/java/org/apache/maven/shared/utils/io/DirectoryScannerTest.java
+++ b/src/test/java/org/apache/maven/shared/utils/io/DirectoryScannerTest.java
@@ -129,7 +129,6 @@ public class DirectoryScannerTest
         ds.setBasedir( new File( "src/test/resources/symlinks/src" ) );
         ds.setFollowSymlinks( false );
         ds.scan();
-        String[] includedDirectories = ds.getIncludedDirectories();
         String[] files = ds.getIncludedFiles();
         
         //FIXME: This should be changed to some kind of assert...WhatEver()...
diff --git 
a/src/test/java/org/apache/maven/shared/utils/io/SymlinkTestSetup.java 
b/src/test/java/org/apache/maven/shared/utils/io/SymlinkTestSetup.java
index 63bcd23..6ae3ba9 100644
--- a/src/test/java/org/apache/maven/shared/utils/io/SymlinkTestSetup.java
+++ b/src/test/java/org/apache/maven/shared/utils/io/SymlinkTestSetup.java
@@ -3,6 +3,7 @@ package org.apache.maven.shared.utils.io;
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 
 import static org.apache.commons.io.FileUtils.write;
 
@@ -36,18 +37,18 @@ public class SymlinkTestSetup
         srcDir.mkdirs();
         File target = new File( srcDir, "targetDir" );
         target.mkdirs();
-        write( new File( target, "targetFile.txt" ), "a regular File payload" 
);
+        write( new File( target, "targetFile.txt" ), "a regular File payload", 
StandardCharsets.UTF_8 );
         File aRegularDir = new File( srcDir, "aRegularDir" );
         aRegularDir.mkdirs();
-        write( new File( aRegularDir, "aRegularFile.txt" ), "a regular File 
payload" );
+        write( new File( aRegularDir, "aRegularFile.txt" ), "a regular File 
payload", StandardCharsets.UTF_8 );
 
         File dirOnTheOutside = new File( root, "dirOnTheOutside" );
         dirOnTheOutside.mkdirs();
-        write( new File( dirOnTheOutside, "FileInDirOnTheOutside.txt" ), "a 
file in dir on the outside" );
-        write( new File( root, "onTheOutside.txt" ), "A file on the outside" );
-        write( new File( srcDir, "fileR.txt" ), "FileR payload" );
-        write( new File( srcDir, "fileW.txt" ), "FileW payload" );
-        write( new File( srcDir, "fileX.txt" ), "FileX payload" );
+        write( new File( dirOnTheOutside, "FileInDirOnTheOutside.txt" ), "a 
file in dir on the outside", StandardCharsets.UTF_8 );
+        write( new File( root, "onTheOutside.txt" ), "A file on the outside", 
StandardCharsets.UTF_8 );
+        write( new File( srcDir, "fileR.txt" ), "FileR payload", 
StandardCharsets.UTF_8 );
+        write( new File( srcDir, "fileW.txt" ), "FileW payload", 
StandardCharsets.UTF_8 );
+        write( new File( srcDir, "fileX.txt" ), "FileX payload", 
StandardCharsets.UTF_8 );
         // todo: set file attributes (not used here)
 
         Java7Support.createSymbolicLink( new File( srcDir, "symDir" ), new 
File( "targetDir" ) );

Reply via email to