commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1439043 - in /commons/proper/compress/trunk/src: changes/ test/java/org/apache/commons/compress/ test/java/org/apache/commons/compress/archivers/ test/java/org/apache/commons/compress/archivers/tar/ test/java/org/apache/commons/compress/ar...
Date Sun, 27 Jan 2013 09:45:54 GMT
Author: bodewig
Date: Sun Jan 27 09:45:53 2013
New Revision: 1439043

URL: http://svn.apache.org/viewvc?rev=1439043&view=rev
Log:
COMPRESS-205 - allow tests to pass even if source tree is placed in strange directories. 
Based on patch by Daniel Lowe

Modified:
    commons/proper/compress/trunk/src/changes/changes.xml
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/ChainingTestCase.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/DetectArchiverTestCase.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/DetectCompressorTestCase.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/LongPathTest.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/SparseFilesTest.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/EncryptedArchiveTest.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Maven221MultiVolumeTest.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestampTest.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/X7875_NewUnixTest.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportIT.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1439043&r1=1439042&r2=1439043&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Sun Jan 27 09:45:53 2013
@@ -147,6 +147,11 @@ The <action> type attribute can be add,u
           ZipArchiveInputStream now consumes the remainder of the
           archive when getNextZipEntry returns null.
         </action>
+        <action type="fix" date="2013-01-27" issue="COMPRESS-205"
+                due-to="Daniel Lowe">
+          Unit tests could fail if the source tree was checked out to
+          a directory tree containign spaces.
+        </action>
     </release>
     <release version="1.4.1" date="2012-05-23"
              description="Release 1.4.1">

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java?rev=1439043&r1=1439042&r2=1439043&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java
Sun Jan 27 09:45:53 2013
@@ -27,6 +27,8 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.net.URI;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
@@ -71,8 +73,18 @@ public abstract class AbstractTestCase e
         return f;
     }
 
