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