View Javadoc

1   /*
2    * $Id: User.java 651946 2008-04-27 13:41:38Z apetrelli $
3    *
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "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 org.apache.struts2.TestAction;
24  import org.apache.struts2.views.jsp.AbstractUITagTest;
25  
26  public class ValidationStylesTest extends AbstractUITagTest {
27      private TextFieldTag tag;
28  
29      public void testNormalStyle() throws Exception {
30          tag.setCssStyle("style");
31          tag.doStartTag();
32          tag.doEndTag();
33  
34          verify(ValidationStylesTest.class.getResource("validationstyles-1.txt"));
35      }
36  
37      public void testErrorStyle() throws Exception {
38          tag.setCssErrorStyle("errstyle");
39          tag.doStartTag();
40          tag.doEndTag();
41  
42          verify(ValidationStylesTest.class.getResource("validationstyles-2.txt"));
43      }
44  
45      public void testErrorClass() throws Exception {
46          tag.setCssErrorClass("errclass");
47          tag.doStartTag();
48          tag.doEndTag();
49  
50          verify(ValidationStylesTest.class.getResource("validationstyles-3.txt"));
51      }
52  
53      public void testStyleAndErrorStyle() throws Exception {
54          tag.setCssStyle("style");
55          tag.setCssErrorStyle("errstyle");
56          tag.doStartTag();
57          tag.doEndTag();
58  
59          verify(ValidationStylesTest.class.getResource("validationstyles-2.txt"));
60      }
61  
62       public void testStyleAndErrorClass() throws Exception {
63          tag.setCssStyle("style");
64          tag.setCssErrorClass("errclass");
65          tag.doStartTag();
66          tag.doEndTag();
67  
68          verify(ValidationStylesTest.class.getResource("validationstyles-3.txt"));
69      }
70  
71      @Override
72      protected void setUp() throws Exception {
73          super.setUp();
74          TestAction testAction = (TestAction) action;
75          tag = new TextFieldTag();
76          tag.setPageContext(pageContext);
77          tag.setId("myId");
78          tag.setLabel("mylabel");
79          tag.setName("foo");
80          tag.setValue("bar");
81          tag.setTitle("mytitle");
82  
83          testAction.addFieldError("foo", "bar error message");
84      }
85  }