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.webwork.components.Head;
09:
10: /**
11: * Unit test for {@link HeadTag}.
12: * <p/>
13: * Note: If unit test fails with encoding difference check the src/test/webwork.properties
14: * and adjust the .txt files accordingly
15: *
16: * @author Claus Ibsen
17: */
18: public class HeadTagTest extends AbstractUITagTest {
19:
20: private HeadTag tag;
21:
22: public void testHead1() throws Exception {
23: tag.doStartTag();
24: tag.doEndTag();
25:
26: verify(HeadTagTest.class.getResource("HeadTagTest-1.txt"));
27: }
28:
29: public void testHead1NoCalender() throws Exception {
30: tag.doStartTag();
31: tag.doEndTag();
32: tag.setCalendarcss(null); // null = should use calendar-blue.css
33:
34: verify(HeadTagTest.class.getResource("HeadTagTest-1.txt"));
35: }
36:
37: public void testHead2() throws Exception {
38: tag.setTheme("ajax");
39: tag.doStartTag();
40: Head component = (Head) tag.getComponent();
41: assertTrue(!component.isDebug());
42: tag.doEndTag();
43:
44: verify(HeadTagTest.class.getResource("HeadTagTest-2.txt"));
45: assertTrue("should have debug false", writer.toString()
46: .indexOf("isDebug: false") > -1);
47: }
48:
49: public void testHead3() throws Exception {
50: tag.setTheme("ajax");
51: tag.setDebug("true");
52: tag.doStartTag();
53: Head component = (Head) tag.getComponent(); // must be done between start and end
54: assertTrue(component.isDebug());
55: tag.doEndTag();
56:
57: verify(HeadTagTest.class.getResource("HeadTagTest-3.txt"));
58: assertTrue("should have debug true", writer.toString().indexOf(
59: "isDebug: true") > -1);
60: }
61:
62: public void testHead4() throws Exception {
63: tag.setCalendarcss("my-calendar");
64: tag.doStartTag();
65: tag.doEndTag();
66:
67: verify(HeadTagTest.class.getResource("HeadTagTest-4.txt"));
68: assertEquals("my-calendar", tag.getCalendarcss());
69: }
70:
71: public void testHead4b() throws Exception {
72: tag.setCalendarcss("my-calendar.css");
73: tag.doStartTag();
74: Head component = (Head) tag.getComponent(); // must be done between start and end
75: assertEquals("my-calendar.css", component.getCalendarcss());
76: tag.doEndTag();
77:
78: verify(HeadTagTest.class.getResource("HeadTagTest-4.txt"));
79: assertEquals("my-calendar.css", tag.getCalendarcss());
80: }
81:
82: protected void setUp() throws Exception {
83: super .setUp();
84: tag = new HeadTag();
85: tag.setPageContext(pageContext);
86: }
87:
88: protected void tearDown() throws Exception {
89: super.tearDown();
90: }
91:
92: }
|