You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by bo...@apache.org on 2016/04/10 06:18:56 UTC
[40/46] commons-compress git commit: Add final modifier to local
variables.
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/archivers/ExceptionMessageTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/archivers/ExceptionMessageTest.java b/src/test/java/org/apache/commons/compress/archivers/ExceptionMessageTest.java
index 36289be..e64d792 100644
--- a/src/test/java/org/apache/commons/compress/archivers/ExceptionMessageTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/ExceptionMessageTest.java
@@ -35,9 +35,9 @@ public class ExceptionMessageTest {
try{
new ArchiveStreamFactory().createArchiveInputStream(null, System.in);
fail("Should raise an IllegalArgumentException.");
- }catch (IllegalArgumentException e) {
+ }catch (final IllegalArgumentException e) {
assertEquals(ARCHIVER_NULL_MESSAGE, e.getMessage());
- } catch (ArchiveException e) {
+ } catch (final ArchiveException e) {
fail("ArchiveException not expected");
}
}
@@ -47,9 +47,9 @@ public class ExceptionMessageTest {
try{
new ArchiveStreamFactory().createArchiveInputStream("zip", null);
fail("Should raise an IllegalArgumentException.");
- }catch (IllegalArgumentException e) {
+ }catch (final IllegalArgumentException e) {
assertEquals(INPUTSTREAM_NULL_MESSAGE, e.getMessage());
- } catch (ArchiveException e) {
+ } catch (final ArchiveException e) {
fail("ArchiveException not expected");
}
}
@@ -59,9 +59,9 @@ public class ExceptionMessageTest {
try{
new ArchiveStreamFactory().createArchiveOutputStream(null, System.out);
fail("Should raise an IllegalArgumentException.");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
assertEquals(ARCHIVER_NULL_MESSAGE, e.getMessage());
- } catch (ArchiveException e){
+ } catch (final ArchiveException e){
fail("ArchiveException not expected");
}
}
@@ -71,9 +71,9 @@ public class ExceptionMessageTest {
try{
new ArchiveStreamFactory().createArchiveOutputStream("zip", null);
fail("Should raise an IllegalArgumentException.");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
assertEquals(OUTPUTSTREAM_NULL_MESSAGE, e.getMessage());
- } catch (ArchiveException e) {
+ } catch (final ArchiveException e) {
fail("ArchiveException not expected");
}
}
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/archivers/JarTestCase.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/archivers/JarTestCase.java b/src/test/java/org/apache/commons/compress/archivers/JarTestCase.java
index ef06021..3717e7a 100644
--- a/src/test/java/org/apache/commons/compress/archivers/JarTestCase.java
+++ b/src/test/java/org/apache/commons/compress/archivers/JarTestCase.java
@@ -93,14 +93,14 @@ public final class JarTestCase 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();
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/archivers/LongPathTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/archivers/LongPathTest.java b/src/test/java/org/apache/commons/compress/archivers/LongPathTest.java
index b7807dc..a363c3a 100644
--- a/src/test/java/org/apache/commons/compress/archivers/LongPathTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/LongPathTest.java
@@ -67,9 +67,9 @@ public class LongPathTest extends AbstractTestCase {
@BeforeClass
public static void setUpFileList() throws Exception {
assertTrue(ARCDIR.exists());
- File listing= new File(ARCDIR,"files.txt");
+ final File listing= new File(ARCDIR,"files.txt");
assertTrue("files.txt is readable",listing.canRead());
- BufferedReader br = new BufferedReader(new FileReader(listing));
+ final BufferedReader br = new BufferedReader(new FileReader(listing));
String line;
while ((line=br.readLine())!=null){
if (!line.startsWith("#")){
@@ -81,8 +81,8 @@ public class LongPathTest extends AbstractTestCase {
@Parameters(name = "file={0}")
public static Collection<Object[]> data() {
- Collection<Object[]> params = new ArrayList<Object[]>();
- for (String f : ARCDIR.list(new FilenameFilter() {
+ final Collection<Object[]> params = new ArrayList<Object[]>();
+ for (final String f : ARCDIR.list(new FilenameFilter() {
@Override
public boolean accept(final File dir, final String name) {
return !name.endsWith(".txt");
@@ -97,7 +97,7 @@ public class LongPathTest extends AbstractTestCase {
@Override
protected String getExpectedString(final ArchiveEntry entry) {
if (entry instanceof TarArchiveEntry) {
- TarArchiveEntry tarEntry = (TarArchiveEntry) entry;
+ final TarArchiveEntry tarEntry = (TarArchiveEntry) entry;
if (tarEntry.isSymbolicLink()) {
return tarEntry.getName() + " -> " + tarEntry.getLinkName();
}
@@ -108,13 +108,14 @@ public class LongPathTest extends AbstractTestCase {
@Test
public void testArchive() throws Exception {
@SuppressWarnings("unchecked") // fileList is of correct type
+ final
ArrayList<String> expected = (ArrayList<String>) FILELIST.clone();
- String name = file.getName();
+ final String name = file.getName();
if ("minotaur.jar".equals(name) || "minotaur-0.jar".equals(name)){
expected.add("META-INF/");
expected.add("META-INF/MANIFEST.MF");
}
- ArchiveInputStream ais = factory.createArchiveInputStream(new BufferedInputStream(new FileInputStream(file)));
+ final ArchiveInputStream ais = factory.createArchiveInputStream(new BufferedInputStream(new FileInputStream(file)));
// check if expected type recognised
if (name.endsWith(".tar")){
assertTrue(ais instanceof TarArchiveInputStream);
@@ -124,7 +125,7 @@ public class LongPathTest extends AbstractTestCase {
assertTrue(ais instanceof CpioArchiveInputStream);
// Hack: cpio does not add trailing "/" to directory names
for(int i=0; i < expected.size(); i++){
- String ent = expected.get(i);
+ final String ent = expected.get(i);
if (ent.endsWith("/")){
expected.set(i, ent.substring(0, ent.length()-1));
}
@@ -133,7 +134,7 @@ public class LongPathTest extends AbstractTestCase {
assertTrue(ais instanceof ArArchiveInputStream);
// CPIO does not store directories or directory names
expected.clear();
- for (String ent : FILELIST) {
+ for (final String ent : FILELIST) {
if (!ent.endsWith("/")) {// not a directory
final int lastSlash = ent.lastIndexOf('/');
if (lastSlash >= 0) { // extract path name
@@ -148,7 +149,7 @@ public class LongPathTest extends AbstractTestCase {
}
try {
checkArchiveContent(ais, expected);
- } catch (AssertionFailedError e) {
+ } catch (final AssertionFailedError e) {
fail("Error processing "+file.getName()+" "+e);
} finally {
ais.close();
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/archivers/LongSymLinkTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/archivers/LongSymLinkTest.java b/src/test/java/org/apache/commons/compress/archivers/LongSymLinkTest.java
index e1612db..6237de8 100644
--- a/src/test/java/org/apache/commons/compress/archivers/LongSymLinkTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/LongSymLinkTest.java
@@ -67,9 +67,9 @@ public class LongSymLinkTest extends AbstractTestCase {
@BeforeClass
public static void setUpFileList() throws Exception {
assertTrue(ARCDIR.exists());
- File listing= new File(ARCDIR,"files.txt");
+ final File listing= new File(ARCDIR,"files.txt");
assertTrue("files.txt is readable",listing.canRead());
- BufferedReader br = new BufferedReader(new FileReader(listing));
+ final BufferedReader br = new BufferedReader(new FileReader(listing));
String line;
while ((line=br.readLine())!=null){
if (!line.startsWith("#")){
@@ -81,8 +81,8 @@ public class LongSymLinkTest extends AbstractTestCase {
@Parameters(name = "file={0}")
public static Collection<Object[]> data() {
- Collection<Object[]> params = new ArrayList<Object[]>();
- for (String f : ARCDIR.list(new FilenameFilter() {
+ final Collection<Object[]> params = new ArrayList<Object[]>();
+ for (final String f : ARCDIR.list(new FilenameFilter() {
@Override
public boolean accept(final File dir, final String name) {
return !name.endsWith(".txt");
@@ -98,7 +98,7 @@ public class LongSymLinkTest extends AbstractTestCase {
@Override
protected String getExpectedString(final ArchiveEntry entry) {
if (entry instanceof TarArchiveEntry) {
- TarArchiveEntry tarEntry = (TarArchiveEntry) entry;
+ final TarArchiveEntry tarEntry = (TarArchiveEntry) entry;
if (tarEntry.isSymbolicLink()) {
return tarEntry.getName() + " -> " + tarEntry.getLinkName();
}
@@ -109,13 +109,14 @@ public class LongSymLinkTest extends AbstractTestCase {
@Test
public void testArchive() throws Exception {
@SuppressWarnings("unchecked") // fileList is of correct type
+ final
ArrayList<String> expected = (ArrayList<String>) FILELIST.clone();
- String name = file.getName();
+ final String name = file.getName();
if ("minotaur.jar".equals(name) || "minotaur-0.jar".equals(name)){
expected.add("META-INF/");
expected.add("META-INF/MANIFEST.MF");
}
- ArchiveInputStream ais = factory.createArchiveInputStream(new BufferedInputStream(new FileInputStream(file)));
+ final ArchiveInputStream ais = factory.createArchiveInputStream(new BufferedInputStream(new FileInputStream(file)));
// check if expected type recognised
if (name.endsWith(".tar")){
assertTrue(ais instanceof TarArchiveInputStream);
@@ -125,7 +126,7 @@ public class LongSymLinkTest extends AbstractTestCase {
assertTrue(ais instanceof CpioArchiveInputStream);
// Hack: cpio does not add trailing "/" to directory names
for(int i=0; i < expected.size(); i++){
- String ent = expected.get(i);
+ final String ent = expected.get(i);
if (ent.endsWith("/")){
expected.set(i, ent.substring(0, ent.length()-1));
}
@@ -134,7 +135,7 @@ public class LongSymLinkTest extends AbstractTestCase {
assertTrue(ais instanceof ArArchiveInputStream);
// CPIO does not store directories or directory names
expected.clear();
- for (String ent : FILELIST) {
+ for (final String ent : FILELIST) {
if (!ent.endsWith("/")) {// not a directory
final int lastSlash = ent.lastIndexOf('/');
if (lastSlash >= 0) { // extract path name
@@ -149,7 +150,7 @@ public class LongSymLinkTest extends AbstractTestCase {
}
try {
checkArchiveContent(ais, expected);
- } catch (AssertionFailedError e) {
+ } catch (final AssertionFailedError e) {
fail("Error processing "+file.getName()+" "+e);
} finally {
ais.close();
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/archivers/TarTestCase.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/archivers/TarTestCase.java b/src/test/java/org/apache/commons/compress/archivers/TarTestCase.java
index f1d2b51..4792583 100644
--- a/src/test/java/org/apache/commons/compress/archivers/TarTestCase.java
+++ b/src/test/java/org/apache/commons/compress/archivers/TarTestCase.java
@@ -59,8 +59,8 @@ public final class TarTestCase extends AbstractTestCase {
@Test
public void testTarArchiveLongNameCreation() throws Exception {
- String name = "testdata/12345678901234567890123456789012345678901234567890123456789012345678901234567890123456.xml";
- byte[] bytes = name.getBytes(CharsetNames.UTF_8);
+ final String name = "testdata/12345678901234567890123456789012345678901234567890123456789012345678901234567890123456.xml";
+ final byte[] bytes = name.getBytes(CharsetNames.UTF_8);
assertEquals(bytes.length, 99);
final File output = new File(dir, "bla.tar");
@@ -76,7 +76,7 @@ public final class TarTestCase extends AbstractTestCase {
entry.setGroupName("excalibur");
entry.setMode(0100000);
os.putArchiveEntry(entry);
- FileInputStream in = new FileInputStream(file1);
+ final FileInputStream in = new FileInputStream(file1);
IOUtils.copy(in, os);
os.closeArchiveEntry();
os.close();
@@ -86,7 +86,7 @@ public final class TarTestCase extends AbstractTestCase {
ArchiveOutputStream os2 = null;
try {
- String toLongName = "testdata/123456789012345678901234567890123456789012345678901234567890123456789012345678901234567.xml";
+ final String toLongName = "testdata/123456789012345678901234567890123456789012345678901234567890123456789012345678901234567.xml";
final File output2 = new File(dir, "bla.tar");
final OutputStream out2 = new FileOutputStream(output2);
os2 = new ArchiveStreamFactory().createArchiveOutputStream("tar", out2);
@@ -101,7 +101,7 @@ public final class TarTestCase extends AbstractTestCase {
os2.putArchiveEntry(entry);
IOUtils.copy(new FileInputStream(file1), os2);
os2.closeArchiveEntry();
- } catch(IOException e) {
+ } catch(final IOException e) {
assertTrue(true);
} finally {
if (os2 != null){
@@ -137,7 +137,7 @@ public final class TarTestCase extends AbstractTestCase {
@Test
public void testDirectoryEntryFromFile() throws Exception {
- File[] tmp = createTempDirAndFile();
+ final File[] tmp = createTempDirAndFile();
File archive = null;
TarArchiveOutputStream tos = null;
TarArchiveInputStream tis = null;
@@ -145,14 +145,14 @@ public final class TarTestCase extends AbstractTestCase {
archive = File.createTempFile("test.", ".tar", tmp[0]);
archive.deleteOnExit();
tos = new TarArchiveOutputStream(new FileOutputStream(archive));
- long beforeArchiveWrite = tmp[0].lastModified();
- TarArchiveEntry in = new TarArchiveEntry(tmp[0], "foo");
+ final long beforeArchiveWrite = tmp[0].lastModified();
+ final TarArchiveEntry in = new TarArchiveEntry(tmp[0], "foo");
tos.putArchiveEntry(in);
tos.closeArchiveEntry();
tos.close();
tos = null;
tis = new TarArchiveInputStream(new FileInputStream(archive));
- TarArchiveEntry out = tis.getNextTarEntry();
+ final TarArchiveEntry out = tis.getNextTarEntry();
tis.close();
tis = null;
assertNotNull(out);
@@ -177,7 +177,7 @@ public final class TarTestCase extends AbstractTestCase {
@Test
public void testExplicitDirectoryEntry() throws Exception {
- File[] tmp = createTempDirAndFile();
+ final File[] tmp = createTempDirAndFile();
File archive = null;
TarArchiveOutputStream tos = null;
TarArchiveInputStream tis = null;
@@ -185,15 +185,15 @@ public final class TarTestCase extends AbstractTestCase {
archive = File.createTempFile("test.", ".tar", tmp[0]);
archive.deleteOnExit();
tos = new TarArchiveOutputStream(new FileOutputStream(archive));
- long beforeArchiveWrite = tmp[0].lastModified();
- TarArchiveEntry in = new TarArchiveEntry("foo/");
+ final long beforeArchiveWrite = tmp[0].lastModified();
+ final TarArchiveEntry in = new TarArchiveEntry("foo/");
in.setModTime(beforeArchiveWrite);
tos.putArchiveEntry(in);
tos.closeArchiveEntry();
tos.close();
tos = null;
tis = new TarArchiveInputStream(new FileInputStream(archive));
- TarArchiveEntry out = tis.getNextTarEntry();
+ final TarArchiveEntry out = tis.getNextTarEntry();
tis.close();
tis = null;
assertNotNull(out);
@@ -217,7 +217,7 @@ public final class TarTestCase extends AbstractTestCase {
@Test
public void testFileEntryFromFile() throws Exception {
- File[] tmp = createTempDirAndFile();
+ final File[] tmp = createTempDirAndFile();
File archive = null;
TarArchiveOutputStream tos = null;
TarArchiveInputStream tis = null;
@@ -226,9 +226,9 @@ public final class TarTestCase extends AbstractTestCase {
archive = File.createTempFile("test.", ".tar", tmp[0]);
archive.deleteOnExit();
tos = new TarArchiveOutputStream(new FileOutputStream(archive));
- TarArchiveEntry in = new TarArchiveEntry(tmp[1], "foo");
+ final TarArchiveEntry in = new TarArchiveEntry(tmp[1], "foo");
tos.putArchiveEntry(in);
- byte[] b = new byte[(int) tmp[1].length()];
+ final byte[] b = new byte[(int) tmp[1].length()];
fis = new FileInputStream(tmp[1]);
while (fis.read(b) > 0) {
tos.write(b);
@@ -239,7 +239,7 @@ public final class TarTestCase extends AbstractTestCase {
tos.close();
tos = null;
tis = new TarArchiveInputStream(new FileInputStream(archive));
- TarArchiveEntry out = tis.getNextTarEntry();
+ final TarArchiveEntry out = tis.getNextTarEntry();
tis.close();
tis = null;
assertNotNull(out);
@@ -266,7 +266,7 @@ public final class TarTestCase extends AbstractTestCase {
@Test
public void testExplicitFileEntry() throws Exception {
- File[] tmp = createTempDirAndFile();
+ final File[] tmp = createTempDirAndFile();
File archive = null;
TarArchiveOutputStream tos = null;
TarArchiveInputStream tis = null;
@@ -275,11 +275,11 @@ public final class TarTestCase extends AbstractTestCase {
archive = File.createTempFile("test.", ".tar", tmp[0]);
archive.deleteOnExit();
tos = new TarArchiveOutputStream(new FileOutputStream(archive));
- TarArchiveEntry in = new TarArchiveEntry("foo");
+ final TarArchiveEntry in = new TarArchiveEntry("foo");
in.setModTime(tmp[1].lastModified());
in.setSize(tmp[1].length());
tos.putArchiveEntry(in);
- byte[] b = new byte[(int) tmp[1].length()];
+ final byte[] b = new byte[(int) tmp[1].length()];
fis = new FileInputStream(tmp[1]);
while (fis.read(b) > 0) {
tos.write(b);
@@ -290,7 +290,7 @@ public final class TarTestCase extends AbstractTestCase {
tos.close();
tos = null;
tis = new TarArchiveInputStream(new FileInputStream(archive));
- TarArchiveEntry out = tis.getNextTarEntry();
+ final TarArchiveEntry out = tis.getNextTarEntry();
tis.close();
tis = null;
assertNotNull(out);
@@ -323,8 +323,8 @@ public final class TarTestCase extends AbstractTestCase {
try {
in.getNextEntry();
fail("Expected IOException");
- } catch (IOException e) {
- Throwable t = e.getCause();
+ } catch (final IOException e) {
+ final Throwable t = e.getCause();
assertTrue("Expected cause = IllegalArgumentException", t instanceof IllegalArgumentException);
}
in.close();
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java b/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java
index b87b291..88584fd 100644
--- a/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java
+++ b/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java
@@ -77,7 +77,7 @@ public final class ZipTestCase extends AbstractTestCase {
out.close();
// Unarchive the same
- List<File> results = new ArrayList<File>();
+ final List<File> results = new ArrayList<File>();
final InputStream is = new FileInputStream(output);
ArchiveInputStream in = null;
@@ -87,9 +87,9 @@ public final class ZipTestCase extends AbstractTestCase {
ZipArchiveEntry entry = null;
while((entry = (ZipArchiveEntry)in.getNextEntry()) != null) {
- File outfile = new File(resultDir.getCanonicalPath() + "/result/" + entry.getName());
+ final File outfile = new File(resultDir.getCanonicalPath() + "/result/" + entry.getName());
outfile.getParentFile().mkdirs();
- OutputStream o = new FileOutputStream(outfile);
+ final OutputStream o = new FileOutputStream(outfile);
try {
IOUtils.copy(in, o);
} finally {
@@ -135,8 +135,8 @@ public final class ZipTestCase extends AbstractTestCase {
@Test
public void testSkipsPK00Prefix() throws Exception {
final File input = getFile("COMPRESS-208.zip");
- InputStream is = new FileInputStream(input);
- ArrayList<String> al = new ArrayList<String>();
+ final InputStream is = new FileInputStream(input);
+ final ArrayList<String> al = new ArrayList<String>();
al.add("test1.xml");
al.add("test2.xml");
try {
@@ -159,8 +159,8 @@ public final class ZipTestCase extends AbstractTestCase {
bla.close();
*/
- ZipFile moby = new ZipFile(getFile("moby.zip"));
- ZipArchiveEntry entry = moby.getEntry("README");
+ final ZipFile moby = new ZipFile(getFile("moby.zip"));
+ final ZipArchiveEntry entry = moby.getEntry("README");
assertEquals("method", ZipMethod.TOKENIZATION.getCode(), entry.getMethod());
assertFalse(moby.canReadEntryData(entry));
moby.close();
@@ -177,16 +177,16 @@ public final class ZipTestCase extends AbstractTestCase {
@Test
public void testSkipEntryWithUnsupportedCompressionMethod()
throws IOException {
- ZipArchiveInputStream zip =
+ final ZipArchiveInputStream zip =
new ZipArchiveInputStream(new FileInputStream(getFile("moby.zip")));
try {
- ZipArchiveEntry entry = zip.getNextZipEntry();
+ final ZipArchiveEntry entry = zip.getNextZipEntry();
assertEquals("method", ZipMethod.TOKENIZATION.getCode(), entry.getMethod());
assertEquals("README", entry.getName());
assertFalse(zip.canReadEntryData(entry));
try {
assertNull(zip.getNextZipEntry());
- } catch (IOException e) {
+ } catch (final IOException e) {
e.printStackTrace();
fail("COMPRESS-93: Unable to skip an unsupported zip entry");
}
@@ -208,7 +208,7 @@ public final class ZipTestCase extends AbstractTestCase {
public void testListAllFilesWithNestedArchive() throws Exception {
final File input = getFile("OSX_ArchiveWithNestedArchive.zip");
- List<String> results = new ArrayList<String>();
+ final List<String> results = new ArrayList<String>();
final InputStream is = new FileInputStream(input);
ArchiveInputStream in = null;
@@ -219,7 +219,7 @@ public final class ZipTestCase extends AbstractTestCase {
while((entry = (ZipArchiveEntry)in.getNextEntry()) != null) {
results.add(entry.getName());
- ArchiveInputStream nestedIn = new ArchiveStreamFactory().createArchiveInputStream("zip", in);
+ final ArchiveInputStream nestedIn = new ArchiveStreamFactory().createArchiveInputStream("zip", in);
ZipArchiveEntry nestedEntry = null;
while((nestedEntry = (ZipArchiveEntry)nestedIn.getNextEntry()) != null) {
results.add(nestedEntry.getName());
@@ -241,7 +241,7 @@ public final class ZipTestCase extends AbstractTestCase {
@Test
public void testDirectoryEntryFromFile() throws Exception {
- File[] tmp = createTempDirAndFile();
+ final File[] tmp = createTempDirAndFile();
File archive = null;
ZipArchiveOutputStream zos = null;
ZipFile zf = null;
@@ -249,14 +249,14 @@ public final class ZipTestCase extends AbstractTestCase {
archive = File.createTempFile("test.", ".zip", tmp[0]);
archive.deleteOnExit();
zos = new ZipArchiveOutputStream(archive);
- long beforeArchiveWrite = tmp[0].lastModified();
- ZipArchiveEntry in = new ZipArchiveEntry(tmp[0], "foo");
+ final long beforeArchiveWrite = tmp[0].lastModified();
+ final ZipArchiveEntry in = new ZipArchiveEntry(tmp[0], "foo");
zos.putArchiveEntry(in);
zos.closeArchiveEntry();
zos.close();
zos = null;
zf = new ZipFile(archive);
- ZipArchiveEntry out = zf.getEntry("foo/");
+ final ZipArchiveEntry out = zf.getEntry("foo/");
assertNotNull(out);
assertEquals("foo/", out.getName());
assertEquals(0, out.getSize());
@@ -277,7 +277,7 @@ public final class ZipTestCase extends AbstractTestCase {
@Test
public void testExplicitDirectoryEntry() throws Exception {
- File[] tmp = createTempDirAndFile();
+ final File[] tmp = createTempDirAndFile();
File archive = null;
ZipArchiveOutputStream zos = null;
ZipFile zf = null;
@@ -285,15 +285,15 @@ public final class ZipTestCase extends AbstractTestCase {
archive = File.createTempFile("test.", ".zip", tmp[0]);
archive.deleteOnExit();
zos = new ZipArchiveOutputStream(archive);
- long beforeArchiveWrite = tmp[0].lastModified();
- ZipArchiveEntry in = new ZipArchiveEntry("foo/");
+ final long beforeArchiveWrite = tmp[0].lastModified();
+ final ZipArchiveEntry in = new ZipArchiveEntry("foo/");
in.setTime(beforeArchiveWrite);
zos.putArchiveEntry(in);
zos.closeArchiveEntry();
zos.close();
zos = null;
zf = new ZipFile(archive);
- ZipArchiveEntry out = zf.getEntry("foo/");
+ final ZipArchiveEntry out = zf.getEntry("foo/");
assertNotNull(out);
assertEquals("foo/", out.getName());
assertEquals(0, out.getSize());
@@ -323,23 +323,23 @@ public final class ZipTestCase extends AbstractTestCase {
public void testCopyRawEntriesFromFile()
throws IOException {
- File[] tmp = createTempDirAndFile();
- File reference = createReferenceFile(tmp[0], Zip64Mode.Never, "expected.");
+ final File[] tmp = createTempDirAndFile();
+ final File reference = createReferenceFile(tmp[0], Zip64Mode.Never, "expected.");
- File a1 = File.createTempFile("src1.", ".zip", tmp[0]);
- ZipArchiveOutputStream zos = new ZipArchiveOutputStream(a1);
+ final File a1 = File.createTempFile("src1.", ".zip", tmp[0]);
+ final ZipArchiveOutputStream zos = new ZipArchiveOutputStream(a1);
zos.setUseZip64(Zip64Mode.Never);
createFirstEntry(zos).close();
- File a2 = File.createTempFile("src2.", ".zip", tmp[0]);
- ZipArchiveOutputStream zos1 = new ZipArchiveOutputStream(a2);
+ final File a2 = File.createTempFile("src2.", ".zip", tmp[0]);
+ final ZipArchiveOutputStream zos1 = new ZipArchiveOutputStream(a2);
zos1.setUseZip64(Zip64Mode.Never);
createSecondEntry(zos1).close();
- ZipFile zf1 = new ZipFile(a1);
- ZipFile zf2 = new ZipFile(a2);
- File fileResult = File.createTempFile("file-actual.", ".zip", tmp[0]);
- ZipArchiveOutputStream zos2 = new ZipArchiveOutputStream(fileResult);
+ final ZipFile zf1 = new ZipFile(a1);
+ final ZipFile zf2 = new ZipFile(a2);
+ final File fileResult = File.createTempFile("file-actual.", ".zip", tmp[0]);
+ final ZipArchiveOutputStream zos2 = new ZipArchiveOutputStream(fileResult);
zf1.copyRawEntries(zos2, allFilesPredicate);
zf2.copyRawEntries(zos2, allFilesPredicate);
zos2.close();
@@ -355,21 +355,21 @@ public final class ZipTestCase extends AbstractTestCase {
public void testCopyRawZip64EntryFromFile()
throws IOException {
- File[] tmp = createTempDirAndFile();
- File reference = File.createTempFile("z64reference.", ".zip", tmp[0]);
- ZipArchiveOutputStream zos1 = new ZipArchiveOutputStream(reference);
+ final File[] tmp = createTempDirAndFile();
+ final File reference = File.createTempFile("z64reference.", ".zip", tmp[0]);
+ final ZipArchiveOutputStream zos1 = new ZipArchiveOutputStream(reference);
zos1.setUseZip64(Zip64Mode.Always);
createFirstEntry(zos1);
zos1.close();
- File a1 = File.createTempFile("zip64src.", ".zip", tmp[0]);
- ZipArchiveOutputStream zos = new ZipArchiveOutputStream(a1);
+ final File a1 = File.createTempFile("zip64src.", ".zip", tmp[0]);
+ final ZipArchiveOutputStream zos = new ZipArchiveOutputStream(a1);
zos.setUseZip64(Zip64Mode.Always);
createFirstEntry(zos).close();
- ZipFile zf1 = new ZipFile(a1);
- File fileResult = File.createTempFile("file-actual.", ".zip", tmp[0]);
- ZipArchiveOutputStream zos2 = new ZipArchiveOutputStream(fileResult);
+ final ZipFile zf1 = new ZipFile(a1);
+ final File fileResult = File.createTempFile("file-actual.", ".zip", tmp[0]);
+ final ZipArchiveOutputStream zos2 = new ZipArchiveOutputStream(fileResult);
zos2.setUseZip64(Zip64Mode.Always);
zf1.copyRawEntries(zos2, allFilesPredicate);
zos2.close();
@@ -380,26 +380,26 @@ public final class ZipTestCase extends AbstractTestCase {
@Test
public void testUnixModeInAddRaw() throws IOException {
- File[] tmp = createTempDirAndFile();
+ final File[] tmp = createTempDirAndFile();
- File a1 = File.createTempFile("unixModeBits.", ".zip", tmp[0]);
- ZipArchiveOutputStream zos = new ZipArchiveOutputStream(a1);
+ final File a1 = File.createTempFile("unixModeBits.", ".zip", tmp[0]);
+ final ZipArchiveOutputStream zos = new ZipArchiveOutputStream(a1);
- ZipArchiveEntry archiveEntry = new ZipArchiveEntry("fred");
+ final ZipArchiveEntry archiveEntry = new ZipArchiveEntry("fred");
archiveEntry.setUnixMode(0664);
archiveEntry.setMethod(ZipEntry.DEFLATED);
zos.addRawArchiveEntry(archiveEntry, new ByteArrayInputStream("fud".getBytes()));
zos.close();
- ZipFile zf1 = new ZipFile(a1);
- ZipArchiveEntry fred = zf1.getEntry("fred");
+ final ZipFile zf1 = new ZipFile(a1);
+ final ZipArchiveEntry fred = zf1.getEntry("fred");
assertEquals(0664, fred.getUnixMode());
zf1.close();
}
private File createReferenceFile(final File directory, final Zip64Mode zipMode, final String prefix) throws IOException {
- File reference = File.createTempFile(prefix, ".zip", directory);
- ZipArchiveOutputStream zos = new ZipArchiveOutputStream(reference);
+ final File reference = File.createTempFile(prefix, ".zip", directory);
+ final ZipArchiveOutputStream zos = new ZipArchiveOutputStream(reference);
zos.setUseZip64(zipMode);
createFirstEntry(zos);
createSecondEntry(zos);
@@ -419,18 +419,18 @@ public final class ZipTestCase extends AbstractTestCase {
private void assertSameFileContents(final File expectedFile, final File actualFile) throws IOException {
- int size = (int) Math.max(expectedFile.length(), actualFile.length());
- ZipFile expected = new ZipFile(expectedFile);
- ZipFile actual = new ZipFile(actualFile);
- byte[] expectedBuf = new byte[size];
- byte[] actualBuf = new byte[size];
+ final int size = (int) Math.max(expectedFile.length(), actualFile.length());
+ final ZipFile expected = new ZipFile(expectedFile);
+ final ZipFile actual = new ZipFile(actualFile);
+ final byte[] expectedBuf = new byte[size];
+ final byte[] actualBuf = new byte[size];
- Enumeration<ZipArchiveEntry> actualInOrder = actual.getEntriesInPhysicalOrder();
- Enumeration<ZipArchiveEntry> expectedInOrder = expected.getEntriesInPhysicalOrder();
+ final Enumeration<ZipArchiveEntry> actualInOrder = actual.getEntriesInPhysicalOrder();
+ final Enumeration<ZipArchiveEntry> expectedInOrder = expected.getEntriesInPhysicalOrder();
while (actualInOrder.hasMoreElements()){
- ZipArchiveEntry actualElement = actualInOrder.nextElement();
- ZipArchiveEntry expectedElement = expectedInOrder.nextElement();
+ final ZipArchiveEntry actualElement = actualInOrder.nextElement();
+ final ZipArchiveEntry expectedElement = expectedInOrder.nextElement();
assertEquals( expectedElement.getName(), actualElement.getName());
// Don't compare timestamps since they may vary;
// there's no support for stubbed out clock (TimeSource) in ZipArchiveOutputStream
@@ -442,8 +442,8 @@ public final class ZipTestCase extends AbstractTestCase {
assertEquals( expectedElement.getExternalAttributes(), actualElement.getExternalAttributes());
assertEquals( expectedElement.getInternalAttributes(), actualElement.getInternalAttributes());
- InputStream actualIs = actual.getInputStream(actualElement);
- InputStream expectedIs = expected.getInputStream(expectedElement);
+ final InputStream actualIs = actual.getInputStream(actualElement);
+ final InputStream expectedIs = expected.getInputStream(expectedElement);
IOUtils.readFully(expectedIs, expectedBuf);
IOUtils.readFully(actualIs, actualBuf);
expectedIs.close();
@@ -458,7 +458,7 @@ public final class ZipTestCase extends AbstractTestCase {
private void createArchiveEntry(final String payload, final ZipArchiveOutputStream zos, final String name)
throws IOException {
- ZipArchiveEntry in = new ZipArchiveEntry(name);
+ final ZipArchiveEntry in = new ZipArchiveEntry(name);
zos.putArchiveEntry(in);
zos.write(payload.getBytes());
@@ -467,7 +467,7 @@ public final class ZipTestCase extends AbstractTestCase {
@Test
public void testFileEntryFromFile() throws Exception {
- File[] tmp = createTempDirAndFile();
+ final File[] tmp = createTempDirAndFile();
File archive = null;
ZipArchiveOutputStream zos = null;
ZipFile zf = null;
@@ -476,9 +476,9 @@ public final class ZipTestCase extends AbstractTestCase {
archive = File.createTempFile("test.", ".zip", tmp[0]);
archive.deleteOnExit();
zos = new ZipArchiveOutputStream(archive);
- ZipArchiveEntry in = new ZipArchiveEntry(tmp[1], "foo");
+ final ZipArchiveEntry in = new ZipArchiveEntry(tmp[1], "foo");
zos.putArchiveEntry(in);
- byte[] b = new byte[(int) tmp[1].length()];
+ final byte[] b = new byte[(int) tmp[1].length()];
fis = new FileInputStream(tmp[1]);
while (fis.read(b) > 0) {
zos.write(b);
@@ -489,7 +489,7 @@ public final class ZipTestCase extends AbstractTestCase {
zos.close();
zos = null;
zf = new ZipFile(archive);
- ZipArchiveEntry out = zf.getEntry("foo");
+ final ZipArchiveEntry out = zf.getEntry("foo");
assertNotNull(out);
assertEquals("foo", out.getName());
assertEquals(tmp[1].length(), out.getSize());
@@ -512,7 +512,7 @@ public final class ZipTestCase extends AbstractTestCase {
@Test
public void testExplicitFileEntry() throws Exception {
- File[] tmp = createTempDirAndFile();
+ final File[] tmp = createTempDirAndFile();
File archive = null;
ZipArchiveOutputStream zos = null;
ZipFile zf = null;
@@ -521,11 +521,11 @@ public final class ZipTestCase extends AbstractTestCase {
archive = File.createTempFile("test.", ".zip", tmp[0]);
archive.deleteOnExit();
zos = new ZipArchiveOutputStream(archive);
- ZipArchiveEntry in = new ZipArchiveEntry("foo");
+ final ZipArchiveEntry in = new ZipArchiveEntry("foo");
in.setTime(tmp[1].lastModified());
in.setSize(tmp[1].length());
zos.putArchiveEntry(in);
- byte[] b = new byte[(int) tmp[1].length()];
+ final byte[] b = new byte[(int) tmp[1].length()];
fis = new FileInputStream(tmp[1]);
while (fis.read(b) > 0) {
zos.write(b);
@@ -536,7 +536,7 @@ public final class ZipTestCase extends AbstractTestCase {
zos.close();
zos = null;
zf = new ZipFile(archive);
- ZipArchiveEntry out = zf.getEntry("foo");
+ final ZipArchiveEntry out = zf.getEntry("foo");
assertNotNull(out);
assertEquals("foo", out.getName());
assertEquals(tmp[1].length(), out.getSize());
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStreamTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStreamTest.java b/src/test/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStreamTest.java
index 2f6625e..5221215 100644
--- a/src/test/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStreamTest.java
@@ -41,20 +41,20 @@ public class ArArchiveInputStreamTest extends AbstractTestCase {
}
private void checkLongNameEntry(final String archive) throws Exception {
- FileInputStream fis = new FileInputStream(getFile(archive));
+ final FileInputStream fis = new FileInputStream(getFile(archive));
ArArchiveInputStream s = null;
try {
s = new ArArchiveInputStream(new BufferedInputStream(fis));
ArchiveEntry e = s.getNextEntry();
assertEquals("this_is_a_long_file_name.txt", e.getName());
assertEquals(14, e.getSize());
- byte[] hello = new byte[14];
+ final byte[] hello = new byte[14];
s.read(hello);
assertEquals("Hello, world!\n", ArchiveUtils.toAsciiString(hello));
e = s.getNextEntry();
assertEquals("this_is_a_long_file_name_as_well.txt", e.getName());
assertEquals(4, e.getSize());
- byte[] bye = new byte[4];
+ final byte[] bye = new byte[4];
s.read(bye);
assertEquals("Bye\n", ArchiveUtils.toAsciiString(bye));
assertNull(s.getNextEntry());
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStreamTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStreamTest.java b/src/test/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStreamTest.java
index 6394ce6..d63283c 100644
--- a/src/test/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStreamTest.java
@@ -37,11 +37,11 @@ public class ArArchiveOutputStreamTest extends AbstractTestCase {
ArArchiveOutputStream os = null;
try {
os = new ArArchiveOutputStream(new ByteArrayOutputStream());
- ArArchiveEntry ae = new ArArchiveEntry("this_is_a_long_name.txt",
+ final ArArchiveEntry ae = new ArArchiveEntry("this_is_a_long_name.txt",
0);
os.putArchiveEntry(ae);
fail("Expected an exception");
- } catch (IOException ex) {
+ } catch (final IOException ex) {
assertTrue(ex.getMessage().startsWith("filename too long"));
} finally {
closeQuietly(os);
@@ -52,12 +52,12 @@ public class ArArchiveOutputStreamTest extends AbstractTestCase {
public void testLongFileNamesWorkUsingBSDDialect() throws Exception {
FileOutputStream fos = null;
ArArchiveOutputStream os = null;
- File[] df = createTempDirAndFile();
+ final File[] df = createTempDirAndFile();
try {
fos = new FileOutputStream(df[1]);
os = new ArArchiveOutputStream(fos);
os.setLongFileMode(ArArchiveOutputStream.LONGFILE_BSD);
- ArArchiveEntry ae = new ArArchiveEntry("this_is_a_long_name.txt",
+ final ArArchiveEntry ae = new ArArchiveEntry("this_is_a_long_name.txt",
14);
os.putArchiveEntry(ae);
os.write(new byte[] {
@@ -69,7 +69,7 @@ public class ArArchiveOutputStreamTest extends AbstractTestCase {
os = null;
fos = null;
- List<String> expected = new ArrayList<String>();
+ final List<String> expected = new ArrayList<String>();
expected.add("this_is_a_long_name.txt");
checkArchiveContent(df[1], expected);
} finally {
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStreamTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStreamTest.java b/src/test/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStreamTest.java
index 40d8f14..1983f1b 100644
--- a/src/test/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStreamTest.java
@@ -32,16 +32,16 @@ public class ArjArchiveInputStreamTest extends AbstractTestCase {
@Test
public void testArjUnarchive() throws Exception {
- StringBuilder expected = new StringBuilder();
+ final StringBuilder expected = new StringBuilder();
expected.append("test1.xml<?xml version=\"1.0\"?>\n");
expected.append("<empty/>test2.xml<?xml version=\"1.0\"?>\n");
expected.append("<empty/>\n");
- ArjArchiveInputStream in = new ArjArchiveInputStream(new FileInputStream(getFile("bla.arj")));
+ final ArjArchiveInputStream in = new ArjArchiveInputStream(new FileInputStream(getFile("bla.arj")));
ArjArchiveEntry entry;
- StringBuilder result = new StringBuilder();
+ final StringBuilder result = new StringBuilder();
while ((entry = in.getNextEntry()) != null) {
result.append(entry.getName());
int tmp;
@@ -56,12 +56,12 @@ public class ArjArchiveInputStreamTest extends AbstractTestCase {
@Test
public void testReadingOfAttributesDosVersion() throws Exception {
- ArjArchiveInputStream in = new ArjArchiveInputStream(new FileInputStream(getFile("bla.arj")));
- ArjArchiveEntry entry = in.getNextEntry();
+ final ArjArchiveInputStream in = new ArjArchiveInputStream(new FileInputStream(getFile("bla.arj")));
+ final ArjArchiveEntry entry = in.getNextEntry();
assertEquals("test1.xml", entry.getName());
assertEquals(30, entry.getSize());
assertEquals(0, entry.getUnixMode());
- Calendar cal = Calendar.getInstance();
+ final Calendar cal = Calendar.getInstance();
cal.set(2008, 9, 6, 23, 50, 52);
cal.set(Calendar.MILLISECOND, 0);
assertEquals(cal.getTime(), entry.getLastModifiedDate());
@@ -70,12 +70,12 @@ public class ArjArchiveInputStreamTest extends AbstractTestCase {
@Test
public void testReadingOfAttributesUnixVersion() throws Exception {
- ArjArchiveInputStream in = new ArjArchiveInputStream(new FileInputStream(getFile("bla.unix.arj")));
- ArjArchiveEntry entry = in.getNextEntry();
+ final ArjArchiveInputStream in = new ArjArchiveInputStream(new FileInputStream(getFile("bla.unix.arj")));
+ final ArjArchiveEntry entry = in.getNextEntry();
assertEquals("test1.xml", entry.getName());
assertEquals(30, entry.getSize());
assertEquals(0664, entry.getUnixMode() & 07777 /* UnixStat.PERM_MASK */);
- Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT+0000"));
+ final Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT+0000"));
cal.set(2008, 9, 6, 21, 50, 52);
cal.set(Calendar.MILLISECOND, 0);
assertEquals(cal.getTime(), entry.getLastModifiedDate());
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStreamTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStreamTest.java b/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStreamTest.java
index 06570f7..f174405 100644
--- a/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStreamTest.java
@@ -29,16 +29,16 @@ public class CpioArchiveInputStreamTest extends AbstractTestCase {
@Test
public void testCpioUnarchive() throws Exception {
- StringBuilder expected = new StringBuilder();
+ final StringBuilder expected = new StringBuilder();
expected.append("./test1.xml<?xml version=\"1.0\"?>\n");
expected.append("<empty/>./test2.xml<?xml version=\"1.0\"?>\n");
expected.append("<empty/>\n");
- CpioArchiveInputStream in = new CpioArchiveInputStream(new FileInputStream(getFile("bla.cpio")));
+ final CpioArchiveInputStream in = new CpioArchiveInputStream(new FileInputStream(getFile("bla.cpio")));
CpioArchiveEntry entry;
- StringBuilder result = new StringBuilder();
+ final StringBuilder result = new StringBuilder();
while ((entry = (CpioArchiveEntry) in.getNextEntry()) != null) {
result.append(entry.getName());
int tmp;
@@ -52,7 +52,7 @@ public class CpioArchiveInputStreamTest extends AbstractTestCase {
@Test
public void testCpioUnarchiveCreatedByRedlineRpm() throws Exception {
- CpioArchiveInputStream in =
+ final CpioArchiveInputStream in =
new CpioArchiveInputStream(new FileInputStream(getFile("redline.cpio")));
CpioArchiveEntry entry= null;
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStreamTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStreamTest.java b/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStreamTest.java
index d2f66f9..ba83771 100644
--- a/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStreamTest.java
@@ -58,7 +58,7 @@ public class CpioArchiveOutputStreamTest extends AbstractTestCase {
try {
in = new CpioArchiveInputStream(new FileInputStream(output));
- CpioArchiveEntry e = ((CpioArchiveInputStream) in)
+ final CpioArchiveEntry e = ((CpioArchiveInputStream) in)
.getNextCPIOEntry();
assertEquals("test1.xml", e.getName());
assertNull(((CpioArchiveInputStream) in).getNextEntry());
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntryTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntryTest.java b/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntryTest.java
index 8dad403..8cc8fd2 100644
--- a/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntryTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntryTest.java
@@ -25,7 +25,7 @@ import org.junit.Test;
public class DumpArchiveEntryTest {
@Test
public void publicNameAddsTrailingSlashForDirectories() {
- DumpArchiveEntry ent = new DumpArchiveEntry("foo", "bar", -1,
+ final DumpArchiveEntry ent = new DumpArchiveEntry("foo", "bar", -1,
DumpArchiveEntry.TYPE
.DIRECTORY);
assertEquals("bar", ent.getSimpleName());
@@ -35,7 +35,7 @@ public class DumpArchiveEntryTest {
@Test
public void publicNameRemovesLeadingDotSlash() {
- DumpArchiveEntry ent = new DumpArchiveEntry("./foo", "bar");
+ final DumpArchiveEntry ent = new DumpArchiveEntry("./foo", "bar");
assertEquals("bar", ent.getSimpleName());
assertEquals("./foo", ent.getOriginalName());
assertEquals("foo", ent.getName());
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStreamTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStreamTest.java b/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStreamTest.java
index e8f2928..bc6df9e 100644
--- a/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStreamTest.java
@@ -31,11 +31,11 @@ public class DumpArchiveInputStreamTest extends AbstractTestCase {
@Test
public void testNotADumpArchive() throws Exception {
- FileInputStream is = new FileInputStream(getFile("bla.zip"));
+ final FileInputStream is = new FileInputStream(getFile("bla.zip"));
try {
new DumpArchiveInputStream(is);
fail("expected an exception");
- } catch (ArchiveException ex) {
+ } catch (final ArchiveException ex) {
// expected
assertTrue(ex.getCause() instanceof ShortFileException);
} finally {
@@ -45,11 +45,11 @@ public class DumpArchiveInputStreamTest extends AbstractTestCase {
@Test
public void testNotADumpArchiveButBigEnough() throws Exception {
- FileInputStream is = new FileInputStream(getFile("zip64support.tar.bz2"));
+ final FileInputStream is = new FileInputStream(getFile("zip64support.tar.bz2"));
try {
new DumpArchiveInputStream(is);
fail("expected an exception");
- } catch (ArchiveException ex) {
+ } catch (final ArchiveException ex) {
// expected
assertTrue(ex.getCause() instanceof UnrecognizedFormatException);
} finally {
@@ -59,16 +59,16 @@ public class DumpArchiveInputStreamTest extends AbstractTestCase {
@Test
public void testConsumesArchiveCompletely() throws Exception {
- InputStream is = DumpArchiveInputStreamTest.class
+ final InputStream is = DumpArchiveInputStreamTest.class
.getResourceAsStream("/archive_with_trailer.dump");
- DumpArchiveInputStream dump = new DumpArchiveInputStream(is);
+ final DumpArchiveInputStream dump = new DumpArchiveInputStream(is);
while (dump.getNextDumpEntry() != null) {
// just consume the archive
}
- byte[] expected = new byte[] {
+ final byte[] expected = new byte[] {
'H', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd', '!', '\n'
};
- byte[] actual = new byte[expected.length];
+ final byte[] actual = new byte[expected.length];
is.read(actual);
assertArrayEquals(expected, actual);
dump.close();
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStreamTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStreamTest.java b/src/test/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStreamTest.java
index 111ebca..3008395 100644
--- a/src/test/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStreamTest.java
@@ -35,7 +35,7 @@ public class JarArchiveOutputStreamTest {
@Test
public void testJarMarker() throws IOException {
- File testArchive = File.createTempFile("jar-aostest", ".jar");
+ final File testArchive = File.createTempFile("jar-aostest", ".jar");
testArchive.deleteOnExit();
JarArchiveOutputStream out = null;
ZipFile zf = null;
@@ -65,7 +65,7 @@ public class JarArchiveOutputStreamTest {
if (out != null) {
try {
out.close();
- } catch (IOException e) { /* swallow */ }
+ } catch (final IOException e) { /* swallow */ }
}
ZipFile.closeQuietly(zf);
AbstractTestCase.tryHardToDelete(testArchive);
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveInputStream.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveInputStream.java b/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveInputStream.java
index 31e1989..a3b8347 100644
--- a/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveInputStream.java
+++ b/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveInputStream.java
@@ -34,7 +34,7 @@ public final class MemoryArchiveInputStream extends ArchiveInputStream {
content = new String[pFiles.length];
for (int i = 0; i < pFiles.length; i++) {
- String[] nameAndContent = pFiles[i];
+ final String[] nameAndContent = pFiles[i];
filenames[i] = nameAndContent[0];
content[i] = nameAndContent[1];
}
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
index 53320d8..1c514d8 100644
--- a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
@@ -43,7 +43,7 @@ public class SevenZFileTest extends AbstractTestCase {
@Test
public void testRandomlySkippingEntries() throws Exception {
// Read sequential reference.
- Map<String, byte[]> entriesByName = new HashMap<String, byte[]>();
+ final Map<String, byte[]> entriesByName = new HashMap<String, byte[]>();
SevenZFile archive = new SevenZFile(getFile("COMPRESS-320/Copy.7z"));
SevenZArchiveEntry entry;
while ((entry = archive.getNextEntry()) != null) {
@@ -53,7 +53,7 @@ public class SevenZFileTest extends AbstractTestCase {
}
archive.close();
- String[] variants = {
+ final String[] variants = {
"BZip2-solid.7z",
"BZip2.7z",
"Copy-solid.7z",
@@ -70,8 +70,8 @@ public class SevenZFileTest extends AbstractTestCase {
};
// TODO: use randomizedtesting for predictable, but different, randomness.
- Random rnd = new Random(0xdeadbeef);
- for (String fileName : variants) {
+ final Random rnd = new Random(0xdeadbeef);
+ for (final String fileName : variants) {
archive = new SevenZFile(getFile("COMPRESS-320/" + fileName));
while ((entry = archive.getNextEntry()) != null) {
@@ -82,7 +82,7 @@ public class SevenZFileTest extends AbstractTestCase {
if (entry.hasStream()) {
assertTrue(entriesByName.containsKey(entry.getName()));
- byte [] content = readFully(archive);
+ final byte [] content = readFully(archive);
assertTrue("Content mismatch on: " + fileName + "!" + entry.getName(),
Arrays.equals(content, entriesByName.get(entry.getName())));
}
@@ -93,8 +93,8 @@ public class SevenZFileTest extends AbstractTestCase {
}
private byte[] readFully(final SevenZFile archive) throws IOException {
- byte [] buf = new byte [1024];
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final byte [] buf = new byte [1024];
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
for (int len = 0; (len = archive.read(buf)) > 0;) {
baos.write(buf, 0, len);
}
@@ -103,7 +103,7 @@ public class SevenZFileTest extends AbstractTestCase {
@Test
public void testAllEmptyFilesArchive() throws Exception {
- SevenZFile archive = new SevenZFile(getFile("7z-empty-mhc-off.7z"));
+ final SevenZFile archive = new SevenZFile(getFile("7z-empty-mhc-off.7z"));
try {
assertNotNull(archive.getNextEntry());
} finally {
@@ -148,8 +148,8 @@ public class SevenZFileTest extends AbstractTestCase {
try {
new SevenZFile(getFile("bla.encrypted.7z"));
fail("shouldn't decrypt without a password");
- } catch (PasswordRequiredException ex) {
- String msg = ex.getMessage();
+ } catch (final PasswordRequiredException ex) {
+ final String msg = ex.getMessage();
assertTrue("Should start with whining about being unable to decrypt",
msg.startsWith("Cannot read encrypted content from "));
assertTrue("Should finish the sentence properly",
@@ -164,7 +164,7 @@ public class SevenZFileTest extends AbstractTestCase {
*/
@Test
public void testCompressedHeaderWithNonDefaultDictionarySize() throws Exception {
- SevenZFile sevenZFile = new SevenZFile(getFile("COMPRESS-256.7z"));
+ final SevenZFile sevenZFile = new SevenZFile(getFile("COMPRESS-256.7z"));
try {
int count = 0;
while (sevenZFile.getNextEntry() != null) {
@@ -193,11 +193,11 @@ public class SevenZFileTest extends AbstractTestCase {
@Test
public void testReadingBackLZMA2DictSize() throws Exception {
- File output = new File(dir, "lzma2-dictsize.7z");
- SevenZOutputFile outArchive = new SevenZOutputFile(output);
+ final File output = new File(dir, "lzma2-dictsize.7z");
+ final SevenZOutputFile outArchive = new SevenZOutputFile(output);
try {
outArchive.setContentMethods(Arrays.asList(new SevenZMethodConfiguration(SevenZMethod.LZMA2, 1 << 20)));
- SevenZArchiveEntry entry = new SevenZArchiveEntry();
+ final SevenZArchiveEntry entry = new SevenZArchiveEntry();
entry.setName("foo.txt");
outArchive.putArchiveEntry(entry);
outArchive.write(new byte[] { 'A' });
@@ -206,10 +206,10 @@ public class SevenZFileTest extends AbstractTestCase {
outArchive.close();
}
- SevenZFile archive = new SevenZFile(output);
+ final SevenZFile archive = new SevenZFile(output);
try {
- SevenZArchiveEntry entry = archive.getNextEntry();
- SevenZMethodConfiguration m = entry.getContentMethods().iterator().next();
+ final SevenZArchiveEntry entry = archive.getNextEntry();
+ final SevenZMethodConfiguration m = entry.getContentMethods().iterator().next();
assertEquals(SevenZMethod.LZMA2, m.getMethod());
assertEquals(1 << 20, m.getOptions());
} finally {
@@ -219,12 +219,12 @@ public class SevenZFileTest extends AbstractTestCase {
@Test
public void testReadingBackDeltaDistance() throws Exception {
- File output = new File(dir, "delta-distance.7z");
- SevenZOutputFile outArchive = new SevenZOutputFile(output);
+ final File output = new File(dir, "delta-distance.7z");
+ final SevenZOutputFile outArchive = new SevenZOutputFile(output);
try {
outArchive.setContentMethods(Arrays.asList(new SevenZMethodConfiguration(SevenZMethod.DELTA_FILTER, 32),
new SevenZMethodConfiguration(SevenZMethod.LZMA2)));
- SevenZArchiveEntry entry = new SevenZArchiveEntry();
+ final SevenZArchiveEntry entry = new SevenZArchiveEntry();
entry.setName("foo.txt");
outArchive.putArchiveEntry(entry);
outArchive.write(new byte[] { 'A' });
@@ -233,10 +233,10 @@ public class SevenZFileTest extends AbstractTestCase {
outArchive.close();
}
- SevenZFile archive = new SevenZFile(output);
+ final SevenZFile archive = new SevenZFile(output);
try {
- SevenZArchiveEntry entry = archive.getNextEntry();
- SevenZMethodConfiguration m = entry.getContentMethods().iterator().next();
+ final SevenZArchiveEntry entry = archive.getNextEntry();
+ final SevenZMethodConfiguration m = entry.getContentMethods().iterator().next();
assertEquals(SevenZMethod.DELTA_FILTER, m.getMethod());
assertEquals(32, m.getOptions());
} finally {
@@ -246,10 +246,10 @@ public class SevenZFileTest extends AbstractTestCase {
@Test
public void getEntriesOfUnarchiveTest() throws IOException {
- SevenZFile sevenZFile = new SevenZFile(getFile("bla.7z"));
+ final SevenZFile sevenZFile = new SevenZFile(getFile("bla.7z"));
try {
- Iterable<SevenZArchiveEntry> entries = sevenZFile.getEntries();
- Iterator<SevenZArchiveEntry> iter = entries.iterator();
+ final Iterable<SevenZArchiveEntry> entries = sevenZFile.getEntries();
+ final Iterator<SevenZArchiveEntry> iter = entries.iterator();
SevenZArchiveEntry entry = iter.next();
assertEquals("test1.xml", entry.getName());
entry = iter.next();
@@ -261,7 +261,7 @@ public class SevenZFileTest extends AbstractTestCase {
}
private void test7zUnarchive(final File f, final SevenZMethod m, final byte[] password) throws Exception {
- SevenZFile sevenZFile = new SevenZFile(f, password);
+ final SevenZFile sevenZFile = new SevenZFile(f, password);
try {
SevenZArchiveEntry entry = sevenZFile.getNextEntry();
assertEquals("test1.xml", entry.getName());
@@ -269,10 +269,10 @@ public class SevenZFileTest extends AbstractTestCase {
entry = sevenZFile.getNextEntry();
assertEquals("test2.xml", entry.getName());
assertEquals(m, entry.getContentMethods().iterator().next().getMethod());
- byte[] contents = new byte[(int)entry.getSize()];
+ final byte[] contents = new byte[(int)entry.getSize()];
int off = 0;
while ((off < contents.length)) {
- int bytesRead = sevenZFile.read(contents, off, contents.length - off);
+ final int bytesRead = sevenZFile.read(contents, off, contents.length - off);
assert(bytesRead >= 0);
off += bytesRead;
}
@@ -284,14 +284,14 @@ public class SevenZFileTest extends AbstractTestCase {
}
private void checkHelloWorld(final String filename) throws Exception {
- SevenZFile sevenZFile = new SevenZFile(getFile(filename));
+ final SevenZFile sevenZFile = new SevenZFile(getFile(filename));
try {
- SevenZArchiveEntry entry = sevenZFile.getNextEntry();
+ final SevenZArchiveEntry entry = sevenZFile.getNextEntry();
assertEquals("Hello world.txt", entry.getName());
- byte[] contents = new byte[(int)entry.getSize()];
+ final byte[] contents = new byte[(int)entry.getSize()];
int off = 0;
while ((off < contents.length)) {
- int bytesRead = sevenZFile.read(contents, off, contents.length - off);
+ final int bytesRead = sevenZFile.read(contents, off, contents.length - off);
assert(bytesRead >= 0);
off += bytesRead;
}
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFileTest.java
----------------------------------------------------------------------
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 3da4b2c..6c717ef 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
@@ -56,12 +56,12 @@ public class SevenZOutputFileTest extends AbstractTestCase {
public void testDirectoriesAndEmptyFiles() throws Exception {
output = new File(dir, "empties.7z");
- Date accessDate = new Date();
- Calendar cal = Calendar.getInstance();
+ final Date accessDate = new Date();
+ final Calendar cal = Calendar.getInstance();
cal.add(Calendar.HOUR, -1);
- Date creationDate = cal.getTime();
+ final Date creationDate = cal.getTime();
- SevenZOutputFile outArchive = new SevenZOutputFile(output);
+ final SevenZOutputFile outArchive = new SevenZOutputFile(output);
try {
SevenZArchiveEntry entry = outArchive.createArchiveEntry(dir, "foo/");
outArchive.putArchiveEntry(entry);
@@ -136,7 +136,7 @@ public class SevenZOutputFileTest extends AbstractTestCase {
assert(entry != null);
assertEquals("dada", entry.getName());
assertEquals(2, entry.getSize());
- byte[] content = new byte[2];
+ final byte[] content = new byte[2];
assertEquals(2, archive.read(content));
assertEquals(5, content[0]);
assertEquals(42, content[1]);
@@ -152,9 +152,9 @@ public class SevenZOutputFileTest extends AbstractTestCase {
@Test
public void testDirectoriesOnly() throws Exception {
output = new File(dir, "dirs.7z");
- SevenZOutputFile outArchive = new SevenZOutputFile(output);
+ final SevenZOutputFile outArchive = new SevenZOutputFile(output);
try {
- SevenZArchiveEntry entry = new SevenZArchiveEntry();
+ final SevenZArchiveEntry entry = new SevenZArchiveEntry();
entry.setName("foo/");
entry.setDirectory(true);
outArchive.putArchiveEntry(entry);
@@ -165,7 +165,7 @@ public class SevenZOutputFileTest extends AbstractTestCase {
final SevenZFile archive = new SevenZFile(output);
try {
- SevenZArchiveEntry entry = archive.getNextEntry();
+ final SevenZArchiveEntry entry = archive.getNextEntry();
assert(entry != null);
assertEquals("foo/", entry.getName());
assertTrue(entry.isDirectory());
@@ -181,12 +181,12 @@ public class SevenZOutputFileTest extends AbstractTestCase {
@Test
public void testCantFinishTwice() throws Exception {
output = new File(dir, "finish.7z");
- SevenZOutputFile outArchive = new SevenZOutputFile(output);
+ final SevenZOutputFile outArchive = new SevenZOutputFile(output);
try {
outArchive.finish();
outArchive.finish();
fail("shouldn't be able to call finish twice");
- } catch (IOException ex) {
+ } catch (final IOException ex) {
assertEquals("This archive has already been finished", ex.getMessage());
} finally {
outArchive.close();
@@ -307,7 +307,7 @@ public class SevenZOutputFileTest extends AbstractTestCase {
@Test
public void testStackOfContentCompressions() throws Exception {
output = new File(dir, "multiple-methods.7z");
- ArrayList<SevenZMethodConfiguration> methods = new ArrayList<SevenZMethodConfiguration>();
+ final ArrayList<SevenZMethodConfiguration> methods = new ArrayList<SevenZMethodConfiguration>();
methods.add(new SevenZMethodConfiguration(SevenZMethod.LZMA2));
methods.add(new SevenZMethodConfiguration(SevenZMethod.COPY));
methods.add(new SevenZMethodConfiguration(SevenZMethod.DEFLATE));
@@ -342,7 +342,7 @@ public class SevenZOutputFileTest extends AbstractTestCase {
@Test
public void testLzma2WithOptionsConfiguration() throws Exception {
output = new File(dir, "lzma2-options2.7z");
- LZMA2Options opts = new LZMA2Options(1);
+ final LZMA2Options opts = new LZMA2Options(1);
createAndReadBack(output, Collections
.singletonList(new SevenZMethodConfiguration(SevenZMethod.LZMA2, opts)));
}
@@ -350,7 +350,7 @@ public class SevenZOutputFileTest extends AbstractTestCase {
@Test
public void testArchiveWithMixedMethods() throws Exception {
output = new File(dir, "mixed-methods.7z");
- SevenZOutputFile outArchive = new SevenZOutputFile(output);
+ final SevenZOutputFile outArchive = new SevenZOutputFile(output);
try {
addFile(outArchive, 0, true);
addFile(outArchive, 1, true, Arrays.asList(new SevenZMethodConfiguration(SevenZMethod.BZIP2)));
@@ -358,7 +358,7 @@ public class SevenZOutputFileTest extends AbstractTestCase {
outArchive.close();
}
- SevenZFile archive = new SevenZFile(output);
+ final SevenZFile archive = new SevenZFile(output);
try {
assertEquals(Boolean.TRUE,
verifyFile(archive, 0, Arrays.asList(new SevenZMethodConfiguration(SevenZMethod.LZMA2))));
@@ -371,12 +371,12 @@ public class SevenZOutputFileTest extends AbstractTestCase {
private void testCompress252(final int numberOfFiles, final int numberOfNonEmptyFiles)
throws Exception {
- int nonEmptyModulus = numberOfNonEmptyFiles != 0
+ final int nonEmptyModulus = numberOfNonEmptyFiles != 0
? numberOfFiles / numberOfNonEmptyFiles
: numberOfFiles + 1;
int nonEmptyFilesAdded = 0;
output = new File(dir, "COMPRESS252-" + numberOfFiles + "-" + numberOfNonEmptyFiles + ".7z");
- SevenZOutputFile archive = new SevenZOutputFile(output);
+ final SevenZOutputFile archive = new SevenZOutputFile(output);
try {
addDir(archive);
for (int i = 0; i < numberOfFiles; i++) {
@@ -391,7 +391,7 @@ public class SevenZOutputFileTest extends AbstractTestCase {
private void verifyCompress252(final File output, final int numberOfFiles, final int numberOfNonEmptyFiles)
throws Exception {
- SevenZFile archive = new SevenZFile(output);
+ final SevenZFile archive = new SevenZFile(output);
int filesFound = 0;
int nonEmptyFilesFound = 0;
try {
@@ -411,13 +411,13 @@ public class SevenZOutputFileTest extends AbstractTestCase {
}
private void addDir(final SevenZOutputFile archive) throws Exception {
- SevenZArchiveEntry entry = archive.createArchiveEntry(dir, "foo/");
+ final SevenZArchiveEntry entry = archive.createArchiveEntry(dir, "foo/");
archive.putArchiveEntry(entry);
archive.closeArchiveEntry();
}
private void verifyDir(final SevenZFile archive) throws Exception {
- SevenZArchiveEntry entry = archive.getNextEntry();
+ final SevenZArchiveEntry entry = archive.getNextEntry();
assertNotNull(entry);
assertEquals("foo/", entry.getName());
assertTrue(entry.isDirectory());
@@ -430,7 +430,7 @@ public class SevenZOutputFileTest extends AbstractTestCase {
private void addFile(final SevenZOutputFile archive, final int index, final boolean nonEmpty, final Iterable<SevenZMethodConfiguration> methods)
throws Exception {
- SevenZArchiveEntry entry = new SevenZArchiveEntry();
+ final SevenZArchiveEntry entry = new SevenZArchiveEntry();
entry.setName("foo/" + index + ".txt");
entry.setContentMethods(methods);
archive.putArchiveEntry(entry);
@@ -444,7 +444,7 @@ public class SevenZOutputFileTest extends AbstractTestCase {
private Boolean verifyFile(final SevenZFile archive, final int index,
final Iterable<SevenZMethodConfiguration> methods) throws Exception {
- SevenZArchiveEntry entry = archive.getNextEntry();
+ final SevenZArchiveEntry entry = archive.getNextEntry();
if (entry == null) {
return null;
}
@@ -464,21 +464,21 @@ public class SevenZOutputFileTest extends AbstractTestCase {
private void testRoundTrip(final SevenZMethod method) throws Exception {
output = new File(dir, method + "-roundtrip.7z");
- ArrayList<SevenZMethodConfiguration> methods = new ArrayList<SevenZMethodConfiguration>();
+ final ArrayList<SevenZMethodConfiguration> methods = new ArrayList<SevenZMethodConfiguration>();
methods.add(new SevenZMethodConfiguration(method));
createAndReadBack(output, methods);
}
private void testFilterRoundTrip(final SevenZMethodConfiguration method) throws Exception {
output = new File(dir, method.getMethod() + "-roundtrip.7z");
- ArrayList<SevenZMethodConfiguration> methods = new ArrayList<SevenZMethodConfiguration>();
+ final ArrayList<SevenZMethodConfiguration> methods = new ArrayList<SevenZMethodConfiguration>();
methods.add(method);
methods.add(new SevenZMethodConfiguration(SevenZMethod.LZMA2));
createAndReadBack(output, methods);
}
private void createAndReadBack(final File output, final Iterable<SevenZMethodConfiguration> methods) throws Exception {
- SevenZOutputFile outArchive = new SevenZOutputFile(output);
+ final SevenZOutputFile outArchive = new SevenZOutputFile(output);
outArchive.setContentMethods(methods);
try {
addFile(outArchive, 0, true);
@@ -486,7 +486,7 @@ public class SevenZOutputFileTest extends AbstractTestCase {
outArchive.close();
}
- SevenZFile archive = new SevenZFile(output);
+ final SevenZFile archive = new SevenZFile(output);
try {
assertEquals(Boolean.TRUE, verifyFile(archive, 0, methods));
} finally {
@@ -497,12 +497,12 @@ public class SevenZOutputFileTest extends AbstractTestCase {
private static void assertContentMethodsEquals(final Iterable<? extends SevenZMethodConfiguration> expected,
final Iterable<? extends SevenZMethodConfiguration> actual) {
assertNotNull(actual);
- Iterator<? extends SevenZMethodConfiguration> expectedIter = expected.iterator();
- Iterator<? extends SevenZMethodConfiguration> actualIter = actual.iterator();
+ final Iterator<? extends SevenZMethodConfiguration> expectedIter = expected.iterator();
+ final Iterator<? extends SevenZMethodConfiguration> actualIter = actual.iterator();
while (expectedIter.hasNext()) {
assertTrue(actualIter.hasNext());
- SevenZMethodConfiguration expConfig = expectedIter.next();
- SevenZMethodConfiguration actConfig = actualIter.next();
+ final SevenZMethodConfiguration expConfig = expectedIter.next();
+ final SevenZMethodConfiguration actConfig = actualIter.next();
assertEquals(expConfig.getMethod(), actConfig.getMethod());
}
assertFalse(actualIter.hasNext());
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java b/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java
index e676062..14cfe64 100644
--- a/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java
+++ b/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java
@@ -52,7 +52,7 @@ public class BigFilesIT {
);
gzin = new GzipCompressorInputStream(in);
tin = new TarArchiveInputStream(gzin);
- TarArchiveEntry e = tin.getNextTarEntry();
+ final TarArchiveEntry e = tin.getNextTarEntry();
assertNotNull(e);
assertNull(tin.getNextTarEntry());
} finally {
@@ -77,19 +77,19 @@ public class BigFilesIT {
.getResourceAsStream(name));
gzin = new GzipCompressorInputStream(in);
tin = new TarArchiveInputStream(gzin);
- TarArchiveEntry e = tin.getNextTarEntry();
+ final TarArchiveEntry e = tin.getNextTarEntry();
assertNotNull(e);
assertEquals(8200l * 1024 * 1024, e.getSize());
long read = 0;
- Random r = new Random(System.currentTimeMillis());
+ final Random r = new Random(System.currentTimeMillis());
int readNow;
- byte[] buf = new byte[1024 * 1024];
+ final byte[] buf = new byte[1024 * 1024];
while ((readNow = tin.read(buf, 0, buf.length)) > 0) {
// testing all bytes for a value of 0 is going to take
// too long, just pick a few ones randomly
for (int i = 0; i < 100; i++) {
- int idx = r.nextInt(readNow);
+ final int idx = r.nextInt(readNow);
assertEquals("testing byte " + (read + idx), 0, buf[idx]);
}
read += readNow;
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/archivers/tar/SparseFilesTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/archivers/tar/SparseFilesTest.java b/src/test/java/org/apache/commons/compress/archivers/tar/SparseFilesTest.java
index ea70495..56ac227 100644
--- a/src/test/java/org/apache/commons/compress/archivers/tar/SparseFilesTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/tar/SparseFilesTest.java
@@ -30,11 +30,11 @@ public class SparseFilesTest {
@Test
public void testOldGNU() throws Throwable {
- File file = getFile("oldgnu_sparse.tar");
+ final File file = getFile("oldgnu_sparse.tar");
TarArchiveInputStream tin = null;
try {
tin = new TarArchiveInputStream(new FileInputStream(file));
- TarArchiveEntry ae = tin.getNextTarEntry();
+ final TarArchiveEntry ae = tin.getNextTarEntry();
assertEquals("sparsefile", ae.getName());
assertTrue(ae.isOldGNUSparse());
assertTrue(ae.isGNUSparse());
@@ -49,7 +49,7 @@ public class SparseFilesTest {
@Test
public void testPaxGNU() throws Throwable {
- File file = getFile("pax_gnu_sparse.tar");
+ final File file = getFile("pax_gnu_sparse.tar");
TarArchiveInputStream tin = null;
try {
tin = new TarArchiveInputStream(new FileInputStream(file));
@@ -64,7 +64,7 @@ public class SparseFilesTest {
}
private void assertPaxGNUEntry(final TarArchiveInputStream tin, final String suffix) throws Throwable {
- TarArchiveEntry ae = tin.getNextTarEntry();
+ final TarArchiveEntry ae = tin.getNextTarEntry();
assertEquals("sparsefile-" + suffix, ae.getName());
assertTrue(ae.isGNUSparse());
assertTrue(ae.isPaxGNUSparse());
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3f2c760a/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java b/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java
index af0e4fd..ca0b4d9 100644
--- a/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java
@@ -43,13 +43,13 @@ public class TarArchiveEntryTest implements TarConstants {
*/
@Test
public void testFileSystemRoot() {
- TarArchiveEntry t = new TarArchiveEntry(new File(ROOT));
+ final TarArchiveEntry t = new TarArchiveEntry(new File(ROOT));
assertEquals("/", t.getName());
}
@Test
public void testTarFileWithFSRoot() throws IOException {
- File f = File.createTempFile("taetest", ".tar");
+ final File f = File.createTempFile("taetest", ".tar");
f.deleteOnExit();
TarArchiveOutputStream tout = null;
TarArchiveInputStream tin = null;
@@ -109,13 +109,13 @@ public class TarArchiveEntryTest implements TarConstants {
@Test
public void testMaxFileSize(){
- TarArchiveEntry t = new TarArchiveEntry("");
+ final TarArchiveEntry t = new TarArchiveEntry("");
t.setSize(0);
t.setSize(1);
try {
t.setSize(-1);
fail("Should have generated IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
+ } catch (final IllegalArgumentException expected) {
}
t.setSize(077777777777L);
t.setSize(0100000000000L);
@@ -123,21 +123,21 @@ public class TarArchiveEntryTest implements TarConstants {
@Test
public void testLinkFlagConstructor() {
- TarArchiveEntry t = new TarArchiveEntry("/foo", LF_GNUTYPE_LONGNAME);
+ final TarArchiveEntry t = new TarArchiveEntry("/foo", LF_GNUTYPE_LONGNAME);
assertGnuMagic(t);
assertEquals("foo", t.getName());
}
@Test
public void testLinkFlagConstructorWithFileFlag() {
- TarArchiveEntry t = new TarArchiveEntry("/foo", LF_NORMAL);
+ final TarArchiveEntry t = new TarArchiveEntry("/foo", LF_NORMAL);
assertPosixMagic(t);
assertEquals("foo", t.getName());
}
@Test
public void testLinkFlagConstructorWithPreserve() {
- TarArchiveEntry t = new TarArchiveEntry("/foo", LF_GNUTYPE_LONGNAME,
+ final TarArchiveEntry t = new TarArchiveEntry("/foo", LF_GNUTYPE_LONGNAME,
true);
assertGnuMagic(t);
assertEquals("/foo", t.getName());
@@ -152,7 +152,7 @@ public class TarArchiveEntryTest implements TarConstants {
}
private String readMagic(final TarArchiveEntry t) {
- byte[] buf = new byte[512];
+ final byte[] buf = new byte[512];
t.writeEntryHeader(buf);
return new String(buf, MAGIC_OFFSET, MAGICLEN + VERSIONLEN);
}