Skip to content

Commit 9f5d73a

Browse files
committed
Add org.apache.commons.io.function.IOStreamTest.testForEachOrderedAdaptParallel()
1 parent 99ae92c commit 9f5d73a

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

src/test/java/org/apache/commons/io/function/IOStreamTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,21 @@ public void testForEachOrdered() throws IOException {
304304
assertEquals("AB", sb.toString());
305305
}
306306

307+
@SuppressWarnings("resource") // custom stream not recognized by compiler warning machinery
308+
@Test
309+
public void testForEachOrderedAdaptParallel() throws IOException {
310+
// compile vs type
311+
assertThrows(IOException.class, () -> IOStream.adapt(Stream.of("A").parallel()).forEach(TestUtils.throwingIOConsumer()));
312+
// compile vs inline
313+
assertThrows(IOException.class, () -> IOStream.adapt(Stream.of("A").parallel()).forEach(e -> {
314+
throw new IOException("Failure");
315+
}));
316+
assertThrows(IOException.class, () -> IOStream.adapt(Stream.of("A", "B").parallel()).forEach(TestUtils.throwingIOConsumer()));
317+
final StringBuilder sb = new StringBuilder();
318+
IOStream.adapt(Stream.of("A", "B").parallel()).forEachOrdered(sb::append);
319+
assertEquals("AB", sb.toString());
320+
}
321+
307322
@SuppressWarnings("resource") // custom stream not recognized by compiler warning machinery
308323
@Test
309324
public void testForEachOrderedAsParallel() throws IOException {

0 commit comments

Comments
 (0)