You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by pa...@apache.org on 2016/11/10 20:52:08 UTC
[1/2] commons-io git commit: use manage version from commons-parent
for maven-antrun-plugin
Repository: commons-io
Updated Branches:
refs/heads/master bb3334507 -> 6b57d2a14
use manage version from commons-parent for maven-antrun-plugin
Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/6e33d3df
Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/6e33d3df
Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/6e33d3df
Branch: refs/heads/master
Commit: 6e33d3df3233e66f98a8dd2ae470752b768fcd54
Parents: bb33345
Author: pascalschumacher <pa...@gmx.net>
Authored: Thu Nov 10 21:24:24 2016 +0100
Committer: pascalschumacher <pa...@gmx.net>
Committed: Thu Nov 10 21:24:24 2016 +0100
----------------------------------------------------------------------
pom.xml | 1 -
1 file changed, 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-io/blob/6e33d3df/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index eedaf3c..c12162e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -374,7 +374,6 @@ file comparators, endian transformation classes, and much more.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
- <version>1.8</version>
<executions>
<execution>
<id>prepare-checkout</id>
[2/2] commons-io git commit: fix some warnings in tests
Posted by pa...@apache.org.
fix some warnings in tests
Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/6b57d2a1
Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/6b57d2a1
Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/6b57d2a1
Branch: refs/heads/master
Commit: 6b57d2a14089735cf1c653a2717d05023a3be441
Parents: 6e33d3d
Author: pascalschumacher <pa...@gmx.net>
Authored: Thu Nov 10 21:51:56 2016 +0100
Committer: pascalschumacher <pa...@gmx.net>
Committed: Thu Nov 10 21:51:56 2016 +0100
----------------------------------------------------------------------
.../org/apache/commons/io/IOUtilsTestCase.java | 23 +-----
.../comparator/ComparatorAbstractTestCase.java | 1 -
.../commons/io/input/BoundedReaderTest.java | 7 +-
...MessageDigestCalculatingInputStreamTest.java | 10 +--
.../org/apache/commons/io/input/TailerTest.java | 10 +--
.../io/output/LockableFileWriterTest.java | 73 ++++----------------
6 files changed, 31 insertions(+), 93 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-io/blob/6b57d2a1/src/test/java/org/apache/commons/io/IOUtilsTestCase.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/io/IOUtilsTestCase.java b/src/test/java/org/apache/commons/io/IOUtilsTestCase.java
index 8c942f2..78297dd 100644
--- a/src/test/java/org/apache/commons/io/IOUtilsTestCase.java
+++ b/src/test/java/org/apache/commons/io/IOUtilsTestCase.java
@@ -50,6 +50,7 @@ import static org.junit.Assert.fail;
* </ul>
* Due to interdependencies in IOUtils and IOUtilsTestlet, one bug may cause multiple tests to fail.
*/
+@SuppressWarnings("deprecation") // deliberately testing deprecated code
public class IOUtilsTestCase extends FileBasedTestCase {
private static final int FILE_SIZE = 1024 * 4 + 1;
@@ -284,8 +285,6 @@ public class IOUtilsTestCase extends FileBasedTestCase {
assertTrue(IOUtils.contentEqualsIgnoreEOL(r1, r2));
}
- @SuppressWarnings("deprecation")
- // testing deprecated method
@Test public void testCopy_ByteArray_OutputStream() throws Exception {
final File destination = TestUtils.newFile(getTestDirectory(), "copy8.txt");
byte[] in;
@@ -305,8 +304,6 @@ public class IOUtilsTestCase extends FileBasedTestCase {
TestUtils.deleteFile(destination);
}
- @SuppressWarnings("deprecation")
- // testing deprecated method
@Test public void testCopy_ByteArray_Writer() throws Exception {
final File destination = TestUtils.newFile(getTestDirectory(), "copy7.txt");
byte[] in;
@@ -324,8 +321,6 @@ public class IOUtilsTestCase extends FileBasedTestCase {
TestUtils.deleteFile(destination);
}
- @SuppressWarnings("deprecation")
- // testing deprecated method
@Test public void testCopy_String_Writer() throws Exception {
final File destination = TestUtils.newFile(getTestDirectory(), "copy6.txt");
String str;
@@ -703,7 +698,6 @@ public class IOUtilsTestCase extends FileBasedTestCase {
IOUtils.closeQuietly(reader);
}
- @SuppressWarnings("deprecation") // deliberately testing deprecated method
@Test public void testReadLines_InputStream() throws Exception {
final File file = TestUtils.newFile(getTestDirectory(), "lines.txt");
InputStream in = null;
@@ -849,8 +843,6 @@ public class IOUtilsTestCase extends FileBasedTestCase {
IOUtils.closeQuietly(input);
}
- @SuppressWarnings("deprecation")
- // testing deprecated method
@Test public void testStringToOutputStream() throws Exception {
final File destination = TestUtils.newFile(getTestDirectory(), "copy5.txt");
String str;
@@ -961,7 +953,6 @@ public class IOUtilsTestCase extends FileBasedTestCase {
}
}
- @SuppressWarnings("deprecation") // deliberately testing deprecated method
@Test public void testToByteArray_Reader() throws IOException {
final String charsetName = "UTF-8";
final byte[] expecteds = charsetName.getBytes(charsetName);
@@ -971,8 +962,6 @@ public class IOUtilsTestCase extends FileBasedTestCase {
Assert.assertArrayEquals(expecteds, actuals);
}
- @SuppressWarnings("deprecation")
- // testing deprecated method
@Test public void testToByteArray_String() throws Exception {
try (FileReader fin = new FileReader(m_testFile)) {
// Create our String. Rely on testReaderToString() to make sure this is valid.
@@ -1006,7 +995,6 @@ public class IOUtilsTestCase extends FileBasedTestCase {
assertEquals(FILE_SIZE, actual.length);
}
- @SuppressWarnings("deprecation") // deliberately testing deprecated method
@Test public void testToCharArray_InputStream() throws Exception {
try (FileInputStream fin = new FileInputStream(m_testFile)) {
final char[] out = IOUtils.toCharArray(fin);
@@ -1044,10 +1032,8 @@ public class IOUtilsTestCase extends FileBasedTestCase {
* @throws Exception
* on error
*/
- @SuppressWarnings("javadoc") // deliberately testing deprecated method
@Test public void testToInputStream_CharSequence() throws Exception {
final CharSequence csq = new StringBuilder("Abc123Xyz!");
- @SuppressWarnings("deprecation")
InputStream inStream = IOUtils.toInputStream(csq); // deliberately testing deprecated method
byte[] bytes = IOUtils.toByteArray(inStream);
assertEqualContent(csq.toString().getBytes(), bytes);
@@ -1069,10 +1055,8 @@ public class IOUtilsTestCase extends FileBasedTestCase {
* @throws Exception
* on error
*/
- @SuppressWarnings("javadoc") // deliberately testing deprecated method
@Test public void testToInputStream_String() throws Exception {
final String str = "Abc123Xyz!";
- @SuppressWarnings("deprecation") // deliberately testing deprecated method
InputStream inStream = IOUtils.toInputStream(str);
byte[] bytes = IOUtils.toByteArray(inStream);
assertEqualContent(str.getBytes(), bytes);
@@ -1084,8 +1068,6 @@ public class IOUtilsTestCase extends FileBasedTestCase {
assertEqualContent(str.getBytes("UTF-8"), bytes);
}
- @SuppressWarnings("deprecation")
- // testing deprecated method
@Test public void testToString_ByteArray() throws Exception {
try (FileInputStream fin = new FileInputStream(m_testFile)) {
final byte[] in = IOUtils.toByteArray(fin);
@@ -1095,7 +1077,6 @@ public class IOUtilsTestCase extends FileBasedTestCase {
}
}
- @SuppressWarnings("deprecation") // deliberately testing deprecated method
@Test public void testToString_InputStream() throws Exception {
try (FileInputStream fin = new FileInputStream(m_testFile)) {
final String out = IOUtils.toString(fin);
@@ -1113,7 +1094,6 @@ public class IOUtilsTestCase extends FileBasedTestCase {
}
}
- @SuppressWarnings("deprecation") // deliberately testing deprecated method
@Test public void testToString_URI() throws Exception {
final URI url = m_testFile.toURI();
final String out = IOUtils.toString(url);
@@ -1136,7 +1116,6 @@ public class IOUtilsTestCase extends FileBasedTestCase {
testToString_URI(null);
}
- @SuppressWarnings("deprecation") // deliberately testing deprecated method
@Test public void testToString_URL() throws Exception {
final URL url = m_testFile.toURI().toURL();
final String out = IOUtils.toString(url);
http://git-wip-us.apache.org/repos/asf/commons-io/blob/6b57d2a1/src/test/java/org/apache/commons/io/comparator/ComparatorAbstractTestCase.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/io/comparator/ComparatorAbstractTestCase.java b/src/test/java/org/apache/commons/io/comparator/ComparatorAbstractTestCase.java
index e4ae902..a019b38 100644
--- a/src/test/java/org/apache/commons/io/comparator/ComparatorAbstractTestCase.java
+++ b/src/test/java/org/apache/commons/io/comparator/ComparatorAbstractTestCase.java
@@ -24,7 +24,6 @@ import java.util.List;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.testtools.FileBasedTestCase;
import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
http://git-wip-us.apache.org/repos/asf/commons-io/blob/6b57d2a1/src/test/java/org/apache/commons/io/input/BoundedReaderTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/io/input/BoundedReaderTest.java b/src/test/java/org/apache/commons/io/input/BoundedReaderTest.java
index 9bd44f5..a66ce0e 100644
--- a/src/test/java/org/apache/commons/io/input/BoundedReaderTest.java
+++ b/src/test/java/org/apache/commons/io/input/BoundedReaderTest.java
@@ -185,8 +185,9 @@ public class BoundedReaderTest
@Test(timeout = 5000)
public void testReadBytesEOF() throws IOException {
BoundedReader mr = new BoundedReader( sr, 3 );
- BufferedReader br = new BufferedReader( mr );
- br.readLine();
- br.readLine();
+ try ( BufferedReader br = new BufferedReader( mr ) ) {
+ br.readLine();
+ br.readLine();
+ }
}
}
http://git-wip-us.apache.org/repos/asf/commons-io/blob/6b57d2a1/src/test/java/org/apache/commons/io/input/MessageDigestCalculatingInputStreamTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/io/input/MessageDigestCalculatingInputStreamTest.java b/src/test/java/org/apache/commons/io/input/MessageDigestCalculatingInputStreamTest.java
index 420b5d9..12542a2 100644
--- a/src/test/java/org/apache/commons/io/input/MessageDigestCalculatingInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/MessageDigestCalculatingInputStreamTest.java
@@ -38,10 +38,12 @@ public class MessageDigestCalculatingInputStreamTest {
final byte[] buffer = generateRandomByteStream(i);
final MessageDigest md5Sum = MessageDigest.getInstance("MD5");
final byte[] expect = md5Sum.digest(buffer);
- final MessageDigestCalculatingInputStream md5InputStream = new MessageDigestCalculatingInputStream(new ByteArrayInputStream(buffer));
- md5InputStream.consume();
- final byte[] got = md5InputStream.getMessageDigest().digest();
- assertArrayEquals(expect, got);
+ try (final MessageDigestCalculatingInputStream md5InputStream =
+ new MessageDigestCalculatingInputStream(new ByteArrayInputStream(buffer))) {
+ md5InputStream.consume();
+ final byte[] got = md5InputStream.getMessageDigest().digest();
+ assertArrayEquals(expect, got);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/commons-io/blob/6b57d2a1/src/test/java/org/apache/commons/io/input/TailerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/io/input/TailerTest.java b/src/test/java/org/apache/commons/io/input/TailerTest.java
index 5090378..5e39fa0 100644
--- a/src/test/java/org/apache/commons/io/input/TailerTest.java
+++ b/src/test/java/org/apache/commons/io/input/TailerTest.java
@@ -63,12 +63,12 @@ public class TailerTest extends FileBasedTestCase {
final File file = new File(getTestDirectory(), "testLongFile.txt");
createFile(file, 0);
- final Writer writer = new FileWriter(file, true);
- for (int i = 0; i < 100000; i++) {
- writer.write("LineLineLineLineLineLineLineLineLineLine\n");
+ try (final Writer writer = new FileWriter(file, true)) {
+ for (int i = 0; i < 100000; i++) {
+ writer.write("LineLineLineLineLineLineLineLineLineLine\n");
+ }
+ writer.write("SBTOURIST\n");
}
- writer.write("SBTOURIST\n");
- IOUtils.closeQuietly(writer);
final TestTailerListener listener = new TestTailerListener();
tailer = new Tailer(file, listener, delay, false);
http://git-wip-us.apache.org/repos/asf/commons-io/blob/6b57d2a1/src/test/java/org/apache/commons/io/output/LockableFileWriterTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/io/output/LockableFileWriterTest.java b/src/test/java/org/apache/commons/io/output/LockableFileWriterTest.java
index 478276b..5b32428 100644
--- a/src/test/java/org/apache/commons/io/output/LockableFileWriterTest.java
+++ b/src/test/java/org/apache/commons/io/output/LockableFileWriterTest.java
@@ -23,7 +23,6 @@ import java.nio.charset.StandardCharsets;
import java.nio.charset.UnsupportedCharsetException;
import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
import org.apache.commons.io.testtools.FileBasedTestCase;
import org.junit.After;
import org.junit.Before;
@@ -65,18 +64,14 @@ public class LockableFileWriterTest extends FileBasedTestCase {
//-----------------------------------------------------------------------
@Test public void testFileLocked() throws IOException {
- LockableFileWriter lfw1 = null;
- LockableFileWriter lfw2 = null;
- LockableFileWriter lfw3 = null;
- try {
- // open a valid locakable writer
- lfw1 = new LockableFileWriter(file);
+
+ // open a valid locakable writer
+ try (LockableFileWriter lfw1 = new LockableFileWriter(file)) {
assertTrue(file.exists());
assertTrue(lockFile.exists());
// try to open a second writer
- try {
- lfw2 = new LockableFileWriter(file);
+ try (LockableFileWriter lfw2 = new LockableFileWriter(file)) {
fail("Somehow able to open a locked file. ");
} catch(final IOException ioe) {
final String msg = ioe.getMessage();
@@ -87,8 +82,7 @@ public class LockableFileWriterTest extends FileBasedTestCase {
}
// try to open a third writer
- try {
- lfw3 = new LockableFileWriter(file);
+ try (LockableFileWriter lfw3 = new LockableFileWriter(file)) {
fail("Somehow able to open a locked file. ");
} catch(final IOException ioe) {
final String msg = ioe.getMessage();
@@ -97,11 +91,6 @@ public class LockableFileWriterTest extends FileBasedTestCase {
assertTrue(file.exists());
assertTrue(lockFile.exists());
}
-
- } finally {
- IOUtils.closeQuietly(lfw1);
- IOUtils.closeQuietly(lfw2);
- IOUtils.closeQuietly(lfw3);
}
assertTrue(file.exists());
assertFalse(lockFile.exists());
@@ -109,17 +98,13 @@ public class LockableFileWriterTest extends FileBasedTestCase {
//-----------------------------------------------------------------------
@Test public void testAlternateLockDir() throws IOException {
- LockableFileWriter lfw1 = null;
- LockableFileWriter lfw2 = null;
- try {
- // open a valid locakable writer
- lfw1 = new LockableFileWriter(file, "UTF-8" ,true, altLockDir.getAbsolutePath());
+ // open a valid locakable writer
+ try (LockableFileWriter lfw1 = new LockableFileWriter(file, "UTF-8" ,true, altLockDir.getAbsolutePath())){
assertTrue(file.exists());
assertTrue(altLockFile.exists());
// try to open a second writer
- try {
- lfw2 = new LockableFileWriter(file, StandardCharsets.UTF_8, true, altLockDir.getAbsolutePath());
+ try (LockableFileWriter lfw2 = new LockableFileWriter(file, StandardCharsets.UTF_8, true, altLockDir.getAbsolutePath())){
fail("Somehow able to open a locked file. ");
} catch(final IOException ioe) {
final String msg = ioe.getMessage();
@@ -128,10 +113,6 @@ public class LockableFileWriterTest extends FileBasedTestCase {
assertTrue(file.exists());
assertTrue(altLockFile.exists());
}
-
- } finally {
- IOUtils.closeQuietly(lfw1);
- IOUtils.closeQuietly(lfw2);
}
assertTrue(file.exists());
assertFalse(altLockFile.exists());
@@ -139,26 +120,18 @@ public class LockableFileWriterTest extends FileBasedTestCase {
//-----------------------------------------------------------------------
@Test public void testFileNotLocked() throws IOException {
- // open a valid locakable writer
- LockableFileWriter lfw1 = null;
- try {
- lfw1 = new LockableFileWriter(file);
+ // open a valid lockable writer
+ try (LockableFileWriter lfw1 = new LockableFileWriter(file)) {
assertTrue(file.exists());
assertTrue(lockFile.exists());
- } finally {
- IOUtils.closeQuietly(lfw1);
}
assertTrue(file.exists());
assertFalse(lockFile.exists());
// open a second valid writer on the same file
- LockableFileWriter lfw2 = null;
- try {
- lfw2 = new LockableFileWriter(file);
+ try (LockableFileWriter lfw2 = new LockableFileWriter(file)) {
assertTrue(file.exists());
assertTrue(lockFile.exists());
- } finally {
- IOUtils.closeQuietly(lfw2);
}
assertTrue(file.exists());
assertFalse(lockFile.exists());
@@ -166,16 +139,12 @@ public class LockableFileWriterTest extends FileBasedTestCase {
//-----------------------------------------------------------------------
@Test public void testConstructor_File_encoding_badEncoding() throws IOException {
- Writer writer = null;
- try {
- writer = new LockableFileWriter(file, "BAD-ENCODE");
+ try (Writer writer = new LockableFileWriter(file, "BAD-ENCODE")) {
fail();
} catch (final UnsupportedCharsetException ex) {
// expected
assertFalse(file.exists());
assertFalse(lockFile.exists());
- } finally {
- IOUtils.closeQuietly(writer);
}
assertFalse(file.exists());
assertFalse(lockFile.exists());
@@ -183,16 +152,12 @@ public class LockableFileWriterTest extends FileBasedTestCase {
//-----------------------------------------------------------------------
@Test public void testConstructor_File_directory() {
- Writer writer = null;
- try {
- writer = new LockableFileWriter(getTestDirectory());
+ try (Writer writer = new LockableFileWriter(getTestDirectory())) {
fail();
} catch (final IOException ex) {
// expected
assertFalse(file.exists());
assertFalse(lockFile.exists());
- } finally {
- IOUtils.closeQuietly(writer);
}
assertFalse(file.exists());
assertFalse(lockFile.exists());
@@ -200,16 +165,12 @@ public class LockableFileWriterTest extends FileBasedTestCase {
//-----------------------------------------------------------------------
@Test public void testConstructor_File_nullFile() throws IOException {
- Writer writer = null;
- try {
- writer = new LockableFileWriter((File) null);
+ try (Writer writer = new LockableFileWriter((File) null)) {
fail();
} catch (final NullPointerException ex) {
// expected
assertFalse(file.exists());
assertFalse(lockFile.exists());
- } finally {
- IOUtils.closeQuietly(writer);
}
assertFalse(file.exists());
assertFalse(lockFile.exists());
@@ -217,16 +178,12 @@ public class LockableFileWriterTest extends FileBasedTestCase {
//-----------------------------------------------------------------------
@Test public void testConstructor_fileName_nullFile() throws IOException {
- Writer writer = null;
- try {
- writer = new LockableFileWriter((String) null);
+ try (Writer writer = new LockableFileWriter((String) null)) {
fail();
} catch (final NullPointerException ex) {
// expected
assertFalse(file.exists());
assertFalse(lockFile.exists());
- } finally {
- IOUtils.closeQuietly(writer);
}
assertFalse(file.exists());
assertFalse(lockFile.exists());