01: /*
02: * Copyright 2007 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.ognl;
17:
18: import junit.framework.TestCase;
19:
20: import org.iscreen.MockValidationFactory;
21: import org.iscreen.ValidationFactory;
22: import org.iscreen.ValidationFactoryConfig;
23:
24: /**
25: * Tests the ValidationFactoryConfig class.
26: *
27: * @author Shellman, Dan
28: */
29: public class OgnlValidationFactoryConfigTest extends TestCase {
30: public OgnlValidationFactoryConfigTest(String name) {
31: super (name);
32: } //end OgnlValidationFactoryConfigTest()
33:
34: /**
35: * Tests the creation of the default factory.
36: */
37: public void testDefaultFactory() {
38: ValidationFactoryConfig config = new ValidationFactoryConfig();
39: ValidationFactory factory;
40:
41: config
42: .setConfigurationLocation("org/iscreen/ognl/integration_test.xml");
43: factory = config.getFactory();
44: assertNotNull(factory);
45: assertNotNull(factory
46: .getValidationService("org.iscreen.test.simple_string"));
47: } //end testDefaultFactory()
48:
49: /**
50: * Tests to make sure config is properly set on the factory.
51: */
52: public void testProperConfig() {
53: ValidationFactoryConfig config = new ValidationFactoryConfig();
54: MockValidationFactory factory;
55:
56: ValidationFactory.registerFactory(MockValidationFactory.class,
57: "mock factory");
58: config.setFactoryId("mock factory");
59: config.addService("someService", "Some Service");
60: config.setConfigurationLocation("some config location");
61: factory = (MockValidationFactory) config.getFactory();
62: assertNotNull(factory);
63: assertTrue(factory.isConfigLoaded());
64: assertTrue(factory.isDefaultLocaleSet());
65: assertNotNull(factory.getService("someService"));
66: } //end testProperConfig()
67: } //end OgnlValidationFactoryConfigTest
|