This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
The following commit(s) were added to refs/heads/master by this push:
new 99ac56a5 Use try-with-resources
99ac56a5 is described below
commit 99ac56a5bec94b9799076ebc86e10c4d24119585
Author: Gary Gregory <[email protected]>
AuthorDate: Sun Feb 5 14:21:40 2023 -0500
Use try-with-resources
Javadoc
---
.../commons/compress/archivers/LongPathTest.java | 77 ++++++++++----------
.../archivers/dump/DumpArchiveInputStreamTest.java | 21 +++---
.../archivers/memory/MemoryArchiveTestCase.java | 38 +++++-----
.../archivers/sevenz/AES256SHA256DecoderTest.java | 1 -
.../compress/archivers/sevenz/FolderTest.java | 3 +-
.../compress/archivers/zip/BitStreamTest.java | 82 +++++++++++-----------
.../archivers/zip/ScatterZipOutputStreamTest.java | 44 ++++++------
.../archivers/zip/ZipArchiveEntryTest.java | 37 +++++-----
.../archivers/zip/ZipArchiveInputStreamTest.java | 19 +++--
.../archivers/zip/ZipSplitOutputStreamTest.java | 14 ++--
.../commons/compress/changes/ChangeTest.java | 3 +-
.../lz4/BlockLZ4CompressorInputStreamTest.java | 14 ++--
.../lz4/FramedLZ4CompressorInputStreamTest.java | 16 ++---
.../FramedSnappyCompressorInputStreamTest.java | 52 +++++---------
.../xz/XZCompressorInputStreamTest.java | 16 ++---
.../xz/XZCompressorOutputStreamTest.java | 3 +-
.../compressors/z/ZCompressorInputStreamTest.java | 15 ++--
.../zstandard/ZstdCompressorInputStreamTest.java | 37 ++++------
.../utils/ChecksumCalculatingInputStreamTest.java | 3 +-
.../utils/ChecksumVerifyingInputStreamTest.java | 3 +-
.../compress/utils/ServiceLoaderIteratorTest.java | 3 +-
21 files changed, 217 insertions(+), 284 deletions(-)
diff --git
a/src/test/java/org/apache/commons/compress/archivers/LongPathTest.java
b/src/test/java/org/apache/commons/compress/archivers/LongPathTest.java
index e9557ebd..53c4c4e1 100644
--- a/src/test/java/org/apache/commons/compress/archivers/LongPathTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/LongPathTest.java
@@ -75,14 +75,15 @@ public class LongPathTest extends AbstractTestCase {
assertTrue(ARCDIR.exists());
final File listing = new File(ARCDIR, "files.txt");
assertTrue(listing.canRead(), "files.txt is readable");
- final BufferedReader br = new
BufferedReader(Files.newBufferedReader(listing.toPath()));
- String line;
- while ((line = br.readLine()) != null) {
- if (!line.startsWith("#")) {
- FILELIST.add(line);
+ try (BufferedReader br = new
BufferedReader(Files.newBufferedReader(listing.toPath()))) {
+ String line;
+ while ((line = br.readLine()) != null) {
+ if (!line.startsWith("#")) {
+ FILELIST.add(line);
+ }
}
+ br.close();
}
- br.close();
}
@Override
@@ -100,49 +101,45 @@ public class LongPathTest extends AbstractTestCase {
@MethodSource("data")
public void testArchive(final File file) throws Exception {
@SuppressWarnings("unchecked") // fileList is of correct type
- final
- ArrayList<String> expected = (ArrayList<String>) FILELIST.clone();
+ final ArrayList<String> expected = (ArrayList<String>)
FILELIST.clone();
final String name = file.getName();
- if ("minotaur.jar".equals(name) || "minotaur-0.jar".equals(name)){
+ if ("minotaur.jar".equals(name) || "minotaur-0.jar".equals(name)) {
expected.add("META-INF/");
expected.add("META-INF/MANIFEST.MF");
}
- final ArchiveInputStream ais = factory.createArchiveInputStream(new
BufferedInputStream(Files.newInputStream(file.toPath())));
- // check if expected type recognized
- if (name.endsWith(".tar")){
- assertTrue(ais instanceof TarArchiveInputStream);
- } else if (name.endsWith(".jar") || name.endsWith(".zip")){
- assertTrue(ais instanceof ZipArchiveInputStream);
- } else if (name.endsWith(".cpio")){
- assertTrue(ais instanceof CpioArchiveInputStream);
- // Hack: cpio does not add trailing "/" to directory names
- for(int i=0; i < expected.size(); i++){
- final String ent = expected.get(i);
- if (ent.endsWith("/")){
- expected.set(i, ent.substring(0, ent.length()-1));
+ try (ArchiveInputStream ais = factory.createArchiveInputStream(new
BufferedInputStream(Files.newInputStream(file.toPath())))) {
+ // check if expected type recognized
+ if (name.endsWith(".tar")) {
+ assertTrue(ais instanceof TarArchiveInputStream);
+ } else if (name.endsWith(".jar") || name.endsWith(".zip")) {
+ assertTrue(ais instanceof ZipArchiveInputStream);
+ } else if (name.endsWith(".cpio")) {
+ assertTrue(ais instanceof CpioArchiveInputStream);
+ // Hack: cpio does not add trailing "/" to directory names
+ for (int i = 0; i < expected.size(); i++) {
+ final String ent = expected.get(i);
+ if (ent.endsWith("/")) {
+ expected.set(i, ent.substring(0, ent.length() - 1));
+ }
}
- }
- } else if (name.endsWith(".ar")){
- assertTrue(ais instanceof ArArchiveInputStream);
- // CPIO does not store directories or directory names
- expected.clear();
- for (final String ent : FILELIST) {
- if (!ent.endsWith("/")) {// not a directory
- final int lastSlash = ent.lastIndexOf('/');
- if (lastSlash >= 0) { // extract path name
- expected.add(ent.substring(lastSlash + 1));
- } else {
- expected.add(ent);
+ } else if (name.endsWith(".ar")) {
+ assertTrue(ais instanceof ArArchiveInputStream);
+ // CPIO does not store directories or directory names
+ expected.clear();
+ for (final String ent : FILELIST) {
+ if (!ent.endsWith("/")) {// not a directory
+ final int lastSlash = ent.lastIndexOf('/');
+ if (lastSlash >= 0) { // extract path name
+ expected.add(ent.substring(lastSlash + 1));
+ } else {
+ expected.add(ent);
+ }
}
}
+ } else {
+ fail("Unexpected file type: " + name);
}
- } else {
- fail("Unexpected file type: "+name);
- }
- try {
assertDoesNotThrow(() -> checkArchiveContent(ais, expected),
"Error processing " + file.getName());
- } finally {
- ais.close();
}
}
}
diff --git
a/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStreamTest.java
b/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStreamTest.java
index 61f2ca3d..8d9bbb41 100644
---
a/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStreamTest.java
+++
b/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStreamTest.java
@@ -59,19 +59,16 @@ public class DumpArchiveInputStreamTest extends
AbstractTestCase {
@Test
public void testConsumesArchiveCompletely() throws Exception {
- final InputStream is = DumpArchiveInputStreamTest.class
- .getResourceAsStream("/archive_with_trailer.dump");
- final DumpArchiveInputStream dump = new DumpArchiveInputStream(is);
- while (dump.getNextDumpEntry() != null) {
- // just consume the archive
+ try (final InputStream is =
DumpArchiveInputStreamTest.class.getResourceAsStream("/archive_with_trailer.dump");
+ DumpArchiveInputStream dump = new DumpArchiveInputStream(is)) {
+ while (dump.getNextDumpEntry() != null) {
+ // just consume the archive
+ }
+ final byte[] expected = { 'H', 'e', 'l', 'l', 'o', ',', ' ', 'w',
'o', 'r', 'l', 'd', '!', '\n' };
+ final byte[] actual = new byte[expected.length];
+ is.read(actual);
+ assertArrayEquals(expected, actual);
}
- final byte[] expected = {
- 'H', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd', '!',
'\n'
- };
- final byte[] actual = new byte[expected.length];
- is.read(actual);
- assertArrayEquals(expected, actual);
- dump.close();
}
@Test
diff --git
a/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveTestCase.java
b/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveTestCase.java
index af81253c..2817298c 100644
---
a/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveTestCase.java
+++
b/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveTestCase.java
@@ -32,27 +32,23 @@ public final class MemoryArchiveTestCase {
@Test
public void testReading() throws IOException {
- final MemoryArchiveInputStream is = new MemoryArchiveInputStream(new
String[][] {
- { "test1", "content1" },
- { "test2", "content2" },
- });
-
- final ArchiveEntry entry1 = is.getNextEntry();
- assertNotNull(entry1);
- assertEquals("test1", entry1.getName());
- final String content1 = is.readString();
- assertEquals("content1", content1);
-
- final ArchiveEntry entry2 = is.getNextEntry();
- assertNotNull(entry2);
- assertEquals("test2", entry2.getName());
- final String content2 = is.readString();
- assertEquals("content2", content2);
-
- final ArchiveEntry entry3 = is.getNextEntry();
- assertNull(entry3);
-
- is.close();
+ try (MemoryArchiveInputStream is = new MemoryArchiveInputStream(new
String[][] { { "test1", "content1" }, { "test2", "content2" } })) {
+
+ final ArchiveEntry entry1 = is.getNextEntry();
+ assertNotNull(entry1);
+ assertEquals("test1", entry1.getName());
+ final String content1 = is.readString();
+ assertEquals("content1", content1);
+
+ final ArchiveEntry entry2 = is.getNextEntry();
+ assertNotNull(entry2);
+ assertEquals("test2", entry2.getName());
+ final String content2 = is.readString();
+ assertEquals("content2", content2);
+
+ final ArchiveEntry entry3 = is.getNextEntry();
+ assertNull(entry3);
+ }
}
}
diff --git
a/src/test/java/org/apache/commons/compress/archivers/sevenz/AES256SHA256DecoderTest.java
b/src/test/java/org/apache/commons/compress/archivers/sevenz/AES256SHA256DecoderTest.java
index f3b0cde6..beb25e7e 100644
---
a/src/test/java/org/apache/commons/compress/archivers/sevenz/AES256SHA256DecoderTest.java
+++
b/src/test/java/org/apache/commons/compress/archivers/sevenz/AES256SHA256DecoderTest.java
@@ -32,7 +32,6 @@ import org.junit.jupiter.api.Test;
/**
* Unit tests for class {@link AES256SHA256Decoder}.
*
- * @date 26.06.2017
* @see AES256SHA256Decoder
**/
public class AES256SHA256DecoderTest {
diff --git
a/src/test/java/org/apache/commons/compress/archivers/sevenz/FolderTest.java
b/src/test/java/org/apache/commons/compress/archivers/sevenz/FolderTest.java
index 03867db8..e93f6498 100644
--- a/src/test/java/org/apache/commons/compress/archivers/sevenz/FolderTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/sevenz/FolderTest.java
@@ -26,9 +26,8 @@ import org.junit.jupiter.api.Test;
/**
* Unit tests for class {@link Folder}.
*
- * @date 26.06.2017
* @see Folder
- **/
+ */
public class FolderTest {
diff --git
a/src/test/java/org/apache/commons/compress/archivers/zip/BitStreamTest.java
b/src/test/java/org/apache/commons/compress/archivers/zip/BitStreamTest.java
index 3c45a3b7..5fcf9987 100644
--- a/src/test/java/org/apache/commons/compress/archivers/zip/BitStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/zip/BitStreamTest.java
@@ -30,66 +30,66 @@ public class BitStreamTest {
@Test
public void testEmptyStream() throws Exception {
- final BitStream stream = new BitStream(new
ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY));
- assertEquals(-1, stream.nextBit(), "next bit");
- assertEquals(-1, stream.nextBit(), "next bit");
- assertEquals(-1, stream.nextBit(), "next bit");
- stream.close();
+ try (BitStream stream = new BitStream(new
ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY))) {
+ assertEquals(-1, stream.nextBit(), "next bit");
+ assertEquals(-1, stream.nextBit(), "next bit");
+ assertEquals(-1, stream.nextBit(), "next bit");
+ }
}
@Test
public void testNextByte() throws Exception {
- final BitStream stream = new BitStream(new ByteArrayInputStream(new
byte[] { (byte) 0xEA, 0x35 }));
- assertEquals(0, stream.nextBit(), "bit 0");
- assertEquals(1, stream.nextBit(), "bit 1");
- assertEquals(0, stream.nextBit(), "bit 2");
- assertEquals(1, stream.nextBit(), "bit 3");
+ try (BitStream stream = new BitStream(new ByteArrayInputStream(new
byte[] { (byte) 0xEA, 0x35 }))) {
+ assertEquals(0, stream.nextBit(), "bit 0");
+ assertEquals(1, stream.nextBit(), "bit 1");
+ assertEquals(0, stream.nextBit(), "bit 2");
+ assertEquals(1, stream.nextBit(), "bit 3");
- assertEquals(0x5E, stream.nextByte(), "next byte");
- assertEquals(-1, stream.nextByte(), "next byte"); // not enough bits
left to read a byte
- stream.close();
+ assertEquals(0x5E, stream.nextByte(), "next byte");
+ assertEquals(-1, stream.nextByte(), "next byte"); // not enough
bits left to read a byte
+ }
}
@Test
public void testNextByteFromEmptyStream() throws Exception {
- final BitStream stream = new BitStream(new
ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY));
- assertEquals(-1, stream.nextByte(), "next byte");
- assertEquals(-1, stream.nextByte(), "next byte");
- stream.close();
+ try (BitStream stream = new BitStream(new
ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY))) {
+ assertEquals(-1, stream.nextByte(), "next byte");
+ assertEquals(-1, stream.nextByte(), "next byte");
+ }
}
@Test
public void testReadAlignedBytes() throws Exception {
- final BitStream stream = new BitStream(new ByteArrayInputStream(new
byte[] { (byte) 0xEA, 0x35 }));
- assertEquals(0xEA, stream.nextByte(), "next byte");
- assertEquals(0x35, stream.nextByte(), "next byte");
- assertEquals(-1, stream.nextByte(), "next byte");
- stream.close();
+ try (BitStream stream = new BitStream(new ByteArrayInputStream(new
byte[] { (byte) 0xEA, 0x35 }))) {
+ assertEquals(0xEA, stream.nextByte(), "next byte");
+ assertEquals(0x35, stream.nextByte(), "next byte");
+ assertEquals(-1, stream.nextByte(), "next byte");
+ }
}
@Test
public void testStream() throws Exception {
- final BitStream stream = new BitStream(new ByteArrayInputStream(new
byte[] { (byte) 0xEA, 0x03 }));
+ try (BitStream stream = new BitStream(new ByteArrayInputStream(new
byte[] { (byte) 0xEA, 0x03 }))) {
- assertEquals(0, stream.nextBit(), "bit 0");
- assertEquals(1, stream.nextBit(), "bit 1");
- assertEquals(0, stream.nextBit(), "bit 2");
- assertEquals(1, stream.nextBit(), "bit 3");
- assertEquals(0, stream.nextBit(), "bit 4");
- assertEquals(1, stream.nextBit(), "bit 5");
- assertEquals(1, stream.nextBit(), "bit 6");
- assertEquals(1, stream.nextBit(), "bit 7");
+ assertEquals(0, stream.nextBit(), "bit 0");
+ assertEquals(1, stream.nextBit(), "bit 1");
+ assertEquals(0, stream.nextBit(), "bit 2");
+ assertEquals(1, stream.nextBit(), "bit 3");
+ assertEquals(0, stream.nextBit(), "bit 4");
+ assertEquals(1, stream.nextBit(), "bit 5");
+ assertEquals(1, stream.nextBit(), "bit 6");
+ assertEquals(1, stream.nextBit(), "bit 7");
- assertEquals(1, stream.nextBit(), "bit 8");
- assertEquals(1, stream.nextBit(), "bit 9");
- assertEquals(0, stream.nextBit(), "bit 10");
- assertEquals(0, stream.nextBit(), "bit 11");
- assertEquals(0, stream.nextBit(), "bit 12");
- assertEquals(0, stream.nextBit(), "bit 13");
- assertEquals(0, stream.nextBit(), "bit 14");
- assertEquals(0, stream.nextBit(), "bit 15");
+ assertEquals(1, stream.nextBit(), "bit 8");
+ assertEquals(1, stream.nextBit(), "bit 9");
+ assertEquals(0, stream.nextBit(), "bit 10");
+ assertEquals(0, stream.nextBit(), "bit 11");
+ assertEquals(0, stream.nextBit(), "bit 12");
+ assertEquals(0, stream.nextBit(), "bit 13");
+ assertEquals(0, stream.nextBit(), "bit 14");
+ assertEquals(0, stream.nextBit(), "bit 15");
- assertEquals(-1, stream.nextBit(), "next bit");
- stream.close();
+ assertEquals(-1, stream.nextBit(), "next bit");
+ }
}
}
diff --git
a/src/test/java/org/apache/commons/compress/archivers/zip/ScatterZipOutputStreamTest.java
b/src/test/java/org/apache/commons/compress/archivers/zip/ScatterZipOutputStreamTest.java
index 0d734c45..eb1fb490 100644
---
a/src/test/java/org/apache/commons/compress/archivers/zip/ScatterZipOutputStreamTest.java
+++
b/src/test/java/org/apache/commons/compress/archivers/zip/ScatterZipOutputStreamTest.java
@@ -49,34 +49,34 @@ public class ScatterZipOutputStreamTest {
@Test
public void putArchiveEntry() throws Exception {
scatterFile = File.createTempFile("scattertest", ".notzip");
- final ScatterZipOutputStream scatterZipOutputStream =
ScatterZipOutputStream.fileBased(scatterFile);
final byte[] B_PAYLOAD = "RBBBBBBS".getBytes();
final byte[] A_PAYLOAD = "XAAY".getBytes();
+ try (ScatterZipOutputStream scatterZipOutputStream =
ScatterZipOutputStream.fileBased(scatterFile)) {
- final ZipArchiveEntry zab = new ZipArchiveEntry("b.txt");
- zab.setMethod(ZipEntry.DEFLATED);
- final ByteArrayInputStream payload = new
ByteArrayInputStream(B_PAYLOAD);
-
scatterZipOutputStream.addArchiveEntry(createZipArchiveEntryRequest(zab,
createPayloadSupplier(payload)));
+ final ZipArchiveEntry zab = new ZipArchiveEntry("b.txt");
+ zab.setMethod(ZipEntry.DEFLATED);
+ final ByteArrayInputStream payload = new
ByteArrayInputStream(B_PAYLOAD);
+
scatterZipOutputStream.addArchiveEntry(createZipArchiveEntryRequest(zab,
createPayloadSupplier(payload)));
- final ZipArchiveEntry zae = new ZipArchiveEntry("a.txt");
- zae.setMethod(ZipEntry.DEFLATED);
- final ByteArrayInputStream payload1 = new
ByteArrayInputStream(A_PAYLOAD);
-
scatterZipOutputStream.addArchiveEntry(createZipArchiveEntryRequest(zae,
createPayloadSupplier(payload1)));
+ final ZipArchiveEntry zae = new ZipArchiveEntry("a.txt");
+ zae.setMethod(ZipEntry.DEFLATED);
+ final ByteArrayInputStream payload1 = new
ByteArrayInputStream(A_PAYLOAD);
+
scatterZipOutputStream.addArchiveEntry(createZipArchiveEntryRequest(zae,
createPayloadSupplier(payload1)));
- target = File.createTempFile("scattertest", ".zip");
- final ZipArchiveOutputStream outputStream = new
ZipArchiveOutputStream(target);
- scatterZipOutputStream.writeTo( outputStream);
- outputStream.close();
- scatterZipOutputStream.close();
+ target = File.createTempFile("scattertest", ".zip");
+ try (ZipArchiveOutputStream outputStream = new
ZipArchiveOutputStream(target)) {
+ scatterZipOutputStream.writeTo(outputStream);
+ }
+ }
- final ZipFile zf = new ZipFile(target);
- final ZipArchiveEntry b_entry =
zf.getEntries("b.txt").iterator().next();
- assertEquals(8, b_entry.getSize());
- assertArrayEquals(B_PAYLOAD,
IOUtils.toByteArray(zf.getInputStream(b_entry)));
+ try (ZipFile zf = new ZipFile(target)) {
+ final ZipArchiveEntry b_entry =
zf.getEntries("b.txt").iterator().next();
+ assertEquals(8, b_entry.getSize());
+ assertArrayEquals(B_PAYLOAD,
IOUtils.toByteArray(zf.getInputStream(b_entry)));
- final ZipArchiveEntry a_entry =
zf.getEntries("a.txt").iterator().next();
- assertEquals(4, a_entry.getSize());
- assertArrayEquals(A_PAYLOAD,
IOUtils.toByteArray(zf.getInputStream(a_entry)));
- zf.close();
+ final ZipArchiveEntry a_entry =
zf.getEntries("a.txt").iterator().next();
+ assertEquals(4, a_entry.getSize());
+ assertArrayEquals(A_PAYLOAD,
IOUtils.toByteArray(zf.getInputStream(a_entry)));
+ }
}
}
diff --git
a/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java
b/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java
index 64c37e9b..645339d8 100644
---
a/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java
+++
b/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java
@@ -170,25 +170,24 @@ public class ZipArchiveEntryTest {
*/
@Test
public void testCompressionMethod() throws Exception {
- final ZipArchiveOutputStream zos =
- new ZipArchiveOutputStream(new ByteArrayOutputStream());
- final ZipArchiveEntry entry = new ZipArchiveEntry("foo");
- assertEquals(-1, entry.getMethod());
- assertFalse(zos.canWriteEntryData(entry));
-
- entry.setMethod(ZipEntry.STORED);
- assertEquals(ZipEntry.STORED, entry.getMethod());
- assertTrue(zos.canWriteEntryData(entry));
-
- entry.setMethod(ZipEntry.DEFLATED);
- assertEquals(ZipEntry.DEFLATED, entry.getMethod());
- assertTrue(zos.canWriteEntryData(entry));
-
- // Test the unsupported "imploded" compression method (6)
- entry.setMethod(6);
- assertEquals(6, entry.getMethod());
- assertFalse(zos.canWriteEntryData(entry));
- zos.close();
+ try (ZipArchiveOutputStream zos = new ZipArchiveOutputStream(new
ByteArrayOutputStream())) {
+ final ZipArchiveEntry entry = new ZipArchiveEntry("foo");
+ assertEquals(-1, entry.getMethod());
+ assertFalse(zos.canWriteEntryData(entry));
+
+ entry.setMethod(ZipEntry.STORED);
+ assertEquals(ZipEntry.STORED, entry.getMethod());
+ assertTrue(zos.canWriteEntryData(entry));
+
+ entry.setMethod(ZipEntry.DEFLATED);
+ assertEquals(ZipEntry.DEFLATED, entry.getMethod());
+ assertTrue(zos.canWriteEntryData(entry));
+
+ // Test the unsupported "imploded" compression method (6)
+ entry.setMethod(6);
+ assertEquals(6, entry.getMethod());
+ assertFalse(zos.canWriteEntryData(entry));
+ }
}
@Test
diff --git
a/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
b/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
index ca089e9e..b5b165fe 100644
---
a/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
+++
b/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
@@ -367,17 +367,14 @@ public class ZipArchiveInputStreamTest extends
AbstractTestCase {
@Test
public void shouldConsumeArchiveCompletely() throws Exception {
- final InputStream is = ZipArchiveInputStreamTest.class
- .getResourceAsStream("/archive_with_trailer.zip");
- final ZipArchiveInputStream zip = new ZipArchiveInputStream(is);
- getAllZipEntries(zip);
- final byte[] expected = {
- 'H', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd', '!',
'\n'
- };
- final byte[] actual = new byte[expected.length];
- is.read(actual);
- assertArrayEquals(expected, actual);
- zip.close();
+ try (InputStream is =
ZipArchiveInputStreamTest.class.getResourceAsStream("/archive_with_trailer.zip");
+ ZipArchiveInputStream zip = new ZipArchiveInputStream(is)) {
+ getAllZipEntries(zip);
+ final byte[] expected = { 'H', 'e', 'l', 'l', 'o', ',', ' ', 'w',
'o', 'r', 'l', 'd', '!', '\n' };
+ final byte[] actual = new byte[expected.length];
+ is.read(actual);
+ assertArrayEquals(expected, actual);
+ }
}
/**
diff --git
a/src/test/java/org/apache/commons/compress/archivers/zip/ZipSplitOutputStreamTest.java
b/src/test/java/org/apache/commons/compress/archivers/zip/ZipSplitOutputStreamTest.java
index 830811d6..55f26ceb 100644
---
a/src/test/java/org/apache/commons/compress/archivers/zip/ZipSplitOutputStreamTest.java
+++
b/src/test/java/org/apache/commons/compress/archivers/zip/ZipSplitOutputStreamTest.java
@@ -50,15 +50,15 @@ public class ZipSplitOutputStreamTest extends
AbstractTestCase {
final ZipSplitOutputStream zipSplitOutputStream = new
ZipSplitOutputStream(testOutputFile, splitSize);
final File fileToTest =
getFile("COMPRESS-477/split_zip_created_by_zip/zip_to_compare_created_by_zip.zip");
- final InputStream inputStream =
Files.newInputStream(fileToTest.toPath());
- final byte[] buffer = new byte[4096];
- int readLen;
+ try (InputStream inputStream =
Files.newInputStream(fileToTest.toPath())) {
+ final byte[] buffer = new byte[4096];
+ int readLen;
- while ((readLen = inputStream.read(buffer)) > 0) {
- zipSplitOutputStream.write(buffer, 0, readLen);
- }
+ while ((readLen = inputStream.read(buffer)) > 0) {
+ zipSplitOutputStream.write(buffer, 0, readLen);
+ }
- inputStream.close();
+ }
zipSplitOutputStream.close();
File zipFile = new File(dir.getPath(), "testCreateSplittedFiles.z01");
diff --git a/src/test/java/org/apache/commons/compress/changes/ChangeTest.java
b/src/test/java/org/apache/commons/compress/changes/ChangeTest.java
index 8c7630f1..5142197b 100644
--- a/src/test/java/org/apache/commons/compress/changes/ChangeTest.java
+++ b/src/test/java/org/apache/commons/compress/changes/ChangeTest.java
@@ -28,9 +28,8 @@ import org.junit.jupiter.api.Test;
/**
* Unit tests for class {@link Change}.
*
- * @date 16.06.2017
* @see Change
- **/
+ */
public class ChangeTest {
@Test
diff --git
a/src/test/java/org/apache/commons/compress/compressors/lz4/BlockLZ4CompressorInputStreamTest.java
b/src/test/java/org/apache/commons/compress/compressors/lz4/BlockLZ4CompressorInputStreamTest.java
index a83595dc..a404edf1 100644
---
a/src/test/java/org/apache/commons/compress/compressors/lz4/BlockLZ4CompressorInputStreamTest.java
+++
b/src/test/java/org/apache/commons/compress/compressors/lz4/BlockLZ4CompressorInputStreamTest.java
@@ -36,20 +36,18 @@ public class BlockLZ4CompressorInputStreamTest extends
AbstractTestCase {
public void multiByteReadConsistentlyReturnsMinusOneAtEof() throws
IOException {
final File input = getFile("bla.tar.block_lz4");
final byte[] buf = new byte[2];
- try (InputStream is = Files.newInputStream(input.toPath())) {
- final BlockLZ4CompressorInputStream in =
- new BlockLZ4CompressorInputStream(is);
+ try (InputStream is = Files.newInputStream(input.toPath());
+ BlockLZ4CompressorInputStream in = new
BlockLZ4CompressorInputStream(is)) {
IOUtils.toByteArray(in);
assertEquals(-1, in.read(buf));
assertEquals(-1, in.read(buf));
- in.close();
}
}
@Test
public void readBlaLz4() throws IOException {
try (InputStream a = new
BlockLZ4CompressorInputStream(newInputStream("bla.tar.block_lz4"));
- InputStream e = newInputStream("bla.tar")) {
+ InputStream e = newInputStream("bla.tar")) {
final byte[] expected = IOUtils.toByteArray(e);
final byte[] actual = IOUtils.toByteArray(a);
assertArrayEquals(expected, actual);
@@ -59,13 +57,11 @@ public class BlockLZ4CompressorInputStreamTest extends
AbstractTestCase {
@Test
public void singleByteReadConsistentlyReturnsMinusOneAtEof() throws
IOException {
final File input = getFile("bla.tar.block_lz4");
- try (InputStream is = Files.newInputStream(input.toPath())) {
- final BlockLZ4CompressorInputStream in =
- new BlockLZ4CompressorInputStream(is);
+ try (InputStream is = Files.newInputStream(input.toPath());
+ BlockLZ4CompressorInputStream in = new
BlockLZ4CompressorInputStream(is)) {
IOUtils.toByteArray(in);
assertEquals(-1, in.read());
assertEquals(-1, in.read());
- in.close();
}
}
}
diff --git
a/src/test/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorInputStreamTest.java
b/src/test/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorInputStreamTest.java
index 4cef1019..3792f098 100644
---
a/src/test/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorInputStreamTest.java
+++
b/src/test/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorInputStreamTest.java
@@ -69,8 +69,8 @@ public final class FramedLZ4CompressorInputStreamTest extends
AbstractTestCase {
private void expectIOException(final String fileName) {
assertThrows(IOException.class, () -> {
- try (InputStream is =
Files.newInputStream(getFile(fileName).toPath())) {
- final FramedLZ4CompressorInputStream in = new
FramedLZ4CompressorInputStream(is);
+ try (InputStream is =
Files.newInputStream(getFile(fileName).toPath());
+ final FramedLZ4CompressorInputStream in = new
FramedLZ4CompressorInputStream(is)) {
IOUtils.toByteArray(in);
}
});
@@ -80,13 +80,11 @@ public final class FramedLZ4CompressorInputStreamTest
extends AbstractTestCase {
public void multiByteReadConsistentlyReturnsMinusOneAtEof() throws
IOException {
final File input = getFile("bla.tar.lz4");
final byte[] buf = new byte[2];
- try (InputStream is = Files.newInputStream(input.toPath())) {
- final FramedLZ4CompressorInputStream in =
- new FramedLZ4CompressorInputStream(is);
+ try (InputStream is = Files.newInputStream(input.toPath());
+ FramedLZ4CompressorInputStream in = new
FramedLZ4CompressorInputStream(is)) {
IOUtils.toByteArray(in);
assertEquals(-1, in.read(buf));
assertEquals(-1, in.read(buf));
- in.close();
}
}
@@ -535,13 +533,11 @@ public final class FramedLZ4CompressorInputStreamTest
extends AbstractTestCase {
@Test
public void singleByteReadConsistentlyReturnsMinusOneAtEof() throws
IOException {
final File input = getFile("bla.tar.lz4");
- try (InputStream is = Files.newInputStream(input.toPath())) {
- final FramedLZ4CompressorInputStream in =
- new FramedLZ4CompressorInputStream(is);
+ try (InputStream is = Files.newInputStream(input.toPath());
+ FramedLZ4CompressorInputStream in = new
FramedLZ4CompressorInputStream(is);) {
IOUtils.toByteArray(in);
assertEquals(-1, in.read());
assertEquals(-1, in.read());
- in.close();
}
}
diff --git
a/src/test/java/org/apache/commons/compress/compressors/snappy/FramedSnappyCompressorInputStreamTest.java
b/src/test/java/org/apache/commons/compress/compressors/snappy/FramedSnappyCompressorInputStreamTest.java
index f8a6bcc6..1550a4a5 100644
---
a/src/test/java/org/apache/commons/compress/compressors/snappy/FramedSnappyCompressorInputStreamTest.java
+++
b/src/test/java/org/apache/commons/compress/compressors/snappy/FramedSnappyCompressorInputStreamTest.java
@@ -37,22 +37,18 @@ import
org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
import org.apache.commons.compress.utils.IOUtils;
import org.junit.jupiter.api.Test;
-public final class FramedSnappyCompressorInputStreamTest
- extends AbstractTestCase {
+public final class FramedSnappyCompressorInputStreamTest extends
AbstractTestCase {
private long mask(final long x) {
- return (((x >>> 15) | (x << 17))
- + FramedSnappyCompressorInputStream.MASK_OFFSET)
- & 0xffffFFFFL;
+ return (((x >>> 15) | (x << 17)) +
FramedSnappyCompressorInputStream.MASK_OFFSET) & 0xffffFFFFL;
}
@Test
public void multiByteReadConsistentlyReturnsMinusOneAtEof() throws
IOException {
final File input = getFile("bla.tar.sz");
final byte[] buf = new byte[2];
- try (InputStream is = Files.newInputStream(input.toPath())) {
- final FramedSnappyCompressorInputStream in =
- new FramedSnappyCompressorInputStream(is);
+ try (InputStream is = Files.newInputStream(input.toPath());
+ FramedSnappyCompressorInputStream in = new
FramedSnappyCompressorInputStream(is);) {
IOUtils.toByteArray(in);
assertEquals(-1, in.read(buf));
assertEquals(-1, in.read(buf));
@@ -81,7 +77,8 @@ public final class FramedSnappyCompressorInputStreamTest
FramedSnappyCompressorInputStream in = new
FramedSnappyCompressorInputStream(is, 1 << 16,
FramedSnappyDialect.IWORK_ARCHIVE);) {
Files.copy(in, o.toPath());
}
- try (InputStream a = Files.newInputStream(o.toPath()); InputStream e =
newInputStream("COMPRESS-358.uncompressed")) {
+ try (InputStream a = Files.newInputStream(o.toPath());
+ InputStream e = newInputStream("COMPRESS-358.uncompressed")) {
final byte[] expected = IOUtils.toByteArray(e);
final byte[] actual = IOUtils.toByteArray(a);
assertArrayEquals(expected, actual);
@@ -91,20 +88,18 @@ public final class FramedSnappyCompressorInputStreamTest
@Test
public void singleByteReadConsistentlyReturnsMinusOneAtEof() throws
IOException {
final File input = getFile("bla.tar.sz");
- try (InputStream is = Files.newInputStream(input.toPath())) {
- final FramedSnappyCompressorInputStream in =
- new FramedSnappyCompressorInputStream(is);
+ try (InputStream is = Files.newInputStream(input.toPath());
+ FramedSnappyCompressorInputStream in = new
FramedSnappyCompressorInputStream(is);) {
IOUtils.toByteArray(in);
assertEquals(-1, in.read());
assertEquals(-1, in.read());
- in.close();
}
}
@Test
public void testAvailable() throws Exception {
- try (InputStream isSz = newInputStream("mixed.txt.sz")) {
- final FramedSnappyCompressorInputStream in = new
FramedSnappyCompressorInputStream(isSz);
+ try (InputStream isSz = newInputStream("mixed.txt.sz");
+ FramedSnappyCompressorInputStream in = new
FramedSnappyCompressorInputStream(isSz)) {
assertEquals(0, in.available()); // no chunk read so far
assertEquals('1', in.read());
assertEquals(3, in.available()); // remainder of first
uncompressed block
@@ -113,7 +108,6 @@ public final class FramedSnappyCompressorInputStreamTest
assertEquals(0, in.available()); // end of chunk, must read next
one
assertEquals(4, in.read(new byte[5], 0, 4));
assertEquals('5', in.read());
- in.close();
}
}
@@ -124,9 +118,7 @@ public final class FramedSnappyCompressorInputStreamTest
}
private void testChecksumUnmasking(final long x) {
- assertEquals(Long.toHexString(x),
- Long.toHexString(FramedSnappyCompressorInputStream
- .unmask(mask(x))));
+ assertEquals(Long.toHexString(x),
Long.toHexString(FramedSnappyCompressorInputStream.unmask(mask(x))));
}
/**
@@ -140,7 +132,8 @@ public final class FramedSnappyCompressorInputStreamTest
try (InputStream in = new FramedSnappyCompressorInputStream(isSz))
{
Files.copy(in, outputSz.toPath());
}
- try (InputStream isGz = newInputStream("lorem-ipsum.txt.gz");
InputStream in = new GzipCompressorInputStream(isGz)) {
+ try (InputStream isGz = newInputStream("lorem-ipsum.txt.gz");
+ InputStream in = new GzipCompressorInputStream(isGz)) {
Files.copy(in, outputGz.toPath());
}
}
@@ -167,25 +160,14 @@ public final class FramedSnappyCompressorInputStreamTest
out.close();
}
- assertArrayEquals(new byte[] { '1', '2', '3', '4',
- '5', '6', '7', '8', '9',
- '5', '6', '7', '8', '9',
- '5', '6', '7', '8', '9',
- '5', '6', '7', '8', '9',
- '5', '6', '7', '8', '9', 10,
- '1', '2', '3', '4',
- '1', '2', '3', '4',
- }, out.toByteArray());
+ assertArrayEquals(new byte[] { '1', '2', '3', '4', '5', '6', '7', '8',
'9', '5', '6', '7', '8', '9', '5', '6', '7', '8', '9', '5', '6', '7', '8', '9',
+ '5', '6', '7', '8', '9', 10, '1', '2', '3', '4', '1', '2',
'3', '4', }, out.toByteArray());
}
@Test
public void testUnskippableChunk() {
- final byte[] input = {
- (byte) 0xff, 6, 0, 0, 's', 'N', 'a', 'P', 'p', 'Y',
- 2, 2, 0, 0, 1, 1
- };
- try (final FramedSnappyCompressorInputStream in =
- new FramedSnappyCompressorInputStream(new
ByteArrayInputStream(input))) {
+ final byte[] input = { (byte) 0xff, 6, 0, 0, 's', 'N', 'a', 'P', 'p',
'Y', 2, 2, 0, 0, 1, 1 };
+ try (final FramedSnappyCompressorInputStream in = new
FramedSnappyCompressorInputStream(new ByteArrayInputStream(input))) {
final IOException exception = assertThrows(IOException.class, ()
-> in.read());
assertTrue(exception.getMessage().contains("Unskippable chunk"));
} catch (final IOException ex) {
diff --git
a/src/test/java/org/apache/commons/compress/compressors/xz/XZCompressorInputStreamTest.java
b/src/test/java/org/apache/commons/compress/compressors/xz/XZCompressorInputStreamTest.java
index 845482c7..2e6803b2 100644
---
a/src/test/java/org/apache/commons/compress/compressors/xz/XZCompressorInputStreamTest.java
+++
b/src/test/java/org/apache/commons/compress/compressors/xz/XZCompressorInputStreamTest.java
@@ -35,13 +35,11 @@ public class XZCompressorInputStreamTest {
private void multiByteReadConsistentlyReturnsMinusOneAtEof(final boolean
decompressConcatenated) throws IOException {
final File input = getFile("bla.tar.xz");
final byte[] buf = new byte[2];
- try (InputStream is = Files.newInputStream(input.toPath())) {
- final XZCompressorInputStream in =
- new XZCompressorInputStream(is, decompressConcatenated);
+ try (InputStream is = Files.newInputStream(input.toPath());
+ XZCompressorInputStream in = new XZCompressorInputStream(is,
decompressConcatenated);) {
IOUtils.toByteArray(in);
assertEquals(-1, in.read(buf));
assertEquals(-1, in.read(buf));
- in.close();
}
}
@@ -57,9 +55,7 @@ public class XZCompressorInputStreamTest {
@Test
public void redundantTestOfAlmostDeprecatedMatchesMethod() {
- final byte[] data = {
- (byte) 0xFD, '7', 'z', 'X', 'Z', '\0'
- };
+ final byte[] data = { (byte) 0xFD, '7', 'z', 'X', 'Z', '\0' };
assertFalse(XZCompressorInputStream.matches(data, 5));
assertTrue(XZCompressorInputStream.matches(data, 6));
assertTrue(XZCompressorInputStream.matches(data, 7));
@@ -69,13 +65,11 @@ public class XZCompressorInputStreamTest {
private void singleByteReadConsistentlyReturnsMinusOneAtEof(final boolean
decompressConcatenated) throws IOException {
final File input = getFile("bla.tar.xz");
- try (InputStream is = Files.newInputStream(input.toPath())) {
- final XZCompressorInputStream in =
- new XZCompressorInputStream(is, decompressConcatenated);
+ try (InputStream is = Files.newInputStream(input.toPath());
+ XZCompressorInputStream in = new XZCompressorInputStream(is,
decompressConcatenated)) {
IOUtils.toByteArray(in);
assertEquals(-1, in.read());
assertEquals(-1, in.read());
- in.close();
}
}
diff --git
a/src/test/java/org/apache/commons/compress/compressors/xz/XZCompressorOutputStreamTest.java
b/src/test/java/org/apache/commons/compress/compressors/xz/XZCompressorOutputStreamTest.java
index 84d50524..ed753fea 100644
---
a/src/test/java/org/apache/commons/compress/compressors/xz/XZCompressorOutputStreamTest.java
+++
b/src/test/java/org/apache/commons/compress/compressors/xz/XZCompressorOutputStreamTest.java
@@ -29,9 +29,8 @@ import org.junit.jupiter.api.Test;
/**
* Unit tests for class {@link XZCompressorOutputStream}.
*
- * @date 16.06.2017
* @see XZCompressorOutputStream
- **/
+ */
public class XZCompressorOutputStreamTest {
diff --git
a/src/test/java/org/apache/commons/compress/compressors/z/ZCompressorInputStreamTest.java
b/src/test/java/org/apache/commons/compress/compressors/z/ZCompressorInputStreamTest.java
index 01578bd4..00542ef6 100644
---
a/src/test/java/org/apache/commons/compress/compressors/z/ZCompressorInputStreamTest.java
+++
b/src/test/java/org/apache/commons/compress/compressors/z/ZCompressorInputStreamTest.java
@@ -35,35 +35,30 @@ import org.junit.jupiter.api.Test;
/**
* Unit tests for class {@link ZCompressorInputStream}.
*
- * @date 16.06.2017
* @see ZCompressorInputStream
- **/
+ */
public class ZCompressorInputStreamTest {
@Test
public void multiByteReadConsistentlyReturnsMinusOneAtEof() throws
IOException {
final File input = getFile("bla.tar.Z");
final byte[] buf = new byte[2];
- try (InputStream is = Files.newInputStream(input.toPath())) {
- final ZCompressorInputStream in =
- new ZCompressorInputStream(is);
+ try (InputStream is = Files.newInputStream(input.toPath());
+ ZCompressorInputStream in = new ZCompressorInputStream(is)) {
IOUtils.toByteArray(in);
assertEquals(-1, in.read(buf));
assertEquals(-1, in.read(buf));
- in.close();
}
}
@Test
public void singleByteReadConsistentlyReturnsMinusOneAtEof() throws
IOException {
final File input = getFile("bla.tar.Z");
- try (InputStream is = Files.newInputStream(input.toPath())) {
- final ZCompressorInputStream in =
- new ZCompressorInputStream(is);
+ try (InputStream is = Files.newInputStream(input.toPath());
+ ZCompressorInputStream in = new ZCompressorInputStream(is)) {
IOUtils.toByteArray(in);
assertEquals(-1, in.read());
assertEquals(-1, in.read());
- in.close();
}
}
diff --git
a/src/test/java/org/apache/commons/compress/compressors/zstandard/ZstdCompressorInputStreamTest.java
b/src/test/java/org/apache/commons/compress/compressors/zstandard/ZstdCompressorInputStreamTest.java
index e5e0be68..14527e79 100644
---
a/src/test/java/org/apache/commons/compress/compressors/zstandard/ZstdCompressorInputStreamTest.java
+++
b/src/test/java/org/apache/commons/compress/compressors/zstandard/ZstdCompressorInputStreamTest.java
@@ -42,37 +42,31 @@ public class ZstdCompressorInputStreamTest extends
AbstractTestCase {
public void multiByteReadConsistentlyReturnsMinusOneAtEof() throws
IOException {
final File input = getFile("zstandard.testdata.zst");
final byte[] buf = new byte[2];
- try (InputStream is = Files.newInputStream(input.toPath())) {
- final ZstdCompressorInputStream in =
- new ZstdCompressorInputStream(is);
+ try (InputStream is = Files.newInputStream(input.toPath());
+ ZstdCompressorInputStream in = new
ZstdCompressorInputStream(is)) {
IOUtils.toByteArray(in);
assertEquals(-1, in.read(buf));
assertEquals(-1, in.read(buf));
- in.close();
}
}
@Test
public void shouldBeAbleToSkipAByte() throws IOException {
final File input = getFile("zstandard.testdata.zst");
- try (InputStream is = Files.newInputStream(input.toPath())) {
- final ZstdCompressorInputStream in =
- new ZstdCompressorInputStream(is);
+ try (InputStream is = Files.newInputStream(input.toPath());
+ ZstdCompressorInputStream in = new
ZstdCompressorInputStream(is)) {
assertEquals(1, in.skip(1));
- in.close();
}
}
@Test
public void singleByteReadConsistentlyReturnsMinusOneAtEof() throws
IOException {
final File input = getFile("zstandard.testdata.zst");
- try (InputStream is = Files.newInputStream(input.toPath())) {
- final ZstdCompressorInputStream in =
- new ZstdCompressorInputStream(is);
+ try (InputStream is = Files.newInputStream(input.toPath());
+ ZstdCompressorInputStream in = new
ZstdCompressorInputStream(is)) {
IOUtils.toByteArray(in);
assertEquals(-1, in.read());
assertEquals(-1, in.read());
- in.close();
}
}
@@ -90,12 +84,9 @@ public class ZstdCompressorInputStreamTest extends
AbstractTestCase {
ois.read(originalFileContent);
}
- try (InputStream is = Files.newInputStream(input.toPath())) {
- final ZstdCompressorInputStream in =
- new ZstdCompressorInputStream(is);
-
+ try (InputStream is = Files.newInputStream(input.toPath());
+ ZstdCompressorInputStream in = new
ZstdCompressorInputStream(is)) {
assertEquals(originalFileContent[0], in.read());
- in.close();
}
}
@@ -149,12 +140,12 @@ public class ZstdCompressorInputStreamTest extends
AbstractTestCase {
final File input = getFile("zstandard.testdata.zst");
final File expected = getFile("zstandard.testdata");
try (InputStream inputStream = Files.newInputStream(input.toPath());
- ZstdCompressorInputStream zstdInputStream = new
ZstdCompressorInputStream(inputStream)) {
+ ZstdCompressorInputStream zstdInputStream = new
ZstdCompressorInputStream(inputStream)) {
final byte[] b = new byte[97];
IOUtils.read(expected, b);
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
int readByte = -1;
- while((readByte = zstdInputStream.read()) != -1) {
+ while ((readByte = zstdInputStream.read()) != -1) {
bos.write(readByte);
}
assertArrayEquals(b, bos.toByteArray());
@@ -166,12 +157,12 @@ public class ZstdCompressorInputStreamTest extends
AbstractTestCase {
final File input = getFile("zstandard.testdata.zst");
final File expected = getFile("zstandard.testdata");
try (InputStream inputStream = Files.newInputStream(input.toPath());
- ZstdCompressorInputStream zstdInputStream = new
ZstdCompressorInputStream(inputStream, NoPool.INSTANCE)) {
+ ZstdCompressorInputStream zstdInputStream = new
ZstdCompressorInputStream(inputStream, NoPool.INSTANCE)) {
final byte[] b = new byte[97];
IOUtils.read(expected, b);
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
int readByte = -1;
- while((readByte = zstdInputStream.read()) != -1) {
+ while ((readByte = zstdInputStream.read()) != -1) {
bos.write(readByte);
}
assertArrayEquals(b, bos.toByteArray());
@@ -183,12 +174,12 @@ public class ZstdCompressorInputStreamTest extends
AbstractTestCase {
final File input = getFile("zstandard.testdata.zst");
final File expected = getFile("zstandard.testdata");
try (InputStream inputStream = Files.newInputStream(input.toPath());
- ZstdCompressorInputStream zstdInputStream = new
ZstdCompressorInputStream(inputStream, RecyclingBufferPool.INSTANCE)) {
+ ZstdCompressorInputStream zstdInputStream = new
ZstdCompressorInputStream(inputStream, RecyclingBufferPool.INSTANCE)) {
final byte[] b = new byte[97];
IOUtils.read(expected, b);
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
int readByte = -1;
- while((readByte = zstdInputStream.read()) != -1) {
+ while ((readByte = zstdInputStream.read()) != -1) {
bos.write(readByte);
}
assertArrayEquals(b, bos.toByteArray());
diff --git
a/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java
b/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java
index 2f60b54a..25423c79 100644
---
a/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java
+++
b/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java
@@ -31,9 +31,8 @@ import org.junit.jupiter.api.Test;
/**
* Unit tests for class {@link ChecksumCalculatingInputStream
org.apache.commons.compress.utils.ChecksumCalculatingInputStream}.
*
- * @date 13.06.2017
* @see ChecksumCalculatingInputStream
- **/
+ */
public class ChecksumCalculatingInputStreamTest {
@Test
diff --git
a/src/test/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStreamTest.java
b/src/test/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStreamTest.java
index ff0a5ef1..f09fa135 100644
---
a/src/test/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStreamTest.java
+++
b/src/test/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStreamTest.java
@@ -30,9 +30,8 @@ import org.junit.jupiter.api.Test;
/**
* Unit tests for class {@link ChecksumVerifyingInputStream
org.apache.commons.compress.utils.ChecksumVerifyingInputStream}.
*
- * @date 13.06.2017
* @see ChecksumVerifyingInputStream
- **/
+ */
public class ChecksumVerifyingInputStreamTest {
@Test
diff --git
a/src/test/java/org/apache/commons/compress/utils/ServiceLoaderIteratorTest.java
b/src/test/java/org/apache/commons/compress/utils/ServiceLoaderIteratorTest.java
index 10393099..9478be73 100644
---
a/src/test/java/org/apache/commons/compress/utils/ServiceLoaderIteratorTest.java
+++
b/src/test/java/org/apache/commons/compress/utils/ServiceLoaderIteratorTest.java
@@ -28,9 +28,8 @@ import org.junit.jupiter.api.Test;
/**
* Unit tests for class {@link ServiceLoaderIterator
org.apache.commons.compress.utils.ServiceLoaderIterator}.
*
- * @date 13.06.2017
* @see ServiceLoaderIterator
- **/
+ */
public class ServiceLoaderIteratorTest {
@Test