01: /*
02: * Copyright (c) 2002-2006 by OpenSymphony
03: * All rights reserved.
04: */
05: package com.opensymphony.webwork.views.jsp.ui;
06:
07: import com.opensymphony.webwork.views.jsp.AbstractUITagTest;
08: import com.opensymphony.xwork.ActionContext;
09:
10: import java.util.Locale;
11:
12: /**
13: * Unit test for {@link DatePickerTag}.
14: *
15: * @author Claus Ibsen
16: */
17: public class DatePickerTagTest extends AbstractUITagTest {
18:
19: private DatePickerTag tag;
20:
21: public void testDefault() throws Exception {
22: tag.doStartTag();
23: tag.doEndTag();
24:
25: verify(DatePickerTagTest.class
26: .getResource("DatePickerTagTest-1.txt"));
27: }
28:
29: public void testLocaleInStack() throws Exception {
30: stack.getContext().put(ActionContext.LOCALE, Locale.FRANCE);
31:
32: tag.setLanguage(null);
33: tag.doStartTag();
34: tag.doEndTag();
35:
36: verify(DatePickerTagTest.class
37: .getResource("DatePickerTagTest-2.txt"));
38: }
39:
40: public void testFormat() throws Exception {
41: tag.setFormat("yyyy/MM/dd hh:mm:ss");
42:
43: tag.doStartTag();
44: tag.doEndTag();
45: assertTrue("Should contain format", writer.toString().indexOf(
46: "yyyy/MM/dd hh:mm:ss") > -1);
47: }
48:
49: public void testLanguage() throws Exception {
50: tag.setLanguage("da");
51:
52: tag.doStartTag();
53: tag.doEndTag();
54: assertTrue("Should contain danish language",
55: writer.toString().indexOf(
56: "/webwork/jscalendar/lang/calendar-da.js") > -1);
57: }
58:
59: public void testShowstime() throws Exception {
60: tag.setShowstime("24");
61:
62: tag.doStartTag();
63: tag.doEndTag();
64: assertTrue("Should contain showsTime 24", writer.toString()
65: .indexOf("showsTime : \"24\"") > -1);
66: }
67:
68: public void testSingleclick() throws Exception {
69: tag.setSingleclick("true");
70:
71: tag.doStartTag();
72: tag.doEndTag();
73: }
74:
75: protected void setUp() throws Exception {
76: super .setUp();
77: tag = new DatePickerTag();
78: tag.setPageContext(pageContext);
79: }
80:
81: protected void tearDown() throws Exception {
82: super.tearDown();
83: }
84:
85: }
|