1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.struts2.views.jsp.ui;
22
23 import java.util.Calendar;
24 import java.util.Date;
25 import java.util.HashMap;
26 import java.util.Map;
27
28 import javax.servlet.jsp.tagext.BodyTagSupport;
29
30
31 /***
32 */
33 public class MockTag extends BodyTagSupport {
34
35 private static final long serialVersionUID = 2694367759647164641L;
36
37 private static String s;
38 private static Integer i;
39 private static Double d;
40 private static Long l;
41 private static Float f;
42 private static Date date;
43 private static Calendar cal;
44 private static HashMap params;
45 private static MockTag instance = new MockTag();
46
47
48 public static MockTag getInstance() {
49 return instance;
50 }
51
52 public void setCal(Calendar cal) {
53 MockTag.cal = cal;
54 }
55
56 public Calendar getCal() {
57 return cal;
58 }
59
60 public void setDate(Date date) {
61 MockTag.date = date;
62 }
63
64 public Date getDate() {
65 return date;
66 }
67
68 public void setDouble(Double d) {
69 MockTag.d = d;
70 }
71
72 public Double getDouble() {
73 return d;
74 }
75
76 public void setFloat(Float f) {
77 MockTag.f = f;
78 }
79
80 public Float getFloat() {
81 return f;
82 }
83
84 public void setInteger(Integer i) {
85 MockTag.i = i;
86 }
87
88 public Integer getInteger() {
89 return i;
90 }
91
92 public void setLong(Long l) {
93 MockTag.l = l;
94 }
95
96 public Long getLong() {
97 return l;
98 }
99
100 public Map getParameters() {
101 return MockTag.params;
102 }
103
104 public void setString(String s) {
105 MockTag.s = s;
106 }
107
108 public String getString() {
109 return s;
110 }
111
112 public void addParameter(String key, Object value) {
113 MockTag.params.put(key, value);
114 }
115
116 /***
117 * resets all the static variables to their initial state. this must be called before each test!
118 */
119 public void reset() {
120 s = null;
121 i = null;
122 l = null;
123 f = null;
124 date = null;
125 cal = null;
126 params = new HashMap();
127 }
128 }