1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.struts2.views.jsp.ui;
19
20 import org.apache.struts2.TestAction;
21 import org.apache.struts2.views.jsp.AbstractUITagTest;
22
23 /***
24 * Test Submit component in "ajax" theme.
25 */
26 public class SubmitAjaxTest extends AbstractUITagTest {
27
28 public void testGenericSimple() throws Exception {
29 AbstractRemoteCallUITag tag = new DivTag();
30 verifyGenericProperties(tag, "simple", new String[]{"value","tabindex","disabled"});
31 }
32
33 public void testGenericXhtml() throws Exception {
34 AbstractRemoteCallUITag tag = new DivTag();
35 verifyGenericProperties(tag, "xhtml", new String[]{"value","tabindex","disabled"});
36 }
37
38 public void testGenericAjax() throws Exception {
39 AbstractRemoteCallUITag tag = new DivTag();
40 verifyGenericProperties(tag, "ajax", new String[]{"value","tabindex","disabled"});
41 }
42
43 public void testSubmit() throws Exception {
44 TestAction testAction = (TestAction) action;
45 testAction.setFoo("bar");
46
47 SubmitTag tag = new SubmitTag();
48 tag.setPageContext(pageContext);
49
50 tag.setId("a");
51 tag.setTheme("ajax");
52 tag.setHref("b");
53 tag.setLoadingText("c");
54 tag.setErrorText("d");
55 tag.setListenTopics("e");
56 tag.setPreInvokeJS("f");
57 tag.setOnLoadJS("g");
58 tag.setHandler("h");
59 tag.setType("submit");
60 tag.setLabel("i");
61 tag.setNotifyTopics("k");
62 tag.setIndicator("l");
63 tag.setShowLoadingText("true");
64 tag.doStartTag();
65 tag.doEndTag();
66
67 verify(SubmitAjaxTest.class.getResource("submit-ajax-1.txt"));
68 }
69
70 public void testButton() throws Exception {
71 TestAction testAction = (TestAction) action;
72 testAction.setFoo("bar");
73
74 SubmitTag tag = new SubmitTag();
75 tag.setPageContext(pageContext);
76
77 tag.setId("a");
78 tag.setTheme("ajax");
79 tag.setHref("b");
80 tag.setLoadingText("c");
81 tag.setErrorText("d");
82 tag.setListenTopics("e");
83 tag.setPreInvokeJS("f");
84 tag.setOnLoadJS("g");
85 tag.setHandler("h");
86 tag.setType("button");
87 tag.setLabel("i");
88 tag.setNotifyTopics("k");
89 tag.setIndicator("l");
90 tag.doStartTag();
91 tag.doEndTag();
92
93 verify(SubmitAjaxTest.class.getResource("submit-ajax-2.txt"));
94 }
95
96 public void testImage() throws Exception {
97 TestAction testAction = (TestAction) action;
98 testAction.setFoo("bar");
99
100 SubmitTag tag = new SubmitTag();
101 tag.setPageContext(pageContext);
102
103 tag.setId("a");
104 tag.setTheme("ajax");
105 tag.setHref("b");
106 tag.setLoadingText("c");
107 tag.setErrorText("d");
108 tag.setListenTopics("e");
109 tag.setPreInvokeJS("f");
110 tag.setOnLoadJS("g");
111 tag.setHandler("h");
112 tag.setType("image");
113 tag.setLabel("i");
114 tag.setSrc("j");
115 tag.setNotifyTopics("k");
116 tag.setIndicator("l");
117 tag.doStartTag();
118 tag.doEndTag();
119
120 verify(SubmitAjaxTest.class.getResource("submit-ajax-3.txt"));
121 }
122 }