Skip to content

Commit bfb06f8

Browse files
committed
Use BOMInputStream type in tests
1 parent 53c5c35 commit bfb06f8

1 file changed

Lines changed: 15 additions & 24 deletions

File tree

src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ private void readBOMInputStreamTwice(final String resource) throws Exception {
193193
assertNotNull(inputStream);
194194
try (BOMInputStream bomInputStream = BOMInputStream.builder().setInputStream(inputStream).get()) {
195195
bomInputStream.mark(1_000_000);
196-
197196
readFile(bomInputStream);
198197
bomInputStream.reset();
199198
readFile(bomInputStream);
@@ -215,7 +214,7 @@ void testAfterReadConsumer() throws Exception {
215214
final byte[] data = { 'A', 'B', 'C', 'D' };
216215
final AtomicBoolean boolRef = new AtomicBoolean();
217216
// @formatter:off
218-
try (InputStream bounded = BOMInputStream.builder()
217+
try (BOMInputStream bounded = BOMInputStream.builder()
219218
.setInputStream(createUtf8Input(data, true))
220219
.setAfterRead(i -> boolRef.set(true))
221220
.get()) {
@@ -226,7 +225,7 @@ void testAfterReadConsumer() throws Exception {
226225
// Throwing
227226
final String message = "test exception message";
228227
// @formatter:off
229-
try (InputStream bounded = BOMInputStream.builder()
228+
try (BOMInputStream bounded = BOMInputStream.builder()
230229
.setInputStream(createUtf8Input(data, true))
231230
.setAfterRead(i -> {
232231
throw new CustomIOException(message);
@@ -241,7 +240,7 @@ void testAfterReadConsumer() throws Exception {
241240
void testAvailableWithBOMAfterClose() throws Exception {
242241
final byte[] data = { 'A', 'B', 'C', 'D' };
243242
final InputStream shadow;
244-
try (InputStream in = BOMInputStream.builder().setInputStream(createUtf8Input(data, true)).get()) {
243+
try (BOMInputStream in = BOMInputStream.builder().setInputStream(createUtf8Input(data, true)).get()) {
245244
assertEquals(7, in.available());
246245
shadow = in;
247246
}
@@ -251,15 +250,15 @@ void testAvailableWithBOMAfterClose() throws Exception {
251250
@Test
252251
void testAvailableWithBOMAfterOpen() throws Exception {
253252
final byte[] data = { 'A', 'B', 'C', 'D' };
254-
try (InputStream in = BOMInputStream.builder().setInputStream(createUtf8Input(data, true)).get()) {
253+
try (BOMInputStream in = BOMInputStream.builder().setInputStream(createUtf8Input(data, true)).get()) {
255254
assertEquals(7, in.available());
256255
}
257256
}
258257

259258
@Test
260259
void testAvailableWithoutBOM() throws Exception {
261260
final byte[] data = { 'A', 'B', 'C', 'D' };
262-
try (InputStream in = BOMInputStream.builder().setInputStream(createUtf8Input(data, false)).get()) {
261+
try (BOMInputStream in = BOMInputStream.builder().setInputStream(createUtf8Input(data, false)).get()) {
263262
assertEquals(4, in.available());
264263
}
265264
}
@@ -274,7 +273,7 @@ void testBuilderGet() {
274273
// this is here for coverage
275274
void testClose() throws Exception {
276275
try (ExpectCloseInputStream del = new ExpectCloseInputStream()) {
277-
try (InputStream in = new BOMInputStream(del)) {
276+
try (BOMInputStream in = new BOMInputStream(del)) {
278277
// nothing
279278
}
280279
del.assertCloseCalled();
@@ -298,7 +297,7 @@ void testEmptyBufferWithBOM() throws Exception {
298297
@Test
299298
void testEmptyBufferWithoutBOM() throws Exception {
300299
final byte[] data = {};
301-
try (InputStream in = BOMInputStream.builder().setInputStream(createUtf8Input(data, false)).get()) {
300+
try (BOMInputStream in = BOMInputStream.builder().setInputStream(createUtf8Input(data, false)).get()) {
302301
final byte[] buf = new byte[1024];
303302
assertEquals(-1, in.read(buf));
304303
}
@@ -338,7 +337,7 @@ void testGetBOMFirstThenReadInclude() throws Exception {
338337
@Test
339338
void testLargeBufferWithBOM() throws Exception {
340339
final byte[] data = { 'A', 'B', 'C' };
341-
try (InputStream in = BOMInputStream.builder().setInputStream(createUtf8Input(data, true)).get()) {
340+
try (BOMInputStream in = BOMInputStream.builder().setInputStream(createUtf8Input(data, true)).get()) {
342341
final byte[] buf = new byte[1024];
343342
assertData(data, buf, in.read(buf));
344343
}
@@ -347,7 +346,7 @@ void testLargeBufferWithBOM() throws Exception {
347346
@Test
348347
void testLargeBufferWithoutBOM() throws Exception {
349348
final byte[] data = { 'A', 'B', 'C' };
350-
try (InputStream in = BOMInputStream.builder().setInputStream(createUtf8Input(data, false)).get()) {
349+
try (BOMInputStream in = BOMInputStream.builder().setInputStream(createUtf8Input(data, false)).get()) {
351350
final byte[] buf = new byte[1024];
352351
assertData(data, buf, in.read(buf));
353352
}
@@ -356,7 +355,7 @@ void testLargeBufferWithoutBOM() throws Exception {
356355
@Test
357356
void testLeadingNonBOMBufferedRead() throws Exception {
358357
final byte[] data = { (byte) 0xEF, (byte) 0xAB, (byte) 0xCD };
359-
try (InputStream in = BOMInputStream.builder().setInputStream(createUtf8Input(data, false)).get()) {
358+
try (BOMInputStream in = BOMInputStream.builder().setInputStream(createUtf8Input(data, false)).get()) {
360359
final byte[] buf = new byte[1024];
361360
assertData(data, buf, in.read(buf));
362361
}
@@ -365,7 +364,7 @@ void testLeadingNonBOMBufferedRead() throws Exception {
365364
@Test
366365
void testLeadingNonBOMSingleRead() throws Exception {
367366
final byte[] data = { (byte) 0xEF, (byte) 0xAB, (byte) 0xCD };
368-
try (InputStream in = BOMInputStream.builder().setInputStream(createUtf8Input(data, false)).get()) {
367+
try (BOMInputStream in = BOMInputStream.builder().setInputStream(createUtf8Input(data, false)).get()) {
369368
assertEquals(0xEF, in.read());
370369
assertEquals(0xAB, in.read());
371370
assertEquals(0xCD, in.read());
@@ -376,12 +375,10 @@ void testLeadingNonBOMSingleRead() throws Exception {
376375
@Test
377376
void testMarkResetAfterReadWithBOM() throws Exception {
378377
final byte[] data = { 'A', 'B', 'C', 'D' };
379-
try (InputStream in = BOMInputStream.builder().setInputStream(createUtf8Input(data, true)).get()) {
378+
try (BOMInputStream in = BOMInputStream.builder().setInputStream(createUtf8Input(data, true)).get()) {
380379
assertTrue(in.markSupported());
381-
382380
in.read();
383381
in.mark(10);
384-
385382
in.read();
386383
in.read();
387384
in.reset();
@@ -392,12 +389,10 @@ void testMarkResetAfterReadWithBOM() throws Exception {
392389
@Test
393390
void testMarkResetAfterReadWithoutBOM() throws Exception {
394391
final byte[] data = { 'A', 'B', 'C', 'D' };
395-
try (InputStream in = BOMInputStream.builder().setInputStream(createUtf8Input(data, false)).get()) {
392+
try (BOMInputStream in = BOMInputStream.builder().setInputStream(createUtf8Input(data, false)).get()) {
396393
assertTrue(in.markSupported());
397-
398394
in.read();
399395
in.mark(10);
400-
401396
in.read();
402397
in.read();
403398
in.reset();
@@ -408,11 +403,9 @@ void testMarkResetAfterReadWithoutBOM() throws Exception {
408403
@Test
409404
void testMarkResetBeforeReadWithBOM() throws Exception {
410405
final byte[] data = { 'A', 'B', 'C', 'D' };
411-
try (InputStream in = BOMInputStream.builder().setInputStream(createUtf8Input(data, true)).get()) {
406+
try (BOMInputStream in = BOMInputStream.builder().setInputStream(createUtf8Input(data, true)).get()) {
412407
assertTrue(in.markSupported());
413-
414408
in.mark(10);
415-
416409
in.read();
417410
in.read();
418411
in.reset();
@@ -423,11 +416,9 @@ void testMarkResetBeforeReadWithBOM() throws Exception {
423416
@Test
424417
void testMarkResetBeforeReadWithoutBOM() throws Exception {
425418
final byte[] data = { 'A', 'B', 'C', 'D' };
426-
try (InputStream in = BOMInputStream.builder().setInputStream(createUtf8Input(data, false)).get()) {
419+
try (BOMInputStream in = BOMInputStream.builder().setInputStream(createUtf8Input(data, false)).get()) {
427420
assertTrue(in.markSupported());
428-
429421
in.mark(10);
430-
431422
in.read();
432423
in.read();
433424
in.reset();

0 commit comments

Comments
 (0)