@@ -105,16 +105,28 @@ public void testReadBufferOffsetLength() throws IOException {
105105 assertEquals (-1 , stream .read (b , 0 , b .length ), "read(b, off, len)" );
106106 }
107107
108- @ Test
109- public void testResetBeforeEndCtor () throws IOException {
110- try (final AutoCloseInputStream inputStream = new AutoCloseInputStream (new ByteArrayInputStream ("1234" .getBytes ()))) {
111- testResetBeforeEnd (inputStream );
112- }
108+ private void testResetBeforeEnd (final AutoCloseInputStream inputStream ) throws IOException {
109+ inputStream .mark (1 );
110+ assertEquals ('1' , inputStream .read ());
111+ inputStream .reset ();
112+ assertEquals ('1' , inputStream .read ());
113+ assertEquals ('2' , inputStream .read ());
114+ inputStream .reset ();
115+ assertEquals ('1' , inputStream .read ());
116+ assertEquals ('2' , inputStream .read ());
117+ assertEquals ('3' , inputStream .read ());
118+ inputStream .reset ();
119+ assertEquals ('1' , inputStream .read ());
120+ assertEquals ('2' , inputStream .read ());
121+ assertEquals ('3' , inputStream .read ());
122+ assertEquals ('4' , inputStream .read ());
123+ inputStream .reset ();
124+ assertEquals ('1' , inputStream .read ());
113125 }
114126
115127 @ Test
116- public void testResetBeforeEndSetInputStream () throws IOException {
117- try (final AutoCloseInputStream inputStream = AutoCloseInputStream . builder (). setInputStream ( new ByteArrayInputStream ("1234" .getBytes ())). get ( )) {
128+ public void testResetBeforeEndCtor () throws IOException {
129+ try (final AutoCloseInputStream inputStream = new AutoCloseInputStream ( new ByteArrayInputStream ("1234" .getBytes ()))) {
118130 testResetBeforeEnd (inputStream );
119131 }
120132 }
@@ -133,23 +145,11 @@ public void testResetBeforeEndSetCharSequence() throws IOException {
133145 }
134146 }
135147
136- private void testResetBeforeEnd (final AutoCloseInputStream inputStream ) throws IOException {
137- inputStream .mark (1 );
138- assertEquals ('1' , inputStream .read ());
139- inputStream .reset ();
140- assertEquals ('1' , inputStream .read ());
141- assertEquals ('2' , inputStream .read ());
142- inputStream .reset ();
143- assertEquals ('1' , inputStream .read ());
144- assertEquals ('2' , inputStream .read ());
145- assertEquals ('3' , inputStream .read ());
146- inputStream .reset ();
147- assertEquals ('1' , inputStream .read ());
148- assertEquals ('2' , inputStream .read ());
149- assertEquals ('3' , inputStream .read ());
150- assertEquals ('4' , inputStream .read ());
151- inputStream .reset ();
152- assertEquals ('1' , inputStream .read ());
148+ @ Test
149+ public void testResetBeforeEndSetInputStream () throws IOException {
150+ try (final AutoCloseInputStream inputStream = AutoCloseInputStream .builder ().setInputStream (new ByteArrayInputStream ("1234" .getBytes ())).get ()) {
151+ testResetBeforeEnd (inputStream );
152+ }
153153 }
154154
155155}
0 commit comments