@@ -64,10 +64,6 @@ private int checkAvail(final InputStream is, final int min) throws Exception {
6464 return available ;
6565 }
6666
67- private Set <String > getRequiredCharsetNames () {
68- return Charsets .requiredCharsets ().keySet ();
69- }
70-
7167 private boolean isAvailabilityTestableForCharset (final String csName ) {
7268 return Charset .forName (csName ).canEncode ()
7369 && !"COMPOUND_TEXT" .equalsIgnoreCase (csName ) && !"x-COMPOUND_TEXT" .equalsIgnoreCase (csName )
@@ -168,11 +164,10 @@ public void testBufferedRead_AvailableCharset(final String csName) throws IOExce
168164 }
169165 }
170166
171- @ Test
172- public void testBufferedRead_RequiredCharset () throws IOException {
173- for (final String csName : getRequiredCharsetNames ()) {
174- testBufferedRead (TEST_STRING , csName );
175- }
167+ @ ParameterizedTest
168+ @ MethodSource (CharsetsTest .REQUIRED_CHARSETS )
169+ public void testBufferedRead_RequiredCharset (final String csName ) throws IOException {
170+ testBufferedRead (TEST_STRING , csName );
176171 }
177172
178173 @ Test
@@ -192,11 +187,10 @@ private void testCharsetMismatchInfiniteLoop(final String csName) throws IOExcep
192187 }
193188 }
194189
195- @ Test
196- public void testCharsetMismatchInfiniteLoop_RequiredCharsets () throws IOException {
197- for (final String csName : getRequiredCharsetNames ()) {
198- testCharsetMismatchInfiniteLoop (csName );
199- }
190+ @ ParameterizedTest
191+ @ MethodSource (CharsetsTest .REQUIRED_CHARSETS )
192+ public void testCharsetMismatchInfiniteLoop_RequiredCharsets (final String csName ) throws IOException {
193+ testCharsetMismatchInfiniteLoop (csName );
200194 }
201195
202196 // Test is broken if readFirst > 0
@@ -283,23 +277,21 @@ public void testIO_356_Loop_UTF8() throws Exception {
283277 testIO_356_Loop (charset .displayName (), (int ) ReaderInputStream .minBufferSize (charset .newEncoder ()));
284278 }
285279
286- @ Test
287- public void testLargeBufferedRead_RequiredCharsets () throws IOException {
288- for (final String csName : getRequiredCharsetNames ()) {
289- testBufferedRead (LARGE_TEST_STRING , csName );
290- }
280+ @ ParameterizedTest
281+ @ MethodSource (CharsetsTest .REQUIRED_CHARSETS )
282+ public void testLargeBufferedRead_RequiredCharsets (final String csName ) throws IOException {
283+ testBufferedRead (LARGE_TEST_STRING , csName );
291284 }
292285
293286 @ Test
294287 public void testLargeBufferedRead_UTF8 () throws IOException {
295288 testBufferedRead (LARGE_TEST_STRING , UTF_8 );
296289 }
297290
298- @ Test
299- public void testLargeSingleByteRead_RequiredCharsets () throws IOException {
300- for (final String csName : getRequiredCharsetNames ()) {
301- testSingleByteRead (LARGE_TEST_STRING , csName );
302- }
291+ @ ParameterizedTest
292+ @ MethodSource (CharsetsTest .REQUIRED_CHARSETS )
293+ public void testLargeSingleByteRead_RequiredCharsets (final String csName ) throws IOException {
294+ testSingleByteRead (LARGE_TEST_STRING , csName );
303295 }
304296
305297 @ Test
@@ -324,12 +316,11 @@ private void testMarkReset(final String csName) throws Exception {
324316 }
325317 }
326318
327- @ Test
319+ @ ParameterizedTest
320+ @ MethodSource (CharsetsTest .REQUIRED_CHARSETS )
328321 @ Disabled // Test broken for charsets that create multiple bytes for a single char
329- public void testMarkReset_RequiredCharsets () throws Exception {
330- for (final String csName : getRequiredCharsetNames ()) {
331- testMarkReset (csName );
332- }
322+ public void testMarkReset_RequiredCharsets (final String csName ) throws Exception {
323+ testMarkReset (csName );
333324 }
334325
335326 @ Test
@@ -392,11 +383,10 @@ public void testReadZero_EmptyString() throws Exception {
392383 }
393384 }
394385
395- @ Test
396- public void testReadZero_RequiredCharsets () throws Exception {
397- for (final String csName : getRequiredCharsetNames ()) {
398- testReadZero (csName );
399- }
386+ @ ParameterizedTest
387+ @ MethodSource (CharsetsTest .REQUIRED_CHARSETS )
388+ public void testReadZero_RequiredCharsets (final String csName ) throws Exception {
389+ testReadZero (csName );
400390 }
401391
402392 private void testResetBeforeEnd (final CharSequenceInputStream inputStream ) throws IOException {
@@ -454,11 +444,10 @@ private void testSingleByteRead(final String testString, final String charsetNam
454444 }
455445 }
456446
457- @ Test
458- public void testSingleByteRead_RequiredCharsets () throws IOException {
459- for (final String csName : getRequiredCharsetNames ()) {
460- testSingleByteRead (TEST_STRING , csName );
461- }
447+ @ ParameterizedTest
448+ @ MethodSource (CharsetsTest .REQUIRED_CHARSETS )
449+ public void testSingleByteRead_RequiredCharsets (final String csName ) throws IOException {
450+ testSingleByteRead (TEST_STRING , csName );
462451 }
463452
464453 @ Test
@@ -472,15 +461,14 @@ public void testSingleByteRead_UTF8() throws IOException {
472461 }
473462
474463
475- @ Test
476- public void testSkip_RequiredCharsets () throws Exception {
477- for (final String csName : getRequiredCharsetNames ()) {
478- try (InputStream r = new CharSequenceInputStream ("test" , csName )) {
479- assertEquals (1 , r .skip (1 ));
480- assertEquals (2 , r .skip (2 ));
481- r .skip (100 );
482- assertEquals (-1 , r .read (), csName );
483- }
464+ @ ParameterizedTest
465+ @ MethodSource (CharsetsTest .REQUIRED_CHARSETS )
466+ public void testSkip_RequiredCharsets (final String csName ) throws Exception {
467+ try (InputStream r = new CharSequenceInputStream ("test" , csName )) {
468+ assertEquals (1 , r .skip (1 ));
469+ assertEquals (2 , r .skip (2 ));
470+ r .skip (100 );
471+ assertEquals (-1 , r .read (), csName );
484472 }
485473 }
486474}
0 commit comments