ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r807073 - in /ant/sandbox/antlibs/compress/trunk/src: main/org/apache/ant/compress/taskdefs/ArchiveBase.java tests/antunit/ar-test.xml tests/antunit/cpio-test.xml tests/antunit/tar-test.xml tests/antunit/zip-test.xml
Date Mon, 24 Aug 2009 04:16:42 GMT
Author: bodewig
Date: Mon Aug 24 04:16:41 2009
New Revision: 807073

URL: http://svn.apache.org/viewvc?rev=807073&view=rev
Log:
tests for prefix and fullpath - make sure all slashes in archive entry names are forward slashes

Modified:
    ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java
    ant/sandbox/antlibs/compress/trunk/src/tests/antunit/ar-test.xml
    ant/sandbox/antlibs/compress/trunk/src/tests/antunit/cpio-test.xml
    ant/sandbox/antlibs/compress/trunk/src/tests/antunit/tar-test.xml
    ant/sandbox/antlibs/compress/trunk/src/tests/antunit/zip-test.xml

Modified: ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java?rev=807073&r1=807072&r2=807073&view=diff
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java
(original)
+++ ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java
Mon Aug 24 04:16:41 2009
@@ -170,7 +170,7 @@
             ResourceCollectionFlags rcFlags = getFlags(rc);
             for (Iterator rs = rc.iterator(); rs.hasNext(); ) {
                 Resource r = (Resource) rs.next();
-                if ((!filesOnly || !r.isDirectory())) {
+                if (!filesOnly || !r.isDirectory()) {
                     ResourceWithFlags rwf =
                         new ResourceWithFlags(r, rcFlags, getFlags(r));
                     if (!"".equals(rwf.getName())
@@ -426,6 +426,19 @@
     }
 
     /**
+     * Ensures a forward slash is used as file separator.
+     */
+    protected static String bendSlashesForward(String s) {
+        if (s != null) {
+            s = s.replace('\\', '/');
+            if (File.separatorChar != '/' && File.separatorChar != '\\') { 
+                s = s.replace(File.separatorChar, '/');
+            }
+        }
+        return s;
+    }
+
+    /**
      * Valid Modes for create/update/replace.
      */
     public static final class Mode extends EnumeratedAttribute {
@@ -555,8 +568,8 @@
                                        String userName, String groupName) {
             super(fileMode, uid, gid, userName, groupName);
             this.dirMode = dirMode;
-            this.prefix = prefix;
-            this.fullpath = fullpath;
+            this.prefix = bendSlashesForward(prefix);
+            this.fullpath = bendSlashesForward(fullpath);
         }
 
         public boolean hasDirModeBeenSet() { return dirMode >= 0; }
@@ -605,6 +618,7 @@
                     }
                     name = prefix + name;
                 }
+                name = bendSlashesForward(name);
             }
             if (r.isDirectory() && !name.endsWith("/")) {
                 name += "/";

Modified: ant/sandbox/antlibs/compress/trunk/src/tests/antunit/ar-test.xml
URL: http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/tests/antunit/ar-test.xml?rev=807073&r1=807072&r2=807073&view=diff
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/src/tests/antunit/ar-test.xml (original)
+++ ant/sandbox/antlibs/compress/trunk/src/tests/antunit/ar-test.xml Mon Aug 24 04:16:41 2009
@@ -189,4 +189,76 @@
                      uid="1000" gid="1000"/>
   </target>
 
+  <target name="testFullpath" depends="setUp">
+    <cmp:ar destfile="${dest}">
+      <cmp:arfileset src="../resources/asf-logo.gif.ar"
+                     fullpath="logo.gif"
+                     includes="asf-logo.gif"/>
+    </cmp:ar>
+    <assertResourceExists>
+      <cmp:arentry name="logo.gif">
+        <file file="${dest}"/>
+      </cmp:arentry>
+    </assertResourceExists>
+    <assertResourceDoesntExist>
+      <cmp:arentry name="asf-logo.gif">
+        <file file="${dest}"/>
+      </cmp:arentry>
+    </assertResourceDoesntExist>
+  </target>
+
+  <target name="testPrefixWithSlash" depends="setUp">
+    <cmp:ar destfile="${dest}">
+      <cmp:arfileset src="../resources/asf-logo.gif.ar"
+                     prefix="x/"
+                     includes="asf-logo.gif"/>
+    </cmp:ar>
+    <assertResourceExists>
+      <cmp:arentry name="x/asf-logo.gif">
+        <file file="${dest}"/>
+      </cmp:arentry>
+    </assertResourceExists>
+    <assertResourceDoesntExist>
+      <cmp:arentry name="asf-logo.gif">
+        <file file="${dest}"/>
+      </cmp:arentry>
+    </assertResourceDoesntExist>
+  </target>
+
+  <target name="testPrefixWithBackslash" depends="setUp">
+    <cmp:ar destfile="${dest}">
+      <cmp:arfileset src="../resources/asf-logo.gif.ar"
+                     prefix="x\"
+                     includes="asf-logo.gif"/>
+    </cmp:ar>
+    <assertResourceExists>
+      <cmp:arentry name="x/asf-logo.gif">
+        <file file="${dest}"/>
+      </cmp:arentry>
+    </assertResourceExists>
+    <assertResourceDoesntExist>
+      <cmp:arentry name="asf-logo.gif">
+        <file file="${dest}"/>
+      </cmp:arentry>
+    </assertResourceDoesntExist>
+  </target>
+
+  <target name="testPrefixWithoutSlash" depends="setUp">
+    <cmp:ar destfile="${dest}">
+      <cmp:arfileset src="../resources/asf-logo.gif.ar"
+                     prefix="x"
+                     includes="asf-logo.gif"/>
+    </cmp:ar>
+    <assertResourceExists>
+      <cmp:arentry name="x/asf-logo.gif">
+        <file file="${dest}"/>
+      </cmp:arentry>
+    </assertResourceExists>
+    <assertResourceDoesntExist>
+      <cmp:arentry name="asf-logo.gif">
+        <file file="${dest}"/>
+      </cmp:arentry>
+    </assertResourceDoesntExist>
+  </target>
+
 </project>

Modified: ant/sandbox/antlibs/compress/trunk/src/tests/antunit/cpio-test.xml
URL: http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/tests/antunit/cpio-test.xml?rev=807073&r1=807072&r2=807073&view=diff
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/src/tests/antunit/cpio-test.xml (original)
+++ ant/sandbox/antlibs/compress/trunk/src/tests/antunit/cpio-test.xml Mon Aug 24 04:16:41
2009
@@ -221,4 +221,76 @@
                      uid="1000" gid="1000"/>
   </target>
 
+  <target name="testFullpath" depends="setUp">
+    <cmp:cpio destfile="${dest}">
+      <cmp:arfileset src="../resources/asf-logo.gif.ar"
+                     fullpath="logo.gif"
+                     includes="asf-logo.gif"/>
+    </cmp:cpio>
+    <assertResourceExists>
+      <cmp:cpioentry name="logo.gif">
+        <file file="${dest}"/>
+      </cmp:cpioentry>
+    </assertResourceExists>
+    <assertResourceDoesntExist>
+      <cmp:cpioentry name="asf-logo.gif">
+        <file file="${dest}"/>
+      </cmp:cpioentry>
+    </assertResourceDoesntExist>
+  </target>
+
+  <target name="testPrefixWithSlash" depends="setUp">
+    <cmp:cpio destfile="${dest}">
+      <cmp:arfileset src="../resources/asf-logo.gif.ar"
+                     prefix="x/"
+                     includes="asf-logo.gif"/>
+    </cmp:cpio>
+    <assertResourceExists>
+      <cmp:cpioentry name="x/asf-logo.gif">
+        <file file="${dest}"/>
+      </cmp:cpioentry>
+    </assertResourceExists>
+    <assertResourceDoesntExist>
+      <cmp:cpioentry name="asf-logo.gif">
+        <file file="${dest}"/>
+      </cmp:cpioentry>
+    </assertResourceDoesntExist>
+  </target>
+
+  <target name="testPrefixWithBackslash" depends="setUp">
+    <cmp:cpio destfile="${dest}">
+      <cmp:arfileset src="../resources/asf-logo.gif.ar"
+                     prefix="x\"
+                     includes="asf-logo.gif"/>
+    </cmp:cpio>
+    <assertResourceExists>
+      <cmp:cpioentry name="x/asf-logo.gif">
+        <file file="${dest}"/>
+      </cmp:cpioentry>
+    </assertResourceExists>
+    <assertResourceDoesntExist>
+      <cmp:cpioentry name="asf-logo.gif">
+        <file file="${dest}"/>
+      </cmp:cpioentry>
+    </assertResourceDoesntExist>
+  </target>
+
+  <target name="testPrefixWithoutSlash" depends="setUp">
+    <cmp:cpio destfile="${dest}">
+      <cmp:arfileset src="../resources/asf-logo.gif.ar"
+                     prefix="x"
+                     includes="asf-logo.gif"/>
+    </cmp:cpio>
+    <assertResourceExists>
+      <cmp:cpioentry name="x/asf-logo.gif">
+        <file file="${dest}"/>
+      </cmp:cpioentry>
+    </assertResourceExists>
+    <assertResourceDoesntExist>
+      <cmp:cpioentry name="asf-logo.gif">
+        <file file="${dest}"/>
+      </cmp:cpioentry>
+    </assertResourceDoesntExist>
+  </target>
+
 </project>

Modified: ant/sandbox/antlibs/compress/trunk/src/tests/antunit/tar-test.xml
URL: http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/tests/antunit/tar-test.xml?rev=807073&r1=807072&r2=807073&view=diff
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/src/tests/antunit/tar-test.xml (original)
+++ ant/sandbox/antlibs/compress/trunk/src/tests/antunit/tar-test.xml Mon Aug 24 04:16:41
2009
@@ -237,4 +237,76 @@
                      uid="1000" gid="1000"/>
   </target>
 
+  <target name="testFullpath" depends="setUp">
+    <cmp:tar destfile="${dest}">
+      <cmp:arfileset src="../resources/asf-logo.gif.ar"
+                     fullpath="logo.gif"
+                     includes="asf-logo.gif"/>
+    </cmp:tar>
+    <assertResourceExists>
+      <cmp:tarentry name="logo.gif">
+        <file file="${dest}"/>
+      </cmp:tarentry>
+    </assertResourceExists>
+    <assertResourceDoesntExist>
+      <cmp:tarentry name="asf-logo.gif">
+        <file file="${dest}"/>
+      </cmp:tarentry>
+    </assertResourceDoesntExist>
+  </target>
+
+  <target name="testPrefixWithSlash" depends="setUp">
+    <cmp:tar destfile="${dest}">
+      <cmp:arfileset src="../resources/asf-logo.gif.ar"
+                     prefix="x/"
+                     includes="asf-logo.gif"/>
+    </cmp:tar>
+    <assertResourceExists>
+      <cmp:tarentry name="x/asf-logo.gif">
+        <file file="${dest}"/>
+      </cmp:tarentry>
+    </assertResourceExists>
+    <assertResourceDoesntExist>
+      <cmp:tarentry name="asf-logo.gif">
+        <file file="${dest}"/>
+      </cmp:tarentry>
+    </assertResourceDoesntExist>
+  </target>
+
+  <target name="testPrefixWithBackslash" depends="setUp">
+    <cmp:tar destfile="${dest}">
+      <cmp:arfileset src="../resources/asf-logo.gif.ar"
+                     prefix="x\"
+                     includes="asf-logo.gif"/>
+    </cmp:tar>
+    <assertResourceExists>
+      <cmp:tarentry name="x/asf-logo.gif">
+        <file file="${dest}"/>
+      </cmp:tarentry>
+    </assertResourceExists>
+    <assertResourceDoesntExist>
+      <cmp:tarentry name="asf-logo.gif">
+        <file file="${dest}"/>
+      </cmp:tarentry>
+    </assertResourceDoesntExist>
+  </target>
+
+  <target name="testPrefixWithoutSlash" depends="setUp">
+    <cmp:tar destfile="${dest}">
+      <cmp:arfileset src="../resources/asf-logo.gif.ar"
+                     prefix="x"
+                     includes="asf-logo.gif"/>
+    </cmp:tar>
+    <assertResourceExists>
+      <cmp:tarentry name="x/asf-logo.gif">
+        <file file="${dest}"/>
+      </cmp:tarentry>
+    </assertResourceExists>
+    <assertResourceDoesntExist>
+      <cmp:tarentry name="asf-logo.gif">
+        <file file="${dest}"/>
+      </cmp:tarentry>
+    </assertResourceDoesntExist>
+  </target>
+
 </project>

Modified: ant/sandbox/antlibs/compress/trunk/src/tests/antunit/zip-test.xml
URL: http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/tests/antunit/zip-test.xml?rev=807073&r1=807072&r2=807073&view=diff
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/src/tests/antunit/zip-test.xml (original)
+++ ant/sandbox/antlibs/compress/trunk/src/tests/antunit/zip-test.xml Mon Aug 24 04:16:41
2009
@@ -204,4 +204,76 @@
     <checkProperties dateTime="2009-07-31-20:11:12 +0200" mode="600"/>
   </target>
 
+  <target name="testFullpath" depends="setUp">
+    <cmp:zip destfile="${dest}">
+      <cmp:arfileset src="../resources/asf-logo.gif.ar"
+                     fullpath="logo.gif"
+                     includes="asf-logo.gif"/>
+    </cmp:zip>
+    <assertResourceExists>
+      <cmp:zipentry name="logo.gif">
+        <file file="${dest}"/>
+      </cmp:zipentry>
+    </assertResourceExists>
+    <assertResourceDoesntExist>
+      <cmp:zipentry name="asf-logo.gif">
+        <file file="${dest}"/>
+      </cmp:zipentry>
+    </assertResourceDoesntExist>
+  </target>
+
+  <target name="testPrefixWithSlash" depends="setUp">
+    <cmp:zip destfile="${dest}">
+      <cmp:arfileset src="../resources/asf-logo.gif.ar"
+                     prefix="x/"
+                     includes="asf-logo.gif"/>
+    </cmp:zip>
+    <assertResourceExists>
+      <cmp:zipentry name="x/asf-logo.gif">
+        <file file="${dest}"/>
+      </cmp:zipentry>
+    </assertResourceExists>
+    <assertResourceDoesntExist>
+      <cmp:zipentry name="asf-logo.gif">
+        <file file="${dest}"/>
+      </cmp:zipentry>
+    </assertResourceDoesntExist>
+  </target>
+
+  <target name="testPrefixWithBackslash" depends="setUp">
+    <cmp:zip destfile="${dest}">
+      <cmp:arfileset src="../resources/asf-logo.gif.ar"
+                     prefix="x\"
+                     includes="asf-logo.gif"/>
+    </cmp:zip>
+    <assertResourceExists>
+      <cmp:zipentry name="x/asf-logo.gif">
+        <file file="${dest}"/>
+      </cmp:zipentry>
+    </assertResourceExists>
+    <assertResourceDoesntExist>
+      <cmp:zipentry name="asf-logo.gif">
+        <file file="${dest}"/>
+      </cmp:zipentry>
+    </assertResourceDoesntExist>
+  </target>
+
+  <target name="testPrefixWithoutSlash" depends="setUp">
+    <cmp:zip destfile="${dest}">
+      <cmp:arfileset src="../resources/asf-logo.gif.ar"
+                     prefix="x"
+                     includes="asf-logo.gif"/>
+    </cmp:zip>
+    <assertResourceExists>
+      <cmp:zipentry name="x/asf-logo.gif">
+        <file file="${dest}"/>
+      </cmp:zipentry>
+    </assertResourceExists>
+    <assertResourceDoesntExist>
+      <cmp:zipentry name="asf-logo.gif">
+        <file file="${dest}"/>
+      </cmp:zipentry>
+    </assertResourceDoesntExist>
+  </target>
+
 </project>



Mime
View raw message