Skip to content

Commit 0d6bb65

Browse files
committed
ConsumableInputStream extends FilterInputStream
- Reduces boilerplace in the test fixture - Use Mockito like the rest of the updated test - Rework test setup to pass on Java 17 and 21 with Mockito
1 parent e731ffd commit 0d6bb65

File tree

2 files changed

+2
-60
lines changed

2 files changed

+2
-60
lines changed

httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/ConsumableInputStream.java

Lines changed: 0 additions & 57 deletions
This file was deleted.

httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestRFC5861Compliance.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ void testConsumesErrorResponseWhenServingStale()
136136
final ClassicHttpRequest req2 = HttpTestUtils.makeDefaultRequest();
137137
final ClassicHttpResponse resp2 = HttpTestUtils.make500Response();
138138
final byte[] body101 = HttpTestUtils.makeRandomBytes(101);
139-
final ByteArrayInputStream buf = new ByteArrayInputStream(body101);
140-
final ConsumableInputStream cis = new ConsumableInputStream(buf);
139+
final ByteArrayInputStream cis = Mockito.spy(new ByteArrayInputStream(body101));
141140
final HttpEntity entity = new InputStreamEntity(cis, 101, null);
142141
resp2.setEntity(entity);
143142

@@ -149,7 +148,7 @@ void testConsumesErrorResponseWhenServingStale()
149148

150149
execute(req2);
151150

152-
assertTrue(cis.wasClosed());
151+
Mockito.verify(cis).close();
153152
}
154153

155154
@Test

0 commit comments

Comments
 (0)