01: /*
02: * Copyright 2006 Dan Shellman
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.iscreen;
17:
18: import java.util.HashMap;
19: import java.util.Map;
20: import junit.framework.TestCase;
21:
22: /**
23: *
24: * @author Shellman, Dan
25: */
26: public class ValidationFactoryTest extends TestCase {
27: /**
28: * Default constructor.
29: */
30: public ValidationFactoryTest(String name) {
31: super (name);
32: } //end ValidationFactoryTest()
33:
34: /**
35: * Tests to ensure that the loadConfig() method is called on a
36: * subclass of the ValidationFactory.
37: */
38: public void testConfigLoaded() {
39: MockValidationFactory factory;
40:
41: factory = new MockValidationFactory();
42: factory.register();
43: factory = (MockValidationFactory) ValidationFactory
44: .buildFactory(factory.getFactoryId(), null, null);
45: assertTrue(factory.isConfigLoaded());
46: } //end testConfigLoaded()
47:
48: /**
49: * Tests to ensure that services are set properly.
50: */
51: public void testSettingServices() {
52: MockValidationFactory factory;
53: Map services = new HashMap();
54:
55: services.put("serviceKey", "foo");
56: factory = new MockValidationFactory();
57: factory.register();
58: factory = (MockValidationFactory) ValidationFactory
59: .buildFactory(factory.getFactoryId(), null, services);
60: assertEquals("foo", factory.getService("serviceKey"));
61: } //end testSettingServices()
62:
63: /**
64: * Tests to ensure that the default locale is set properly.
65: */
66: public void testSettingDefaultLocale() {
67: MockValidationFactory factory;
68:
69: factory = new MockValidationFactory();
70: factory.register();
71: factory = (MockValidationFactory) ValidationFactory
72: .buildFactory(factory.getFactoryId(), null, null);
73: assertTrue(factory.isDefaultLocaleSet());
74: factory = (MockValidationFactory) ValidationFactory
75: .buildFactory(factory.getFactoryId(), null, null, null);
76: assertTrue(factory.isDefaultLocaleSet());
77: } //end testSettingDefaultLocale()
78: } //end ValidationFactoryTest
|