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 org.apache.struts2.TestAction;
25 import org.apache.struts2.views.jsp.AbstractUITagTest;
26
27
28 /***
29 */
30 public class AnchorTest extends AbstractUITagTest {
31
32 public void testSimple() throws Exception {
33 TestAction testAction = (TestAction) action;
34 testAction.setFoo("bar");
35
36 AnchorTag tag = new AnchorTag();
37 tag.setPageContext(pageContext);
38
39 tag.setId("mylink");
40 tag.setHref("a");
41 tag.doStartTag();
42 tag.doEndTag();
43
44 verify(AnchorTest.class.getResource("href-1.txt"));
45 }
46
47 public void testSimpleBadQuote() throws Exception {
48 TestAction testAction = (TestAction) action;
49 testAction.setFoo("bar");
50
51 AnchorTag tag = new AnchorTag();
52 tag.setPageContext(pageContext);
53
54 tag.setId("mylink");
55 tag.setHref("a\"");
56 tag.doStartTag();
57 tag.doEndTag();
58
59 verify(AnchorTest.class.getResource("href-2.txt"));
60 }
61
62 public void testDynamicAttribute() throws Exception {
63 TestAction testAction = (TestAction) action;
64 testAction.setFoo("bar");
65
66 AnchorTag tag = new AnchorTag();
67 tag.setPageContext(pageContext);
68
69 tag.setId("mylink");
70 tag.setHref("a");
71
72 tag.setDynamicAttribute("uri", "dynAttrName", "dynAttrValue");
73
74 tag.doStartTag();
75 tag.doEndTag();
76
77 verify(AnchorTest.class.getResource("Anchor-2.txt"));
78 }
79 }