KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.apache.hivemind.test.HiveMindTestCase;
18 import org.apache.tapestry.IMarkupWriter;
19 import org.apache.tapestry.IRender;
20 import org.apache.tapestry.IRequestCycle;
21 import org.apache.tapestry.test.Creator;
22 import org.easymock.MockControl;
23
24 /**
25  * Tests for the {@link org.apache.tapestry.html.Shell}  component.
26  *
27  * @author Howard M. Lewis Ship
28  * @since 4.0
29  */

30 public class TestShell extends HiveMindTestCase
31 {
32     private Creator _creator = new Creator();
33
34     private IMarkupWriter newMarkupWriter()
35     {
36         return (IMarkupWriter) newMock(IMarkupWriter.class);
37     }
38
39     private IRequestCycle newRequestCycle(boolean rewinding)
40     {
41         MockControl control = newControl(IRequestCycle.class);
42         IRequestCycle cycle = (IRequestCycle) control.getMock();
43
44         cycle.isRewinding();
45         control.setReturnValue(rewinding);
46
47         return cycle;
48     }
49
50     private IRender newRender()
51     {
52         return (IRender) newMock(IRender.class);
53     }
54
55     /**
56      * Test that Shell does very little when the entire page is rewinding (which itself is a
57      * holdback to the action service).
58      */

59
60     public void testRewinding()
61     {
62         IMarkupWriter writer = newMarkupWriter();
63         IRequestCycle cycle = newRequestCycle(true);
64
65         IRender body = newRender();
66
67         body.render(writer, cycle);
68
69         replayControls();
70
71         Shell shell = (Shell) _creator.newInstance(Shell.class);
72
73         shell.addBody(body);
74
75         shell.render(writer, cycle);
76
77         verifyControls();
78     }
79 }
Popular Tags