commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r759793 - /commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java
Date Sun, 29 Mar 2009 22:20:02 GMT
Author: sebb
Date: Sun Mar 29 22:20:02 2009
New Revision: 759793

URL: http://svn.apache.org/viewvc?rev=759793&view=rev
Log:
Use archiveList for keeping track of archive contents

Modified:
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java?rev=759793&r1=759792&r2=759793&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java
Sun Mar 29 22:20:02 2009
@@ -18,11 +18,13 @@
  */
 package org.apache.commons.compress.changes;
 
+import java.io.BufferedInputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.InputStream;
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 
 import org.apache.commons.compress.AbstractTestCase;
@@ -42,6 +44,16 @@
     
     private ArchiveStreamFactory factory = new ArchiveStreamFactory();
 
+    private void archiveListDelete(String prefix){
+        Iterator it = archiveList.iterator();
+        while(it.hasNext()){
+            String entry = (String) it.next();
+            if (entry.equals(prefix) || entry.startsWith(prefix+"/")){
+                it.remove();
+            }
+        }
+    }
+
     /**
      * Tries to delete the folder "bla" from a zip file. This should result in
      * the deletion of bla/*, which actually means bla/test4.xml should be
@@ -67,6 +79,7 @@
 
             ChangeSet changes = new ChangeSet();
             changes.delete("bla");
+            archiveListDelete("bla");
             changes.perform(ais, out);
             is.close();
 
@@ -77,15 +90,7 @@
                 ais.close();
         }
 
-        List expected = new ArrayList();
-        expected.add("testdata/test1.xml");
-        expected.add("testdata/test2.xml");
-        expected.add("test/test3.xml");
-        expected.add("test.txt");
-        expected.add("something/bla");
-        expected.add("test with spaces.txt");
-
-        this.checkArchiveContent(result, expected);
+        this.checkArchiveContent(result, archiveList);
     }
 
     /**
@@ -111,6 +116,7 @@
 
             ChangeSet changes = new ChangeSet();
             changes.delete("bla/test5.xml");
+            archiveListDelete("bla/test5.xml");
             changes.perform(ais, out);
             is.close();
 
@@ -121,16 +127,7 @@
                 ais.close();
         }
 
-        List expected = new ArrayList();
-        expected.add("testdata/test1.xml");
-        expected.add("testdata/test2.xml");
-        expected.add("test/test3.xml");
-        expected.add("test.txt");
-        expected.add("something/bla");
-        expected.add("test with spaces.txt");
-        expected.add("bla/test4.xml");
-        expected.add("bla/blubber/test6.xml");
-        this.checkArchiveContent(result, expected);
+        this.checkArchiveContent(result, archiveList);
     }
 
     /**
@@ -156,11 +153,13 @@
 
             ChangeSet changes = new ChangeSet();
             changes.delete("bla");
+            archiveListDelete("bla");
 
             // Add a file
             final File file1 = getFile("test.txt");
             ArchiveEntry entry = new ZipArchiveEntry("bla/test.txt");
             changes.add(entry, new FileInputStream(file1));
+            archiveList.add("bla/test.txt");
 
             changes.perform(ais, out);
             is.close();
@@ -172,16 +171,7 @@
                 ais.close();
         }
 
-        List expected = new ArrayList();
-        expected.add("testdata/test1.xml");
-        expected.add("testdata/test2.xml");
-        expected.add("test/test3.xml");
-        expected.add("test.txt");
-        expected.add("something/bla");
-        expected.add("bla/test.txt");
-        expected.add("test with spaces.txt");
-
-        this.checkArchiveContent(result, expected);
+        this.checkArchiveContent(result, archiveList);
     }
 
     /**
@@ -208,8 +198,10 @@
             final File file1 = getFile("test.txt");
             ArchiveEntry entry = new ZipArchiveEntry("blub/test.txt");
             changes.add(entry, new FileInputStream(file1));
+            archiveList.add("blub/test.txt");
 
             changes.delete("testdata/test1.xml");
+            archiveListDelete("testdata/test1.xml");
 
             changes.perform(ais, out);
             is.close();
@@ -221,22 +213,11 @@
                 ais.close();
         }
 
-        List expected = new ArrayList();
-        expected.add("testdata/test2.xml");
-        expected.add("test/test3.xml");
-        expected.add("blub/test.txt");
-        expected.add("bla/test5.xml");
-        expected.add("bla/blubber/test6.xml");
-        expected.add("test.txt");
-        expected.add("something/bla");
-        expected.add("bla/test4.xml");
-        expected.add("test with spaces.txt");
-
-        this.checkArchiveContent(result, expected);
+        this.checkArchiveContent(result, archiveList);
     }
 
     /**
-     * add blub/test.txt + delete blub Should add dir1/test.txt and delete it
+     * add blub/test.txt + delete blub Should add blub/test.txt and delete it
      * afterwards. In this example, the zip archive should stay untouched.
      * 
      * @throws Exception
@@ -260,8 +241,10 @@
             final File file1 = getFile("test.txt");
             ArchiveEntry entry = new ZipArchiveEntry("blub/test.txt");
             changes.add(entry, new FileInputStream(file1));
+            archiveList.add("blub/test.txt");
 
             changes.delete("blub");
+            archiveListDelete("blub");
 
             changes.perform(ais, out);
             is.close();
@@ -273,18 +256,7 @@
                 ais.close();
         }
 
-        List expected = new ArrayList();
-        expected.add("testdata/test1.xml");
-        expected.add("testdata/test2.xml");
-        expected.add("test/test3.xml");
-        expected.add("test.txt");
-        expected.add("bla/test5.xml");
-        expected.add("bla/blubber/test6.xml");
-        expected.add("something/bla");
-        expected.add("bla/test4.xml");
-        expected.add("test with spaces.txt");
-
-        this.checkArchiveContent(result, expected);
+        this.checkArchiveContent(result, archiveList);
     }
 
     /**
@@ -314,8 +286,10 @@
             final File file1 = getFile("test.txt");
             ArchiveEntry entry = new ZipArchiveEntry("bla/test.txt");
             changes.add(entry, new FileInputStream(file1));
+            archiveList.add("bla/test.txt");
 
             changes.delete("bla");
+            archiveListDelete("bla");
 
             changes.perform(ais, out);
             is.close();
@@ -327,15 +301,7 @@
                 ais.close();
         }
 
-        List expected = new ArrayList();
-        expected.add("testdata/test1.xml");
-        expected.add("testdata/test2.xml");
-        expected.add("test/test3.xml");
-        expected.add("test.txt");
-        expected.add("something/bla");
-        expected.add("test with spaces.txt");
-
-        this.checkArchiveContent(result, expected);
+        this.checkArchiveContent(result, archiveList);
     }
 
     /**
@@ -483,7 +449,6 @@
         List expected = new ArrayList();
         expected.add("test1.xml");
         expected.add("testdata/test.txt");
-        // TODO: automatic detection of TAR archive temp fails here
         final ArchiveInputStream in = factory.createArchiveInputStream("tar", new FileInputStream(temp));
         this.checkArchiveContent(in, expected);
     }



Mime
View raw message