1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.jelly.ant.tag;
17
18 import junit.framework.AssertionFailedError;
19
20 import org.apache.commons.jelly.JellyTagException;
21 import org.apache.commons.jelly.TagSupport;
22 import org.apache.commons.jelly.XMLOutput;
23 import org.apache.commons.jelly.impl.BeanSource;
24 import org.apache.commons.jelly.tags.ant.AntTagLibrary;
25 import org.apache.commons.logging.Log;
26 import org.apache.commons.logging.LogFactory;
27 import org.apache.tools.ant.types.Path;
28
29 /***
30 * A mock tag which is used for testing the Ant nested properties behaviour
31 *
32 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
33 * @version $Revision: 1.9 $
34 */
35 public class DummyTag extends TagSupport implements BeanSource {
36
37 /*** The Log to which logging calls will be made. */
38 private static Log log = LogFactory.getLog(DummyTag.class);
39
40 private String var;
41
42 private boolean calledCreatepath;
43 private boolean calledSetClasspath;
44 private boolean calledSetFlag;
45
46 private Path classpath;
47 private boolean flag;
48
49 public DummyTag() {
50 }
51
52
53
54 public Object getBean() {
55 return this;
56 }
57
58
59
60 public void doTag(XMLOutput output) throws JellyTagException {
61
62 if (! calledSetFlag) {
63 throw new AssertionFailedError("call to setFlag() was not made");
64 }
65
66 calledCreatepath = false;
67 calledSetClasspath = false;
68
69 invokeBody(output);
70
71 if (! calledCreatepath) {
72 throw new AssertionFailedError("call to createClasspath() was not made");
73 }
74
75 if (! calledSetClasspath) {
76 throw new AssertionFailedError("call to setClasspath() was not made");
77 }
78 log.info( "Called with classpath: " + classpath );
79
80 if (var != null) {
81 context.setVariable(var, classpath);
82 }
83 }
84
85
86
87 public Path createClasspath() {
88 log.info("called createClasspath()");
89 calledCreatepath = true;
90 return new Path( AntTagLibrary.getProject(context) );
91 }
92
93 public void setClasspath(Path classpath) {
94 log.info("called setClasspath()");
95 calledSetClasspath = true;
96 this.classpath = classpath;
97 }
98
99 public void setFlag(boolean flag)
100 {
101 log.info("called setFlag()");
102 calledSetFlag = true;
103 this.flag = flag;
104
105 }
106
107
108
109
110 public void setVar(String var) {
111 this.var = var;
112 }
113 }