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