This is an automated email from the ASF dual-hosted git repository. ebourg pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-compress.git
commit 9bb5a8dbd1965bf97c217fca91984ebaae84b83b Author: Emmanuel Bourg <ebo...@apache.org> AuthorDate: Mon Jul 19 14:54:21 2021 +0200 Remove unnecessary throws clauses --- .../apache/commons/compress/archivers/Lister.java | 6 ++-- .../archivers/sevenz/AES256SHA256Decoder.java | 2 +- .../commons/compress/harmony/pack200/Archive.java | 7 ++--- .../harmony/unpack200/AttributeLayoutMap.java | 2 +- .../compress/harmony/unpack200/SegmentHeader.java | 2 +- .../compress/archivers/examples/ExpanderTest.java | 2 +- .../archivers/examples/SevenZArchiverTest.java | 2 +- .../archivers/sevenz/AES256SHA256DecoderTest.java | 3 +- .../archivers/sevenz/SevenZOutputFileTest.java | 2 +- .../archivers/tar/TarArchiveInputStreamTest.java | 4 +-- .../compress/archivers/tar/TarFileTest.java | 7 ++--- .../compress/archivers/tar/TarUtilsTest.java | 12 ++++---- .../compress/archivers/zip/CircularBufferTest.java | 4 +-- .../compress/archivers/zip/DataDescriptorTest.java | 2 +- .../archivers/zip/ExtraFieldUtilsTest.java | 8 ++---- .../zip/ParallelScatterZipCreatorTest.java | 4 +-- .../compress/archivers/zip/ZipEncodingTest.java | 4 +-- .../zip/ZipFileIgnoringLocalFileHeaderTest.java | 2 +- .../compress/archivers/zip/ZipFileTest.java | 6 ++-- .../compress/archivers/zip/ZipUtilTest.java | 2 +- .../commons/compress/compressors/ZTestCase.java | 2 +- .../lz4/FramedLZ4CompressorInputStreamTest.java | 32 +++++++++++----------- .../lz77support/LZ77CompressorTest.java | 3 +- .../harmony/pack200/tests/ArchiveTest.java | 6 ++-- .../compress/harmony/pack200/tests/CodecTest.java | 2 +- .../harmony/pack200/tests/PackingOptionsTest.java | 3 +- .../unpack200/tests/SegmentConstantPoolTest.java | 4 +-- .../commons/compress/utils/ByteUtilsTest.java | 4 +-- .../MultiReadOnlySeekableByteChannelTest.java | 14 +++++----- .../utils/SeekableInMemoryByteChannelTest.java | 4 +-- 30 files changed, 74 insertions(+), 83 deletions(-) diff --git a/src/main/java/org/apache/commons/compress/archivers/Lister.java b/src/main/java/org/apache/commons/compress/archivers/Lister.java index 78627cf..dd70d64 100644 --- a/src/main/java/org/apache/commons/compress/archivers/Lister.java +++ b/src/main/java/org/apache/commons/compress/archivers/Lister.java @@ -89,7 +89,7 @@ public final class Lister { } } - private static void list7z(final File f) throws ArchiveException, IOException { + private static void list7z(final File f) throws IOException { try (SevenZFile z = new SevenZFile(f)) { System.out.println("Created " + z); ArchiveEntry ae; @@ -101,7 +101,7 @@ public final class Lister { } } - private static void listZipUsingZipFile(final File f) throws ArchiveException, IOException { + private static void listZipUsingZipFile(final File f) throws IOException { try (ZipFile z = new ZipFile(f)) { System.out.println("Created " + z); for (final Enumeration<ZipArchiveEntry> en = z.getEntries(); en.hasMoreElements(); ) { @@ -110,7 +110,7 @@ public final class Lister { } } - private static void listZipUsingTarFile(final File f) throws ArchiveException, IOException { + private static void listZipUsingTarFile(final File f) throws IOException { try (TarFile t = new TarFile(f)) { System.out.println("Created " + t); for (TarArchiveEntry en : t.getEntries()) { diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/AES256SHA256Decoder.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/AES256SHA256Decoder.java index 3cac16b..e6bb12c 100644 --- a/src/main/java/org/apache/commons/compress/archivers/sevenz/AES256SHA256Decoder.java +++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/AES256SHA256Decoder.java @@ -32,7 +32,7 @@ import org.apache.commons.compress.PasswordRequiredException; class AES256SHA256Decoder extends CoderBase { @Override InputStream decode(final String archiveName, final InputStream in, final long uncompressedLength, - final Coder coder, final byte[] passwordBytes, final int maxMemoryLimitInKb) throws IOException { + final Coder coder, final byte[] passwordBytes, final int maxMemoryLimitInKb) { return new InputStream() { private boolean isInitialized; private CipherInputStream cipherInputStream; diff --git a/src/main/java/org/apache/commons/compress/harmony/pack200/Archive.java b/src/main/java/org/apache/commons/compress/harmony/pack200/Archive.java index fca897c..0bd969b 100644 --- a/src/main/java/org/apache/commons/compress/harmony/pack200/Archive.java +++ b/src/main/java/org/apache/commons/compress/harmony/pack200/Archive.java @@ -100,7 +100,7 @@ public class Archive { } } - private void doZeroEffortPack() throws IOException, Pack200Exception { + private void doZeroEffortPack() throws IOException { PackingUtils.log("Start to perform a zero-effort packing"); if (jarInputStream != null) { PackingUtils.copyThroughJar(jarInputStream, outputStream); @@ -137,7 +137,7 @@ public class Archive { outputStream.close(); } - private List splitIntoSegments(final List packingFileList) throws IOException, Pack200Exception { + private List splitIntoSegments(final List packingFileList) { final List segmentUnitList = new ArrayList(); List classes = new ArrayList(); List files = new ArrayList(); @@ -172,8 +172,7 @@ public class Archive { return segmentUnitList; } - private boolean addJarEntry(final PackingFile packingFile, final List javaClasses, final List files) - throws IOException, Pack200Exception { + private boolean addJarEntry(final PackingFile packingFile, final List javaClasses, final List files) { final long segmentLimit = options.getSegmentLimit(); if (segmentLimit != -1 && segmentLimit != 0) { // -1 is a special case where only one segment is created and diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/AttributeLayoutMap.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/AttributeLayoutMap.java index afa7dd3..8f6d03c 100644 --- a/src/main/java/org/apache/commons/compress/harmony/unpack200/AttributeLayoutMap.java +++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/AttributeLayoutMap.java @@ -160,7 +160,7 @@ public class AttributeLayoutMap { return null; } - public AttributeLayout getAttributeLayout(final int index, final int context) throws Pack200Exception { + public AttributeLayout getAttributeLayout(final int index, final int context) { final Map map = layouts[context]; return (AttributeLayout) map.get(Integer.valueOf(index)); } diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/SegmentHeader.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/SegmentHeader.java index e1b0363..858bbeb 100644 --- a/src/main/java/org/apache/commons/compress/harmony/unpack200/SegmentHeader.java +++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/SegmentHeader.java @@ -99,7 +99,7 @@ public class SegmentHeader { private int archiveSizeOffset; - public void read(final InputStream in) throws IOException, Pack200Exception, Error, Pack200Exception { + public void read(final InputStream in) throws IOException, Error, Pack200Exception { final int word[] = decodeScalar("archive_magic_word", in, Codec.BYTE1, magic.length); for (int m = 0; m < magic.length; m++) { diff --git a/src/test/java/org/apache/commons/compress/archivers/examples/ExpanderTest.java b/src/test/java/org/apache/commons/compress/archivers/examples/ExpanderTest.java index 1a9cf30..3091f64 100644 --- a/src/test/java/org/apache/commons/compress/archivers/examples/ExpanderTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/examples/ExpanderTest.java @@ -157,7 +157,7 @@ public class ExpanderTest extends AbstractTestCase { verifyTargetDir(); } - private void setup7z() throws IOException, ArchiveException { + private void setup7z() throws IOException { archive = new File(dir, "test.7z"); final File dummy = new File(dir, "x"); try (OutputStream o = Files.newOutputStream(dummy.toPath())) { diff --git a/src/test/java/org/apache/commons/compress/archivers/examples/SevenZArchiverTest.java b/src/test/java/org/apache/commons/compress/archivers/examples/SevenZArchiverTest.java index 5a61914..97b00d6 100644 --- a/src/test/java/org/apache/commons/compress/archivers/examples/SevenZArchiverTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/examples/SevenZArchiverTest.java @@ -85,7 +85,7 @@ public class SevenZArchiverTest extends AbstractTestCase { } } - private void verifyContent() throws IOException, ArchiveException { + private void verifyContent() throws IOException { try (SevenZFile z = new SevenZFile(target)) { assertDir("a", z.getNextEntry()); assertDir("a/b", z.getNextEntry()); 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 2037d7e..bbcf692 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 @@ -21,7 +21,6 @@ package org.apache.commons.compress.archivers.sevenz; import org.junit.Test; import java.io.BufferedInputStream; -import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; @@ -39,7 +38,7 @@ public class AES256SHA256DecoderTest { @Test - public void testDecodeWithNonEmptyString() throws IOException { + public void testDecodeWithNonEmptyString() { final AES256SHA256Decoder aES256SHA256Decoder = new AES256SHA256Decoder(); final BufferedInputStream bufferedInputStream = new BufferedInputStream(null, 3138); diff --git a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFileTest.java b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFileTest.java index 43237ad..ea8c749 100644 --- a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFileTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFileTest.java @@ -261,7 +261,7 @@ public class SevenZOutputFileTest extends AbstractTestCase { } @Test - public void testCantFinishTwice() throws Exception { + public void testCantFinishTwice() { output = new File(dir, "finish.7z"); try (SevenZOutputFile outArchive = new SevenZOutputFile(output)) { outArchive.finish(); diff --git a/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java b/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java index a49ade9..eab8e84 100644 --- a/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java @@ -85,7 +85,7 @@ public class TarArchiveInputStreamTest extends AbstractTestCase { } @Test - public void testCompress197() throws Exception { + public void testCompress197() { try (TarArchiveInputStream tar = getTestStream("/COMPRESS-197.tar")) { TarArchiveEntry entry = tar.getNextTarEntry(); while (entry != null) { @@ -143,7 +143,7 @@ public class TarArchiveInputStreamTest extends AbstractTestCase { } @Test - public void readsArchiveCompletely_COMPRESS245() throws Exception { + public void readsArchiveCompletely_COMPRESS245() { try (InputStream is = TarArchiveInputStreamTest.class .getResourceAsStream("/COMPRESS-245.tar.gz")) { final InputStream gin = new GZIPInputStream(is); diff --git a/src/test/java/org/apache/commons/compress/archivers/tar/TarFileTest.java b/src/test/java/org/apache/commons/compress/archivers/tar/TarFileTest.java index 1aa241a..e5a9c4f 100644 --- a/src/test/java/org/apache/commons/compress/archivers/tar/TarFileTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/tar/TarFileTest.java @@ -34,7 +34,6 @@ import java.util.TimeZone; import java.util.zip.GZIPInputStream; import org.apache.commons.compress.AbstractTestCase; -import org.apache.commons.compress.archivers.ArchiveException; import org.apache.commons.compress.utils.CharsetNames; import org.apache.commons.compress.utils.IOUtils; import org.junit.Test; @@ -81,7 +80,7 @@ public class TarFileTest extends AbstractTestCase { } @Test - public void testCompress197() throws Exception { + public void testCompress197() { try (final TarFile tarFile = new TarFile(getPath("COMPRESS-197.tar"))) { } catch (final IOException e) { fail("COMPRESS-197: " + e.getMessage()); @@ -127,7 +126,7 @@ public class TarFileTest extends AbstractTestCase { } @Test - public void readsArchiveCompletely_COMPRESS245() throws Exception { + public void readsArchiveCompletely_COMPRESS245() { try { final Path tempTar = resultDir.toPath().resolve("COMPRESS-245.tar"); try (final GZIPInputStream gin = new GZIPInputStream( @@ -249,7 +248,7 @@ public class TarFileTest extends AbstractTestCase { } @Test - public void testDirectoryWithLongNameEndsWithSlash() throws IOException, ArchiveException { + public void testDirectoryWithLongNameEndsWithSlash() throws IOException { final String rootPath = dir.getAbsolutePath(); final String dirDirectory = "COMPRESS-509"; final int count = 100; diff --git a/src/test/java/org/apache/commons/compress/archivers/tar/TarUtilsTest.java b/src/test/java/org/apache/commons/compress/archivers/tar/TarUtilsTest.java index adb2408..e820c06 100644 --- a/src/test/java/org/apache/commons/compress/archivers/tar/TarUtilsTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/tar/TarUtilsTest.java @@ -71,7 +71,7 @@ public class TarUtilsTest { } @Test - public void testParseOctal() throws Exception{ + public void testParseOctal() { long value; byte [] buffer; final long MAX_OCTAL = 077777777777L; // Allowed 11 digits @@ -98,7 +98,7 @@ public class TarUtilsTest { } @Test - public void testParseOctalInvalid() throws Exception{ + public void testParseOctalInvalid() { byte [] buffer; buffer=ByteUtils.EMPTY_BYTE_ARRAY; try { @@ -204,14 +204,14 @@ public class TarUtilsTest { } @Test - public void testNegative() throws Exception { + public void testNegative() { final byte [] buffer = new byte[22]; TarUtils.formatUnsignedOctalString(-1, buffer, 0, buffer.length); assertEquals("1777777777777777777777", new String(buffer, StandardCharsets.UTF_8)); } @Test - public void testOverflow() throws Exception { + public void testOverflow() { final byte [] buffer = new byte[8-1]; // a lot of the numbers have 8-byte buffers (nul term) TarUtils.formatUnsignedOctalString(07777777L, buffer, 0, buffer.length); assertEquals("7777777", new String(buffer, StandardCharsets.UTF_8)); @@ -382,7 +382,7 @@ public class TarUtilsTest { } @Test - public void testParseOctalCompress330() throws Exception{ + public void testParseOctalCompress330() { final long expected = 0100000; final byte [] buffer = new byte[] { 32, 32, 32, 32, 32, 49, 48, 48, 48, 48, 48, 32 @@ -665,7 +665,7 @@ public class TarUtilsTest { } @Test - public void parsePAX01SparseHeadersRejectsOddNumberOfEntries() throws Exception { + public void parsePAX01SparseHeadersRejectsOddNumberOfEntries() { thrown.expect(RuntimeException.class); thrown.expectMessage(startsWith("Corrupted TAR archive")); final String map = "0,10,20,0,20"; diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/CircularBufferTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/CircularBufferTest.java index 5feff81..dbbdb66 100644 --- a/src/test/java/org/apache/commons/compress/archivers/zip/CircularBufferTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/zip/CircularBufferTest.java @@ -28,7 +28,7 @@ import org.junit.Test; public class CircularBufferTest { @Test - public void testPutAndGet() throws Exception { + public void testPutAndGet() { final int size = 16; final CircularBuffer buffer = new CircularBuffer(size); for (int i = 0; i < size / 2; i++) { @@ -46,7 +46,7 @@ public class CircularBufferTest { } @Test - public void testCopy() throws Exception { + public void testCopy() { final CircularBuffer buffer = new CircularBuffer(16); buffer.put(1); diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/DataDescriptorTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/DataDescriptorTest.java index f0310a5..d54de45 100644 --- a/src/test/java/org/apache/commons/compress/archivers/zip/DataDescriptorTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/zip/DataDescriptorTest.java @@ -47,7 +47,7 @@ public class DataDescriptorTest { } @After - public void tearDown() throws Exception { + public void tearDown() { rmdir(dir); } diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtilsTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtilsTest.java index ef6ceae..1b13436 100644 --- a/src/test/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtilsTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtilsTest.java @@ -105,7 +105,7 @@ public class ExtraFieldUtilsTest implements UnixStat { } @Test - public void parseTurnsArrayIndexOutOfBoundsIntoZipException() throws Exception { + public void parseTurnsArrayIndexOutOfBoundsIntoZipException() { ExtraFieldUtils.register(AiobThrowingExtraField.class); final AiobThrowingExtraField f = new AiobThrowingExtraField(); final byte[] d = new byte[4 + AiobThrowingExtraField.LENGTH]; @@ -274,14 +274,12 @@ public class ExtraFieldUtilsTest implements UnixStat { } @Override - public void parseFromLocalFileData(final byte[] buffer, final int offset, final int length) - throws ZipException { + public void parseFromLocalFileData(final byte[] buffer, final int offset, final int length) { throw new ArrayIndexOutOfBoundsException(); } @Override - public void parseFromCentralDirectoryData(final byte[] buffer, final int offset, final int length) - throws ZipException { + public void parseFromCentralDirectoryData(final byte[] buffer, final int offset, final int length) { parseFromLocalFileData(buffer, offset, length); } } diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreatorTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreatorTest.java index 588f5fc..b306294 100644 --- a/src/test/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreatorTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreatorTest.java @@ -89,7 +89,7 @@ public class ParallelScatterZipCreatorTest { } @Test(expected = IllegalArgumentException.class) - public void throwsExceptionWithCompressionLevelTooBig() throws Exception { + public void throwsExceptionWithCompressionLevelTooBig() { final int compressLevelTooBig = Deflater.BEST_COMPRESSION + 1; final ExecutorService es = Executors.newFixedThreadPool(1); final ScatterGatherBackingStoreSupplier supp = () -> new FileBasedScatterGatherBackingStore(tmp = File.createTempFile("parallelscatter", "n1")); @@ -98,7 +98,7 @@ public class ParallelScatterZipCreatorTest { } @Test(expected = IllegalArgumentException.class) - public void throwsExceptionWithCompressionLevelTooSmall() throws Exception { + public void throwsExceptionWithCompressionLevelTooSmall() { final int compressLevelTooSmall = Deflater.DEFAULT_COMPRESSION - 1; final ExecutorService es = Executors.newFixedThreadPool(1); final ScatterGatherBackingStoreSupplier supp = () -> new FileBasedScatterGatherBackingStore(tmp = File.createTempFile("parallelscatter", "n1")); diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ZipEncodingTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ZipEncodingTest.java index 7ed9544..483a984 100644 --- a/src/test/java/org/apache/commons/compress/archivers/zip/ZipEncodingTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/zip/ZipEncodingTest.java @@ -53,7 +53,7 @@ public class ZipEncodingTest { } @Test - public void testGetNonexistentEncoding() throws IOException { + public void testGetNonexistentEncoding() { final ZipEncoding ze = ZipEncodingHelper.getZipEncoding("I-am-a-banana"); assertNotNull(ze); if (ze instanceof CharsetAccessor) { @@ -63,7 +63,7 @@ public class ZipEncodingTest { } @Test - public void testIsUTF8() throws IOException { + public void testIsUTF8() { assertTrue(ZipEncodingHelper.isUTF8("UTF-8")); assertTrue(ZipEncodingHelper.isUTF8("UTF8")); Assert.assertEquals(Charset.defaultCharset().name().equals("UTF-8"), ZipEncodingHelper.isUTF8(null)); diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileIgnoringLocalFileHeaderTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileIgnoringLocalFileHeaderTest.java index a043e8f..1f69d20 100644 --- a/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileIgnoringLocalFileHeaderTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileIgnoringLocalFileHeaderTest.java @@ -42,7 +42,7 @@ public class ZipFileIgnoringLocalFileHeaderTest { } @After - public void tearDown() throws Exception { + public void tearDown() { AbstractTestCase.rmdir(dir); } diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java index f38caa4..8370c16 100644 --- a/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java @@ -593,7 +593,7 @@ public class ZipFileTest { * Test non power of 2 alignment. */ @Test(expected = IllegalArgumentException.class) - public void testInvalidAlignment() throws Exception { + public void testInvalidAlignment() { final ZipArchiveEntry entry = new ZipArchiveEntry("dummy"); entry.setAlignment(3); } @@ -751,13 +751,13 @@ public class ZipFileTest { } @Test(expected = IllegalArgumentException.class) - public void testSetLevelTooSmallForZipArchiveOutputStream() throws Exception { + public void testSetLevelTooSmallForZipArchiveOutputStream() { final ZipArchiveOutputStream outputStream = new ZipArchiveOutputStream(new ByteArrayOutputStream()); outputStream.setLevel(Deflater.DEFAULT_COMPRESSION - 1); } @Test(expected = IllegalArgumentException.class) - public void testSetLevelTooBigForZipArchiveOutputStream() throws Exception { + public void testSetLevelTooBigForZipArchiveOutputStream() { final ZipArchiveOutputStream outputStream = new ZipArchiveOutputStream(new ByteArrayOutputStream()); outputStream.setLevel(Deflater.BEST_COMPRESSION + 1); } diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ZipUtilTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ZipUtilTest.java index 14e6a4d..5466279 100644 --- a/src/test/java/org/apache/commons/compress/archivers/zip/ZipUtilTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/zip/ZipUtilTest.java @@ -59,7 +59,7 @@ public class ZipUtilTest { } @Test - public void testZipLong() throws Exception { + public void testZipLong() { final ZipLong test = ZipUtil.toDosTime(time); assertEquals(test.getValue(), zl.getValue()); } diff --git a/src/test/java/org/apache/commons/compress/compressors/ZTestCase.java b/src/test/java/org/apache/commons/compress/compressors/ZTestCase.java index 0a51cab..9e074e6 100644 --- a/src/test/java/org/apache/commons/compress/compressors/ZTestCase.java +++ b/src/test/java/org/apache/commons/compress/compressors/ZTestCase.java @@ -52,7 +52,7 @@ public final class ZTestCase extends AbstractTestCase { } @Test - public void testMatches() throws Exception { + public void testMatches() { assertFalse(ZCompressorInputStream.matches(new byte[] { 1, 2, 3, 4 }, 4)); assertFalse(ZCompressorInputStream.matches(new byte[] { 0x1f, 2, 3, 4 }, 4)); assertFalse(ZCompressorInputStream.matches(new byte[] { 1, (byte)0x9d, 3, 4 }, 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 ad0931b..951293b 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 @@ -164,7 +164,7 @@ public final class FramedLZ4CompressorInputStreamTest } @Test - public void rejectsFileWithoutFrameDescriptor() throws IOException { + public void rejectsFileWithoutFrameDescriptor() { final byte[] input = new byte[] { 4, 0x22, 0x4d, 0x18 // signature }; @@ -178,7 +178,7 @@ public final class FramedLZ4CompressorInputStreamTest } @Test - public void rejectsFileWithoutBlockSizeByte() throws IOException { + public void rejectsFileWithoutBlockSizeByte() { final byte[] input = new byte[] { 4, 0x22, 0x4d, 0x18, // signature 0x64, // flag - Version 01, block independent, no block checksum, no content size, with content checksum @@ -193,7 +193,7 @@ public final class FramedLZ4CompressorInputStreamTest } @Test - public void rejectsFileWithWrongVersion() throws IOException { + public void rejectsFileWithWrongVersion() { final byte[] input = new byte[] { 4, 0x22, 0x4d, 0x18, // signature 0x24, // flag - Version 00, block independent, no block checksum, no content size, with content checksum @@ -208,7 +208,7 @@ public final class FramedLZ4CompressorInputStreamTest } @Test - public void rejectsFileWithInsufficientContentSize() throws IOException { + public void rejectsFileWithInsufficientContentSize() { final byte[] input = new byte[] { 4, 0x22, 0x4d, 0x18, // signature 0x6C, // flag - Version 01, block independent, no block checksum, with content size, with content checksum @@ -224,7 +224,7 @@ public final class FramedLZ4CompressorInputStreamTest } @Test - public void rejectsFileWithoutHeaderChecksum() throws IOException { + public void rejectsFileWithoutHeaderChecksum() { final byte[] input = new byte[] { 4, 0x22, 0x4d, 0x18, // signature 0x64, // flag - Version 01, block independent, no block checksum, no content size, with content checksum @@ -240,7 +240,7 @@ public final class FramedLZ4CompressorInputStreamTest } @Test - public void rejectsFileWithBadHeaderChecksum() throws IOException { + public void rejectsFileWithBadHeaderChecksum() { final byte[] input = new byte[] { 4, 0x22, 0x4d, 0x18, // signature 0x64, // flag - Version 01, block independent, no block checksum, no content size, with content checksum @@ -293,7 +293,7 @@ public final class FramedLZ4CompressorInputStreamTest } @Test - public void rejectsBlocksWithoutChecksum() throws IOException { + public void rejectsBlocksWithoutChecksum() { final byte[] input = new byte[] { 4, 0x22, 0x4d, 0x18, // signature 0x70, // flag - Version 01, block independent, with block checksum, no content size, no content checksum @@ -313,7 +313,7 @@ public final class FramedLZ4CompressorInputStreamTest } @Test - public void rejectsStreamsWithoutContentChecksum() throws IOException { + public void rejectsStreamsWithoutContentChecksum() { final byte[] input = new byte[] { 4, 0x22, 0x4d, 0x18, // signature 0x64, // flag - Version 01, block independent, no block checksum, no content size, with content checksum @@ -334,7 +334,7 @@ public final class FramedLZ4CompressorInputStreamTest } @Test - public void rejectsStreamsWithBadContentChecksum() throws IOException { + public void rejectsStreamsWithBadContentChecksum() { final byte[] input = new byte[] { 4, 0x22, 0x4d, 0x18, // signature 0x64, // flag - Version 01, block independent, no block checksum, no content size, with content checksum @@ -407,7 +407,7 @@ public final class FramedLZ4CompressorInputStreamTest } @Test - public void rejectsSkippableFrameFollowedByJunk() throws IOException { + public void rejectsSkippableFrameFollowedByJunk() { final byte[] input = new byte[] { 4, 0x22, 0x4d, 0x18, // signature 0x60, // flag - Version 01, block independent, no block checksum, no content size, no content checksum @@ -432,7 +432,7 @@ public final class FramedLZ4CompressorInputStreamTest } @Test - public void rejectsSkippableFrameFollowedByTooFewBytes() throws IOException { + public void rejectsSkippableFrameFollowedByTooFewBytes() { final byte[] input = new byte[] { 4, 0x22, 0x4d, 0x18, // signature 0x60, // flag - Version 01, block independent, no block checksum, no content size, no content checksum @@ -457,7 +457,7 @@ public final class FramedLZ4CompressorInputStreamTest } @Test - public void rejectsSkippableFrameWithPrematureEnd() throws IOException { + public void rejectsSkippableFrameWithPrematureEnd() { final byte[] input = new byte[] { 4, 0x22, 0x4d, 0x18, // signature 0x60, // flag - Version 01, block independent, no block checksum, no content size, no content checksum @@ -481,7 +481,7 @@ public final class FramedLZ4CompressorInputStreamTest } @Test - public void rejectsSkippableFrameWithPrematureEndInLengthBytes() throws IOException { + public void rejectsSkippableFrameWithPrematureEndInLengthBytes() { final byte[] input = new byte[] { 4, 0x22, 0x4d, 0x18, // signature 0x60, // flag - Version 01, block independent, no block checksum, no content size, no content checksum @@ -504,7 +504,7 @@ public final class FramedLZ4CompressorInputStreamTest } @Test - public void rejectsSkippableFrameWithBadSignatureTrailer() throws IOException { + public void rejectsSkippableFrameWithBadSignatureTrailer() { final byte[] input = new byte[] { 4, 0x22, 0x4d, 0x18, // signature 0x60, // flag - Version 01, block independent, no block checksum, no content size, no content checksum @@ -526,7 +526,7 @@ public final class FramedLZ4CompressorInputStreamTest } @Test - public void rejectsSkippableFrameWithBadSignaturePrefix() throws IOException { + public void rejectsSkippableFrameWithBadSignaturePrefix() { final byte[] input = new byte[] { 4, 0x22, 0x4d, 0x18, // signature 0x60, // flag - Version 01, block independent, no block checksum, no content size, no content checksum @@ -548,7 +548,7 @@ public final class FramedLZ4CompressorInputStreamTest } @Test - public void rejectsTrailingBytesAfterValidFrame() throws IOException { + public void rejectsTrailingBytesAfterValidFrame() { final byte[] input = new byte[] { 4, 0x22, 0x4d, 0x18, // signature 0x60, // flag - Version 01, block independent, no block checksum, no content size, no content checksum diff --git a/src/test/java/org/apache/commons/compress/compressors/lz77support/LZ77CompressorTest.java b/src/test/java/org/apache/commons/compress/compressors/lz77support/LZ77CompressorTest.java index 6691b82..2e4f3f7 100644 --- a/src/test/java/org/apache/commons/compress/compressors/lz77support/LZ77CompressorTest.java +++ b/src/test/java/org/apache/commons/compress/compressors/lz77support/LZ77CompressorTest.java @@ -289,8 +289,7 @@ public class LZ77CompressorTest { assertEquals(LZ77Compressor.Block.BlockType.EOD, blocks.get(expectedSize - 1).getType()); } - private static final void assertLiteralBlock(final String expectedContent, final LZ77Compressor.Block block) - throws IOException { + private static final void assertLiteralBlock(final String expectedContent, final LZ77Compressor.Block block) { assertLiteralBlock(expectedContent.getBytes(StandardCharsets.US_ASCII), block); } diff --git a/src/test/java/org/apache/commons/compress/harmony/pack200/tests/ArchiveTest.java b/src/test/java/org/apache/commons/compress/harmony/pack200/tests/ArchiveTest.java index e296735..6238e29 100644 --- a/src/test/java/org/apache/commons/compress/harmony/pack200/tests/ArchiveTest.java +++ b/src/test/java/org/apache/commons/compress/harmony/pack200/tests/ArchiveTest.java @@ -127,8 +127,7 @@ public class ArchiveTest extends TestCase { compareFiles(jarFile, jarFile2); } - public void testAlternativeConstructor() throws FileNotFoundException, - IOException, URISyntaxException, Pack200Exception { + public void testAlternativeConstructor() throws IOException, URISyntaxException, Pack200Exception { JarInputStream inStream = new JarInputStream(new FileInputStream( new File(Archive.class.getResource( "/pack200/sqlUnpacked.jar").toURI()))); @@ -298,8 +297,7 @@ public class ArchiveTest extends TestCase { } } - private void compareJarEntries(JarFile jarFile, JarFile jarFile2) - throws IOException { + private void compareJarEntries(JarFile jarFile, JarFile jarFile2) { Enumeration entries = jarFile.entries(); while (entries.hasMoreElements()) { diff --git a/src/test/java/org/apache/commons/compress/harmony/pack200/tests/CodecTest.java b/src/test/java/org/apache/commons/compress/harmony/pack200/tests/CodecTest.java index f6ca8c4..bf1dcea 100644 --- a/src/test/java/org/apache/commons/compress/harmony/pack200/tests/CodecTest.java +++ b/src/test/java/org/apache/commons/compress/harmony/pack200/tests/CodecTest.java @@ -107,7 +107,7 @@ public class CodecTest extends TestCase { decode(BYTE1S2, new byte[] { 11 }, -3, 0); } - public void testCardinality() throws Exception { + public void testCardinality() { BHSDCodec byte1 = Codec.BYTE1; assertEquals(256, byte1.cardinality()); assertEquals(0, byte1.smallest()); diff --git a/src/test/java/org/apache/commons/compress/harmony/pack200/tests/PackingOptionsTest.java b/src/test/java/org/apache/commons/compress/harmony/pack200/tests/PackingOptionsTest.java index 6c367f5..b29b68b 100644 --- a/src/test/java/org/apache/commons/compress/harmony/pack200/tests/PackingOptionsTest.java +++ b/src/test/java/org/apache/commons/compress/harmony/pack200/tests/PackingOptionsTest.java @@ -637,8 +637,7 @@ public class PackingOptionsTest extends TestCase { // compareFiles(in, new JarFile(file)); // } - private void compareJarEntries(JarFile jarFile, JarFile jarFile2) - throws IOException { + private void compareJarEntries(JarFile jarFile, JarFile jarFile2) { Enumeration entries = jarFile.entries(); while (entries.hasMoreElements()) { diff --git a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/SegmentConstantPoolTest.java b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/SegmentConstantPoolTest.java index 24bbb67..aa2cfe4 100644 --- a/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/SegmentConstantPoolTest.java +++ b/src/test/java/org/apache/commons/compress/harmony/unpack200/tests/SegmentConstantPoolTest.java @@ -58,7 +58,7 @@ public class SegmentConstantPoolTest extends TestCase { String[] testMethodArray = { "<init>()", "clone()", "equals()", "<init>", "isNull()", "Other" }; - public void testMatchSpecificPoolEntryIndex_SingleArray() throws Exception { + public void testMatchSpecificPoolEntryIndex_SingleArray() { MockSegmentConstantPool mockInstance = new MockSegmentConstantPool(); // Elements should be found at the proper position. assertEquals(0, mockInstance.matchSpecificPoolEntryIndex( @@ -84,7 +84,7 @@ public class SegmentConstantPoolTest extends TestCase { testClassArray, "java/lang/String", 2)); } - public void testMatchSpecificPoolEntryIndex_DoubleArray() throws Exception { + public void testMatchSpecificPoolEntryIndex_DoubleArray() { MockSegmentConstantPool mockInstance = new MockSegmentConstantPool(); // Elements should be found at the proper position. assertEquals(0, mockInstance.matchSpecificPoolEntryIndex( diff --git a/src/test/java/org/apache/commons/compress/utils/ByteUtilsTest.java b/src/test/java/org/apache/commons/compress/utils/ByteUtilsTest.java index 45b52d3..5c053da 100644 --- a/src/test/java/org/apache/commons/compress/utils/ByteUtilsTest.java +++ b/src/test/java/org/apache/commons/compress/utils/ByteUtilsTest.java @@ -195,14 +195,14 @@ public class ByteUtilsTest { @Test - public void toLittleEndianToByteArray() throws IOException { + public void toLittleEndianToByteArray() { final byte[] b = new byte[4]; toLittleEndian(b, 2 + 3 * 256 + 4 * 256 * 256, 1, 3); assertArrayEquals(new byte[] { 2, 3, 4 }, Arrays.copyOfRange(b, 1, 4)); } @Test - public void toLittleEndianToByteArrayUnsignedInt32() throws IOException { + public void toLittleEndianToByteArrayUnsignedInt32() { final byte[] b = new byte[4]; toLittleEndian(b, 2 + 3 * 256 + 4 * 256 * 256 + 128L * 256 * 256 * 256, 0, 4); assertArrayEquals(new byte[] { 2, 3, 4, (byte) 128 }, b); diff --git a/src/test/java/org/apache/commons/compress/utils/MultiReadOnlySeekableByteChannelTest.java b/src/test/java/org/apache/commons/compress/utils/MultiReadOnlySeekableByteChannelTest.java index a12630e..b50d01d 100644 --- a/src/test/java/org/apache/commons/compress/utils/MultiReadOnlySeekableByteChannelTest.java +++ b/src/test/java/org/apache/commons/compress/utils/MultiReadOnlySeekableByteChannelTest.java @@ -50,7 +50,7 @@ public class MultiReadOnlySeekableByteChannelTest { } @Test - public void forSeekableByteChannelsThrowsOnNullArg() throws IOException { + public void forSeekableByteChannelsThrowsOnNullArg() { thrown.expect(NullPointerException.class); MultiReadOnlySeekableByteChannel.forSeekableByteChannels(null); } @@ -62,7 +62,7 @@ public class MultiReadOnlySeekableByteChannelTest { } @Test - public void forSeekableByteChannelsReturnsIdentityForSingleElement() throws IOException { + public void forSeekableByteChannelsReturnsIdentityForSingleElement() { final SeekableByteChannel e = makeEmpty(); final SeekableByteChannel m = MultiReadOnlySeekableByteChannel.forSeekableByteChannels(e); Assert.assertSame(e, m); @@ -107,7 +107,7 @@ public class MultiReadOnlySeekableByteChannelTest { } @Test - public void closesAllAndThrowsExceptionIfCloseThrows() throws IOException { + public void closesAllAndThrowsExceptionIfCloseThrows() { final SeekableByteChannel[] ts = new ThrowingSeekableByteChannel[] { new ThrowingSeekableByteChannel(), new ThrowingSeekableByteChannel() @@ -151,7 +151,7 @@ public class MultiReadOnlySeekableByteChannelTest { return new SeekableInMemoryByteChannel(arr); } - private SeekableByteChannel makeMulti(final byte[][] arr) throws IOException { + private SeekableByteChannel makeMulti(final byte[][] arr) { final SeekableByteChannel[] s = new SeekableByteChannel[arr.length]; for (int i = 0; i < s.length; i++) { s[i] = makeSingle(arr[i]); @@ -276,11 +276,11 @@ public class MultiReadOnlySeekableByteChannelTest { return 0; } @Override - public long position() throws IOException { + public long position() { return 0; } @Override - public SeekableByteChannel position(final long newPosition) throws IOException { + public SeekableByteChannel position(final long newPosition) { return this; } @Override @@ -288,7 +288,7 @@ public class MultiReadOnlySeekableByteChannelTest { return 0; } @Override - public SeekableByteChannel truncate(final long size) throws IOException { + public SeekableByteChannel truncate(final long size) { return this; } } diff --git a/src/test/java/org/apache/commons/compress/utils/SeekableInMemoryByteChannelTest.java b/src/test/java/org/apache/commons/compress/utils/SeekableInMemoryByteChannelTest.java index 7eee967..e2bcf50 100644 --- a/src/test/java/org/apache/commons/compress/utils/SeekableInMemoryByteChannelTest.java +++ b/src/test/java/org/apache/commons/compress/utils/SeekableInMemoryByteChannelTest.java @@ -145,7 +145,7 @@ public class SeekableInMemoryByteChannelTest { } @Test - public void shouldTruncateContentsProperly() throws IOException { + public void shouldTruncateContentsProperly() { //given final SeekableInMemoryByteChannel c = new SeekableInMemoryByteChannel(testData); //when @@ -194,7 +194,7 @@ public class SeekableInMemoryByteChannelTest { } @Test(expected = IllegalArgumentException.class) - public void shouldThrowExceptionWhenTruncatingToIncorrectSize() throws IOException { + public void shouldThrowExceptionWhenTruncatingToIncorrectSize() { //given final SeekableInMemoryByteChannel c = new SeekableInMemoryByteChannel(); //when