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

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git


The following commit(s) were added to refs/heads/master by this push:
     new 681d84df Formatting "()->x" -> "() -> x"
681d84df is described below

commit 681d84dfeab6006dc3218323dc66f426fc2e13f6
Author: Gary Gregory <[email protected]>
AuthorDate: Fri May 12 17:08:11 2023 -0400

    Formatting "()->x" -> "() -> x"
---
 .../java/org/apache/commons/io/IOUtilsTest.java    | 74 ++++++++--------------
 1 file changed, 26 insertions(+), 48 deletions(-)

diff --git a/src/test/java/org/apache/commons/io/IOUtilsTest.java 
b/src/test/java/org/apache/commons/io/IOUtilsTest.java
index 395b8e8f..cfbe2526 100644
--- a/src/test/java/org/apache/commons/io/IOUtilsTest.java
+++ b/src/test/java/org/apache/commons/io/IOUtilsTest.java
@@ -104,6 +104,7 @@ public class IOUtilsTest {
 
     /** Determine if this is windows. */
     private static final boolean WINDOWS = File.separatorChar == '\\';
+
     /*
      * Note: this is not particularly beautiful code. A better way to check 
for flush and close status would be to
      * implement "trojan horse" wrapper implementations of the various stream 
classes, which set a flag when relevant
@@ -198,14 +199,10 @@ public class IOUtilsTest {
     @Test
     public void testAsBufferedNull() {
         final String npeExpectedMessage = "Expected NullPointerException";
-        assertThrows(NullPointerException.class, 
()->IOUtils.buffer((InputStream) null),
-                npeExpectedMessage );
-        assertThrows(NullPointerException.class, 
()->IOUtils.buffer((OutputStream) null),
-                npeExpectedMessage);
-        assertThrows(NullPointerException.class, ()->IOUtils.buffer((Reader) 
null),
-                npeExpectedMessage);
-        assertThrows(NullPointerException.class, ()->IOUtils.buffer((Writer) 
null),
-                npeExpectedMessage);
+        assertThrows(NullPointerException.class, () -> 
IOUtils.buffer((InputStream) null), npeExpectedMessage);
+        assertThrows(NullPointerException.class, () -> 
IOUtils.buffer((OutputStream) null), npeExpectedMessage);
+        assertThrows(NullPointerException.class, () -> IOUtils.buffer((Reader) 
null), npeExpectedMessage);
+        assertThrows(NullPointerException.class, () -> IOUtils.buffer((Writer) 
null), npeExpectedMessage);
     }
 
     @Test
@@ -935,8 +932,7 @@ public class IOUtilsTest {
             assertEquals(0, buffer.remaining());
             assertEquals(0, input.read(buffer));
             buffer.clear();
-            assertThrows(EOFException.class, ()->IOUtils.readFully(input, 
buffer),
-                    "Should have failed with EOFException");
+            assertThrows(EOFException.class, () -> IOUtils.readFully(input, 
buffer), "Should have failed with EOFException");
         } finally {
             IOUtils.closeQuietly(input, fileInputStream);
         }
@@ -960,13 +956,11 @@ public class IOUtilsTest {
         final byte[] buffer = new byte[size];
         final InputStream input = new ByteArrayInputStream(new byte[size]);
 
-        assertThrows(IllegalArgumentException.class, ()-> 
IOUtils.readFully(input, buffer, 0, -1),
-                "Should have failed with IllegalArgumentException");
+        assertThrows(IllegalArgumentException.class, () -> 
IOUtils.readFully(input, buffer, 0, -1), "Should have failed with 
IllegalArgumentException");
 
         IOUtils.readFully(input, buffer, 0, 0);
         IOUtils.readFully(input, buffer, 0, size - 1);
-        assertThrows(EOFException.class, ()-> IOUtils.readFully(input, buffer, 
0, 2),
-                "Should have failed with EOFException");
+        assertThrows(EOFException.class, () -> IOUtils.readFully(input, 
buffer, 0, 2), "Should have failed with EOFException");
         IOUtils.closeQuietly(input);
     }
 
@@ -995,8 +989,7 @@ public class IOUtilsTest {
             assertEquals(0, input.read(buffer));
             IOUtils.readFully(input, buffer);
             buffer.clear();
-            assertThrows(EOFException.class, ()->IOUtils.readFully(input, 
buffer),
-                    "Should have failed with EOFxception");
+            assertThrows(EOFException.class, () -> IOUtils.readFully(input, 
buffer), "Should have failed with EOFxception");
         } finally {
             IOUtils.closeQuietly(input, fileInputStream);
         }
@@ -1010,10 +1003,8 @@ public class IOUtilsTest {
 
         IOUtils.readFully(input, buffer, 0, 0);
         IOUtils.readFully(input, buffer, 0, size - 3);
-        assertThrows(IllegalArgumentException.class, 
()->IOUtils.readFully(input, buffer, 0, -1),
-                "Should have failed with IllegalArgumentException" );
-        assertThrows(EOFException.class, ()->IOUtils.readFully(input, buffer, 
0, 5),
-                "Should have failed with EOFException" );
+        assertThrows(IllegalArgumentException.class, () -> 
IOUtils.readFully(input, buffer, 0, -1), "Should have failed with 
IllegalArgumentException");
+        assertThrows(EOFException.class, () -> IOUtils.readFully(input, 
buffer, 0, 5), "Should have failed with EOFException");
         IOUtils.closeQuietly(input);
     }
 
@@ -1320,13 +1311,11 @@ public class IOUtilsTest {
         final int size = 1027;
 
         final InputStream input = new ByteArrayInputStream(new byte[size]);
-        assertThrows(IllegalArgumentException.class, 
()->IOUtils.skipFully(input, -1),
-                "Should have failed with IllegalArgumentException" );
+        assertThrows(IllegalArgumentException.class, () -> 
IOUtils.skipFully(input, -1), "Should have failed with 
IllegalArgumentException");
 
         IOUtils.skipFully(input, 0);
         IOUtils.skipFully(input, size - 1);
-        assertThrows(IOException.class, ()->  IOUtils.skipFully(input, 2),
-        "Should have failed with IOException" );
+        assertThrows(IOException.class, () -> IOUtils.skipFully(input, 2), 
"Should have failed with IOException");
         IOUtils.closeQuietly(input);
     }
 
@@ -1335,12 +1324,10 @@ public class IOUtilsTest {
         final FileInputStream fileInputStream = new FileInputStream(testFile);
         final FileChannel fileChannel = fileInputStream.getChannel();
         try {
-            assertThrows(IllegalArgumentException.class, 
()->IOUtils.skipFully(fileChannel, -1),
-                    "Should have failed with IllegalArgumentException" );
+            assertThrows(IllegalArgumentException.class, () -> 
IOUtils.skipFully(fileChannel, -1), "Should have failed with 
IllegalArgumentException");
             IOUtils.skipFully(fileChannel, 0);
             IOUtils.skipFully(fileChannel, FILE_SIZE - 1);
-            assertThrows(IOException.class, ()->IOUtils.skipFully(fileChannel, 
2),
-                    "Should have failed with IOException" );
+            assertThrows(IOException.class, () -> 
IOUtils.skipFully(fileChannel, 2), "Should have failed with IOException");
         } finally {
             IOUtils.closeQuietly(fileChannel, fileInputStream);
         }
@@ -1353,10 +1340,8 @@ public class IOUtilsTest {
 
         IOUtils.skipFully(input, 0);
         IOUtils.skipFully(input, size - 3);
-        assertThrows(IllegalArgumentException.class, 
()->IOUtils.skipFully(input, -1),
-                "Should have failed with IllegalArgumentException" );
-        assertThrows(IOException.class, ()->IOUtils.skipFully(input, 5),
-                "Should have failed with IOException" );
+        assertThrows(IllegalArgumentException.class, () -> 
IOUtils.skipFully(input, -1), "Should have failed with 
IllegalArgumentException");
+        assertThrows(IOException.class, () -> IOUtils.skipFully(input, 5), 
"Should have failed with IOException");
         IOUtils.closeQuietly(input);
     }
 
@@ -1428,12 +1413,11 @@ public class IOUtilsTest {
 
     @Test
     public void testToByteArray_InputStream_NegativeSize() throws Exception {
-
         try (InputStream fin = Files.newInputStream(testFilePath)) {
-           final IllegalArgumentException exc = 
assertThrows(IllegalArgumentException.class,
-                   ()->IOUtils.toByteArray(fin, -1), "Should have failed with 
IllegalArgumentException" );
+            final IllegalArgumentException exc = 
assertThrows(IllegalArgumentException.class, () -> IOUtils.toByteArray(fin, -1),
+                    "Should have failed with IllegalArgumentException");
             assertTrue(exc.getMessage().startsWith("Size must be equal or 
greater than zero"),
-                "Exception message does not start with \"Size must be equal or 
greater than zero\"");
+                    "Exception message does not start with \"Size must be 
equal or greater than zero\"");
         }
     }
 
@@ -1450,30 +1434,25 @@ public class IOUtilsTest {
 
     @Test
     public void testToByteArray_InputStream_SizeIllegal() throws Exception {
-
         try (InputStream fin = Files.newInputStream(testFilePath)) {
-            final IOException exc = assertThrows(IOException.class,
-                    ()->IOUtils.toByteArray(fin, testFile.length() + 1), 
"Should have failed with IOException" );
-            assertTrue(exc.getMessage().startsWith("Unexpected read size"),
-                "Exception message does not start with \"Unexpected read 
size\"");
+            final IOException exc = assertThrows(IOException.class, () -> 
IOUtils.toByteArray(fin, testFile.length() + 1),
+                    "Should have failed with IOException");
+            assertTrue(exc.getMessage().startsWith("Unexpected read size"), 
"Exception message does not start with \"Unexpected read size\"");
         }
     }
 
     @Test
     public void testToByteArray_InputStream_SizeLong() throws Exception {
-
         try (InputStream fin = Files.newInputStream(testFilePath)) {
-            final IllegalArgumentException exc = 
assertThrows(IllegalArgumentException.class,
-                    ()-> IOUtils.toByteArray(fin, (long) Integer.MAX_VALUE + 
1),
-                    "Should have failed with IllegalArgumentException" );
+            final IllegalArgumentException exc = 
assertThrows(IllegalArgumentException.class, () -> IOUtils.toByteArray(fin, 
(long) Integer.MAX_VALUE + 1),
+                    "Should have failed with IllegalArgumentException");
             assertTrue(exc.getMessage().startsWith("Size cannot be greater 
than Integer max value"),
-                "Exception message does not start with \"Size cannot be 
greater than Integer max value\"");
+                    "Exception message does not start with \"Size cannot be 
greater than Integer max value\"");
         }
     }
 
     @Test
     public void testToByteArray_InputStream_SizeOne() throws Exception {
-
         try (InputStream fin = Files.newInputStream(testFilePath)) {
             final byte[] out = IOUtils.toByteArray(fin, 1);
             assertNotNull(out, "Out cannot be null");
@@ -1483,7 +1462,6 @@ public class IOUtilsTest {
 
     @Test
     public void testToByteArray_InputStream_SizeZero() throws Exception {
-
         try (InputStream fin =Files.newInputStream(testFilePath)) {
             final byte[] out = IOUtils.toByteArray(fin, 0);
             assertNotNull(out, "Out cannot be null");

Reply via email to