1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.junit.annotation;
16
17 import java.lang.reflect.Method;
18
19 import org.junit.Assert;
20 import org.junit.Test;
21
22
23
24
25
26
27 public class AnnotationUtilsTest {
28
29
30
31
32 @Test
33 @Alerts(DEFAULT = "default",
34 CHROME = "chrome",
35 EDGE = "edge",
36 FF = "ff",
37 FF_ESR = "ff esr")
38 public void obsoleteDefaultBecauseAllBrowserExpectationsDefinedIndividually() throws Exception {
39 testFail("Obsolete DEFAULT because all browser expectations defined individually",
40 "obsoleteDefaultBecauseAllBrowserExpectationsDefinedIndividually");
41 }
42
43
44
45
46 @Test
47 @Alerts(DEFAULT = "redundant",
48 CHROME = "redundant")
49 public void redundantAlertChrome() throws Exception {
50 testFail("Redundant @Alerts for Chrome in AnnotationUtilsTest.redundantAlertChrome()",
51 "redundantAlertChrome");
52 }
53
54
55
56
57 @Test
58 @Alerts(DEFAULT = "redundant",
59 EDGE = "redundant")
60 public void redundantAlertEdge() throws Exception {
61 testFail("Redundant @Alerts for Edge in AnnotationUtilsTest.redundantAlertEdge()",
62 "redundantAlertEdge");
63 }
64
65
66
67
68 @Test
69 @Alerts(DEFAULT = "redundant",
70 FF = "redundant")
71 public void redundantAlertFf() throws Exception {
72 testFail("Redundant @Alerts for FF in AnnotationUtilsTest.redundantAlertFf()",
73 "redundantAlertFf");
74 }
75
76
77
78
79 @Test
80 @Alerts(DEFAULT = "redundant",
81 FF_ESR = "redundant")
82 public void redundantAlertFfEsr() throws Exception {
83 testFail("Redundant @Alerts for FF-ESR in AnnotationUtilsTest.redundantAlertFfEsr()",
84 "redundantAlertFfEsr");
85 }
86
87
88
89
90 @Test
91 @Alerts("redundant")
92 @HtmlUnitNYI("redundant")
93 public void redundantHtmlUnitNYI() throws Exception {
94 testFail("Redundant @HtmlUnitNYI for DEFAULT in AnnotationUtilsTest.redundantHtmlUnitNYI()",
95 "redundantHtmlUnitNYI");
96 }
97
98
99
100
101 @Test
102 @Alerts("redundant")
103 @HtmlUnitNYI(CHROME = "redundant")
104 public void redundantHtmlUnitNYIChrome() throws Exception {
105 testFail("Redundant @HtmlUnitNYI for Chrome in AnnotationUtilsTest.redundantHtmlUnitNYIChrome()",
106 "redundantHtmlUnitNYIChrome");
107 }
108
109
110
111
112 @Test
113 @Alerts("redundant")
114 @HtmlUnitNYI(EDGE = "redundant")
115 public void redundantHtmlUnitNYIEdge() throws Exception {
116 testFail("Redundant @HtmlUnitNYI for Edge in AnnotationUtilsTest.redundantHtmlUnitNYIEdge()",
117 "redundantHtmlUnitNYIEdge");
118 }
119
120
121
122
123 @Test
124 @Alerts("redundant")
125 @HtmlUnitNYI(FF = "redundant")
126 public void redundantHtmlUnitNYIFf() throws Exception {
127 testFail("Redundant @HtmlUnitNYI for FF in AnnotationUtilsTest.redundantHtmlUnitNYIFf()",
128 "redundantHtmlUnitNYIFf");
129 }
130
131
132
133
134 @Test
135 @Alerts("redundant")
136 @HtmlUnitNYI(FF_ESR = "redundant")
137 public void redundantHtmlUnitNYIFfEsr() throws Exception {
138 testFail("Redundant @HtmlUnitNYI for FF-ESR in AnnotationUtilsTest.redundantHtmlUnitNYIFfEsr()",
139 "redundantHtmlUnitNYIFfEsr");
140 }
141
142
143
144
145 @Test
146 @Alerts(DEFAULT = "",
147 CHROME = "redundant")
148 @HtmlUnitNYI(CHROME = "redundant")
149 public void redundantChromeHtmlUnitNYIChrome() throws Exception {
150 testFail("Redundant @HtmlUnitNYI for Chrome in AnnotationUtilsTest.redundantChromeHtmlUnitNYIChrome()",
151 "redundantChromeHtmlUnitNYIChrome");
152 }
153
154
155
156
157 @Test
158 @Alerts(DEFAULT = "",
159 EDGE = "redundant")
160 @HtmlUnitNYI(EDGE = "redundant")
161 public void redundantEdgeHtmlUnitNYIEdge() throws Exception {
162 testFail("Redundant @HtmlUnitNYI for Edge in AnnotationUtilsTest.redundantEdgeHtmlUnitNYIEdge()",
163 "redundantEdgeHtmlUnitNYIEdge");
164 }
165
166
167
168
169 @Test
170 @Alerts(DEFAULT = "",
171 FF = "redundant")
172 @HtmlUnitNYI(FF = "redundant")
173 public void redundantFfHtmlUnitNYIFf() throws Exception {
174 testFail("Redundant @HtmlUnitNYI for FF in AnnotationUtilsTest.redundantFfHtmlUnitNYIFf()",
175 "redundantFfHtmlUnitNYIFf");
176 }
177
178
179
180
181 @Test
182 @Alerts(DEFAULT = "",
183 FF_ESR = "redundant")
184 @HtmlUnitNYI(FF_ESR = "redundant")
185 public void redundantFfEsrHtmlUnitNYIFfEsr() throws Exception {
186 testFail("Redundant @HtmlUnitNYI for FF-ESR in AnnotationUtilsTest.redundantFfEsrHtmlUnitNYIFfEsr()",
187 "redundantFfEsrHtmlUnitNYIFfEsr");
188 }
189
190
191
192
193 @Test
194 @Alerts(CHROME = "redundant")
195 @HtmlUnitNYI(CHROME = "redundant")
196 public void redundantChrome2HtmlUnitNYIChrome() throws Exception {
197 testFail("Redundant @HtmlUnitNYI for Chrome in AnnotationUtilsTest.redundantChrome2HtmlUnitNYIChrome()",
198 "redundantChrome2HtmlUnitNYIChrome");
199 }
200
201
202
203
204 @Test
205 @Alerts(EDGE = "redundant")
206 @HtmlUnitNYI(EDGE = "redundant")
207 public void redundantEdge2HtmlUnitNYIEdge() throws Exception {
208 testFail("Redundant @HtmlUnitNYI for Edge in AnnotationUtilsTest.redundantEdge2HtmlUnitNYIEdge()",
209 "redundantEdge2HtmlUnitNYIEdge");
210 }
211
212
213
214
215 @Test
216 @Alerts(FF = "redundant")
217 @HtmlUnitNYI(FF = "redundant")
218 public void redundantFf2HtmlUnitNYIFf() throws Exception {
219 testFail("Redundant @HtmlUnitNYI for FF in AnnotationUtilsTest.redundantFf2HtmlUnitNYIFf()",
220 "redundantFf2HtmlUnitNYIFf");
221 }
222
223
224
225
226 @Test
227 @Alerts(FF_ESR = "redundant")
228 @HtmlUnitNYI(FF_ESR = "redundant")
229 public void redundantFfEsr2HtmlUnitNYIFfEsr() throws Exception {
230 testFail("Redundant @HtmlUnitNYI for FF-ESR in AnnotationUtilsTest.redundantFfEsr2HtmlUnitNYIFfEsr()",
231 "redundantFfEsr2HtmlUnitNYIFfEsr");
232 }
233
234 private void testFail(final String expectedMsg, final String methodName) throws Exception {
235 final Method method = getClass().getMethod(methodName, (Class[]) null);
236
237 try {
238 AnnotationUtils.assertAlerts(method);
239 Assert.fail("AssertionError expected");
240 }
241 catch (final AssertionError e) {
242 Assert.assertEquals(expectedMsg, e.getMessage());
243 }
244 }
245 }