View Javadoc

1   /*
2    * $Id: DatePickerTagTest.java 439747 2006-09-03 09:22:46Z mrdon $
3    *
4    * Copyright 2006 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.struts2.views.jsp.ui;
19  
20  import java.util.Locale;
21  
22  import org.apache.struts2.views.jsp.AbstractUITagTest;
23  
24  import com.opensymphony.xwork2.ActionContext;
25  
26  /***
27   * Unit test for {@link DatePickerTag}.
28   *
29   */
30  public class DatePickerTagTest extends AbstractUITagTest {
31  
32      private DatePickerTag tag;
33  
34      public void testDefault() throws Exception {
35          tag.doStartTag();
36          tag.doEndTag();
37  
38          verify(DatePickerTagTest.class.getResource("DatePickerTagTest-1.txt"));
39      }
40  
41      public void testLocaleInStack() throws Exception {
42          stack.getContext().put(ActionContext.LOCALE, Locale.FRANCE);
43  
44          tag.doStartTag();
45          tag.doEndTag();
46  
47          verify(DatePickerTagTest.class.getResource("DatePickerTagTest-2.txt"));
48      }
49  
50      public void testFormat() throws Exception {
51          tag.setFormat("#yyyy/#MM/#dd #hh:#mm:#ss");
52  
53          tag.doStartTag();
54          tag.doEndTag();
55          assertTrue("Should contain format", writer.toString().indexOf("#yyyy/#MM/#dd #hh:#mm:#ss") > -1);
56      }
57  
58      // NOTE: Switching to Dojo's DatePicker, i18n is not supported, 
59      //       Commenting out this test case
60      /*public void testLanguage() throws Exception {
61          tag.setLanguage("da");
62  
63          tag.doStartTag();
64          tag.doEndTag();
65          assertTrue("Should contain danish language", writer.toString().indexOf("/struts/jscalendar/lang/calendar-da.js") > -1);
66      }*/
67  
68      
69      // NOTE: Switching to Dojo's DatePicker, showing time is not supported.
70      //       Commenting this test case
71      /*public void testShowstime() throws Exception {
72          tag.setShowstime("24");
73  
74          tag.doStartTag();
75          tag.doEndTag();
76          assertTrue("Should contain showsTime 24", writer.toString().indexOf("showsTime      :    \"24\"") > -1);
77      }*/
78  
79      // NOTE: Switching to Dojo's DatePickuer, single / double click to popup
80      //       is not supported. Commenting out this test case.
81      /*public void testSingleclick() throws Exception {
82          tag.setSingleclick("true");
83  
84          tag.doStartTag();
85          tag.doEndTag();
86      }*/
87  
88      protected void setUp() throws Exception {
89          super.setUp();
90          tag = new DatePickerTag();
91          tag.setPageContext(pageContext);
92      }
93  
94      protected void tearDown() throws Exception {
95          super.tearDown();
96      }
97  
98  }