http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/archivers/zip/ZipEightByteIntegerTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ZipEightByteIntegerTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ZipEightByteIntegerTest.java index 8df0edb..e38f819 100644 --- a/src/test/java/org/apache/commons/compress/archivers/zip/ZipEightByteIntegerTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/zip/ZipEightByteIntegerTest.java @@ -35,8 +35,8 @@ public class ZipEightByteIntegerTest { */ @Test public void testLongToBytes() { - ZipEightByteInteger zl = new ZipEightByteInteger(0xAB12345678l); - byte[] result = zl.getBytes(); + final ZipEightByteInteger zl = new ZipEightByteInteger(0xAB12345678l); + final byte[] result = zl.getBytes(); assertEquals("length getBytes", 8, result.length); assertEquals("first byte getBytes", 0x78, result[0]); assertEquals("second byte getBytes", 0x56, result[1]); @@ -53,8 +53,8 @@ public class ZipEightByteIntegerTest { */ @Test public void testLongFromBytes() { - byte[] val = new byte[] {0x78, 0x56, 0x34, 0x12, (byte) 0xAB, 0x00, 0x00, 0x00}; - ZipEightByteInteger zl = new ZipEightByteInteger(val); + final byte[] val = new byte[] {0x78, 0x56, 0x34, 0x12, (byte) 0xAB, 0x00, 0x00, 0x00}; + final ZipEightByteInteger zl = new ZipEightByteInteger(val); assertEquals("longValue from bytes", 0xAB12345678l, zl.getLongValue()); } @@ -63,10 +63,10 @@ public class ZipEightByteIntegerTest { */ @Test public void testBIToBytes() { - ZipEightByteInteger zl = + final ZipEightByteInteger zl = new ZipEightByteInteger(BigInteger.valueOf(Long.MAX_VALUE) .shiftLeft(1)); - byte[] result = zl.getBytes(); + final byte[] result = zl.getBytes(); assertEquals("length getBytes", 8, result.length); assertEquals("first byte getBytes", (byte) 0xFE, result[0]); assertEquals("second byte getBytes", (byte) 0xFF, result[1]); @@ -83,8 +83,8 @@ public class ZipEightByteIntegerTest { */ @Test public void testBIFromBytes() { - byte[] val = new byte[] {(byte) 0xFE, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}; - ZipEightByteInteger zl = new ZipEightByteInteger(val); + final byte[] val = new byte[] {(byte) 0xFE, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}; + final ZipEightByteInteger zl = new ZipEightByteInteger(val); assertEquals("value from bytes", BigInteger.valueOf(Long.MAX_VALUE).shiftLeft(1), zl.getValue()); @@ -95,9 +95,9 @@ public class ZipEightByteIntegerTest { */ @Test public void testEquals() { - ZipEightByteInteger zl = new ZipEightByteInteger(0x12345678); - ZipEightByteInteger zl2 = new ZipEightByteInteger(0x12345678); - ZipEightByteInteger zl3 = new ZipEightByteInteger(0x87654321); + final ZipEightByteInteger zl = new ZipEightByteInteger(0x12345678); + final ZipEightByteInteger zl2 = new ZipEightByteInteger(0x12345678); + final ZipEightByteInteger zl3 = new ZipEightByteInteger(0x87654321); assertTrue("reflexive", zl.equals(zl)); @@ -115,7 +115,7 @@ public class ZipEightByteIntegerTest { */ @Test public void testSign() { - ZipEightByteInteger zl = new ZipEightByteInteger(new byte[] {(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}); + final ZipEightByteInteger zl = new ZipEightByteInteger(new byte[] {(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}); assertEquals(BigInteger.valueOf(Long.MAX_VALUE).shiftLeft(1).setBit(0), zl.getValue()); }
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/archivers/zip/ZipEncodingTest.java ---------------------------------------------------------------------- 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 237adf2..f0c049a 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 @@ -60,7 +60,7 @@ public class ZipEncodingTest { // the defined ones // retrieved by // awk '/^0x/ && NF>2 {print $1;}' CP1252.TXT - byte[] b = + final byte[] b = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, @@ -116,8 +116,8 @@ public class ZipEncodingTest { Assert.assertEquals(expected.length, actual.limit()); - for (byte anExpected : expected) { - byte a = actual.get(); + for (final byte anExpected : expected) { + final byte a = actual.get(); Assert.assertEquals(anExpected, a); } @@ -126,7 +126,7 @@ public class ZipEncodingTest { private void doSimpleEncodingTest(final String name, byte[] testBytes) throws IOException { - ZipEncoding enc = ZipEncodingHelper.getZipEncoding(name); + final ZipEncoding enc = ZipEncodingHelper.getZipEncoding(name); if (testBytes == null) { @@ -136,11 +136,11 @@ public class ZipEncodingTest { } } - String decoded = enc.decode(testBytes); + final String decoded = enc.decode(testBytes); assertTrue(enc.canEncode(decoded)); - ByteBuffer encoded = enc.encode(decoded); + final ByteBuffer encoded = enc.encode(decoded); assertEquals(testBytes, encoded); http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java ---------------------------------------------------------------------- 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 8a35b5d..3876f59 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 @@ -48,7 +48,7 @@ public class ZipFileTest { @Test public void testCDOrder() throws Exception { readOrderTest(); - ArrayList<ZipArchiveEntry> l = Collections.list(zf.getEntries()); + final ArrayList<ZipArchiveEntry> l = Collections.list(zf.getEntries()); assertEntryName(l, 0, "AbstractUnicodeExtraField"); assertEntryName(l, 1, "AsiExtraField"); assertEntryName(l, 2, "ExtraFieldUtils"); @@ -77,7 +77,7 @@ public class ZipFileTest { @Test public void testPhysicalOrder() throws Exception { readOrderTest(); - ArrayList<ZipArchiveEntry> l = Collections.list(zf.getEntriesInPhysicalOrder()); + final ArrayList<ZipArchiveEntry> l = Collections.list(zf.getEntriesInPhysicalOrder()); assertEntryName(l, 0, "AbstractUnicodeExtraField"); assertEntryName(l, 1, "AsiExtraField"); assertEntryName(l, 2, "ExtraFieldUtils"); @@ -109,20 +109,20 @@ public class ZipFileTest { zf.close(); try { zf.close(); - } catch (Exception ex) { + } catch (final Exception ex) { fail("Caught exception of second close"); } } @Test public void testReadingOfStoredEntry() throws Exception { - File f = File.createTempFile("commons-compress-zipfiletest", ".zip"); + final File f = File.createTempFile("commons-compress-zipfiletest", ".zip"); f.deleteOnExit(); OutputStream o = null; InputStream i = null; try { o = new FileOutputStream(f); - ZipArchiveOutputStream zo = new ZipArchiveOutputStream(o); + final ZipArchiveOutputStream zo = new ZipArchiveOutputStream(o); ZipArchiveEntry ze = new ZipArchiveEntry("foo"); ze.setMethod(ZipEntry.STORED); ze.setSize(4); @@ -138,7 +138,7 @@ public class ZipFileTest { ze = zf.getEntry("foo"); assertNotNull(ze); i = zf.getInputStream(ze); - byte[] b = new byte[4]; + final byte[] b = new byte[4]; assertEquals(4, i.read(b)); assertEquals(-1, i.read()); } finally { @@ -157,7 +157,7 @@ public class ZipFileTest { */ @Test public void testWinzipBackSlashWorkaround() throws Exception { - File archive = getFile("test-winzip.zip"); + final File archive = getFile("test-winzip.zip"); zf = new ZipFile(archive); assertNull(zf.getEntry("\u00e4\\\u00fc.txt")); assertNotNull(zf.getEntry("\u00e4/\u00fc.txt")); @@ -170,7 +170,7 @@ public class ZipFileTest { */ @Test public void testSkipsPK00Prefix() throws Exception { - File archive = getFile("COMPRESS-208.zip"); + final File archive = getFile("COMPRESS-208.zip"); zf = new ZipFile(archive); assertNotNull(zf.getEntry("test1.xml")); assertNotNull(zf.getEntry("test2.xml")); @@ -198,16 +198,16 @@ public class ZipFileTest { // I looked into creating a test with hard links, but zip does not appear to // support hard links, so nevermind. - File archive = getFile("COMPRESS-214_unix_symlinks.zip"); + final File archive = getFile("COMPRESS-214_unix_symlinks.zip"); zf = new ZipFile(archive); - Enumeration<ZipArchiveEntry> en = zf.getEntries(); + final Enumeration<ZipArchiveEntry> en = zf.getEntries(); while (en.hasMoreElements()) { - ZipArchiveEntry zae = en.nextElement(); - String link = zf.getUnixSymlink(zae); + final ZipArchiveEntry zae = en.nextElement(); + final String link = zf.getUnixSymlink(zae); if (zae.isUnixSymlink()) { - String name = zae.getName(); - String expected = expectedVals.get(name); + final String name = zae.getName(); + final String expected = expectedVals.get(name); assertEquals(expected, link); } else { // Should be null if it's not a symlink! @@ -221,15 +221,15 @@ public class ZipFileTest { */ @Test public void testDuplicateEntry() throws Exception { - File archive = getFile("COMPRESS-227.zip"); + final File archive = getFile("COMPRESS-227.zip"); zf = new ZipFile(archive); - ZipArchiveEntry ze = zf.getEntry("test1.txt"); + final ZipArchiveEntry ze = zf.getEntry("test1.txt"); assertNotNull(ze); assertNotNull(zf.getInputStream(ze)); int numberOfEntries = 0; - for (ZipArchiveEntry entry : zf.getEntries("test1.txt")) { + for (final ZipArchiveEntry entry : zf.getEntries("test1.txt")) { numberOfEntries++; assertNotNull(zf.getInputStream(entry)); } @@ -241,11 +241,11 @@ public class ZipFileTest { */ @Test public void testExcessDataInZip64ExtraField() throws Exception { - File archive = getFile("COMPRESS-228.zip"); + final File archive = getFile("COMPRESS-228.zip"); zf = new ZipFile(archive); // actually, if we get here, the test already has passed - ZipArchiveEntry ze = zf.getEntry("src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java"); + final ZipArchiveEntry ze = zf.getEntry("src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java"); assertEquals(26101, ze.getSize()); } @@ -277,9 +277,9 @@ public class ZipFileTest { */ @Test public void testReadingOfFirstStoredEntry() throws Exception { - File archive = getFile("COMPRESS-264.zip"); + final File archive = getFile("COMPRESS-264.zip"); zf = new ZipFile(archive); - ZipArchiveEntry ze = zf.getEntry("test.txt"); + final ZipArchiveEntry ze = zf.getEntry("test.txt"); assertEquals(5, ze.getSize()); assertArrayEquals(new byte[] {'d', 'a', 't', 'a', '\n'}, IOUtils.toByteArray(zf.getInputStream(ze))); @@ -287,11 +287,11 @@ public class ZipFileTest { @Test public void testUnzipBZip2CompressedEntry() throws Exception { - File archive = getFile("bzip2-zip.zip"); + final File archive = getFile("bzip2-zip.zip"); zf = new ZipFile(archive); - ZipArchiveEntry ze = zf.getEntry("lots-of-as"); + final ZipArchiveEntry ze = zf.getEntry("lots-of-as"); assertEquals(42, ze.getSize()); - byte[] expected = new byte[42]; + final byte[] expected = new byte[42]; Arrays.fill(expected , (byte)'a'); assertArrayEquals(expected, IOUtils.toByteArray(zf.getInputStream(ze))); } @@ -307,14 +307,14 @@ public class ZipFileTest { * central directory order is different from entry data order. */ private void readOrderTest() throws Exception { - File archive = getFile("ordertest.zip"); + final File archive = getFile("ordertest.zip"); zf = new ZipFile(archive); } private static void assertEntryName(final ArrayList<ZipArchiveEntry> entries, final int index, final String expectedName) { - ZipArchiveEntry ze = entries.get(index); + final ZipArchiveEntry ze = entries.get(index); assertEquals("src/main/java/org/apache/commons/compress/archivers/zip/" + expectedName + ".java", ze.getName()); http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/archivers/zip/ZipLongTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ZipLongTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ZipLongTest.java index 33a1b7b..f72d886 100644 --- a/src/test/java/org/apache/commons/compress/archivers/zip/ZipLongTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/zip/ZipLongTest.java @@ -33,8 +33,8 @@ public class ZipLongTest { */ @Test public void testToBytes() { - ZipLong zl = new ZipLong(0x12345678); - byte[] result = zl.getBytes(); + final ZipLong zl = new ZipLong(0x12345678); + final byte[] result = zl.getBytes(); assertEquals("length getBytes", 4, result.length); assertEquals("first byte getBytes", 0x78, result[0]); assertEquals("second byte getBytes", 0x56, result[1]); @@ -47,7 +47,7 @@ public class ZipLongTest { */ @Test public void testPut() { - byte[] arr = new byte[5]; + final byte[] arr = new byte[5]; ZipLong.putLong(0x12345678, arr, 1); assertEquals("first byte getBytes", 0x78, arr[1]); assertEquals("second byte getBytes", 0x56, arr[2]); @@ -60,8 +60,8 @@ public class ZipLongTest { */ @Test public void testFromBytes() { - byte[] val = new byte[] {0x78, 0x56, 0x34, 0x12}; - ZipLong zl = new ZipLong(val); + final byte[] val = new byte[] {0x78, 0x56, 0x34, 0x12}; + final ZipLong zl = new ZipLong(val); assertEquals("value from bytes", 0x12345678, zl.getValue()); } @@ -70,9 +70,9 @@ public class ZipLongTest { */ @Test public void testEquals() { - ZipLong zl = new ZipLong(0x12345678); - ZipLong zl2 = new ZipLong(0x12345678); - ZipLong zl3 = new ZipLong(0x87654321); + final ZipLong zl = new ZipLong(0x12345678); + final ZipLong zl2 = new ZipLong(0x12345678); + final ZipLong zl3 = new ZipLong(0x87654321); assertTrue("reflexive", zl.equals(zl)); @@ -90,14 +90,14 @@ public class ZipLongTest { */ @Test public void testSign() { - ZipLong zl = new ZipLong(new byte[] {(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}); + final ZipLong zl = new ZipLong(new byte[] {(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}); assertEquals(0x00000000FFFFFFFFl, zl.getValue()); } @Test public void testClone() { - ZipLong s1 = new ZipLong(42); - ZipLong s2 = (ZipLong) s1.clone(); + final ZipLong s1 = new ZipLong(42); + final ZipLong s2 = (ZipLong) s1.clone(); assertNotSame(s1, s2); assertEquals(s1, s2); assertEquals(s1.getValue(), s2.getValue()); http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/archivers/zip/ZipShortTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ZipShortTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ZipShortTest.java index eb498ba..7354e97 100644 --- a/src/test/java/org/apache/commons/compress/archivers/zip/ZipShortTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/zip/ZipShortTest.java @@ -33,8 +33,8 @@ public class ZipShortTest { */ @Test public void testToBytes() { - ZipShort zs = new ZipShort(0x1234); - byte[] result = zs.getBytes(); + final ZipShort zs = new ZipShort(0x1234); + final byte[] result = zs.getBytes(); assertEquals("length getBytes", 2, result.length); assertEquals("first byte getBytes", 0x34, result[0]); assertEquals("second byte getBytes", 0x12, result[1]); @@ -46,7 +46,7 @@ public class ZipShortTest { */ @Test public void testPut() { - byte[] arr = new byte[3]; + final byte[] arr = new byte[3]; ZipShort.putShort(0x1234, arr, 1); assertEquals("first byte getBytes", 0x34, arr[1]); assertEquals("second byte getBytes", 0x12, arr[2]); @@ -58,8 +58,8 @@ public class ZipShortTest { */ @Test public void testFromBytes() { - byte[] val = new byte[] {0x34, 0x12}; - ZipShort zs = new ZipShort(val); + final byte[] val = new byte[] {0x34, 0x12}; + final ZipShort zs = new ZipShort(val); assertEquals("value from bytes", 0x1234, zs.getValue()); } @@ -68,9 +68,9 @@ public class ZipShortTest { */ @Test public void testEquals() { - ZipShort zs = new ZipShort(0x1234); - ZipShort zs2 = new ZipShort(0x1234); - ZipShort zs3 = new ZipShort(0x5678); + final ZipShort zs = new ZipShort(0x1234); + final ZipShort zs2 = new ZipShort(0x1234); + final ZipShort zs3 = new ZipShort(0x5678); assertTrue("reflexive", zs.equals(zs)); @@ -88,14 +88,14 @@ public class ZipShortTest { */ @Test public void testSign() { - ZipShort zs = new ZipShort(new byte[] {(byte)0xFF, (byte)0xFF}); + final ZipShort zs = new ZipShort(new byte[] {(byte)0xFF, (byte)0xFF}); assertEquals(0x0000FFFF, zs.getValue()); } @Test public void testClone() { - ZipShort s1 = new ZipShort(42); - ZipShort s2 = (ZipShort) s1.clone(); + final ZipShort s1 = new ZipShort(42); + final ZipShort s2 = (ZipShort) s1.clone(); assertNotSame(s1, s2); assertEquals(s1, s2); assertEquals(s1.getValue(), s2.getValue()); http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/archivers/zip/ZipUtilTest.java ---------------------------------------------------------------------- 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 ea7e9a4..1ce819f 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 @@ -37,18 +37,18 @@ public class ZipUtilTest { @Before public void setUp() throws Exception { time = new Date(); - Calendar cal = Calendar.getInstance(); + final Calendar cal = Calendar.getInstance(); cal.setTime(time); - int year = cal.get(Calendar.YEAR); - int month = cal.get(Calendar.MONTH) + 1; - long value = ((year - 1980) << 25) + final int year = cal.get(Calendar.YEAR); + final int month = cal.get(Calendar.MONTH) + 1; + final long value = ((year - 1980) << 25) | (month << 21) | (cal.get(Calendar.DAY_OF_MONTH) << 16) | (cal.get(Calendar.HOUR_OF_DAY) << 11) | (cal.get(Calendar.MINUTE) << 5) | (cal.get(Calendar.SECOND) >> 1); - byte[] result = new byte[4]; + final byte[] result = new byte[4]; result[0] = (byte) ((value & 0xFF)); result[1] = (byte) ((value & 0xFF00) >> 8); result[2] = (byte) ((value & 0xFF0000) >> 16); @@ -58,7 +58,7 @@ public class ZipUtilTest { @Test public void testZipLong() throws Exception { - ZipLong test = ZipUtil.toDosTime(time); + final ZipLong test = ZipUtil.toDosTime(time); assertEquals(test.getValue(), zl.getValue()); } @@ -74,16 +74,16 @@ public class ZipUtilTest { @Test public void testMinTime(){ - byte[] b1 = ZipUtil.toDosTime(0); - byte b10 = b1[0]; // Save the first byte + final byte[] b1 = ZipUtil.toDosTime(0); + final byte b10 = b1[0]; // Save the first byte b1[0]++; // change it - byte[] b2 = ZipUtil.toDosTime(0); // get the same time + final byte[] b2 = ZipUtil.toDosTime(0); // get the same time assertEquals(b10,b2[0]); // first byte should still be the same } @Test public void testOutsideCalendar(){ - byte[] b1 = ZipUtil.toDosTime(160441200000L); // 1.1..1975 + final byte[] b1 = ZipUtil.toDosTime(160441200000L); // 1.1..1975 assertEquals(0, b1[0]); assertEquals(33, b1[1]); assertEquals(0, b1[2]); @@ -92,9 +92,9 @@ public class ZipUtilTest { @Test public void testInsideCalendar(){ - TimeZone tz = TimeZone.getDefault(); - long date = 476096400000L; // 1.1.1985, 10:00 am GMT - byte[] b1 = ZipUtil.toDosTime(date - tz.getOffset(date)); + final TimeZone tz = TimeZone.getDefault(); + final long date = 476096400000L; // 1.1.1985, 10:00 am GMT + final byte[] b1 = ZipUtil.toDosTime(date - tz.getOffset(date)); assertEquals(0, b1[0]); assertEquals(72, b1[1]); assertEquals(65, b1[2]); @@ -103,7 +103,7 @@ public class ZipUtilTest { @Test public void testReverse() { - byte[][] bTest = new byte[6][]; + final byte[][] bTest = new byte[6][]; bTest[0] = new byte[]{}; bTest[1] = new byte[]{1}; bTest[2] = new byte[]{1, 2}; @@ -111,7 +111,7 @@ public class ZipUtilTest { bTest[4] = new byte[]{1, 2, 3, 4}; bTest[5] = new byte[]{1, 2, 3, 4, 5}; - byte[][] rTest = new byte[6][]; + final byte[][] rTest = new byte[6][]; rTest[0] = new byte[]{}; rTest[1] = new byte[]{1}; rTest[2] = new byte[]{2, 1}; @@ -122,7 +122,7 @@ public class ZipUtilTest { assertEquals("test and result arrays are same length", bTest.length, rTest.length); for (int i = 0; i < bTest.length; i++) { - byte[] result = ZipUtil.reverse(bTest[i]); + final byte[] result = ZipUtil.reverse(bTest[i]); assertTrue("reverse mutates in-place", bTest[i] == result); assertTrue("reverse actually reverses", Arrays.equals(rTest[i], result)); } @@ -130,45 +130,45 @@ public class ZipUtilTest { @Test public void testBigToLong() { - BigInteger big1 = BigInteger.valueOf(1); - BigInteger big2 = BigInteger.valueOf(Long.MAX_VALUE); - BigInteger big3 = BigInteger.valueOf(Long.MIN_VALUE); + final BigInteger big1 = BigInteger.valueOf(1); + final BigInteger big2 = BigInteger.valueOf(Long.MAX_VALUE); + final BigInteger big3 = BigInteger.valueOf(Long.MIN_VALUE); assertEquals(1L, ZipUtil.bigToLong(big1)); assertEquals(Long.MAX_VALUE, ZipUtil.bigToLong(big2)); assertEquals(Long.MIN_VALUE, ZipUtil.bigToLong(big3)); - BigInteger big4 = big2.add(big1); + final BigInteger big4 = big2.add(big1); try { ZipUtil.bigToLong(big4); fail("Should have thrown IllegalArgumentException"); - } catch (IllegalArgumentException iae) { + } catch (final IllegalArgumentException iae) { // All is good. } - BigInteger big5 = big3.subtract(big1); + final BigInteger big5 = big3.subtract(big1); try { ZipUtil.bigToLong(big5); fail("ZipUtil.bigToLong(BigInteger) should have thrown IllegalArgumentException"); - } catch (IllegalArgumentException iae) { + } catch (final IllegalArgumentException iae) { // All is good. } } @Test public void testLongToBig() { - long l0 = 0; - long l1 = 1; - long l2 = -1; - long l3 = Integer.MIN_VALUE; - long l4 = Long.MAX_VALUE; - long l5 = Long.MIN_VALUE; - - BigInteger big0 = ZipUtil.longToBig(l0); - BigInteger big1 = ZipUtil.longToBig(l1); - BigInteger big2 = ZipUtil.longToBig(l2); - BigInteger big3 = ZipUtil.longToBig(l3); - BigInteger big4 = ZipUtil.longToBig(l4); + final long l0 = 0; + final long l1 = 1; + final long l2 = -1; + final long l3 = Integer.MIN_VALUE; + final long l4 = Long.MAX_VALUE; + final long l5 = Long.MIN_VALUE; + + final BigInteger big0 = ZipUtil.longToBig(l0); + final BigInteger big1 = ZipUtil.longToBig(l1); + final BigInteger big2 = ZipUtil.longToBig(l2); + final BigInteger big3 = ZipUtil.longToBig(l3); + final BigInteger big4 = ZipUtil.longToBig(l4); assertEquals(0, big0.longValue()); assertEquals(1, big1.longValue()); @@ -179,7 +179,7 @@ public class ZipUtilTest { try { ZipUtil.longToBig(l5); fail("ZipUtil.longToBig(long) should have thrown IllegalArgumentException"); - } catch (IllegalArgumentException iae) { + } catch (final IllegalArgumentException iae) { } } @@ -189,7 +189,7 @@ public class ZipUtilTest { // Yay, we can completely test all possible input values in this case! int expectedVal = 128; for (int i = Byte.MIN_VALUE; i <= Byte.MAX_VALUE; i++) { - byte b = (byte) i; + final byte b = (byte) i; assertEquals(expectedVal, ZipUtil.signedByteToUnsignedInt(b)); expectedVal++; if (expectedVal == 256) { @@ -202,7 +202,7 @@ public class ZipUtilTest { public void testUnsignedIntToSignedByte() { int unsignedVal = 128; for (int i = Byte.MIN_VALUE; i <= Byte.MAX_VALUE; i++) { - byte expectedVal = (byte) i; + final byte expectedVal = (byte) i; assertEquals(expectedVal, ZipUtil.unsignedIntToSignedByte(unsignedVal)); unsignedVal++; if (unsignedVal == 256) { @@ -213,14 +213,14 @@ public class ZipUtilTest { try { ZipUtil.unsignedIntToSignedByte(-1); fail("ZipUtil.unsignedIntToSignedByte(-1) should have thrown IllegalArgumentException"); - } catch (IllegalArgumentException iae) { + } catch (final IllegalArgumentException iae) { // All is good. } try { ZipUtil.unsignedIntToSignedByte(256); fail("ZipUtil.unsignedIntToSignedByte(256) should have thrown IllegalArgumentException"); - } catch (IllegalArgumentException iae) { + } catch (final IllegalArgumentException iae) { // All is good. } http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java b/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java index b9edb0b..a546a89 100644 --- a/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java +++ b/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java @@ -50,9 +50,9 @@ public final class ChangeSetTestCase extends AbstractTestCase { // Delete a directory tree private void archiveListDeleteDir(final String prefix){ - Iterator<String> it = archiveList.iterator(); + final Iterator<String> it = archiveList.iterator(); while(it.hasNext()){ - String entry = it.next(); + final String entry = it.next(); if (entry.startsWith(prefix+"/")){ // TODO won't work with folders it.remove(); } @@ -61,9 +61,9 @@ public final class ChangeSetTestCase extends AbstractTestCase { // Delete a single file private void archiveListDelete(final String prefix){ - Iterator<String> it = archiveList.iterator(); + final Iterator<String> it = archiveList.iterator(); while(it.hasNext()){ - String entry = it.next(); + final String entry = it.next(); if (entry.equals(prefix)){ it.remove(); } @@ -85,15 +85,15 @@ public final class ChangeSetTestCase extends AbstractTestCase { in = new FileInputStream(getFile("test.txt")); in2 = new FileInputStream(getFile("test2.xml")); - ArchiveEntry e = new ZipArchiveEntry("test.txt"); - ArchiveEntry e2 = new ZipArchiveEntry("test.txt"); + final ArchiveEntry e = new ZipArchiveEntry("test.txt"); + final ArchiveEntry e2 = new ZipArchiveEntry("test.txt"); - ChangeSet changes = new ChangeSet(); + final ChangeSet changes = new ChangeSet(); changes.add(e, in); changes.add(e2, in2); assertEquals(1, changes.getChanges().size()); - Change c = changes.getChanges().iterator().next(); + final Change c = changes.getChanges().iterator().next(); assertEquals(in2, c.getInput()); } finally { if (in != null) { @@ -120,15 +120,15 @@ public final class ChangeSetTestCase extends AbstractTestCase { in = new FileInputStream(getFile("test.txt")); in2 = new FileInputStream(getFile("test2.xml")); - ArchiveEntry e = new ZipArchiveEntry("test.txt"); - ArchiveEntry e2 = new ZipArchiveEntry("test.txt"); + final ArchiveEntry e = new ZipArchiveEntry("test.txt"); + final ArchiveEntry e2 = new ZipArchiveEntry("test.txt"); - ChangeSet changes = new ChangeSet(); + final ChangeSet changes = new ChangeSet(); changes.add(e, in, true); changes.add(e2, in2, false); assertEquals(1, changes.getChanges().size()); - Change c = changes.getChanges().iterator().next(); + final Change c = changes.getChanges().iterator().next(); assertEquals(in, c.getInput()); } finally { if (in != null) { @@ -151,11 +151,11 @@ public final class ChangeSetTestCase extends AbstractTestCase { @Test public void testDeleteDir() throws Exception { final String archivename = "cpio"; - File input = this.createArchive(archivename); + final File input = this.createArchive(archivename); ArchiveOutputStream out = null; ArchiveInputStream ais = null; - File result = File.createTempFile("test", "."+archivename); + final File result = File.createTempFile("test", "."+archivename); result.deleteOnExit(); try { @@ -165,10 +165,10 @@ public final class ChangeSetTestCase extends AbstractTestCase { out = factory.createArchiveOutputStream(archivename, new FileOutputStream(result)); - ChangeSet changes = new ChangeSet(); + final ChangeSet changes = new ChangeSet(); changes.deleteDir("bla"); archiveListDeleteDir("bla"); - ChangeSetPerformer performer = new ChangeSetPerformer(changes); + final ChangeSetPerformer performer = new ChangeSetPerformer(changes); performer.perform(ais, out); is.close(); @@ -193,11 +193,11 @@ public final class ChangeSetTestCase extends AbstractTestCase { @Test public void testDeleteDir2() throws Exception { final String archivename = "cpio"; - File input = this.createArchive(archivename); + final File input = this.createArchive(archivename); ArchiveOutputStream out = null; ArchiveInputStream ais = null; - File result = File.createTempFile("test", "."+archivename); + final File result = File.createTempFile("test", "."+archivename); result.deleteOnExit(); try { @@ -207,10 +207,10 @@ public final class ChangeSetTestCase extends AbstractTestCase { out = factory.createArchiveOutputStream(archivename, new FileOutputStream(result)); - ChangeSet changes = new ChangeSet(); + final ChangeSet changes = new ChangeSet(); changes.deleteDir("la"); archiveListDeleteDir("la"); - ChangeSetPerformer performer = new ChangeSetPerformer(changes); + final ChangeSetPerformer performer = new ChangeSetPerformer(changes); performer.perform(ais, out); is.close(); @@ -235,11 +235,11 @@ public final class ChangeSetTestCase extends AbstractTestCase { @Test public void testDeleteDir3() throws Exception { final String archivename = "cpio"; - File input = this.createArchive(archivename); + final File input = this.createArchive(archivename); ArchiveOutputStream out = null; ArchiveInputStream ais = null; - File result = File.createTempFile("test", "."+archivename); + final File result = File.createTempFile("test", "."+archivename); result.deleteOnExit(); try { @@ -249,10 +249,10 @@ public final class ChangeSetTestCase extends AbstractTestCase { out = factory.createArchiveOutputStream(archivename, new FileOutputStream(result)); - ChangeSet changes = new ChangeSet(); + final ChangeSet changes = new ChangeSet(); changes.deleteDir("test.txt"); archiveListDeleteDir("test.txt"); - ChangeSetPerformer performer = new ChangeSetPerformer(changes); + final ChangeSetPerformer performer = new ChangeSetPerformer(changes); performer.perform(ais, out); is.close(); @@ -277,11 +277,11 @@ public final class ChangeSetTestCase extends AbstractTestCase { @Test public void testDeleteFile() throws Exception { final String archivename = "cpio"; - File input = this.createArchive(archivename); + final File input = this.createArchive(archivename); ArchiveOutputStream out = null; ArchiveInputStream ais = null; - File result = File.createTempFile("test", "."+archivename); + final File result = File.createTempFile("test", "."+archivename); result.deleteOnExit(); try { @@ -291,11 +291,11 @@ public final class ChangeSetTestCase extends AbstractTestCase { out = factory.createArchiveOutputStream(archivename, new FileOutputStream(result)); - ChangeSet changes = new ChangeSet(); + final ChangeSet changes = new ChangeSet(); changes.delete("bla/test5.xml"); archiveListDelete("bla/test5.xml"); - ChangeSetPerformer performer = new ChangeSetPerformer(changes); + final ChangeSetPerformer performer = new ChangeSetPerformer(changes); performer.perform(ais, out); is.close(); @@ -320,11 +320,11 @@ public final class ChangeSetTestCase extends AbstractTestCase { @Test public void testDeleteFile2() throws Exception { final String archivename = "cpio"; - File input = this.createArchive(archivename); + final File input = this.createArchive(archivename); ArchiveOutputStream out = null; ArchiveInputStream ais = null; - File result = File.createTempFile("test", "."+archivename); + final File result = File.createTempFile("test", "."+archivename); result.deleteOnExit(); try { @@ -334,11 +334,11 @@ public final class ChangeSetTestCase extends AbstractTestCase { out = factory.createArchiveOutputStream(archivename, new FileOutputStream(result)); - ChangeSet changes = new ChangeSet(); + final ChangeSet changes = new ChangeSet(); changes.delete("bla"); //archiveListDelete("bla"); - ChangeSetPerformer performer = new ChangeSetPerformer(changes); + final ChangeSetPerformer performer = new ChangeSetPerformer(changes); performer.perform(ais, out); is.close(); @@ -364,11 +364,11 @@ public final class ChangeSetTestCase extends AbstractTestCase { @Test public void testDeletePlusAddSame() throws Exception { final String archivename = "zip"; - File input = this.createArchive(archivename); + final File input = this.createArchive(archivename); ArchiveOutputStream out = null; ArchiveInputStream ais = null; - File result = File.createTempFile("test", "."+archivename); + final File result = File.createTempFile("test", "."+archivename); result.deleteOnExit(); File testtxt = null; @@ -379,17 +379,17 @@ public final class ChangeSetTestCase extends AbstractTestCase { out = factory.createArchiveOutputStream(archivename, new FileOutputStream(result)); - ChangeSet changes = new ChangeSet(); + final ChangeSet changes = new ChangeSet(); changes.delete("test/test3.xml"); archiveListDelete("test/test3.xml"); // Add a file testtxt = getFile("test.txt"); - ArchiveEntry entry = out.createArchiveEntry(testtxt, "test/test3.xml"); + final ArchiveEntry entry = out.createArchiveEntry(testtxt, "test/test3.xml"); changes.add(entry, new FileInputStream(testtxt)); archiveList.add("test/test3.xml"); - ChangeSetPerformer performer = new ChangeSetPerformer(changes); + final ChangeSetPerformer performer = new ChangeSetPerformer(changes); performer.perform(ais, out); is.close(); @@ -410,10 +410,10 @@ public final class ChangeSetTestCase extends AbstractTestCase { final BufferedInputStream buf = new BufferedInputStream(is); in = factory.createArchiveInputStream(buf); check = this.checkArchiveContent(in, archiveList, false); - File test3xml = new File(check,"result/test/test3.xml"); + final File test3xml = new File(check,"result/test/test3.xml"); assertEquals(testtxt.length(), test3xml.length()); - BufferedReader reader = new BufferedReader(new FileReader(test3xml)); + final BufferedReader reader = new BufferedReader(new FileReader(test3xml)); String str; while ((str = reader.readLine()) != null) { // All lines look like this @@ -436,11 +436,11 @@ public final class ChangeSetTestCase extends AbstractTestCase { @Test public void testChangeSetResults() throws Exception { final String archivename = "cpio"; - File input = this.createArchive(archivename); + final File input = this.createArchive(archivename); ArchiveOutputStream out = null; ArchiveInputStream ais = null; - File result = File.createTempFile("test", "."+archivename); + final File result = File.createTempFile("test", "."+archivename); result.deleteOnExit(); try { @@ -449,18 +449,18 @@ public final class ChangeSetTestCase extends AbstractTestCase { out = factory.createArchiveOutputStream(archivename, new FileOutputStream(result)); - ChangeSet changes = new ChangeSet(); + final ChangeSet changes = new ChangeSet(); changes.deleteDir("bla"); archiveListDeleteDir("bla"); // Add a file final File file1 = getFile("test.txt"); - ArchiveEntry entry = out.createArchiveEntry(file1, "bla/test.txt"); + final ArchiveEntry entry = out.createArchiveEntry(file1, "bla/test.txt"); changes.add(entry, new FileInputStream(file1)); archiveList.add("bla/test.txt"); - ChangeSetPerformer performer = new ChangeSetPerformer(changes); - ChangeSetResults results = performer.perform(ais, out); + final ChangeSetPerformer performer = new ChangeSetPerformer(changes); + final ChangeSetResults results = performer.perform(ais, out); is.close(); // Checks @@ -500,11 +500,11 @@ public final class ChangeSetTestCase extends AbstractTestCase { @Test public void testDeletePlusAdd() throws Exception { final String archivename = "cpio"; - File input = this.createArchive(archivename); + final File input = this.createArchive(archivename); ArchiveOutputStream out = null; ArchiveInputStream ais = null; - File result = File.createTempFile("test", "."+archivename); + final File result = File.createTempFile("test", "."+archivename); result.deleteOnExit(); try { @@ -513,17 +513,17 @@ public final class ChangeSetTestCase extends AbstractTestCase { out = factory.createArchiveOutputStream(archivename, new FileOutputStream(result)); - ChangeSet changes = new ChangeSet(); + final ChangeSet changes = new ChangeSet(); changes.deleteDir("bla"); archiveListDeleteDir("bla"); // Add a file final File file1 = getFile("test.txt"); - ArchiveEntry entry = out.createArchiveEntry(file1, "bla/test.txt"); + final ArchiveEntry entry = out.createArchiveEntry(file1, "bla/test.txt"); changes.add(entry, new FileInputStream(file1)); archiveList.add("bla/test.txt"); - ChangeSetPerformer performer = new ChangeSetPerformer(changes); + final ChangeSetPerformer performer = new ChangeSetPerformer(changes); performer.perform(ais, out); is.close(); @@ -547,11 +547,11 @@ public final class ChangeSetTestCase extends AbstractTestCase { @Test public void testDeleteFromAndAddToZip() throws Exception { final String archivename = "zip"; - File input = this.createArchive(archivename); + final File input = this.createArchive(archivename); ArchiveOutputStream out = null; ArchiveInputStream ais = null; - File result = File.createTempFile("test", "."+archivename); + final File result = File.createTempFile("test", "."+archivename); result.deleteOnExit(); try { @@ -560,17 +560,17 @@ public final class ChangeSetTestCase extends AbstractTestCase { out = factory.createArchiveOutputStream(archivename, new FileOutputStream(result)); - ChangeSet changes = new ChangeSet(); + final ChangeSet changes = new ChangeSet(); final File file1 = getFile("test.txt"); - ArchiveEntry entry = new ZipArchiveEntry("blub/test.txt"); + final ArchiveEntry entry = new ZipArchiveEntry("blub/test.txt"); changes.add(entry, new FileInputStream(file1)); archiveList.add("blub/test.txt"); changes.delete("testdata/test1.xml"); archiveListDelete("testdata/test1.xml"); - ChangeSetPerformer performer = new ChangeSetPerformer(changes); + final ChangeSetPerformer performer = new ChangeSetPerformer(changes); performer.perform(ais, out); is.close(); @@ -594,11 +594,11 @@ public final class ChangeSetTestCase extends AbstractTestCase { @Test public void testDeleteFromAndAddToZipUsingZipFilePerform() throws Exception { final String archivename = "zip"; - File input = this.createArchive(archivename); + final File input = this.createArchive(archivename); ArchiveOutputStream out = null; ZipFile ais = null; - File result = File.createTempFile("test", "."+archivename); + final File result = File.createTempFile("test", "."+archivename); result.deleteOnExit(); try { @@ -606,17 +606,17 @@ public final class ChangeSetTestCase extends AbstractTestCase { out = factory.createArchiveOutputStream(archivename, new FileOutputStream(result)); - ChangeSet changes = new ChangeSet(); + final ChangeSet changes = new ChangeSet(); final File file1 = getFile("test.txt"); - ArchiveEntry entry = new ZipArchiveEntry("blub/test.txt"); + final ArchiveEntry entry = new ZipArchiveEntry("blub/test.txt"); changes.add(entry, new FileInputStream(file1)); archiveList.add("blub/test.txt"); changes.delete("testdata/test1.xml"); archiveListDelete("testdata/test1.xml"); - ChangeSetPerformer performer = new ChangeSetPerformer(changes); + final ChangeSetPerformer performer = new ChangeSetPerformer(changes); performer.perform(ais, out); } finally { @@ -640,11 +640,11 @@ public final class ChangeSetTestCase extends AbstractTestCase { @Test public void testAddDeleteAdd() throws Exception { final String archivename = "cpio"; - File input = this.createArchive(archivename); + final File input = this.createArchive(archivename); ArchiveOutputStream out = null; ArchiveInputStream ais = null; - File result = File.createTempFile("test", "."+archivename); + final File result = File.createTempFile("test", "."+archivename); result.deleteOnExit(); try { @@ -653,17 +653,17 @@ public final class ChangeSetTestCase extends AbstractTestCase { out = factory.createArchiveOutputStream(archivename, new FileOutputStream(result)); - ChangeSet changes = new ChangeSet(); + final ChangeSet changes = new ChangeSet(); final File file1 = getFile("test.txt"); - ArchiveEntry entry = new CpioArchiveEntry("blub/test.txt"); + final ArchiveEntry entry = new CpioArchiveEntry("blub/test.txt"); changes.add(entry, new FileInputStream(file1)); archiveList.add("blub/test.txt"); changes.deleteDir("blub"); archiveListDeleteDir("blub"); - ChangeSetPerformer performer = new ChangeSetPerformer(changes); + final ChangeSetPerformer performer = new ChangeSetPerformer(changes); performer.perform(ais, out); is.close(); @@ -689,11 +689,11 @@ public final class ChangeSetTestCase extends AbstractTestCase { @Test public void testDeleteAddDelete() throws Exception { final String archivename = "cpio"; - File input = this.createArchive(archivename); + final File input = this.createArchive(archivename); ArchiveOutputStream out = null; ArchiveInputStream ais = null; - File result = File.createTempFile("test", "."+archivename); + final File result = File.createTempFile("test", "."+archivename); result.deleteOnExit(); try { @@ -702,19 +702,19 @@ public final class ChangeSetTestCase extends AbstractTestCase { out = factory.createArchiveOutputStream(archivename, new FileOutputStream(result)); - ChangeSet changes = new ChangeSet(); + final ChangeSet changes = new ChangeSet(); changes.deleteDir("bla"); final File file1 = getFile("test.txt"); - ArchiveEntry entry = new CpioArchiveEntry("bla/test.txt"); + final ArchiveEntry entry = new CpioArchiveEntry("bla/test.txt"); changes.add(entry, new FileInputStream(file1)); archiveList.add("bla/test.txt"); changes.deleteDir("bla"); archiveListDeleteDir("bla"); - ChangeSetPerformer performer = new ChangeSetPerformer(changes); + final ChangeSetPerformer performer = new ChangeSetPerformer(changes); performer.perform(ais, out); is.close(); @@ -742,7 +742,7 @@ public final class ChangeSetTestCase extends AbstractTestCase { ArchiveInputStream ais = null; File temp = null; try { - ChangeSet changes = new ChangeSet(); + final ChangeSet changes = new ChangeSet(); changes.delete("test2.xml"); final File input = getFile("bla.zip"); @@ -754,7 +754,7 @@ public final class ChangeSetTestCase extends AbstractTestCase { out = factory.createArchiveOutputStream("zip", new FileOutputStream(temp)); - ChangeSetPerformer performer = new ChangeSetPerformer(changes); + final ChangeSetPerformer performer = new ChangeSetPerformer(changes); performer.perform(ais, out); } finally { @@ -766,7 +766,7 @@ public final class ChangeSetTestCase extends AbstractTestCase { } } - List<String> expected = new ArrayList<String>(); + final List<String> expected = new ArrayList<String>(); expected.add("test1.xml"); this.checkArchiveContent(temp, expected); @@ -783,7 +783,7 @@ public final class ChangeSetTestCase extends AbstractTestCase { ArchiveInputStream ais = null; File temp = null; try { - ChangeSet changes = new ChangeSet(); + final ChangeSet changes = new ChangeSet(); changes.delete("test2.xml"); final File input = getFile("bla.tar"); @@ -794,7 +794,7 @@ public final class ChangeSetTestCase extends AbstractTestCase { out = factory.createArchiveOutputStream("tar", new FileOutputStream(temp)); - ChangeSetPerformer performer = new ChangeSetPerformer(changes); + final ChangeSetPerformer performer = new ChangeSetPerformer(changes); performer.perform(ais, out); } finally { @@ -805,7 +805,7 @@ public final class ChangeSetTestCase extends AbstractTestCase { ais.close(); } } - List<String> expected = new ArrayList<String>(); + final List<String> expected = new ArrayList<String>(); expected.add("test1.xml"); this.checkArchiveContent(temp, expected); } @@ -821,7 +821,7 @@ public final class ChangeSetTestCase extends AbstractTestCase { ArchiveInputStream ais = null; File temp = null; try { - ChangeSet changes = new ChangeSet(); + final ChangeSet changes = new ChangeSet(); changes.delete("test2.xml"); changes.deleteDir("META-INF"); changes.delete(".classpath"); @@ -835,7 +835,7 @@ public final class ChangeSetTestCase extends AbstractTestCase { out = factory.createArchiveOutputStream("jar", new FileOutputStream(temp)); - ChangeSetPerformer performer = new ChangeSetPerformer(changes); + final ChangeSetPerformer performer = new ChangeSetPerformer(changes); performer.perform(ais, out); } finally { @@ -846,7 +846,7 @@ public final class ChangeSetTestCase extends AbstractTestCase { ais.close(); } } - List<String> expected = new ArrayList<String>(); + final List<String> expected = new ArrayList<String>(); expected.add("test1.xml"); this.checkArchiveContent(temp, expected); } @@ -857,7 +857,7 @@ public final class ChangeSetTestCase extends AbstractTestCase { ArchiveInputStream ais = null; File temp = null; try { - ChangeSet changes = new ChangeSet(); + final ChangeSet changes = new ChangeSet(); changes.delete("test2.xml"); final File file1 = getFile("test.txt"); @@ -882,7 +882,7 @@ public final class ChangeSetTestCase extends AbstractTestCase { out = factory.createArchiveOutputStream("tar", new FileOutputStream(temp)); - ChangeSetPerformer performer = new ChangeSetPerformer(changes); + final ChangeSetPerformer performer = new ChangeSetPerformer(changes); performer.perform(ais, out); } finally { @@ -893,7 +893,7 @@ public final class ChangeSetTestCase extends AbstractTestCase { ais.close(); } } - List<String> expected = new ArrayList<String>(); + final List<String> expected = new ArrayList<String>(); expected.add("test1.xml"); expected.add("testdata/test.txt"); final ArchiveInputStream in = factory.createArchiveInputStream("tar", new FileInputStream(temp)); @@ -911,14 +911,14 @@ public final class ChangeSetTestCase extends AbstractTestCase { ArchiveInputStream ais = null; File temp = null; try { - ChangeSet changes = new ChangeSet(); + final ChangeSet changes = new ChangeSet(); changes.delete("test2.xml"); changes.deleteDir("META-INF"); changes.delete(".classpath"); changes.delete(".project"); final File file1 = getFile("test.txt"); - JarArchiveEntry entry = new JarArchiveEntry("testdata/test.txt"); + final JarArchiveEntry entry = new JarArchiveEntry("testdata/test.txt"); changes.add(entry, new FileInputStream(file1)); final File input = getFile("bla.jar"); @@ -929,7 +929,7 @@ public final class ChangeSetTestCase extends AbstractTestCase { out = factory.createArchiveOutputStream("jar", new FileOutputStream(temp)); - ChangeSetPerformer performer = new ChangeSetPerformer(changes); + final ChangeSetPerformer performer = new ChangeSetPerformer(changes); performer.perform(ais, out); } finally { @@ -940,7 +940,7 @@ public final class ChangeSetTestCase extends AbstractTestCase { ais.close(); } } - List<String> expected = new ArrayList<String>(); + final List<String> expected = new ArrayList<String>(); expected.add("test1.xml"); expected.add("testdata/test.txt"); this.checkArchiveContent(temp, expected); @@ -957,7 +957,7 @@ public final class ChangeSetTestCase extends AbstractTestCase { ArchiveInputStream ais = null; File temp = null; try { - ChangeSet changes = new ChangeSet(); + final ChangeSet changes = new ChangeSet(); changes.delete("test2.xml"); final File input = getFile("bla.ar"); @@ -968,7 +968,7 @@ public final class ChangeSetTestCase extends AbstractTestCase { out = factory.createArchiveOutputStream("ar", new FileOutputStream(temp)); - ChangeSetPerformer performer = new ChangeSetPerformer(changes); + final ChangeSetPerformer performer = new ChangeSetPerformer(changes); performer.perform(ais, out); } finally { @@ -980,7 +980,7 @@ public final class ChangeSetTestCase extends AbstractTestCase { } } - List<String> expected = new ArrayList<String>(); + final List<String> expected = new ArrayList<String>(); expected.add("test1.xml"); this.checkArchiveContent(temp, expected); } @@ -996,7 +996,7 @@ public final class ChangeSetTestCase extends AbstractTestCase { ArchiveInputStream ais = null; File temp = null; try { - ChangeSet changes = new ChangeSet(); + final ChangeSet changes = new ChangeSet(); changes.delete("test2.xml"); final File file1 = getFile("test.txt"); @@ -1014,7 +1014,7 @@ public final class ChangeSetTestCase extends AbstractTestCase { out = factory.createArchiveOutputStream("ar", new FileOutputStream(temp)); - ChangeSetPerformer performer = new ChangeSetPerformer(changes); + final ChangeSetPerformer performer = new ChangeSetPerformer(changes); performer.perform(ais, out); } finally { @@ -1025,7 +1025,7 @@ public final class ChangeSetTestCase extends AbstractTestCase { ais.close(); } } - List<String> expected = new ArrayList<String>(); + final List<String> expected = new ArrayList<String>(); expected.add("test1.xml"); expected.add("test.txt"); this.checkArchiveContent(temp, expected); @@ -1065,14 +1065,14 @@ public final class ChangeSetTestCase extends AbstractTestCase { @Test public void testAddToEmptyArchive() throws Exception { final String archivename = "zip"; - File input = this.createEmptyArchive(archivename); + final File input = this.createEmptyArchive(archivename); ArchiveOutputStream out = null; ArchiveInputStream ais = null; InputStream is = null; - File result = File.createTempFile("test", "."+archivename); + final File result = File.createTempFile("test", "."+archivename); result.deleteOnExit(); - ChangeSet changes = new ChangeSet(); + final ChangeSet changes = new ChangeSet(); try { is = new FileInputStream(input); @@ -1082,10 +1082,10 @@ public final class ChangeSetTestCase extends AbstractTestCase { new FileOutputStream(result)); final File file1 = getFile("test.txt"); - ArchiveEntry entry = new ZipArchiveEntry("bla/test.txt"); + final ArchiveEntry entry = new ZipArchiveEntry("bla/test.txt"); changes.add(entry, new FileInputStream(file1)); archiveList.add("bla/test.txt"); - ChangeSetPerformer performer = new ChangeSetPerformer(changes); + final ChangeSetPerformer performer = new ChangeSetPerformer(changes); performer.perform(ais, out); is.close(); @@ -1111,14 +1111,14 @@ public final class ChangeSetTestCase extends AbstractTestCase { @Test public void testDeleteAddToOneFileArchive() throws Exception { final String archivename = "zip"; - File input = this.createSingleEntryArchive(archivename); + final File input = this.createSingleEntryArchive(archivename); ArchiveOutputStream out = null; ArchiveInputStream ais = null; InputStream is = null; - File result = File.createTempFile("test", "."+archivename); + final File result = File.createTempFile("test", "."+archivename); result.deleteOnExit(); - ChangeSet changes = new ChangeSet(); + final ChangeSet changes = new ChangeSet(); try { is = new FileInputStream(input); @@ -1130,11 +1130,11 @@ public final class ChangeSetTestCase extends AbstractTestCase { archiveListDelete("test1.xml"); final File file = getFile("test.txt"); - ArchiveEntry entry = out.createArchiveEntry(file,"bla/test.txt"); + final ArchiveEntry entry = out.createArchiveEntry(file,"bla/test.txt"); changes.add(entry, new FileInputStream(file)); archiveList.add("bla/test.txt"); - ChangeSetPerformer performer = new ChangeSetPerformer(changes); + final ChangeSetPerformer performer = new ChangeSetPerformer(changes); performer.perform(ais, out); is.close(); @@ -1160,14 +1160,14 @@ public final class ChangeSetTestCase extends AbstractTestCase { @Test public void testAddDeleteToOneFileArchive() throws Exception { final String archivename = "cpio"; - File input = this.createSingleEntryArchive(archivename); + final File input = this.createSingleEntryArchive(archivename); ArchiveOutputStream out = null; ArchiveInputStream ais = null; InputStream is = null; - File result = File.createTempFile("test", "."+archivename); + final File result = File.createTempFile("test", "."+archivename); result.deleteOnExit(); - ChangeSet changes = new ChangeSet(); + final ChangeSet changes = new ChangeSet(); try { is = new FileInputStream(input); @@ -1176,14 +1176,14 @@ public final class ChangeSetTestCase extends AbstractTestCase { out = factory.createArchiveOutputStream(archivename, new FileOutputStream(result)); final File file = getFile("test.txt"); - ArchiveEntry entry = out.createArchiveEntry(file,"bla/test.txt"); + final ArchiveEntry entry = out.createArchiveEntry(file,"bla/test.txt"); changes.add(entry, new FileInputStream(file)); archiveList.add("bla/test.txt"); changes.delete("test1.xml"); archiveListDelete("test1.xml"); - ChangeSetPerformer performer = new ChangeSetPerformer(changes); + final ChangeSetPerformer performer = new ChangeSetPerformer(changes); performer.perform(ais, out); is.close(); @@ -1210,11 +1210,11 @@ public final class ChangeSetTestCase extends AbstractTestCase { @Test public void testAddAllreadyExistingWithReplaceTrue() throws Exception { final String archivename = "zip"; - File input = this.createArchive(archivename); + final File input = this.createArchive(archivename); ArchiveOutputStream out = null; ArchiveInputStream ais = null; - File result = File.createTempFile("test", "."+archivename); + final File result = File.createTempFile("test", "."+archivename); result.deleteOnExit(); try { @@ -1223,14 +1223,14 @@ public final class ChangeSetTestCase extends AbstractTestCase { out = factory.createArchiveOutputStream(archivename, new FileOutputStream(result)); - ChangeSet changes = new ChangeSet(); + final ChangeSet changes = new ChangeSet(); final File file1 = getFile("test.txt"); - ArchiveEntry entry = new ZipArchiveEntry("testdata/test1.xml"); + final ArchiveEntry entry = new ZipArchiveEntry("testdata/test1.xml"); changes.add(entry, new FileInputStream(file1), true); - ChangeSetPerformer performer = new ChangeSetPerformer(changes); - ChangeSetResults results = performer.perform(ais, out); + final ChangeSetPerformer performer = new ChangeSetPerformer(changes); + final ChangeSetResults results = performer.perform(ais, out); assertTrue(results.getAddedFromChangeSet().contains("testdata/test1.xml")); is.close(); @@ -1255,11 +1255,11 @@ public final class ChangeSetTestCase extends AbstractTestCase { @Test public void testAddAllreadyExistingWithReplaceFalse() throws Exception { final String archivename = "zip"; - File input = this.createArchive(archivename); + final File input = this.createArchive(archivename); ArchiveOutputStream out = null; ArchiveInputStream ais = null; - File result = File.createTempFile("test", "."+archivename); + final File result = File.createTempFile("test", "."+archivename); result.deleteOnExit(); try { @@ -1268,14 +1268,14 @@ public final class ChangeSetTestCase extends AbstractTestCase { out = factory.createArchiveOutputStream(archivename, new FileOutputStream(result)); - ChangeSet changes = new ChangeSet(); + final ChangeSet changes = new ChangeSet(); final File file1 = getFile("test.txt"); - ArchiveEntry entry = new ZipArchiveEntry("testdata/test1.xml"); + final ArchiveEntry entry = new ZipArchiveEntry("testdata/test1.xml"); changes.add(entry, new FileInputStream(file1), false); - ChangeSetPerformer performer = new ChangeSetPerformer(changes); - ChangeSetResults results = performer.perform(ais, out); + final ChangeSetPerformer performer = new ChangeSetPerformer(changes); + final ChangeSetResults results = performer.perform(ais, out); assertTrue(results.getAddedFromStream().contains("testdata/test1.xml")); assertTrue(results.getAddedFromChangeSet().isEmpty()); assertTrue(results.getDeleted().isEmpty()); http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/compressors/BZip2TestCase.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/compress/compressors/BZip2TestCase.java b/src/test/java/org/apache/commons/compress/compressors/BZip2TestCase.java index 5132166..0ae8dee 100644 --- a/src/test/java/org/apache/commons/compress/compressors/BZip2TestCase.java +++ b/src/test/java/org/apache/commons/compress/compressors/BZip2TestCase.java @@ -41,7 +41,7 @@ public final class BZip2TestCase extends AbstractTestCase { output = new File(dir, "test.txt.bz2"); final OutputStream out = new FileOutputStream(output); final CompressorOutputStream cos = new CompressorStreamFactory().createCompressorOutputStream("bzip2", out); - FileInputStream in = new FileInputStream(input); + final FileInputStream in = new FileInputStream(input); IOUtils.copy(in, cos); cos.close(); in.close(); @@ -53,7 +53,7 @@ public final class BZip2TestCase extends AbstractTestCase { final InputStream is = new FileInputStream(toDecompress); final CompressorInputStream in = new CompressorStreamFactory().createCompressorInputStream("bzip2", is); - FileOutputStream os = new FileOutputStream(decompressed); + final FileOutputStream os = new FileOutputStream(decompressed); IOUtils.copy(in, os); is.close(); os.close(); @@ -68,7 +68,7 @@ public final class BZip2TestCase extends AbstractTestCase { final File output = new File(dir, "bla.txt"); final InputStream is = new FileInputStream(input); final CompressorInputStream in = new CompressorStreamFactory().createCompressorInputStream("bzip2", is); - FileOutputStream os = new FileOutputStream(output); + final FileOutputStream os = new FileOutputStream(output); IOUtils.copy(in, os); is.close(); os.close(); http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/compressors/DeflateTestCase.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/compress/compressors/DeflateTestCase.java b/src/test/java/org/apache/commons/compress/compressors/DeflateTestCase.java index 7d6a7e5..b713ed3 100644 --- a/src/test/java/org/apache/commons/compress/compressors/DeflateTestCase.java +++ b/src/test/java/org/apache/commons/compress/compressors/DeflateTestCase.java @@ -67,7 +67,7 @@ public final class DeflateTestCase extends AbstractTestCase { final File output = new File(dir, "test1.xml.deflate"); final OutputStream out = new FileOutputStream(output); try { - DeflateParameters params = new DeflateParameters(); + final DeflateParameters params = new DeflateParameters(); params.setWithZlibHeader(false); final CompressorOutputStream cos = new DeflateCompressorOutputStream(out, params); try { @@ -119,7 +119,7 @@ public final class DeflateTestCase extends AbstractTestCase { final File output = new File(dir, "bla.tar"); final InputStream is = new FileInputStream(input); try { - DeflateParameters params = new DeflateParameters(); + final DeflateParameters params = new DeflateParameters(); params.setWithZlibHeader(false); final CompressorInputStream in = new DeflateCompressorInputStream(is, params); FileOutputStream out = null; http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/compressors/DetectCompressorTestCase.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/compress/compressors/DetectCompressorTestCase.java b/src/test/java/org/apache/commons/compress/compressors/DetectCompressorTestCase.java index eccbd5e..674a2a0 100644 --- a/src/test/java/org/apache/commons/compress/compressors/DetectCompressorTestCase.java +++ b/src/test/java/org/apache/commons/compress/compressors/DetectCompressorTestCase.java @@ -89,30 +89,30 @@ public final class DetectCompressorTestCase { @Test public void testDetection() throws Exception { - CompressorInputStream bzip2 = getStreamFor("bla.txt.bz2"); + final CompressorInputStream bzip2 = getStreamFor("bla.txt.bz2"); assertNotNull(bzip2); assertTrue(bzip2 instanceof BZip2CompressorInputStream); - CompressorInputStream gzip = getStreamFor("bla.tgz"); + final CompressorInputStream gzip = getStreamFor("bla.tgz"); assertNotNull(gzip); assertTrue(gzip instanceof GzipCompressorInputStream); - CompressorInputStream pack200 = getStreamFor("bla.pack"); + final CompressorInputStream pack200 = getStreamFor("bla.pack"); assertNotNull(pack200); assertTrue(pack200 instanceof Pack200CompressorInputStream); - CompressorInputStream xz = getStreamFor("bla.tar.xz"); + final CompressorInputStream xz = getStreamFor("bla.tar.xz"); assertNotNull(xz); assertTrue(xz instanceof XZCompressorInputStream); - CompressorInputStream zlib = getStreamFor("bla.tar.deflatez"); + final CompressorInputStream zlib = getStreamFor("bla.tar.deflatez"); assertNotNull(zlib); assertTrue(zlib instanceof DeflateCompressorInputStream); try { factory.createCompressorInputStream(new ByteArrayInputStream(new byte[0])); fail("No exception thrown for an empty input stream"); - } catch (CompressorException e) { + } catch (final CompressorException e) { // expected } } @@ -129,7 +129,7 @@ public final class DetectCompressorTestCase { try { fac.setDecompressConcatenated(true); fail("Expected IllegalStateException"); - } catch (IllegalStateException ise) { + } catch (final IllegalStateException ise) { // expected } @@ -138,7 +138,7 @@ public final class DetectCompressorTestCase { try { fac.setDecompressConcatenated(true); fail("Expected IllegalStateException"); - } catch (IllegalStateException ise) { + } catch (final IllegalStateException ise) { // expected } } @@ -146,13 +146,13 @@ public final class DetectCompressorTestCase { @Test public void testMutiples() throws Exception { for(int i=0; i <tests.length; i++) { - TestData test = tests[i]; + final TestData test = tests[i]; final CompressorStreamFactory fac = test.factory; assertNotNull("Test entry "+i, fac); assertEquals("Test entry "+i, test.concat, fac.getDecompressConcatenated()); - CompressorInputStream in = getStreamFor(test.fileName, fac); + final CompressorInputStream in = getStreamFor(test.fileName, fac); assertNotNull("Test entry "+i,in); - for (char entry : test.entryNames) { + for (final char entry : test.entryNames) { assertEquals("Test entry" + i, entry, in.read()); } assertEquals(0, in.available()); http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/compressors/FramedSnappyTestCase.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/compress/compressors/FramedSnappyTestCase.java b/src/test/java/org/apache/commons/compress/compressors/FramedSnappyTestCase.java index 67b5c82..f8f04c4 100644 --- a/src/test/java/org/apache/commons/compress/compressors/FramedSnappyTestCase.java +++ b/src/test/java/org/apache/commons/compress/compressors/FramedSnappyTestCase.java @@ -92,7 +92,7 @@ public final class FramedSnappyTestCase final File original = getFile("bla.tar"); final FileInputStream written = new FileInputStream(output); try { - FileInputStream orig = new FileInputStream(original); + final FileInputStream orig = new FileInputStream(original); try { assertArrayEquals(IOUtils.toByteArray(written), IOUtils.toByteArray(orig)); http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/compressors/GZipTestCase.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/compress/compressors/GZipTestCase.java b/src/test/java/org/apache/commons/compress/compressors/GZipTestCase.java index 5f133ab..624abeb 100644 --- a/src/test/java/org/apache/commons/compress/compressors/GZipTestCase.java +++ b/src/test/java/org/apache/commons/compress/compressors/GZipTestCase.java @@ -135,7 +135,7 @@ public final class GZipTestCase extends AbstractTestCase { in.close(); out.close(); - byte[] data = ((ByteArrayOutputStream) out).toByteArray(); + final byte[] data = ((ByteArrayOutputStream) out).toByteArray(); in = new ByteArrayInputStream(data, 0, data.length - 1); cin = new CompressorStreamFactory() .createCompressorInputStream("gz", in); @@ -144,7 +144,7 @@ public final class GZipTestCase extends AbstractTestCase { try { IOUtils.copy(cin, out); fail("Expected an exception"); - } catch (IOException ioex) { + } catch (final IOException ioex) { // the whole point of the test } @@ -163,7 +163,7 @@ public final class GZipTestCase extends AbstractTestCase { @Test public void testInteroperabilityWithGzipCompressorInputStream() throws Exception { - FileInputStream fis = new FileInputStream(getFile("test3.xml")); + final FileInputStream fis = new FileInputStream(getFile("test3.xml")); byte[] content; try { content = IOUtils.toByteArray(fis); @@ -171,28 +171,28 @@ public final class GZipTestCase extends AbstractTestCase { fis.close(); } - ByteArrayOutputStream bout = new ByteArrayOutputStream(); + final ByteArrayOutputStream bout = new ByteArrayOutputStream(); - GzipParameters parameters = new GzipParameters(); + final GzipParameters parameters = new GzipParameters(); parameters.setCompressionLevel(Deflater.BEST_COMPRESSION); parameters.setOperatingSystem(3); parameters.setFilename("test3.xml"); parameters.setComment("Test file"); parameters.setModificationTime(System.currentTimeMillis()); - GzipCompressorOutputStream out = new GzipCompressorOutputStream(bout, parameters); + final GzipCompressorOutputStream out = new GzipCompressorOutputStream(bout, parameters); out.write(content); out.flush(); out.close(); - GzipCompressorInputStream in = new GzipCompressorInputStream(new ByteArrayInputStream(bout.toByteArray())); - byte[] content2 = IOUtils.toByteArray(in); + final GzipCompressorInputStream in = new GzipCompressorInputStream(new ByteArrayInputStream(bout.toByteArray())); + final byte[] content2 = IOUtils.toByteArray(in); Assert.assertArrayEquals("uncompressed content", content, content2); } @Test public void testInteroperabilityWithGZIPInputStream() throws Exception { - FileInputStream fis = new FileInputStream(getFile("test3.xml")); + final FileInputStream fis = new FileInputStream(getFile("test3.xml")); byte[] content; try { content = IOUtils.toByteArray(fis); @@ -200,45 +200,45 @@ public final class GZipTestCase extends AbstractTestCase { fis.close(); } - ByteArrayOutputStream bout = new ByteArrayOutputStream(); + final ByteArrayOutputStream bout = new ByteArrayOutputStream(); - GzipParameters parameters = new GzipParameters(); + final GzipParameters parameters = new GzipParameters(); parameters.setCompressionLevel(Deflater.BEST_COMPRESSION); parameters.setOperatingSystem(3); parameters.setFilename("test3.xml"); parameters.setComment("Test file"); parameters.setModificationTime(System.currentTimeMillis()); - GzipCompressorOutputStream out = new GzipCompressorOutputStream(bout, parameters); + final GzipCompressorOutputStream out = new GzipCompressorOutputStream(bout, parameters); out.write(content); out.flush(); out.close(); - GZIPInputStream in = new GZIPInputStream(new ByteArrayInputStream(bout.toByteArray())); - byte[] content2 = IOUtils.toByteArray(in); + final GZIPInputStream in = new GZIPInputStream(new ByteArrayInputStream(bout.toByteArray())); + final byte[] content2 = IOUtils.toByteArray(in); Assert.assertArrayEquals("uncompressed content", content, content2); } @Test public void testInvalidCompressionLevel() { - GzipParameters parameters = new GzipParameters(); + final GzipParameters parameters = new GzipParameters(); try { parameters.setCompressionLevel(10); fail("IllegalArgumentException not thrown"); - } catch (IllegalArgumentException e) { + } catch (final IllegalArgumentException e) { // expected } try { parameters.setCompressionLevel(-5); fail("IllegalArgumentException not thrown"); - } catch (IllegalArgumentException e) { + } catch (final IllegalArgumentException e) { // expected } } private void testExtraFlags(final int compressionLevel, final int flag) throws Exception { - FileInputStream fis = new FileInputStream(getFile("test3.xml")); + final FileInputStream fis = new FileInputStream(getFile("test3.xml")); byte[] content; try { content = IOUtils.toByteArray(fis); @@ -246,11 +246,11 @@ public final class GZipTestCase extends AbstractTestCase { fis.close(); } - ByteArrayOutputStream bout = new ByteArrayOutputStream(); + final ByteArrayOutputStream bout = new ByteArrayOutputStream(); - GzipParameters parameters = new GzipParameters(); + final GzipParameters parameters = new GzipParameters(); parameters.setCompressionLevel(compressionLevel); - GzipCompressorOutputStream out = new GzipCompressorOutputStream(bout, parameters); + final GzipCompressorOutputStream out = new GzipCompressorOutputStream(bout, parameters); IOUtils.copy(new ByteArrayInputStream(content), out); out.flush(); out.close(); @@ -275,28 +275,28 @@ public final class GZipTestCase extends AbstractTestCase { @Test public void testOverWrite() throws Exception { - GzipCompressorOutputStream out = new GzipCompressorOutputStream(new ByteArrayOutputStream()); + final GzipCompressorOutputStream out = new GzipCompressorOutputStream(new ByteArrayOutputStream()); out.close(); try { out.write(0); fail("IOException expected"); - } catch (IOException e) { + } catch (final IOException e) { // expected } } @Test public void testMetadataRoundTrip() throws Exception { - ByteArrayOutputStream bout = new ByteArrayOutputStream(); + final ByteArrayOutputStream bout = new ByteArrayOutputStream(); - GzipParameters parameters = new GzipParameters(); + final GzipParameters parameters = new GzipParameters(); parameters.setCompressionLevel(Deflater.BEST_COMPRESSION); parameters.setModificationTime(123456000); parameters.setOperatingSystem(13); parameters.setFilename("test3.xml"); parameters.setComment("Umlaute möglich?"); - GzipCompressorOutputStream out = new GzipCompressorOutputStream(bout, parameters); - FileInputStream fis = new FileInputStream(getFile("test3.xml")); + final GzipCompressorOutputStream out = new GzipCompressorOutputStream(bout, parameters); + final FileInputStream fis = new FileInputStream(getFile("test3.xml")); try { IOUtils.copy(fis, out); } finally { @@ -304,10 +304,10 @@ public final class GZipTestCase extends AbstractTestCase { out.close(); } - GzipCompressorInputStream input = + final GzipCompressorInputStream input = new GzipCompressorInputStream(new ByteArrayInputStream(bout.toByteArray())); input.close(); - GzipParameters readParams = input.getMetaData(); + final GzipParameters readParams = input.getMetaData(); assertEquals(Deflater.BEST_COMPRESSION, readParams.getCompressionLevel()); assertEquals(123456000, readParams.getModificationTime()); assertEquals(13, readParams.getOperatingSystem()); http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/compressors/Pack200TestCase.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/compress/compressors/Pack200TestCase.java b/src/test/java/org/apache/commons/compress/compressors/Pack200TestCase.java index 3f30f0d..22a0488 100644 --- a/src/test/java/org/apache/commons/compress/compressors/Pack200TestCase.java +++ b/src/test/java/org/apache/commons/compress/compressors/Pack200TestCase.java @@ -77,14 +77,14 @@ public final class Pack200TestCase extends AbstractTestCase { ArchiveEntry entry = in.getNextEntry(); while (entry != null) { - File archiveEntry = new File(dir, entry.getName()); + final File archiveEntry = new File(dir, entry.getName()); archiveEntry.getParentFile().mkdirs(); if (entry.isDirectory()) { archiveEntry.mkdir(); entry = in.getNextEntry(); continue; } - OutputStream out = new FileOutputStream(archiveEntry); + final OutputStream out = new FileOutputStream(archiveEntry); IOUtils.copy(in, out); out.close(); entry = in.getNextEntry(); @@ -136,7 +136,7 @@ public final class Pack200TestCase extends AbstractTestCase { try { final ArchiveInputStream in = new ArchiveStreamFactory() .createArchiveInputStream("jar", is); - List<String> files = new ArrayList<String>(); + final List<String> files = new ArrayList<String>(); files.add("testdata/test1.xml"); files.add("testdata/test2.xml"); checkArchiveContent(in, files); @@ -150,7 +150,7 @@ public final class Pack200TestCase extends AbstractTestCase { public void testGoodSignature() throws Exception { final InputStream is = new FileInputStream(getFile("bla.pack")); try { - byte[] sig = new byte[4]; + final byte[] sig = new byte[4]; is.read(sig); assertTrue(Pack200CompressorInputStream.matches(sig, 4)); } finally { @@ -162,7 +162,7 @@ public final class Pack200TestCase extends AbstractTestCase { public void testBadSignature() throws Exception { final InputStream is = new FileInputStream(getFile("bla.jar")); try { - byte[] sig = new byte[4]; + final byte[] sig = new byte[4]; is.read(sig); assertFalse(Pack200CompressorInputStream.matches(sig, 4)); } finally { @@ -174,7 +174,7 @@ public final class Pack200TestCase extends AbstractTestCase { public void testShortSignature() throws Exception { final InputStream is = new FileInputStream(getFile("bla.pack")); try { - byte[] sig = new byte[2]; + final byte[] sig = new byte[2]; is.read(sig); assertFalse(Pack200CompressorInputStream.matches(sig, 2)); } finally { @@ -184,7 +184,7 @@ public final class Pack200TestCase extends AbstractTestCase { @Test public void testInputStreamMethods() throws Exception { - Map<String, String> m = new HashMap<String, String>(); + final Map<String, String> m = new HashMap<String, String>(); m.put("foo", "bar"); final InputStream is = new Pack200CompressorInputStream(new FileInputStream(getFile("bla.jar")), @@ -195,7 +195,7 @@ public final class Pack200TestCase extends AbstractTestCase { assertTrue(is.markSupported()); is.mark(5); assertEquals(0x50, is.read()); - byte[] rest = new byte[3]; + final byte[] rest = new byte[3]; assertEquals(3, is.read(rest)); assertEquals(0x4b, rest[0]); assertEquals(3, rest[1]); @@ -212,7 +212,7 @@ public final class Pack200TestCase extends AbstractTestCase { @Test public void testOutputStreamMethods() throws Exception { final File output = new File(dir, "bla.pack"); - Map<String, String> m = new HashMap<String, String>(); + final Map<String, String> m = new HashMap<String, String>(); m.put("foo", "bar"); final OutputStream out = new FileOutputStream(output); try { http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/compressors/XZTestCase.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/compress/compressors/XZTestCase.java b/src/test/java/org/apache/commons/compress/compressors/XZTestCase.java index 2a86b3f..6718340 100644 --- a/src/test/java/org/apache/commons/compress/compressors/XZTestCase.java +++ b/src/test/java/org/apache/commons/compress/compressors/XZTestCase.java @@ -36,7 +36,7 @@ public final class XZTestCase extends AbstractTestCase { @Test public void testXZCreation() throws Exception { - long max = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getMax(); + final long max = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getMax(); System.out.println("XZTestCase: HeapMax="+max+" bytes "+(double)max/(1024*1024)+" MB"); final File input = getFile("test1.xml"); final File output = new File(dir, "test1.xml.xz");