KickJava   Java API By Example, From Geeks To Geeks.

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


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.binding;
16
17 import org.apache.hivemind.Location;
18 import org.apache.tapestry.IBinding;
19 import org.apache.tapestry.coerce.ValueConverter;
20 import org.apache.tapestry.services.InjectedValueProvider;
21 import org.easymock.MockControl;
22
23 /**
24  * Tests for {@link org.apache.tapestry.binding.HiveMindBinding}and
25  * {@link org.apache.tapestry.binding.HiveMindBindingFactory}.
26  *
27  * @author Howard M. Lewis Ship
28  * @since 4.0
29  */

30 public class TestHiveMindBinding extends BindingTestCase
31 {
32     private IBinding newBinding(ValueConverter converter, InjectedValueProvider provider,
33             String JavaDoc objectReference, Location location)
34     {
35         HiveMindBindingFactory factory = new HiveMindBindingFactory();
36
37         factory.setValueConverter(converter);
38         factory.setInjectedValueProvider(provider);
39
40         return factory.createBinding(null, "binding description", objectReference, location);
41     }
42
43     public void testSuccess()
44     {
45         Object JavaDoc injectedValue = new Object JavaDoc();
46         Location l = fabricateLocation(12);
47
48         MockControl control = newControl(InjectedValueProvider.class);
49         InjectedValueProvider provider = (InjectedValueProvider) control.getMock();
50
51         provider.obtainValue("spring:bean", l);
52         control.setReturnValue(injectedValue);
53
54         ValueConverter converter = newValueConverter();
55
56         replayControls();
57
58         IBinding binding = newBinding(converter, provider, "spring:bean", l);
59
60         assertSame(injectedValue, binding.getObject());
61
62         verifyControls();
63     }
64 }
Popular Tags