KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > binding > TestListenerMethodBinding


1 // Copyright 2004, 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.binding;
16
17 import org.apache.hivemind.Location;
18 import org.apache.tapestry.IActionListener;
19 import org.apache.tapestry.IComponent;
20 import org.apache.tapestry.coerce.ValueConverter;
21 import org.apache.tapestry.listener.ListenerMap;
22 import org.easymock.MockControl;
23
24 /**
25  * Test for {@link org.apache.tapestry.binding.ListenerMethodBinding}.
26  *
27  * @author Howard M. Lewis Ship
28  * @since 4.0
29  */

30 public class TestListenerMethodBinding extends BindingTestCase
31 {
32     public void testGetObject()
33     {
34         MockControl cc = newControl(IComponent.class);
35         IComponent component = (IComponent) cc.getMock();
36
37         MockControl lmc = newControl(ListenerMap.class);
38         ListenerMap lm = (ListenerMap) lmc.getMock();
39
40         IActionListener listener = (IActionListener) newMock(IActionListener.class);
41
42         component.getListeners();
43         cc.setReturnValue(lm);
44
45         lm.getListener("foo");
46         lmc.setReturnValue(listener);
47
48         ValueConverter vc = newValueConverter();
49
50         Location l = newLocation();
51
52         replayControls();
53
54         ListenerMethodBinding b = new ListenerMethodBinding(component, "foo", "param", vc, l);
55
56         assertSame(listener, b.getObject());
57         assertSame(component, b.getComponent());
58
59         verifyControls();
60     }
61 }
Popular Tags