1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.jelly.tags.junit;
17
18 import java.io.File;
19
20 import org.apache.commons.jelly.JellyTagException;
21 import org.apache.commons.jelly.MissingAttributeException;
22 import org.apache.commons.jelly.XMLOutput;
23 import org.apache.commons.jelly.expression.Expression;
24
25 /***
26 * Checks that a file cant be found.
27 *
28 * @author <a href="mailto:dion@apache.org">Dion Gillard</a>
29 * @version $Revision: 345902 $
30 */
31 public class AssertFileNotFoundTag extends AssertTagSupport
32 {
33 /*** the file to check */
34 private File file;
35
36 /***
37 * Do the tag functionality: check the file can't be found.
38 * @param output a place to write text output
39 * @throws JellyTagException if the file exists.
40 */
41 public void doTag(XMLOutput output) throws JellyTagException
42 {
43 String message = getBodyText();
44 if (message == null || message.length() == 0)
45 {
46 message = "File exists.";
47 }
48
49
50 if (file == null)
51 {
52 throw new MissingAttributeException("file");
53 }
54 else
55 {
56 assertFalse(message, file.exists());
57 }
58 }
59
60 /***
61 * The file to be tested. If this file exists, the test will pass.
62 * @param aFile the file to test.
63 */
64 public void setFile(File aFile)
65 {
66 file = aFile;
67 }
68 }