KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > html > TestInsertText


1 // Copyright 2005 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.tapestry.html;
16
17 import java.io.IOException JavaDoc;
18
19 import org.apache.hivemind.ApplicationRuntimeException;
20 import org.apache.tapestry.IMarkupWriter;
21 import org.apache.tapestry.IRequestCycle;
22 import org.apache.tapestry.components.BaseComponentTestCase;
23 import org.easymock.MockControl;
24
25 /**
26  * Tests for {@link org.apache.tapestry.html.InsertText}.
27  *
28  * @author Howard M. Lewis Ship
29  * @since 4.0
30  */

31 public class TestInsertText extends BaseComponentTestCase
32 {
33     public void testRewinding()
34     {
35         IMarkupWriter writer = newWriter();
36         IRequestCycle cycle = newCycle(true);
37
38         replayControls();
39
40         InsertText component = (InsertText) newInstance(InsertText.class);
41
42         component.render(writer, cycle);
43
44         verifyControls();
45     }
46
47     public void testRenderNull()
48     {
49         IMarkupWriter writer = newWriter();
50         IRequestCycle cycle = newCycle(false);
51
52         replayControls();
53
54         InsertText component = (InsertText) newInstance(InsertText.class);
55
56         component.render(writer, cycle);
57
58         verifyControls();
59     }
60
61     public void testRenderBreaks()
62     {
63         IMarkupWriter writer = newWriter();
64         IRequestCycle cycle = newCycle(false);
65
66         writer.print("Now is the time", false);
67         writer.beginEmpty("br");
68         writer.print("for all good men", false);
69         writer.beginEmpty("br");
70         writer.print("to come to the aid of their Tapestry.", false);
71
72         replayControls();
73
74         InsertText component = (InsertText) newInstance(
75                 InsertText.class,
76                 "value",
77                 "Now is the time\nfor all good men\nto come to the aid of their Tapestry.");
78
79         component.finishLoad(cycle, null, null);
80         component.render(writer, cycle);
81
82         verifyControls();
83     }
84
85     public void testRenderParas()
86     {
87         IMarkupWriter writer = newWriter();
88         IRequestCycle cycle = newCycle(false);
89
90         writer.begin("p");
91         writer.print("Now is the time", false);
92         writer.end();
93
94         writer.begin("p");
95         writer.print("for all good men", false);
96         writer.end();
97
98         writer.begin("p");
99         writer.print("to come to the aid of their Tapestry.", false);
100         writer.end();
101
102         replayControls();
103
104         InsertText component = (InsertText) newInstance(InsertText.class, new Object JavaDoc[]
105         { "mode", InsertTextMode.PARAGRAPH, "value",
106                 "Now is the time\nfor all good men\nto come to the aid of their Tapestry." });
107
108         component.render(writer, cycle);
109
110         verifyControls();
111     }
112
113     public void testRenderRaw()
114     {
115         IMarkupWriter writer = newWriter();
116         IRequestCycle cycle = newCycle(false);
117
118         writer.print("output", true);
119         writer.beginEmpty("br");
120         writer.print("<b>raw</b>", true);
121
122         replayControls();
123
124         InsertText component = (InsertText) newInstance(InsertText.class, new Object JavaDoc[]
125         { "value", "output\n<b>raw</b>", "raw", Boolean.TRUE });
126
127         component.finishLoad(cycle, null, null);
128         component.render(writer, cycle);
129
130         verifyControls();
131     }
132 }
133
Popular Tags