Skip to content

Commit 681d84d

Browse files
committed
Formatting "()->x" -> "() -> x"
1 parent 3b7a0aa commit 681d84d

1 file changed

Lines changed: 26 additions & 48 deletions

File tree

src/test/java/org/apache/commons/io/IOUtilsTest.java

Lines changed: 26 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ public class IOUtilsTest {
104104

105105
/** Determine if this is windows. */
106106
private static final boolean WINDOWS = File.separatorChar == '\\';
107+
107108
/*
108109
* Note: this is not particularly beautiful code. A better way to check for flush and close status would be to
109110
* implement "trojan horse" wrapper implementations of the various stream classes, which set a flag when relevant
@@ -198,14 +199,10 @@ public int read() throws IOException {
198199
@Test
199200
public void testAsBufferedNull() {
200201
final String npeExpectedMessage = "Expected NullPointerException";
201-
assertThrows(NullPointerException.class, ()->IOUtils.buffer((InputStream) null),
202-
npeExpectedMessage );
203-
assertThrows(NullPointerException.class, ()->IOUtils.buffer((OutputStream) null),
204-
npeExpectedMessage);
205-
assertThrows(NullPointerException.class, ()->IOUtils.buffer((Reader) null),
206-
npeExpectedMessage);
207-
assertThrows(NullPointerException.class, ()->IOUtils.buffer((Writer) null),
208-
npeExpectedMessage);
202+
assertThrows(NullPointerException.class, () -> IOUtils.buffer((InputStream) null), npeExpectedMessage);
203+
assertThrows(NullPointerException.class, () -> IOUtils.buffer((OutputStream) null), npeExpectedMessage);
204+
assertThrows(NullPointerException.class, () -> IOUtils.buffer((Reader) null), npeExpectedMessage);
205+
assertThrows(NullPointerException.class, () -> IOUtils.buffer((Writer) null), npeExpectedMessage);
209206
}
210207

211208
@Test
@@ -935,8 +932,7 @@ public void testRead_ReadableByteChannel() throws Exception {
935932
assertEquals(0, buffer.remaining());
936933
assertEquals(0, input.read(buffer));
937934
buffer.clear();
938-
assertThrows(EOFException.class, ()->IOUtils.readFully(input, buffer),
939-
"Should have failed with EOFException");
935+
assertThrows(EOFException.class, () -> IOUtils.readFully(input, buffer), "Should have failed with EOFException");
940936
} finally {
941937
IOUtils.closeQuietly(input, fileInputStream);
942938
}
@@ -960,13 +956,11 @@ public void testReadFully_InputStream_ByteArray() throws Exception {
960956
final byte[] buffer = new byte[size];
961957
final InputStream input = new ByteArrayInputStream(new byte[size]);
962958

963-
assertThrows(IllegalArgumentException.class, ()-> IOUtils.readFully(input, buffer, 0, -1),
964-
"Should have failed with IllegalArgumentException");
959+
assertThrows(IllegalArgumentException.class, () -> IOUtils.readFully(input, buffer, 0, -1), "Should have failed with IllegalArgumentException");
965960

966961
IOUtils.readFully(input, buffer, 0, 0);
967962
IOUtils.readFully(input, buffer, 0, size - 1);
968-
assertThrows(EOFException.class, ()-> IOUtils.readFully(input, buffer, 0, 2),
969-
"Should have failed with EOFException");
963+
assertThrows(EOFException.class, () -> IOUtils.readFully(input, buffer, 0, 2), "Should have failed with EOFException");
970964
IOUtils.closeQuietly(input);
971965
}
972966

@@ -995,8 +989,7 @@ public void testReadFully_ReadableByteChannel() throws Exception {
995989
assertEquals(0, input.read(buffer));
996990
IOUtils.readFully(input, buffer);
997991
buffer.clear();
998-
assertThrows(EOFException.class, ()->IOUtils.readFully(input, buffer),
999-
"Should have failed with EOFxception");
992+
assertThrows(EOFException.class, () -> IOUtils.readFully(input, buffer), "Should have failed with EOFxception");
1000993
} finally {
1001994
IOUtils.closeQuietly(input, fileInputStream);
1002995
}
@@ -1010,10 +1003,8 @@ public void testReadFully_Reader() throws Exception {
10101003

10111004
IOUtils.readFully(input, buffer, 0, 0);
10121005
IOUtils.readFully(input, buffer, 0, size - 3);
1013-
assertThrows(IllegalArgumentException.class, ()->IOUtils.readFully(input, buffer, 0, -1),
1014-
"Should have failed with IllegalArgumentException" );
1015-
assertThrows(EOFException.class, ()->IOUtils.readFully(input, buffer, 0, 5),
1016-
"Should have failed with EOFException" );
1006+
assertThrows(IllegalArgumentException.class, () -> IOUtils.readFully(input, buffer, 0, -1), "Should have failed with IllegalArgumentException");
1007+
assertThrows(EOFException.class, () -> IOUtils.readFully(input, buffer, 0, 5), "Should have failed with EOFException");
10171008
IOUtils.closeQuietly(input);
10181009
}
10191010

@@ -1320,13 +1311,11 @@ public void testSkipFully_InputStream() throws Exception {
13201311
final int size = 1027;
13211312

13221313
final InputStream input = new ByteArrayInputStream(new byte[size]);
1323-
assertThrows(IllegalArgumentException.class, ()->IOUtils.skipFully(input, -1),
1324-
"Should have failed with IllegalArgumentException" );
1314+
assertThrows(IllegalArgumentException.class, () -> IOUtils.skipFully(input, -1), "Should have failed with IllegalArgumentException");
13251315

13261316
IOUtils.skipFully(input, 0);
13271317
IOUtils.skipFully(input, size - 1);
1328-
assertThrows(IOException.class, ()-> IOUtils.skipFully(input, 2),
1329-
"Should have failed with IOException" );
1318+
assertThrows(IOException.class, () -> IOUtils.skipFully(input, 2), "Should have failed with IOException");
13301319
IOUtils.closeQuietly(input);
13311320
}
13321321

@@ -1335,12 +1324,10 @@ public void testSkipFully_ReadableByteChannel() throws Exception {
13351324
final FileInputStream fileInputStream = new FileInputStream(testFile);
13361325
final FileChannel fileChannel = fileInputStream.getChannel();
13371326
try {
1338-
assertThrows(IllegalArgumentException.class, ()->IOUtils.skipFully(fileChannel, -1),
1339-
"Should have failed with IllegalArgumentException" );
1327+
assertThrows(IllegalArgumentException.class, () -> IOUtils.skipFully(fileChannel, -1), "Should have failed with IllegalArgumentException");
13401328
IOUtils.skipFully(fileChannel, 0);
13411329
IOUtils.skipFully(fileChannel, FILE_SIZE - 1);
1342-
assertThrows(IOException.class, ()->IOUtils.skipFully(fileChannel, 2),
1343-
"Should have failed with IOException" );
1330+
assertThrows(IOException.class, () -> IOUtils.skipFully(fileChannel, 2), "Should have failed with IOException");
13441331
} finally {
13451332
IOUtils.closeQuietly(fileChannel, fileInputStream);
13461333
}
@@ -1353,10 +1340,8 @@ public void testSkipFully_Reader() throws Exception {
13531340

13541341
IOUtils.skipFully(input, 0);
13551342
IOUtils.skipFully(input, size - 3);
1356-
assertThrows(IllegalArgumentException.class, ()->IOUtils.skipFully(input, -1),
1357-
"Should have failed with IllegalArgumentException" );
1358-
assertThrows(IOException.class, ()->IOUtils.skipFully(input, 5),
1359-
"Should have failed with IOException" );
1343+
assertThrows(IllegalArgumentException.class, () -> IOUtils.skipFully(input, -1), "Should have failed with IllegalArgumentException");
1344+
assertThrows(IOException.class, () -> IOUtils.skipFully(input, 5), "Should have failed with IOException");
13601345
IOUtils.closeQuietly(input);
13611346
}
13621347

@@ -1428,12 +1413,11 @@ public void testToByteArray_InputStream_LongerThanIntegerMaxValue() throws Excep
14281413

14291414
@Test
14301415
public void testToByteArray_InputStream_NegativeSize() throws Exception {
1431-
14321416
try (InputStream fin = Files.newInputStream(testFilePath)) {
1433-
final IllegalArgumentException exc = assertThrows(IllegalArgumentException.class,
1434-
()->IOUtils.toByteArray(fin, -1), "Should have failed with IllegalArgumentException" );
1417+
final IllegalArgumentException exc = assertThrows(IllegalArgumentException.class, () -> IOUtils.toByteArray(fin, -1),
1418+
"Should have failed with IllegalArgumentException");
14351419
assertTrue(exc.getMessage().startsWith("Size must be equal or greater than zero"),
1436-
"Exception message does not start with \"Size must be equal or greater than zero\"");
1420+
"Exception message does not start with \"Size must be equal or greater than zero\"");
14371421
}
14381422
}
14391423

@@ -1450,30 +1434,25 @@ public void testToByteArray_InputStream_Size() throws Exception {
14501434

14511435
@Test
14521436
public void testToByteArray_InputStream_SizeIllegal() throws Exception {
1453-
14541437
try (InputStream fin = Files.newInputStream(testFilePath)) {
1455-
final IOException exc = assertThrows(IOException.class,
1456-
()->IOUtils.toByteArray(fin, testFile.length() + 1), "Should have failed with IOException" );
1457-
assertTrue(exc.getMessage().startsWith("Unexpected read size"),
1458-
"Exception message does not start with \"Unexpected read size\"");
1438+
final IOException exc = assertThrows(IOException.class, () -> IOUtils.toByteArray(fin, testFile.length() + 1),
1439+
"Should have failed with IOException");
1440+
assertTrue(exc.getMessage().startsWith("Unexpected read size"), "Exception message does not start with \"Unexpected read size\"");
14591441
}
14601442
}
14611443

14621444
@Test
14631445
public void testToByteArray_InputStream_SizeLong() throws Exception {
1464-
14651446
try (InputStream fin = Files.newInputStream(testFilePath)) {
1466-
final IllegalArgumentException exc = assertThrows(IllegalArgumentException.class,
1467-
()-> IOUtils.toByteArray(fin, (long) Integer.MAX_VALUE + 1),
1468-
"Should have failed with IllegalArgumentException" );
1447+
final IllegalArgumentException exc = assertThrows(IllegalArgumentException.class, () -> IOUtils.toByteArray(fin, (long) Integer.MAX_VALUE + 1),
1448+
"Should have failed with IllegalArgumentException");
14691449
assertTrue(exc.getMessage().startsWith("Size cannot be greater than Integer max value"),
1470-
"Exception message does not start with \"Size cannot be greater than Integer max value\"");
1450+
"Exception message does not start with \"Size cannot be greater than Integer max value\"");
14711451
}
14721452
}
14731453

14741454
@Test
14751455
public void testToByteArray_InputStream_SizeOne() throws Exception {
1476-
14771456
try (InputStream fin = Files.newInputStream(testFilePath)) {
14781457
final byte[] out = IOUtils.toByteArray(fin, 1);
14791458
assertNotNull(out, "Out cannot be null");
@@ -1483,7 +1462,6 @@ public void testToByteArray_InputStream_SizeOne() throws Exception {
14831462

14841463
@Test
14851464
public void testToByteArray_InputStream_SizeZero() throws Exception {
1486-
14871465
try (InputStream fin =Files.newInputStream(testFilePath)) {
14881466
final byte[] out = IOUtils.toByteArray(fin, 0);
14891467
assertNotNull(out, "Out cannot be null");

0 commit comments

Comments
 (0)