ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1182253 - in /ant/antlibs/compress/trunk/src: main/org/apache/ant/compress/taskdefs/Pack200Normalize.java tests/antunit/pack200normalize-test.xml
Date Wed, 12 Oct 2011 08:16:33 GMT
Author: bodewig
Date: Wed Oct 12 08:16:32 2011
New Revision: 1182253

URL: http://svn.apache.org/viewvc?rev=1182253&view=rev
Log:
some more sanity checks

Modified:
    ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Pack200Normalize.java
    ant/antlibs/compress/trunk/src/tests/antunit/pack200normalize-test.xml

Modified: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Pack200Normalize.java
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Pack200Normalize.java?rev=1182253&r1=1182252&r2=1182253&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Pack200Normalize.java
(original)
+++ ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Pack200Normalize.java
Wed Oct 12 08:16:32 2011
@@ -85,6 +85,15 @@ public class Pack200Normalize extends Ta
         if (src == null) {
             throw new BuildException("srcFile attribute is required");
         }
+        if (!src.exists()) {
+            throw new BuildException(src + " doesn't exists");
+        }
+        if (!src.isFile()) {
+            throw new BuildException(src + " must be a file");
+        }
+        if (dest != null && dest.isDirectory()) {
+            throw new BuildException(dest + " must be a file");
+        }
         if (force ||
             (dest != null
              && SelectorUtils.isOutOfDate(new FileResource(src),

Modified: ant/antlibs/compress/trunk/src/tests/antunit/pack200normalize-test.xml
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/tests/antunit/pack200normalize-test.xml?rev=1182253&r1=1182252&r2=1182253&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/tests/antunit/pack200normalize-test.xml (original)
+++ ant/antlibs/compress/trunk/src/tests/antunit/pack200normalize-test.xml Wed Oct 12 08:16:32
2011
@@ -36,6 +36,24 @@
     </au:expectfailure>
   </target>
 
+  <target name="testSrcfileMustExist">
+    <au:expectfailure>
+      <cmp:pack200normalize srcfile="${bar}"/>
+    </au:expectfailure>
+  </target>
+
+  <target name="testSrcfileMustNotBeADirectory">
+    <au:expectfailure>
+      <cmp:pack200normalize srcfile="${output}"/>
+    </au:expectfailure>
+  </target>
+
+  <target name="testDestfileMustNotBeADirectory">
+    <au:expectfailure>
+      <cmp:pack200normalize srcfile="${foo}" destfile="${output}"/>
+    </au:expectfailure>
+  </target>
+
   <target name="testNormalizeSelfWithoutForceDoesntDoAnything">
     <cmp:pack200normalize srcfile="${foo}"/>
     <au:assertLogContains
@@ -62,8 +80,16 @@
     <au:assertDestIsOutofdate src="${foo}" dest="${bar}"/>
   </target>
 
-  <target name="testNormalize">
+  <target name="testNormalizeNonExistantTarget">
+    <sleep seconds="2"/>
+    <cmp:pack200normalize srcfile="${foo}" destfile="${bar}"/>
+    <au:assertDestIsOutofdate dest="${foo}" src="${bar}"/>
+  </target>
+
+  <target name="testNormalizesOutOfDateTarget">
+    <touch file="${bar}"/>
     <sleep seconds="2"/>
+    <touch file="${foo}"/>
     <cmp:pack200normalize srcfile="${foo}" destfile="${bar}"/>
     <au:assertDestIsOutofdate dest="${foo}" src="${bar}"/>
   </target>



Mime
View raw message