KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > describe > TestRenderStrategy


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.describe;
16
17 import org.apache.tapestry.IMarkupWriter;
18 import org.apache.tapestry.IRender;
19 import org.apache.tapestry.IRequestCycle;
20
21 /**
22  * Tests for {@link org.apache.tapestry.describe.RenderableAdapterFactoryImpl},
23  * {@link org.apache.tapestry.describe.RenderBridge}and
24  * {@link org.apache.tapestry.describe.DefaultRenderStrategy}.
25  *
26  * @author Howard M. Lewis Ship
27  * @since 4.0
28  */

29 public class TestRenderStrategy extends BaseDescribeTestCase
30 {
31     private RenderStrategy newStrategy()
32     {
33         return (RenderStrategy) newMock(RenderStrategy.class);
34     }
35
36     public void testRenderBridge()
37     {
38         IMarkupWriter writer = newWriter();
39         RenderStrategy strategy = newStrategy();
40         IRequestCycle cycle = newCycle();
41
42         Object JavaDoc object = new Object JavaDoc();
43
44         strategy.renderObject(object, writer, cycle);
45
46         replayControls();
47
48         new RenderBridge(object, strategy).render(writer, cycle);
49
50         verifyControls();
51     }
52
53     public void testRenderableAdapterFactory()
54     {
55         IMarkupWriter writer = newWriter();
56         RenderStrategy strategy = newStrategy();
57         IRequestCycle cycle = newCycle();
58
59         Object JavaDoc object = new Object JavaDoc();
60
61         strategy.renderObject(object, writer, cycle);
62
63         replayControls();
64
65         RenderableAdapterFactoryImpl factory = new RenderableAdapterFactoryImpl();
66         factory.setStrategy(strategy);
67
68         IRender renderable = factory.getRenderableAdaptor(object);
69
70         renderable.render(writer, cycle);
71
72         verifyControls();
73     }
74
75     public void testDefaultRenderableAdapter()
76     {
77         IMarkupWriter writer = newWriter();
78         HTMLDescriber describer = newDescriber();
79         IRequestCycle cycle = newCycle();
80
81         Object JavaDoc object = new Object JavaDoc();
82
83         describer.describeObject(object, writer);
84
85         replayControls();
86
87         DefaultRenderStrategy strategy = new DefaultRenderStrategy();
88         strategy.setDescriber(describer);
89
90         strategy.renderObject(object, writer, cycle);
91
92         verifyControls();
93     }
94 }
Popular Tags