KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > valid > TestValidatorBindingFactory


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

30 public class TestValidatorBindingFactory extends HiveMindTestCase
31 {
32     public void testFactory()
33     {
34         IValidator validator = (IValidator) newMock(IValidator.class);
35         ValueConverter vc = (ValueConverter) newMock(ValueConverter.class);
36
37         MockControl vbfc = newControl(BeanFactory.class);
38         BeanFactory vbf = (BeanFactory) vbfc.getMock();
39
40         vbf.get("foo,bar=baz");
41         vbfc.setReturnValue(validator);
42
43         Location l = newLocation();
44
45         replayControls();
46
47         ValidatorBindingFactory factory = new ValidatorBindingFactory();
48         factory.setValueConverter(vc);
49         factory.setValidatorBeanFactory(vbf);
50
51         IBinding binding = factory.createBinding(null, "validator bean", "foo,bar=baz", l);
52
53         assertSame(validator, binding.getObject());
54         assertSame(l, binding.getLocation());
55
56         verifyControls();
57     }
58 }
Popular Tags