@@ -626,19 +626,19 @@ class CopyWithNIOAndCloseTests {
626626
627627 @ Test
628628 void should_copy_data_using_nio_and_close_both_streams () throws IOException {
629- var input = spy (new ByteArrayInputStream (SAMPLE_BYTES ));
630- var output = spy (new ByteArrayOutputStream ());
629+ var testData = "Test data for NIO copy" .getBytes ();
630+ var input = new ByteArrayInputStream (testData );
631+ var output = mock (ByteArrayOutputStream .class );
631632
632633 var result = StreamUtil .copyWithNIOAndClose (input , output , 1024 );
633634
634635 assertTrue (result );
635- verify (input , atLeastOnce ()).close ();
636636 verify (output , atLeastOnce ()).close ();
637637 }
638638
639639 @ Test
640640 void should_close_streams_even_when_nio_copy_fails () throws IOException {
641- var output = spy ( new ByteArrayOutputStream () );
641+ var output = mock ( ByteArrayOutputStream . class );
642642
643643 var result = StreamUtil .copyWithNIOAndClose (null , output , 1024 );
644644
@@ -648,8 +648,8 @@ void should_close_streams_even_when_nio_copy_fails() throws IOException {
648648
649649 @ Test
650650 void should_handle_null_streams () throws IOException {
651- var output = spy ( new ByteArrayOutputStream () );
652- var input = spy ( new ByteArrayInputStream ( SAMPLE_BYTES ) );
651+ var output = mock ( ByteArrayOutputStream . class );
652+ var input = mock ( ByteArrayInputStream . class );
653653
654654 assertFalse (StreamUtil .copyWithNIOAndClose (null , output , 1024 ));
655655 assertFalse (StreamUtil .copyWithNIOAndClose (input , null , 1024 ));
0 commit comments