KickJava   Java API By Example, From Geeks To Geeks.

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


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.hivemind.test.HiveMindTestCase;
19 import org.apache.tapestry.IBeanProvider;
20 import org.apache.tapestry.IComponent;
21 import org.apache.tapestry.coerce.ValueConverter;
22 import org.easymock.MockControl;
23
24 /**
25  * @author Howard M. Lewis Ship
26  */

27 public class TestBeanBinding extends HiveMindTestCase
28 {
29     public void testCreate()
30     {
31         ValueConverter vc = (ValueConverter) newMock(ValueConverter.class);
32
33         MockControl componentc = newControl(IComponent.class);
34         IComponent component = (IComponent) componentc.getMock();
35
36         MockControl beanProviderc = newControl(IBeanProvider.class);
37         IBeanProvider beanProvider = (IBeanProvider) beanProviderc.getMock();
38
39         Location l = fabricateLocation(21);
40
41         Object JavaDoc bean = new Object JavaDoc();
42
43         component.getBeans();
44         componentc.setReturnValue(beanProvider);
45
46         beanProvider.getBean("fred");
47         beanProviderc.setReturnValue(bean);
48
49         replayControls();
50
51         BeanBinding binding = new BeanBinding("param", vc, l, component, "fred");
52
53         assertSame(bean, binding.getObject());
54
55         verifyControls();
56
57         assertSame(component, binding.getComponent());
58         assertSame(l, binding.getLocation());
59         assertEquals("param", binding.getDescription());
60     }
61
62 }
Popular Tags