01: /*
02: * $Id: FileTest.java 471756 2006-11-06 15:01:43Z husted $
03: *
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "License"); you may not use this file except in compliance
10: * with the License. You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing,
15: * software distributed under the License is distributed on an
16: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17: * KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations
19: * under the License.
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: public class FileTest extends AbstractUITagTest {
31:
32: public FileTest() {
33: }
34:
35: public void testSimple() throws Exception {
36: TestAction testAction = (TestAction) action;
37: testAction.setFoo("bar");
38:
39: FileTag tag = new FileTag();
40: tag.setPageContext(pageContext);
41: tag.setLabel("mylabel");
42: tag.setName("myname");
43: tag.setAccept("*.txt");
44: tag.setValue("%{foo}");
45: tag.setSize("10");
46: tag.setTitle("mytitle");
47:
48: tag.doStartTag();
49: tag.doEndTag();
50:
51: verify(TextFieldTag.class.getResource("File-1.txt"));
52: }
53:
54: /**
55: * Initialize a map of {@link org.apache.struts2.views.jsp.AbstractUITagTest.PropertyHolder} for generic tag
56: * property testing. Will be used when calling {@link #verifyGenericProperties(org.apache.struts2.views.jsp.ui.AbstractUITag,
57: * String, String[])} as properties to verify.<p/> This implementation extends testdata from AbstractUITag.
58: *
59: * @return A Map of PropertyHolders values bound to {@link org.apache.struts2.views.jsp.AbstractUITagTest.PropertyHolder#getName()}
60: * as key.
61: */
62: protected Map initializedGenericTagTestProperties() {
63: Map result = super .initializedGenericTagTestProperties();
64: new PropertyHolder("accept", "someAccepted").addToMap(result);
65: new PropertyHolder("size", "101").addToMap(result);
66: return result;
67: }
68:
69: public void testGenericSimple() throws Exception {
70: FileTag tag = new FileTag();
71: verifyGenericProperties(tag, "simple", null);
72: }
73:
74: public void testGenericXhtml() throws Exception {
75: FileTag tag = new FileTag();
76: verifyGenericProperties(tag, "xhtml", null);
77: }
78:
79: public void testGenericAjax() throws Exception {
80: FileTag tag = new FileTag();
81: verifyGenericProperties(tag, "ajax", null);
82: }
83:
84: }
|