commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krosenv...@apache.org
Subject svn commit: r1746593 [2/2] - in /commons/proper/io/trunk/src: main/java/org/apache/commons/io/ main/java/org/apache/commons/io/comparator/ main/java/org/apache/commons/io/filefilter/ main/java/org/apache/commons/io/input/ main/java/org/apache/commons/i...
Date Thu, 02 Jun 2016 15:36:15 GMT
Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestParamFile.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestParamFile.java?rev=1746593&r1=1746592&r2=1746593&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestParamFile.java
(original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestParamFile.java
Thu Jun  2 15:36:15 2016
@@ -82,7 +82,7 @@ public class ReversedLinesFileReaderTest
         final File testFileIso = new File(this.getClass().getResource("/" + fileName).toURI());
         reversedLinesFileReader = new ReversedLinesFileReader(testFileIso, buffSize, encoding);
 
-        final Stack<String> lineStack = new Stack<String>();
+        final Stack<String> lineStack = new Stack<>();
 
         bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(testFileIso),
encoding));
         String line = null;

Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/TailerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/TailerTest.java?rev=1746593&r1=1746592&r2=1746593&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/TailerTest.java (original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/TailerTest.java Thu
Jun  2 15:36:15 2016
@@ -130,7 +130,7 @@ public class TailerTest extends FileBase
         Writer out = new OutputStreamWriter(new FileOutputStream(file), charsetUTF8);
         BufferedReader reader = null;
         try{
-            List<String> lines = new ArrayList<String>();
+            List<String> lines = new ArrayList<>();
             reader = new BufferedReader(new InputStreamReader(new FileInputStream(origin),
charsetUTF8));
             String line;
             while((line = reader.readLine()) != null){

Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/XmlStreamReaderTest.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/XmlStreamReaderTest.java?rev=1746593&r1=1746592&r2=1746593&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/XmlStreamReaderTest.java
(original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/XmlStreamReaderTest.java
Thu Jun  2 15:36:15 2016
@@ -380,7 +380,7 @@ public class XmlStreamReaderTest {
     private static final int[] UTF_32LE_BOM_BYTES = {0xFF, 0XFE, 0x00, 0x00};
     private static final int[] UTF_8_BOM_BYTES = {0xEF, 0xBB, 0xBF};
 
-    private static final Map<String, int[]> BOMs = new HashMap<String, int[]>();
+    private static final Map<String, int[]> BOMs = new HashMap<>();
 
     static {
         BOMs.put("no-bom", NO_BOM_BYTES);
@@ -406,7 +406,7 @@ public class XmlStreamReaderTest {
     private static final MessageFormat INFO = new MessageFormat(
             "\nBOM : {0}\nDoc : {1}\nStream Enc : {2}\nProlog Enc : {3}\n");
 
-    private static final Map<String, MessageFormat> XMLs = new HashMap<String, MessageFormat>();
+    private static final Map<String, MessageFormat> XMLs = new HashMap<>();
 
     static {
         XMLs.put(XML1, XML);

Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/monitor/CollectionFileListener.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/monitor/CollectionFileListener.java?rev=1746593&r1=1746592&r2=1746593&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/monitor/CollectionFileListener.java
(original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/monitor/CollectionFileListener.java
Thu Jun  2 15:36:15 2016
@@ -29,12 +29,12 @@ public class CollectionFileListener impl
 
     private static final long serialVersionUID = 939724715678693963L;
     private final boolean clearOnStart;
-    private final Collection<File> createdFiles = new ArrayList<File>();
-    private final Collection<File> changedFiles = new ArrayList<File>();
-    private final Collection<File> deletedFiles = new ArrayList<File>();
-    private final Collection<File> createdDirectories = new ArrayList<File>();
-    private final Collection<File> changedDirectories = new ArrayList<File>();
-    private final Collection<File> deletedDirectories = new ArrayList<File>();
+    private final Collection<File> createdFiles = new ArrayList<>();
+    private final Collection<File> changedFiles = new ArrayList<>();
+    private final Collection<File> deletedFiles = new ArrayList<>();
+    private final Collection<File> createdDirectories = new ArrayList<>();
+    private final Collection<File> changedDirectories = new ArrayList<>();
+    private final Collection<File> deletedDirectories = new ArrayList<>();
 
     /**
      * Create a new observer.

Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/AppendableOutputStreamTest.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/AppendableOutputStreamTest.java?rev=1746593&r1=1746592&r2=1746593&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/AppendableOutputStreamTest.java
(original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/AppendableOutputStreamTest.java
Thu Jun  2 15:36:15 2016
@@ -32,7 +32,7 @@ public class AppendableOutputStreamTest
 
     @Before
     public void setUp() throws Exception {
-        out = new AppendableOutputStream<StringBuilder>(new StringBuilder());
+        out = new AppendableOutputStream<>(new StringBuilder());
     }
 
     @Test

Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/ClosedOutputStreamTest.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/ClosedOutputStreamTest.java?rev=1746593&r1=1746592&r2=1746593&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/ClosedOutputStreamTest.java
(original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/ClosedOutputStreamTest.java
Thu Jun  2 15:36:15 2016
@@ -34,15 +34,11 @@ public class ClosedOutputStreamTest {
      */
     @Test
     public void testRead() throws Exception {
-        ClosedOutputStream cos = null;
-        try {
-            cos = new ClosedOutputStream();
+        try (ClosedOutputStream cos = new ClosedOutputStream()) {
             cos.write('x');
             fail("write(b)");
         } catch (final IOException e) {
             // expected
-        } finally {
-            cos.close();
         }
     }
 

Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/ProxyWriterTest.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/ProxyWriterTest.java?rev=1746593&r1=1746592&r2=1746593&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/ProxyWriterTest.java
(original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/ProxyWriterTest.java
Thu Jun  2 15:36:15 2016
@@ -189,11 +189,8 @@ public class ProxyWriterTest {
                 throw new UnsupportedEncodingException("Bah");
             }
         };
-        final ProxyWriter proxy = new ProxyWriter(osw);
-        try {
+        try (ProxyWriter proxy = new ProxyWriter(osw)) {
             proxy.append('c');
-        } finally {
-            proxy.close();
         }
     }
 
@@ -205,11 +202,8 @@ public class ProxyWriterTest {
                 throw new UnsupportedEncodingException("Bah");
             }
         };
-        final ProxyWriter proxy = new ProxyWriter(osw);
-        try {
+        try (ProxyWriter proxy = new ProxyWriter(osw)) {
             proxy.append("ABCE");
-        } finally {
-            proxy.close();
         }
     }
 
@@ -221,11 +215,8 @@ public class ProxyWriterTest {
                 throw new UnsupportedEncodingException("Bah");
             }
         };
-        final ProxyWriter proxy = new ProxyWriter(osw);
-        try {
+        try (ProxyWriter proxy = new ProxyWriter(osw)) {
             proxy.append("ABCE", 1, 2);
-        } finally {
-            proxy.close();
         }
     }
 
@@ -237,11 +228,8 @@ public class ProxyWriterTest {
                 throw new UnsupportedEncodingException("Bah");
             }
         };
-        final ProxyWriter proxy = new ProxyWriter(osw);
-        try {
+        try (ProxyWriter proxy = new ProxyWriter(osw)) {
             proxy.write((int) 'a');
-        } finally {
-            proxy.close();
         }
     }
 
@@ -253,11 +241,8 @@ public class ProxyWriterTest {
                 throw new UnsupportedEncodingException("Bah");
             }
         };
-        final ProxyWriter proxy = new ProxyWriter(osw);
-        try {
+        try (ProxyWriter proxy = new ProxyWriter(osw)) {
             proxy.write("ABCE".toCharArray());
-        } finally {
-            proxy.close();
         }
     }
 
@@ -269,11 +254,8 @@ public class ProxyWriterTest {
                 throw new UnsupportedEncodingException("Bah");
             }
         };
-        final ProxyWriter proxy = new ProxyWriter(osw);
-        try {
+        try (ProxyWriter proxy = new ProxyWriter(osw)) {
             proxy.write("ABCE".toCharArray(), 2, 3);
-        } finally {
-            proxy.close();
         }
     }
 
@@ -285,11 +267,8 @@ public class ProxyWriterTest {
                 throw new UnsupportedEncodingException("Bah");
             }
         };
-        final ProxyWriter proxy = new ProxyWriter(osw);
-        try {
+        try (ProxyWriter proxy = new ProxyWriter(osw)) {
             proxy.write("ABCE");
-        } finally {
-            proxy.close();
         }
     }
 
@@ -301,11 +280,8 @@ public class ProxyWriterTest {
                 throw new UnsupportedEncodingException("Bah");
             }
         };
-        final ProxyWriter proxy = new ProxyWriter(osw);
-        try {
+        try (ProxyWriter proxy = new ProxyWriter(osw)) {
             proxy.write("ABCE", 1, 3);
-        } finally {
-            proxy.close();
         }
     }
 
@@ -317,11 +293,8 @@ public class ProxyWriterTest {
                 throw new UnsupportedEncodingException("Bah");
             }
         };
-        final ProxyWriter proxy = new ProxyWriter(osw);
-        try {
+        try (ProxyWriter proxy = new ProxyWriter(osw)) {
             proxy.flush();
-        } finally {
-            proxy.close();
         }
     }
 

Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/serialization/ClosingBase.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/serialization/ClosingBase.java?rev=1746593&r1=1746592&r2=1746593&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/serialization/ClosingBase.java
(original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/serialization/ClosingBase.java
Thu Jun  2 15:36:15 2016
@@ -30,7 +30,7 @@ import org.junit.Before;
  *  and cleans them up.
  */
 public class ClosingBase {
-    private final List<Closeable> toClose = new ArrayList<Closeable>();
+    private final List<Closeable> toClose = new ArrayList<>();
 
     protected <T extends Closeable> T willClose(T t) {
         toClose.add(t);

Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/serialization/MoreComplexObject.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/serialization/MoreComplexObject.java?rev=1746593&r1=1746592&r2=1746593&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/serialization/MoreComplexObject.java
(original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/serialization/MoreComplexObject.java
Thu Jun  2 15:36:15 2016
@@ -38,7 +38,7 @@ public class MoreComplexObject implement
     private final int pInt = random.nextInt();
     private final long pLong = random.nextLong();
     private final Integer [] intArray = { random.nextInt(), random.nextInt() };
-    private final List<Boolean> boolList = new ArrayList<Boolean>();
+    private final List<Boolean> boolList = new ArrayList<>();
     
     MoreComplexObject() {
         for(int i=0 ; i < 5; i++) {

Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/testtools/TestUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/testtools/TestUtils.java?rev=1746593&r1=1746592&r2=1746593&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/testtools/TestUtils.java (original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/testtools/TestUtils.java Thu
Jun  2 15:36:15 2016
@@ -114,10 +114,8 @@ public abstract class TestUtils {
                     " have differing file sizes (" + f0.length() +
                     " vs " + f1.length() + ")", ( f0.length() == f1.length() ) );
         */
-        final InputStream is0 = new java.io.FileInputStream(f0);
-        try {
-            final InputStream is1 = new java.io.FileInputStream(f1);
-            try {
+        try (InputStream is0 = new FileInputStream(f0)) {
+            try (InputStream is1 = new FileInputStream(f1)) {
                 final byte[] buf0 = new byte[1024];
                 final byte[] buf1 = new byte[1024];
                 int n0 = 0;
@@ -133,11 +131,7 @@ public abstract class TestUtils {
                     assertTrue("The files " + f0 + " and " + f1 +
                             " have different content", Arrays.equals(buf0, buf1));
                 }
-            } finally {
-                is1.close();
             }
-        } finally {
-            is0.close();
         }
     }
 
@@ -149,10 +143,9 @@ public abstract class TestUtils {
      * @throws IOException If an I/O error occurs while reading the file contents
      */
     public static void assertEqualContent(final byte[] b0, final File file) throws IOException
{
-        final InputStream is = new java.io.FileInputStream(file);
         int count = 0, numRead = 0;
         final byte[] b1 = new byte[b0.length];
-        try {
+        try (InputStream is = new FileInputStream(file)) {
             while (count < b0.length && numRead >= 0) {
                 numRead = is.read(b1, count, b0.length);
                 count += numRead;
@@ -161,8 +154,6 @@ public abstract class TestUtils {
             for (int i = 0; i < count; i++) {
                 assertEquals("byte " + i + " differs", b0[i], b1[i]);
             }
-        } finally {
-            is.close();
         }
     }
 
@@ -174,10 +165,9 @@ public abstract class TestUtils {
      * @throws IOException If an I/O error occurs while reading the file contents
      */
     public static void assertEqualContent(final char[] c0, final File file) throws IOException
{
-        final Reader ir = new java.io.FileReader(file);
         int count = 0, numRead = 0;
         final char[] c1 = new char[c0.length];
-        try {
+        try (Reader ir = new FileReader(file)) {
             while (count < c0.length && numRead >= 0) {
                 numRead = ir.read(c1, count, c0.length);
                 count += numRead;
@@ -186,8 +176,6 @@ public abstract class TestUtils {
             for (int i = 0; i < count; i++) {
                 assertEquals("char " + i + " differs", c0[i], c1[i]);
             }
-        } finally {
-            ir.close();
         }
     }
 



Mime
View raw message