-    protected File getFile(String path) {
-        return new File("src/test/resources", path);
+    public static File getFile(String path) throws IOException {
+        URL url = AbstractTestCase.class.getClassLoader().getResource(path);
+        if (url == null) {
+            throw new FileNotFoundException("couldn't find " + path);
+        }
+        URI uri = null;
+        try {
+            uri = url.toURI();
+        } catch (java.net.URISyntaxException ex) {
+            throw new IOException(ex);
+        }
+        return new File(uri);
     }
 
     @Override

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/ChainingTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/ChainingTestCase.java?rev=1439043&r1=1439042&r2=1439043&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/ChainingTestCase.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/ChainingTestCase.java
Sun Jan 27 09:45:53 2013
@@ -30,7 +30,7 @@ import org.apache.commons.compress.compr
 public class ChainingTestCase extends AbstractTestCase {
 
     public void testTarGzip() throws Exception {
-        File file = new File("src/test/resources/bla.tgz");
+        File file = getFile("bla.tgz");
         final TarArchiveInputStream is = new TarArchiveInputStream(new GzipCompressorInputStream(new
FileInputStream(file)));
         final TarArchiveEntry entry = (TarArchiveEntry)is.getNextEntry();
         assertNotNull(entry);
@@ -39,7 +39,7 @@ public class ChainingTestCase extends Ab
     }
 
     public void testTarBzip2() throws Exception {
-        File file = new File("src/test/resources/bla.tar.bz2");
+        File file = getFile("bla.tar.bz2");
         final TarArchiveInputStream is = new TarArchiveInputStream(new BZip2CompressorInputStream(new
FileInputStream(file)));
         final TarArchiveEntry entry = (TarArchiveEntry)is.getNextEntry();
         assertNotNull(entry);

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/DetectArchiverTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/DetectArchiverTestCase.java?rev=1439043&r1=1439042&r2=1439043&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/DetectArchiverTestCase.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/DetectArchiverTestCase.java
Sun Jan 27 09:45:53 2013
@@ -21,7 +21,7 @@ package org.apache.commons.compress;
 import java.io.BufferedInputStream;
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
+import java.io.IOException;
 import java.net.URL;
 
 import org.apache.commons.compress.archivers.ArchiveException;
@@ -38,7 +38,7 @@ public final class DetectArchiverTestCas
 
     final ClassLoader classLoader = getClass().getClassLoader();
 
-    public void testDetectionNotArchive() throws FileNotFoundException {
+    public void testDetectionNotArchive() throws IOException {
         try {
             getStreamFor("test.txt");
             fail("Expected ArchiveException");
@@ -83,12 +83,10 @@ public final class DetectArchiverTestCas
     }
 
     private ArchiveInputStream getStreamFor(String resource)
-            throws ArchiveException, FileNotFoundException {
-        final URL rsc = classLoader.getResource(resource);
-        assertNotNull("Could not find resource "+resource,rsc);
+            throws ArchiveException, IOException {
         return factory.createArchiveInputStream(
                    new BufferedInputStream(new FileInputStream(
-                       new File(rsc.getFile()))));
+                       getFile(resource))));
     }
 
     // Check that the empty archives created by the code are readable

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/DetectCompressorTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/DetectCompressorTestCase.java?rev=1439043&r1=1439042&r2=1439043&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/DetectCompressorTestCase.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/DetectCompressorTestCase.java
Sun Jan 27 09:45:53 2013
@@ -18,10 +18,12 @@
  */
 package org.apache.commons.compress;
 
+import static org.apache.commons.compress.AbstractTestCase.getFile;
+
 import java.io.BufferedInputStream;
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
+import java.io.IOException;
 import java.net.URL;
 
 import junit.framework.TestCase;
@@ -54,13 +56,10 @@ public final class DetectCompressorTestC
     }
 
     private CompressorInputStream getStreamFor(String resource)
-            throws CompressorException, FileNotFoundException {
-
-        final URL rsc = classLoader.getResource(resource);
-        assertNotNull("Could not find resource "+resource,rsc);
+            throws CompressorException, IOException {
         return factory.createCompressorInputStream(
                    new BufferedInputStream(new FileInputStream(
-                       new File(rsc.getFile()))));
+                       getFile(resource))));
     }
 
 }

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/LongPathTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/LongPathTest.java?rev=1439043&r1=1439042&r2=1439043&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/LongPathTest.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/LongPathTest.java
Sun Jan 27 09:45:53 2013
@@ -62,9 +62,7 @@ public class LongPathTest extends Abstra
 
     public static TestSuite suite() throws IOException{
         TestSuite suite = new TestSuite("LongPathTests");
-        URL resource = classLoader.getResource("longpath");
-        assertNotNull("Cannot find 'longpath' resource",resource);
-        File arcdir =new File(resource.getFile());
+        File arcdir = getFile("longpath");
         assertTrue(arcdir.exists());
         File listing= new File(arcdir,"files.txt");
         assertTrue("File listing is readable",listing.canRead());

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/SparseFilesTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/SparseFilesTest.java?rev=1439043&r1=1439042&r2=1439043&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/SparseFilesTest.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/SparseFilesTest.java
Sun Jan 27 09:45:53 2013
@@ -18,18 +18,17 @@
 
 package org.apache.commons.compress.archivers.tar;
 
+import static org.apache.commons.compress.AbstractTestCase.getFile;
+
 import java.io.File;
 import java.io.FileInputStream;
-import java.net.URI;
-import java.net.URL;
 
 import junit.framework.TestCase;
 
 public class SparseFilesTest extends TestCase {
 
     public void testOldGNU() throws Throwable {
-        URL tar = getClass().getResource("/oldgnu_sparse.tar");
-        File file = new File(new URI(tar.toString()));
+        File file = getFile("oldgnu_sparse.tar");
         TarArchiveInputStream tin = null;
         try {
             tin = new TarArchiveInputStream(new FileInputStream(file));

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java?rev=1439043&r1=1439042&r2=1439043&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java
Sun Jan 27 09:45:53 2013
@@ -18,6 +18,7 @@
 
 package org.apache.commons.compress.archivers.tar;
 
+import static org.apache.commons.compress.AbstractTestCase.getFile;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
@@ -25,12 +26,9 @@ import static org.junit.Assert.fail;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
-import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
 import java.io.IOException;
-import java.net.URI;
-import java.net.URL;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.Map;
@@ -78,10 +76,9 @@ public class TarArchiveInputStreamTest {
 
     @Test
     public void workaroundForBrokenTimeHeader() throws Exception {
-        URL tar = getClass().getResource("/simple-aix-native-tar.tar");
         TarArchiveInputStream in = null;
         try {
-            in = new TarArchiveInputStream(new FileInputStream(new File(new URI(tar.toString()))));
+            in = new TarArchiveInputStream(new FileInputStream(getFile("simple-aix-native-tar.tar")));
             TarArchiveEntry tae = in.getNextTarEntry();
             tae = in.getNextTarEntry();
             assertEquals("sample/link-to-txt-file.lnk", tae.getName());
@@ -97,20 +94,19 @@ public class TarArchiveInputStreamTest {
 
     @Test
     public void datePriorToEpochInGNUFormat() throws Exception {
-        datePriorToEpoch("/preepoch-star.tar");
+        datePriorToEpoch("preepoch-star.tar");
     }
 
 
     @Test
     public void datePriorToEpochInPAXFormat() throws Exception {
-        datePriorToEpoch("/preepoch-posix.tar");
+        datePriorToEpoch("preepoch-posix.tar");
     }
 
     private void datePriorToEpoch(String archive) throws Exception {
-        URL tar = getClass().getResource(archive);
         TarArchiveInputStream in = null;
         try {
-            in = new TarArchiveInputStream(new FileInputStream(new File(new URI(tar.toString()))));
+            in = new TarArchiveInputStream(new FileInputStream(getFile(archive)));
             TarArchiveEntry tae = in.getNextTarEntry();
             assertEquals("foo", tae.getName());
             Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/EncryptedArchiveTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/EncryptedArchiveTest.java?rev=1439043&r1=1439042&r2=1439043&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/EncryptedArchiveTest.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/EncryptedArchiveTest.java
Sun Jan 27 09:45:53 2013
@@ -18,21 +18,19 @@
 
 package org.apache.commons.compress.archivers.zip;
 
+import static org.apache.commons.compress.AbstractTestCase.getFile;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
 
 import junit.framework.TestCase;
 
 public class EncryptedArchiveTest extends TestCase {
 
     public void testReadPasswordEncryptedEntryViaZipFile()
-        throws IOException, URISyntaxException {
-        URL zip = getClass().getResource("/password-encrypted.zip");
-        File file = new File(new URI(zip.toString()));
+        throws IOException {
+        File file = getFile("password-encrypted.zip");
         ZipFile zf = null;
         try {
             zf = new ZipFile(file);
@@ -53,9 +51,8 @@ public class EncryptedArchiveTest extend
     }
 
     public void testReadPasswordEncryptedEntryViaStream()
-        throws IOException, URISyntaxException {
-        URL zip = getClass().getResource("/password-encrypted.zip");
-        File file = new File(new URI(zip.toString()));
+        throws IOException {
+        File file = getFile("password-encrypted.zip");
         ZipArchiveInputStream zin = null;
         try {
             zin = new ZipArchiveInputStream(new FileInputStream(file));

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Maven221MultiVolumeTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Maven221MultiVolumeTest.java?rev=1439043&r1=1439042&r2=1439043&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Maven221MultiVolumeTest.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Maven221MultiVolumeTest.java
Sun Jan 27 09:45:53 2013
@@ -18,12 +18,11 @@
 
 package org.apache.commons.compress.archivers.zip;
 
+import static org.apache.commons.compress.AbstractTestCase.getFile;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
 
 import junit.framework.TestCase;
 
@@ -66,12 +65,10 @@ public class Maven221MultiVolumeTest ext
     private static final String LAST_ENTRY_NAME =
         "apache-maven-2.2.1/lib/maven-2.2.1-uber.jar";
 
-    public void testRead7ZipMultiVolumeArchiveForStream() throws IOException,
-            URISyntaxException {
+    public void testRead7ZipMultiVolumeArchiveForStream() throws IOException {
 
-        URL zip = getClass().getResource("/apache-maven-2.2.1.zip.001");
-        FileInputStream archive = new FileInputStream(
-            new File(new URI(zip.toString())));
+        FileInputStream archive =
+            new FileInputStream(getFile("apache-maven-2.2.1.zip.001"));
         ZipArchiveInputStream zi = null;
         try {
             zi = new ZipArchiveInputStream(archive,null,false);
@@ -114,10 +111,8 @@ public class Maven221MultiVolumeTest ext
         }
     }
 
-    public void testRead7ZipMultiVolumeArchiveForFile()
-        throws URISyntaxException {
-        URL zip = getClass().getResource("/apache-maven-2.2.1.zip.001");
-        File file = new File(new URI(zip.toString()));
+    public void testRead7ZipMultiVolumeArchiveForFile() throws IOException {
+        File file = getFile("apache-maven-2.2.1.zip.001");
         try {
             new ZipFile(file);
             fail("Expected ZipFile to fail");

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java?rev=1439043&r1=1439042&r2=1439043&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java
Sun Jan 27 09:45:53 2013
@@ -18,14 +18,14 @@
 
 package org.apache.commons.compress.archivers.zip;
 
+import static org.apache.commons.compress.AbstractTestCase.getFile;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
-import java.net.URI;
 import java.net.URISyntaxException;
-import java.net.URL;
 import java.nio.ByteBuffer;
 import java.util.Enumeration;
 import java.util.zip.CRC32;
@@ -87,8 +87,7 @@ public class UTF8ZipFilesTest extends Ab
      * - which is true for OIL_BARREL_TXT.
      */
     public void testRead7ZipArchive() throws IOException, URISyntaxException {
-        URL zip = getClass().getResource("/utf8-7zip-test.zip");
-        File archive = new File(new URI(zip.toString()));
+        File archive = getFile("utf8-7zip-test.zip");
         ZipFile zf = null;
         try {
             zf = new ZipFile(archive, CP437, false);
@@ -102,9 +101,8 @@ public class UTF8ZipFilesTest extends Ab
 
     public void testRead7ZipArchiveForStream() throws IOException,
                                                       URISyntaxException {
-        URL zip = getClass().getResource("/utf8-7zip-test.zip");
         FileInputStream archive =
-            new FileInputStream(new File(new URI(zip.toString())));
+            new FileInputStream(getFile("utf8-7zip-test.zip"));
         ZipArchiveInputStream zi = null;
         try {
             zi = new ZipArchiveInputStream(archive, CP437, false);
@@ -123,8 +121,7 @@ public class UTF8ZipFilesTest extends Ab
      * the central directory.
      */
     public void testReadWinZipArchive() throws IOException, URISyntaxException {
-        URL zip = getClass().getResource("/utf8-winzip-test.zip");
-        File archive = new File(new URI(zip.toString()));
+        File archive = getFile("utf8-winzip-test.zip");
         ZipFile zf = null;
         try {
             zf = new ZipFile(archive, null, true);
@@ -150,9 +147,8 @@ public class UTF8ZipFilesTest extends Ab
 
     public void testReadWinZipArchiveForStream() throws IOException,
                                                       URISyntaxException {
-        URL zip = getClass().getResource("/utf8-winzip-test.zip");
         FileInputStream archive =
-            new FileInputStream(new File(new URI(zip.toString())));
+            new FileInputStream(getFile("utf8-winzip-test.zip"));
         ZipArchiveInputStream zi = null;
         try {
             zi = new ZipArchiveInputStream(archive, null, true);
@@ -204,8 +200,7 @@ public class UTF8ZipFilesTest extends Ab
 
     public void testRawNameReadFromZipFile()
         throws IOException, URISyntaxException {
-        URL zip = getClass().getResource("/utf8-7zip-test.zip");
-        File archive = new File(new URI(zip.toString()));
+        File archive = getFile("utf8-7zip-test.zip");
         ZipFile zf = null;
         try {
             zf = new ZipFile(archive, CP437, false);
@@ -217,9 +212,8 @@ public class UTF8ZipFilesTest extends Ab
 
     public void testRawNameReadFromStream()
         throws IOException, URISyntaxException {
-        URL zip = getClass().getResource("/utf8-7zip-test.zip");
         FileInputStream archive =
-            new FileInputStream(new File(new URI(zip.toString())));
+            new FileInputStream(getFile("utf8-7zip-test.zip"));
         ZipArchiveInputStream zi = null;
         try {
             zi = new ZipArchiveInputStream(archive, CP437, false);

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestampTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestampTest.java?rev=1439043&r1=1439042&r2=1439043&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestampTest.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestampTest.java
Sun Jan 27 09:45:53 2013
@@ -21,8 +21,6 @@ import org.junit.Before;
 import org.junit.Test;
 
 import java.io.File;
-import java.net.URI;
-import java.net.URL;
 import java.text.SimpleDateFormat;
 import java.util.Arrays;
 import java.util.Calendar;
@@ -31,6 +29,7 @@ import java.util.Enumeration;
 import java.util.TimeZone;
 import java.util.zip.ZipException;
 
+import static org.apache.commons.compress.AbstractTestCase.getFile;
 import static org.apache.commons.compress.archivers.zip.X5455_ExtendedTimestamp.ACCESS_TIME_BIT;
 import static org.apache.commons.compress.archivers.zip.X5455_ExtendedTimestamp.CREATE_TIME_BIT;
 import static org.apache.commons.compress.archivers.zip.X5455_ExtendedTimestamp.MODIFY_TIME_BIT;
@@ -87,8 +86,7 @@ public class X5455_ExtendedTimestampTest
         1999's acc time:  Jan 1st, 1999-01-01/00:00:03
          */
 
-        URL zip = getClass().getResource("/COMPRESS-210_unix_time_zip_test.zip");
-        File archive = new File(new URI(zip.toString()));
+        File archive = getFile("COMPRESS-210_unix_time_zip_test.zip");
         ZipFile zf = null;
 
         try {

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/X7875_NewUnixTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/X7875_NewUnixTest.java?rev=1439043&r1=1439042&r2=1439043&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/X7875_NewUnixTest.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/X7875_NewUnixTest.java
Sun Jan 27 09:45:53 2013
@@ -22,12 +22,11 @@ import org.junit.Before;
 import org.junit.Test;
 
 import java.io.File;
-import java.net.URI;
-import java.net.URL;
 import java.util.Arrays;
 import java.util.Enumeration;
 import java.util.zip.ZipException;
 
+import static org.apache.commons.compress.AbstractTestCase.getFile;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -46,8 +45,7 @@ public class X7875_NewUnixTest {
 
     @Test
     public void testSampleFile() throws Exception {
-        URL zip = getClass().getResource("/COMPRESS-211_uid_gid_zip_test.zip");
-        File archive = new File(new URI(zip.toString()));
+        File archive = getFile("COMPRESS-211_uid_gid_zip_test.zip");
         ZipFile zf = null;
 
         try {

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportIT.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportIT.java?rev=1439043&r1=1439042&r2=1439043&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportIT.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportIT.java
Sun Jan 27 09:45:53 2013
@@ -18,6 +18,7 @@
 
 package org.apache.commons.compress.archivers.zip;
 
+import static org.apache.commons.compress.AbstractTestCase.getFile;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -35,8 +36,6 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.RandomAccessFile;
-import java.net.URI;
-import java.net.URL;
 import java.util.Enumeration;
 import java.util.Random;
 import java.util.zip.ZipEntry;
@@ -2320,56 +2319,48 @@ public class Zip64SupportIT {
         }
     }
 
-    private static File getFile(String name) throws Throwable {
-        URL url = Zip64SupportIT.class.getResource(name);
-        assumeNotNull(url);
-        File file = new File(new URI(url.toString()));
-        assumeTrue(file.exists());
-        return file;
-    }
-
     private static File get5GBZerosFile() throws Throwable {
-        return getFile("/5GB_of_Zeros.zip");
+        return getFile("5GB_of_Zeros.zip");
     }
 
     private static File get5GBZerosFileGeneratedBy7ZIP() throws Throwable {
-        return getFile("/5GB_of_Zeros_7ZIP.zip");
+        return getFile("5GB_of_Zeros_7ZIP.zip");
     }
 
     private static File get5GBZerosFileGeneratedByJava7Jar() throws Throwable {
-        return getFile("/5GB_of_Zeros_jar.zip");
+        return getFile("5GB_of_Zeros_jar.zip");
     }
 
     private static File get5GBZerosFileGeneratedByWinZIP() throws Throwable {
-        return getFile("/5GB_of_Zeros_WinZip.zip");
+        return getFile("5GB_of_Zeros_WinZip.zip");
     }
 
     private static File get5GBZerosFileGeneratedByPKZip() throws Throwable {
-        return getFile("/5GB_of_Zeros_PKZip.zip");
+        return getFile("5GB_of_Zeros_PKZip.zip");
     }
 
     private static File get100KFileFile() throws Throwable {
-        return getFile("/100k_Files.zip");
+        return getFile("100k_Files.zip");
     }
 
     private static File get100KFileFileGeneratedBy7ZIP() throws Throwable {
-        return getFile("/100k_Files_7ZIP.zip");
+        return getFile("100k_Files_7ZIP.zip");
     }
 
     private static File get100KFileFileGeneratedByWinCF() throws Throwable {
-        return getFile("/100k_Files_WindowsCompressedFolders.zip");
+        return getFile("100k_Files_WindowsCompressedFolders.zip");
     }
 
     private static File get100KFileFileGeneratedByJava7Jar() throws Throwable {
-        return getFile("/100k_Files_jar.zip");
+        return getFile("100k_Files_jar.zip");
     }
 
     private static File get100KFileFileGeneratedByWinZIP() throws Throwable {
-        return getFile("/100k_Files_WinZIP.zip");
+        return getFile("100k_Files_WinZIP.zip");
     }
 
     private static File get100KFileFileGeneratedByPKZip() throws Throwable {
-        return getFile("/100k_Files_PKZip.zip");
+        return getFile("100k_Files_PKZip.zip");
     }
 
     private static File getTempFile(String testName) throws Throwable {

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java?rev=1439043&r1=1439042&r2=1439043&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java
Sun Jan 27 09:45:53 2013
@@ -18,12 +18,12 @@
 
 package org.apache.commons.compress.archivers.zip;
 
+import static org.apache.commons.compress.AbstractTestCase.getFile;
+
 import junit.framework.TestCase;
 
 import java.io.ByteArrayOutputStream;
 import java.io.File;
-import java.net.URI;
-import java.net.URL;
 import java.util.Enumeration;
 import java.util.TreeMap;
 import java.util.zip.ZipEntry;
@@ -59,8 +59,7 @@ public class ZipArchiveEntryTest extends
         // I looked into creating a test with hard links, but zip does not appear to
         // support hard links, so nevermind.
 
-        URL zip = getClass().getResource("/COMPRESS-214_unix_symlinks.zip");
-        File archive = new File(new URI(zip.toString()));
+        File archive = getFile("COMPRESS-214_unix_symlinks.zip");
         ZipFile zf = null;
 
         try {

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java?rev=1439043&r1=1439042&r2=1439043&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
Sun Jan 27 09:45:53 2013
@@ -18,6 +18,7 @@
 
 package org.apache.commons.compress.archivers.zip;
 
+import static org.apache.commons.compress.AbstractTestCase.getFile;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
@@ -26,8 +27,6 @@ import java.io.BufferedInputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
-import java.net.URI;
-import java.net.URL;
 
 import org.junit.Test;
 
@@ -38,10 +37,9 @@ public class ZipArchiveInputStreamTest {
      */
     @Test
     public void winzipBackSlashWorkaround() throws Exception {
-        URL zip = getClass().getResource("/test-winzip.zip");
         ZipArchiveInputStream in = null;
         try {
-            in = new ZipArchiveInputStream(new FileInputStream(new File(new URI(zip.toString()))));
+            in = new ZipArchiveInputStream(new FileInputStream(getFile("test-winzip.zip")));
             ZipArchiveEntry zae = in.getNextZipEntry();
             zae = in.getNextZipEntry();
             zae = in.getNextZipEntry();
@@ -58,11 +56,10 @@ public class ZipArchiveInputStreamTest {
      */
     @Test
     public void properUseOfInflater() throws Exception {
-        URL zip = getClass().getResource("/COMPRESS-189.zip");
         ZipFile zf = null;
         ZipArchiveInputStream in = null;
         try {
-            zf = new ZipFile(new File(new URI(zip.toString())));
+            zf = new ZipFile(getFile("COMPRESS-189.zip"));
             ZipArchiveEntry zae = zf.getEntry("USD0558682-20080101.ZIP");
             in = new ZipArchiveInputStream(new BufferedInputStream(zf.getInputStream(zae)));
             ZipArchiveEntry innerEntry;

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java?rev=1439043&r1=1439042&r2=1439043&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
Sun Jan 27 09:45:53 2013
@@ -18,12 +18,12 @@
 
 package org.apache.commons.compress.archivers.zip;
 
+import static org.apache.commons.compress.AbstractTestCase.getFile;
+
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.net.URI;
-import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.zip.ZipEntry;
@@ -145,8 +145,7 @@ public class ZipFileTest extends TestCas
      * @see "https://issues.apache.org/jira/browse/COMPRESS-176"
      */
     public void testWinzipBackSlashWorkaround() throws Exception {
-        URL zip = getClass().getResource("/test-winzip.zip");
-        File archive = new File(new URI(zip.toString()));
+        File archive = getFile("test-winzip.zip");
         zf = new ZipFile(archive);
         assertNull(zf.getEntry("\u00e4\\\u00fc.txt"));
         assertNotNull(zf.getEntry("\u00e4/\u00fc.txt"));
@@ -158,8 +157,7 @@ public class ZipFileTest extends TestCas
      * >COMPRESS-208</a>.
      */
     public void testSkipsPK00Prefix() throws Exception {
-        URL zip = getClass().getResource("/COMPRESS-208.zip");
-        File archive = new File(new URI(zip.toString()));
+        File archive = getFile("COMPRESS-208.zip");
         zf = new ZipFile(archive);
         assertNotNull(zf.getEntry("test1.xml"));
         assertNotNull(zf.getEntry("test2.xml"));
@@ -176,8 +174,7 @@ public class ZipFileTest extends TestCas
      * central directory order is different from entry data order.
      */
     private void readOrderTest() throws Exception {
-        URL zip = getClass().getResource("/ordertest.zip");
-        File archive = new File(new URI(zip.toString()));
+        File archive = getFile("ordertest.zip");
         zf = new ZipFile(archive);
     }
 



Mime
View raw message