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