This is an automated email from the ASF dual-hosted git repository.
elharo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-shared-utils.git
The following commit(s) were added to refs/heads/master by this push:
new 001baa7 fix a number of small warnings and formatting issues (#10)
001baa7 is described below
commit 001baa7d7b534f1cec4bc509e750c03e53a695ce
Author: Elliotte Rusty Harold <[email protected]>
AuthorDate: Mon Mar 23 16:29:34 2020 -0400
fix a number of small warnings and formatting issues (#10)
* fix a number of small warnings and formatting issues
* setters shouldn't return values
---
.../apache/maven/shared/utils/io/FileUtils.java | 8 ----
.../org/apache/maven/shared/utils/xml/Xpp3Dom.java | 9 ----
.../maven/shared/utils/XmlStreamReaderTest.java | 54 ++++++++--------------
.../shared/utils/cli/CommandLineUtilsTest.java | 26 ++++++-----
.../maven/shared/utils/io/SymlinkTestSetup.java | 15 +++---
5 files changed, 41 insertions(+), 71 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/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/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 4483527..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
@@ -127,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/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" ) );