Author: sebb
Date: Wed May 12 18:48:53 2010
New Revision: 943629
URL: http://svn.apache.org/viewvc?rev=943629&view=rev
Log:
Add zip and jar versions of longpath tests.
Also acts as auto-detect test case
Added:
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/LongPathTest.java
- copied, changed from r943618,
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarReadTest.java
commons/proper/compress/trunk/src/test/resources/longpath/
- copied from r942754,
commons/proper/compress/trunk/src/test/resources/tarlongpath/
commons/proper/compress/trunk/src/test/resources/longpath/minotaur-0.jar
(with props)
commons/proper/compress/trunk/src/test/resources/longpath/minotaur-M.jar
(with props)
commons/proper/compress/trunk/src/test/resources/longpath/minotaur-c.zip
(with props)
commons/proper/compress/trunk/src/test/resources/longpath/minotaur-z.zip
(with props)
commons/proper/compress/trunk/src/test/resources/longpath/minotaur.jar
(with props)
commons/proper/compress/trunk/src/test/resources/longpath/minotaur.zip
(with props)
Removed:
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarReadTest.java
commons/proper/compress/trunk/src/test/resources/tarlongpath/
Copied:
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/LongPathTest.java
(from r943618,
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarReadTest.java)
URL:
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/LongPathTest.java?p2=commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/LongPathTest.java&p1=commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarReadTest.java&r1=943618&r2=943629&rev=943629&view=diff
==============================================================================
---
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarReadTest.java
(original)
+++
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/LongPathTest.java
Wed May 12 18:48:53 2010
@@ -16,8 +16,9 @@
*
*/
-package org.apache.commons.compress.archivers.tar;
+package org.apache.commons.compress.archivers;
+import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
@@ -25,10 +26,13 @@ import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
+import junit.framework.AssertionFailedError;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.commons.compress.AbstractTestCase;
+import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
+import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
/**
* Test that can read various tar file examples.
@@ -36,26 +40,28 @@ import org.apache.commons.compress.Abstr
* The class uses nested suites in order to be able to name the test after the
file name,
* as JUnit does not allow one to change the display name of a test.
*/
-public class TarReadTest extends AbstractTestCase {
+public class LongPathTest extends AbstractTestCase {
- private static final ClassLoader classLoader =
TarReadTest.class.getClassLoader();
+ private static final ClassLoader classLoader =
LongPathTest.class.getClassLoader();
private File file;
private static final ArrayList fileList = new ArrayList();
+
+ private final ArchiveStreamFactory factory = new ArchiveStreamFactory();
- public TarReadTest(String name) {
+ public LongPathTest(String name) {
super(name);
}
- private TarReadTest(String name, File file){
+ private LongPathTest(String name, File file){
super(name);
this.file = file;
}
public static TestSuite suite() throws IOException{
TestSuite suite = new TestSuite("TarReadTests");
- File arcdir =new
File(classLoader.getResource("tarlongpath").getFile());
+ File arcdir =new File(classLoader.getResource("longpath").getFile());
assertTrue(arcdir.exists());
File listing= new File(arcdir,"files.txt");
assertTrue("File listing is readable",listing.canRead());
@@ -76,15 +82,33 @@ public class TarReadTest extends Abstrac
}
// Appears to be the only way to give the test a variable name
TestSuite namedSuite = new TestSuite(file.getName());
- Test test = new TarReadTest("testArchive", file);
+ Test test = new LongPathTest("testArchive", file);
namedSuite.addTest(test);
suite.addTest(namedSuite);
}
return suite;
}
- public void testArchive() throws Exception{
+ public void testArchive() throws Exception {
ArrayList expected=(ArrayList) fileList.clone();
- checkArchiveContent(new TarArchiveInputStream(new
FileInputStream(file)), expected);
+ 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)));
+ // check if expected type recognised
+ if (name.endsWith(".tar")){
+ assertTrue(ais instanceof TarArchiveInputStream);
+ } else if (name.endsWith(".jar") || name.endsWith(".zip")){
+ assertTrue(ais instanceof ZipArchiveInputStream);
+ } else {
+ fail("Unexpected file type: "+name);
+ }
+ try {
+ checkArchiveContent(ais, expected);
+ } catch (AssertionFailedError e) {
+ fail("Error processing "+file.getName()+" "+e);
+ }
}
}
Added: commons/proper/compress/trunk/src/test/resources/longpath/minotaur-0.jar
URL:
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/resources/longpath/minotaur-0.jar?rev=943629&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
commons/proper/compress/trunk/src/test/resources/longpath/minotaur-0.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: commons/proper/compress/trunk/src/test/resources/longpath/minotaur-M.jar
URL:
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/resources/longpath/minotaur-M.jar?rev=943629&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
commons/proper/compress/trunk/src/test/resources/longpath/minotaur-M.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: commons/proper/compress/trunk/src/test/resources/longpath/minotaur-c.zip
URL:
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/resources/longpath/minotaur-c.zip?rev=943629&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
commons/proper/compress/trunk/src/test/resources/longpath/minotaur-c.zip
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: commons/proper/compress/trunk/src/test/resources/longpath/minotaur-z.zip
URL:
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/resources/longpath/minotaur-z.zip?rev=943629&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
commons/proper/compress/trunk/src/test/resources/longpath/minotaur-z.zip
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: commons/proper/compress/trunk/src/test/resources/longpath/minotaur.jar
URL:
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/resources/longpath/minotaur.jar?rev=943629&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
commons/proper/compress/trunk/src/test/resources/longpath/minotaur.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: commons/proper/compress/trunk/src/test/resources/longpath/minotaur.zip
URL:
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/resources/longpath/minotaur.zip?rev=943629&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
commons/proper/compress/trunk/src/test/resources/longpath/minotaur.zip
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream