commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r344025 - in /jakarta/commons/proper/jelly/trunk/jelly-tags/junit/src: java/org/apache/commons/jelly/tags/junit/ test/org/apache/commons/jelly/tags/junit/
Date Mon, 14 Nov 2005 02:48:18 GMT
Author: dion
Date: Sun Nov 13 18:48:10 2005
New Revision: 344025

URL: http://svn.apache.org/viewcvs?rev=344025&view=rev
Log:
Add AssertFileNotFoundTag and tests

Added:
    jakarta/commons/proper/jelly/trunk/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit/AssertFileNotFoundTag.java
Modified:
    jakarta/commons/proper/jelly/trunk/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit/JUnitTagLibrary.java
    jakarta/commons/proper/jelly/trunk/jelly-tags/junit/src/test/org/apache/commons/jelly/tags/junit/suite.jelly

Added: jakarta/commons/proper/jelly/trunk/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit/AssertFileNotFoundTag.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jelly/trunk/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit/AssertFileNotFoundTag.java?rev=344025&view=auto
==============================================================================
--- jakarta/commons/proper/jelly/trunk/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit/AssertFileNotFoundTag.java
(added)
+++ jakarta/commons/proper/jelly/trunk/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit/AssertFileNotFoundTag.java
Sun Nov 13 18:48:10 2005
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2002,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.jelly.tags.junit;
+
+import java.io.File;
+
+import org.apache.commons.jelly.JellyTagException;
+import org.apache.commons.jelly.XMLOutput;
+import org.apache.commons.jelly.expression.Expression;
+
+/**
+ * Checks that a file cant be found.
+ *
+ * @author <a href="mailto:dion@apache.org">Dion Gillard</a>
+ * @version $Revision: 344020 $
+ */
+public class AssertFileNotFoundTag extends AssertTagSupport
+{
+    /** the file to check */
+    private File file;
+
+    /**
+     * Do the tag functionality: check the file can't be found.
+     * @param output a place to write text output
+     * @throws JellyTagException if the file exists.
+     */
+    public void doTag(XMLOutput output) throws JellyTagException
+    {
+        String message = getBodyText();
+        if (message == null || message.length() == 0)
+        {
+            message = "File exists.";
+        }
+
+        
+        if (file == null)
+        {
+            fail(message, "file given is null");
+        }
+        else
+        {
+            if (file.exists())
+            {
+                fail(message);
+            }
+        }
+    }
+    
+    /**
+     * The file to be tested. If this file exists, the test will pass.
+     * @param aFile the file to test.
+     */
+    public void setFile(File aFile)
+    {
+        file = aFile;
+    }
+}

Modified: jakarta/commons/proper/jelly/trunk/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit/JUnitTagLibrary.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jelly/trunk/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit/JUnitTagLibrary.java?rev=344025&r1=344024&r2=344025&view=diff
==============================================================================
--- jakarta/commons/proper/jelly/trunk/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit/JUnitTagLibrary.java
(original)
+++ jakarta/commons/proper/jelly/trunk/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit/JUnitTagLibrary.java
Sun Nov 13 18:48:10 2005
@@ -43,6 +43,7 @@
         registerTag("assert", AssertTag.class);
         registerTag("assertEquals", AssertEqualsTag.class);
         registerTag("assertFileExists", AssertFileExistsTag.class);
+        registerTag("assertFileNotFound", AssertFileNotFoundTag.class);
         registerTag("assertThrows", AssertThrowsTag.class);
         registerTag("fail", FailTag.class);
         registerTag("run", RunTag.class );

Modified: jakarta/commons/proper/jelly/trunk/jelly-tags/junit/src/test/org/apache/commons/jelly/tags/junit/suite.jelly
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jelly/trunk/jelly-tags/junit/src/test/org/apache/commons/jelly/tags/junit/suite.jelly?rev=344025&r1=344024&r2=344025&view=diff
==============================================================================
--- jakarta/commons/proper/jelly/trunk/jelly-tags/junit/src/test/org/apache/commons/jelly/tags/junit/suite.jelly
(original)
+++ jakarta/commons/proper/jelly/trunk/jelly-tags/junit/src/test/org/apache/commons/jelly/tags/junit/suite.jelly
Sun Nov 13 18:48:10 2005
@@ -137,4 +137,13 @@
     <test:assert test="${ex != null}">No exception thrown for bad file</test:assert>
   </test:case>
 
+
+  <test:case name="assertFileNotFound">
+    <test:assertFileNotFound file="${basedir}/dummydummy">Dummy file found</test:assertFileNotFound>
+
+    <test:assertThrows var="ex">
+      <test:assertFileNotFound file="${basedir}/project.xml">Bad file</test:assertFileNotFound>
+    </test:assertThrows>
+    <test:assert test="${ex != null}">No exception thrown for file that exists</test:assert>
+  </test:case>
 </test:suite>



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message