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.Map;
24
25 import org.apache.struts2.TestAction;
26 import org.apache.struts2.views.jsp.AbstractUITagTest;
27
28
29 /***
30 */
31 public class FileTest extends AbstractUITagTest {
32
33 public FileTest() {
34 }
35
36
37 public void testSimple() throws Exception {
38 TestAction testAction = (TestAction) action;
39 testAction.setFoo("bar");
40
41 FileTag tag = new FileTag();
42 tag.setPageContext(pageContext);
43 tag.setLabel("mylabel");
44 tag.setName("myname");
45 tag.setAccept("*.txt");
46 tag.setValue("%{foo}");
47 tag.setSize("10");
48 tag.setTitle("mytitle");
49
50 tag.doStartTag();
51 tag.doEndTag();
52
53 verify(TextFieldTag.class.getResource("File-1.txt"));
54 }
55
56 /***
57 * Initialize a map of {@link org.apache.struts2.views.jsp.AbstractUITagTest.PropertyHolder} for generic tag
58 * property testing. Will be used when calling {@link #verifyGenericProperties(org.apache.struts2.views.jsp.ui.AbstractUITag,
59 * String, String[])} as properties to verify.<p/> This implementation extends testdata from AbstractUITag.
60 *
61 * @return A Map of PropertyHolders values bound to {@link org.apache.struts2.views.jsp.AbstractUITagTest.PropertyHolder#getName()}
62 * as key.
63 */
64 protected Map initializedGenericTagTestProperties() {
65 Map result = super.initializedGenericTagTestProperties();
66 new PropertyHolder("accept", "someAccepted").addToMap(result);
67 new PropertyHolder("size", "101").addToMap(result);
68 return result;
69 }
70
71 public void testGenericSimple() throws Exception {
72 FileTag tag = new FileTag();
73 verifyGenericProperties(tag, "simple", null);
74 }
75
76 public void testGenericXhtml() throws Exception {
77 FileTag tag = new FileTag();
78 verifyGenericProperties(tag, "xhtml", null);
79 }
80
81 public void testGenericAjax() throws Exception {
82 FileTag tag = new FileTag();
83 verifyGenericProperties(tag, "ajax", null);
84 }
85
86 }