Note
Task 8379818: Refactor java/nio/file/Files/StreamLinesTest.java to Use JUnit
Moved StreamLinesTest from TestNG to JUnit and removed dependencies on OpTestCase.
Overview#
The java/nio/file/Files/StreamLinesTest.java file contains tests that verify the behavior of the stream returned by Files.lines. These tests were originally run using TestNG and relied on helper classes from the test library, namely java.util.stream.OpTestCase and TestData.
Recently, there has been a movement within the net community (and across OpenJDK as a whole) to transition from TestNG to JUnit5.
In this update, we migrated these tests to JUnit, removing dependencies on TestNG and OpTestCase. Specifically, annotations like @DataProvider and @Test(dataProvider = "lines") were replaced with JUnit's @ParameterizedTest and @MethodSource("lines").
The validation previously performed using withData(...).expectedResult(...).exercise() now involves collecting the results of Files.lines into a list via toList(), then comparing it to expected values using assertEquals.
try (Stream<String> s = Files.lines(p, cs)) {
assertEquals(expected, s.toList());
}
As a result, the test execution environment changed from testng/othervm to junit/othervm, and dependencies on /lib/testlibrary/bootlib and java.base/java.util.stream.OpTestCase are no longer required.
Discovered in JBS on 2026/03/18#
This issue was discovered as part of a series of efforts to migrate existing tests to JUnit. The StreamLinesTest class inherited from OpTestCase, so simply replacing annotations wasn't sufficient.
First, the data generation side was changed from returning an Object[][] with TestNG's DataProvider to returning a Stream<Arguments> with JUnit's MethodSource.
Additionally, since description strings are not used in assertions, they were passed to Arguments.argumentSet for use as test display names.
static Arguments of(String description, IntFunction<String> lineGenerator,
IntFunction<LineSeparator> separatorGenerator, int n, Charset cs) {
return Arguments.argumentSet(description, lineGenerator, separatorGenerator, n, cs);
}
Review Feedback from 2026/03/19-26#
During the review process, it was pointed out that the public modifier was unnecessary and was removed.
Marcono12341 suggested using Arguments.argumentSet instead of passing description strings as arguments, which was implemented.
Later, Brian Burkhalter2 reviewed imports order and the necessity of helper method checkLines.
Indeed, since List#equals compares both elements and size, checking sizes separately is redundant.
Therefore, checkLines was removed in favor of directly using assertEquals(expected, s.toList()).
Integration Request on 2026/03/26#
After receiving approval from Burkhalter2, the review was confirmed, and /integrate was performed to submit an integration request.
Integrated on 2026/03/27#
Burkhalter2 sponsored the commit as 1ed1bb83, integrating it into JDK.
Footnotes#
-
Marcono1234 - OverviewMarcono1234 has 89 repositories available. Follow their code on GitHub.GitHub
↩
-
https://openjdk.org/census#bpbopenjdk.org↩ ↩2 ↩3
-
8379818: Refactor java/nio/file/Files/StreamLinesTest.java to use JUnit · openjdk/jdk@1ed1bb8JDK main-line development https://openjdk.org/projects/jdk - 8379818: Refactor java/nio/file/Files/StreamLinesTest.java to use JUnit · openjdk/jdk@1ed1bb8GitHub
↩