@@ -509,33 +509,31 @@ public void testContentEquals_InputStream_InputStream() throws Exception {
509509 {
510510 assertTrue (IOUtils .contentEquals ((InputStream ) null , null ));
511511 }
512+ final byte [] dataEmpty = "" .getBytes (StandardCharsets .UTF_8 );
513+ final byte [] dataAbc = "ABC" .getBytes (StandardCharsets .UTF_8 );
514+ final byte [] dataAbcd = "ABCD" .getBytes (StandardCharsets .UTF_8 );
512515 {
513- final ByteArrayInputStream input1 = new ByteArrayInputStream ("" . getBytes ( StandardCharsets . UTF_8 ) );
516+ final ByteArrayInputStream input1 = new ByteArrayInputStream (dataEmpty );
514517 assertFalse (IOUtils .contentEquals (input1 , null ));
515518 }
516519 {
517- final ByteArrayInputStream input1 = new ByteArrayInputStream ("" . getBytes ( StandardCharsets . UTF_8 ) );
520+ final ByteArrayInputStream input1 = new ByteArrayInputStream (dataEmpty );
518521 assertFalse (IOUtils .contentEquals (null , input1 ));
519522 }
520523 {
521- final ByteArrayInputStream input1 = new ByteArrayInputStream ("" . getBytes ( StandardCharsets . UTF_8 ) );
524+ final ByteArrayInputStream input1 = new ByteArrayInputStream (dataEmpty );
522525 assertTrue (IOUtils .contentEquals (input1 , input1 ));
523526 }
524527 {
525- final ByteArrayInputStream input1 = new ByteArrayInputStream ("ABC" . getBytes ( StandardCharsets . UTF_8 ) );
528+ final ByteArrayInputStream input1 = new ByteArrayInputStream (dataAbc );
526529 assertTrue (IOUtils .contentEquals (input1 , input1 ));
527530 }
528- assertTrue (IOUtils .contentEquals (new ByteArrayInputStream ("" .getBytes (StandardCharsets .UTF_8 )),
529- new ByteArrayInputStream ("" .getBytes (StandardCharsets .UTF_8 ))));
530- assertTrue (IOUtils .contentEquals (
531- new BufferedInputStream (new ByteArrayInputStream ("" .getBytes (StandardCharsets .UTF_8 ))),
532- new BufferedInputStream (new ByteArrayInputStream ("" .getBytes (StandardCharsets .UTF_8 )))));
533- assertTrue (IOUtils .contentEquals (new ByteArrayInputStream ("ABC" .getBytes (StandardCharsets .UTF_8 )),
534- new ByteArrayInputStream ("ABC" .getBytes (StandardCharsets .UTF_8 ))));
535- assertFalse (IOUtils .contentEquals (new ByteArrayInputStream ("ABCD" .getBytes (StandardCharsets .UTF_8 )),
536- new ByteArrayInputStream ("ABC" .getBytes (StandardCharsets .UTF_8 ))));
537- assertFalse (IOUtils .contentEquals (new ByteArrayInputStream ("ABC" .getBytes (StandardCharsets .UTF_8 )),
538- new ByteArrayInputStream ("ABCD" .getBytes (StandardCharsets .UTF_8 ))));
531+ assertTrue (IOUtils .contentEquals (new ByteArrayInputStream (dataEmpty ), new ByteArrayInputStream (dataEmpty )));
532+ assertTrue (IOUtils .contentEquals (new BufferedInputStream (new ByteArrayInputStream (dataEmpty )),
533+ new BufferedInputStream (new ByteArrayInputStream (dataEmpty ))));
534+ assertTrue (IOUtils .contentEquals (new ByteArrayInputStream (dataAbc ), new ByteArrayInputStream (dataAbc )));
535+ assertFalse (IOUtils .contentEquals (new ByteArrayInputStream (dataAbcd ), new ByteArrayInputStream (dataAbc )));
536+ assertFalse (IOUtils .contentEquals (new ByteArrayInputStream (dataAbc ), new ByteArrayInputStream (dataAbcd )));
539537 // Tests with larger inputs that DEFAULT_BUFFER_SIZE in case internal buffers are used.
540538 final byte [] bytes2XDefaultA = new byte [IOUtils .DEFAULT_BUFFER_SIZE * 2 ];
541539 final byte [] bytes2XDefaultB = new byte [IOUtils .DEFAULT_BUFFER_SIZE * 2 ];
0 commit comments