01: /*
02: * Copyright 2006-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: import org.iscreen.*;
20:
21: /**
22: * Tests the ValidationServiceWrapper class.
23: *
24: * @author Shellman, Dan
25: */
26: public class OgnlValidationServiceWrapperTest extends TestCase {
27: public OgnlValidationServiceWrapperTest(String name) {
28: super (name);
29: } //end OgnlValidationServiceWrapperTest()
30:
31: /**
32: * Tests the retrieval of a validation service, given a validation
33: * factory config and validation set name.
34: */
35: public void testServiceRetrievalViaConfig() {
36: ValidationFactoryConfig config = new ValidationFactoryConfig();
37: ValidationServiceWrapper wrapper;
38:
39: config
40: .setConfigurationLocation("org/iscreen/ognl/integration_test.xml");
41: wrapper = new ValidationServiceWrapper(config,
42: "org.iscreen.test.simple_string");
43: assertEquals(wrapper.getServiceName(),
44: "org.iscreen.test.simple_string");
45: try {
46: wrapper.validate("This is way too long");
47: fail("Expected a failure during validation.");
48: } catch (ValidationException e) {
49: }
50: } //end testServiceRetrievalViaConfig()
51:
52: /**
53: * Tests the retrieval of a validation service, given a validation
54: * factory and validation set name.
55: */
56: public void testServiceRetrievalViaFactory() {
57: ValidationFactoryConfig config = new ValidationFactoryConfig();
58: ValidationServiceWrapper wrapper;
59:
60: config
61: .setConfigurationLocation("org/iscreen/ognl/integration_test.xml");
62: wrapper = new ValidationServiceWrapper(config.getFactory(),
63: "org.iscreen.test.simple_string");
64: assertEquals(wrapper.getServiceName(),
65: "org.iscreen.test.simple_string");
66: try {
67: wrapper.validate("This is way too long");
68: fail("Expected a failure during validation.");
69: } catch (ValidationException e) {
70: }
71: } //end testServiceRetrievalViaFactory()
72: } //end OgnlValidationServiceWrapperTest
|