3636
3737public class CharSequenceInputStreamTest {
3838
39+ private static final String UTF_16 = StandardCharsets .UTF_16 .name ();
40+ private static final String UTF_8 = StandardCharsets .UTF_8 .name ();
3941 private static final String ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
4042 private static final String LARGE_TEST_STRING ;
4143
@@ -172,7 +174,7 @@ public void testBufferedRead_RequiredCharset() throws IOException {
172174
173175 @ Test
174176 public void testBufferedRead_UTF8 () throws IOException {
175- testBufferedRead (TEST_STRING , "UTF-8" );
177+ testBufferedRead (TEST_STRING , UTF_8 );
176178 }
177179
178180 private void testCharsetMismatchInfiniteLoop (final String csName ) throws IOException {
@@ -222,37 +224,37 @@ private void testIO_356(final int bufferSize, final int dataSize, final int read
222224
223225 @ Test
224226 public void testIO_356_B10_D10_S0_UTF16 () throws Exception {
225- testIO_356 (10 , 10 , 0 , "UTF-16" );
227+ testIO_356 (10 , 10 , 0 , UTF_16 );
226228 }
227229
228230 @ Test
229231 public void testIO_356_B10_D10_S0_UTF8 () throws Exception {
230- testIO_356 (10 , 10 , 0 , "UTF-8" );
232+ testIO_356 (10 , 10 , 0 , UTF_8 );
231233 }
232234
233235 @ Test
234236 public void testIO_356_B10_D10_S1_UTF8 () throws Exception {
235- testIO_356 (10 , 10 , 1 , "UTF-8" );
237+ testIO_356 (10 , 10 , 1 , UTF_8 );
236238 }
237239
238240 @ Test
239241 public void testIO_356_B10_D10_S2_UTF8 () throws Exception {
240- testIO_356 (10 , 10 , 2 , "UTF-8" );
242+ testIO_356 (10 , 10 , 2 , UTF_8 );
241243 }
242244
243245 @ Test
244246 public void testIO_356_B10_D13_S0_UTF8 () throws Exception {
245- testIO_356 (10 , 13 , 0 , "UTF-8" );
247+ testIO_356 (10 , 13 , 0 , UTF_8 );
246248 }
247249
248250 @ Test
249251 public void testIO_356_B10_D13_S1_UTF8 () throws Exception {
250- testIO_356 (10 , 13 , 1 , "UTF-8" );
252+ testIO_356 (10 , 13 , 1 , UTF_8 );
251253 }
252254
253255 @ Test
254256 public void testIO_356_B10_D20_S0_UTF8 () throws Exception {
255- testIO_356 (10 , 20 , 0 , "UTF-8" );
257+ testIO_356 (10 , 20 , 0 , UTF_8 );
256258 }
257259
258260 private void testIO_356_Loop (final String csName , final int maxBytesPerChar ) throws Exception {
@@ -284,7 +286,7 @@ public void testLargeBufferedRead_RequiredCharsets() throws IOException {
284286
285287 @ Test
286288 public void testLargeBufferedRead_UTF8 () throws IOException {
287- testBufferedRead (LARGE_TEST_STRING , "UTF-8" );
289+ testBufferedRead (LARGE_TEST_STRING , UTF_8 );
288290 }
289291
290292 @ Test
@@ -296,7 +298,7 @@ public void testLargeSingleByteRead_RequiredCharsets() throws IOException {
296298
297299 @ Test
298300 public void testLargeSingleByteRead_UTF8 () throws IOException {
299- testSingleByteRead (LARGE_TEST_STRING , "UTF-8" );
301+ testSingleByteRead (LARGE_TEST_STRING , UTF_8 );
300302 }
301303
302304 // This test is broken for charsets that don't create a single byte for each char
@@ -331,12 +333,12 @@ public void testMarkReset_USASCII() throws Exception {
331333
332334 @ Test
333335 public void testMarkReset_UTF8 () throws Exception {
334- testMarkReset ("UTF-8" );
336+ testMarkReset (UTF_8 );
335337 }
336338
337339 @ Test
338340 public void testMarkSupported () throws Exception {
339- try (InputStream r = new CharSequenceInputStream ("test" , "UTF-8" )) {
341+ try (InputStream r = new CharSequenceInputStream ("test" , UTF_8 )) {
340342 assertTrue (r .markSupported ());
341343 }
342344 }
@@ -366,7 +368,7 @@ private void testReadZero(final String csName) throws Exception {
366368
367369 @ Test
368370 public void testReadZero_EmptyString () throws Exception {
369- try (InputStream r = new CharSequenceInputStream ("" , "UTF-8" )) {
371+ try (InputStream r = new CharSequenceInputStream ("" , UTF_8 )) {
370372 final byte [] bytes = new byte [30 ];
371373 assertEquals (0 , r .read (bytes , 0 , 0 ));
372374 }
@@ -401,12 +403,12 @@ public void testSingleByteRead_RequiredCharsets() throws IOException {
401403
402404 @ Test
403405 public void testSingleByteRead_UTF16 () throws IOException {
404- testSingleByteRead (TEST_STRING , "UTF-16" );
406+ testSingleByteRead (TEST_STRING , UTF_16 );
405407 }
406408
407409 @ Test
408410 public void testSingleByteRead_UTF8 () throws IOException {
409- testSingleByteRead (TEST_STRING , "UTF-8" );
411+ testSingleByteRead (TEST_STRING , UTF_8 );
410412 }
411413
412414 // This is broken for charsets that don't map each char to a byte
@@ -435,6 +437,6 @@ public void testSkip_USASCII() throws Exception {
435437
436438 @ Test
437439 public void testSkip_UTF8 () throws Exception {
438- testSkip ("UTF-8" );
440+ testSkip (UTF_8 );
439441 }
440442}
0 commit comments