KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > services > impl > TestEngineServiceOuterProxy


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.services.impl;
16
17 import org.apache.hivemind.test.HiveMindTestCase;
18 import org.apache.tapestry.IRequestCycle;
19 import org.apache.tapestry.engine.IEngineService;
20 import org.apache.tapestry.engine.ILink;
21 import org.easymock.MockControl;
22
23 /**
24  * Tests for {@link org.apache.tapestry.services.impl.EngineServiceOuterProxy}.
25  *
26  * @author Howard M. Lewis Ship
27  * @since 4.0
28  */

29 public class TestEngineServiceOuterProxy extends HiveMindTestCase
30 {
31     public void testToString()
32     {
33         IEngineService s = new EngineServiceOuterProxy("fred");
34
35         assertEquals("<OuterProxy for engine service 'fred'>", s.toString());
36     }
37
38     public void testGetLink()
39     {
40         IRequestCycle cycle = newCycle();
41         ILink link = (ILink) newMock(ILink.class);
42
43         MockControl control = newControl(IEngineService.class);
44         IEngineService delegate = (IEngineService) control.getMock();
45
46         Object JavaDoc parameter = new Object JavaDoc();
47
48         delegate.getLink(cycle, parameter);
49         control.setReturnValue(link);
50
51         replayControls();
52
53         EngineServiceOuterProxy proxy = new EngineServiceOuterProxy("xxx");
54         proxy.installDelegate(delegate);
55
56         assertSame(link, proxy.getLink(cycle, parameter));
57
58         verifyControls();
59     }
60
61     private IRequestCycle newCycle()
62     {
63         return (IRequestCycle) newMock(IRequestCycle.class);
64     }
65
66     public void testGetName()
67     {
68
69         EngineServiceOuterProxy proxy = new EngineServiceOuterProxy("Fred");
70
71         assertEquals("Fred", proxy.getName());
72     }
73
74     public void testService() throws Exception JavaDoc
75     {
76         IRequestCycle cycle = newCycle();
77         IEngineService delegate = (IEngineService) newMock(IEngineService.class);
78
79         delegate.service(cycle);
80
81         replayControls();
82
83         EngineServiceOuterProxy proxy = new EngineServiceOuterProxy("xxx");
84         proxy.installDelegate(delegate);
85
86         assertSame(delegate, proxy.getDelegate());
87
88         proxy.service(cycle);
89
90         verifyControls();
91     }
92 }
Popular Tags