01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.commons.validator;
18:
19: import java.io.InputStream;
20: import junit.framework.Test;
21: import junit.framework.TestCase;
22: import junit.framework.TestSuite;
23: import org.apache.commons.validator.custom.CustomValidatorResources;
24:
25: /**
26: * Test custom ValidatorResources.
27: *
28: * @version $Revision: 478392 $ $Date: 2006-11-22 23:51:09 +0000 (Wed, 22 Nov 2006) $
29: */
30: public class CustomValidatorResourcesTest extends TestCase {
31:
32: /**
33: * Construct a test case with the specified name.
34: * @param name Name of the test
35: */
36: public CustomValidatorResourcesTest(String name) {
37: super (name);
38: }
39:
40: /**
41: * Start the tests.
42: *
43: * @param theArgs the arguments. Not used
44: */
45: public static void main(String[] theArgs) {
46: junit.awtui.TestRunner
47: .main(new String[] { ValidatorResultsTest.class
48: .getName() });
49: }
50:
51: /**
52: * Create a Test Suite
53: * @return a test suite (<code>TestSuite</code>) that includes all methods
54: * starting with "test"
55: */
56: public static Test suite() {
57: return new TestSuite(CustomValidatorResourcesTest.class);
58: }
59:
60: /**
61: * Set up.
62: */
63: protected void setUp() {
64: }
65:
66: /**
67: * Tear Down
68: */
69: protected void tearDown() {
70: }
71:
72: /**
73: * Test creating a custom validator resources.
74: */
75: public void testCustomResources() {
76: // Load resources
77: InputStream in = null;
78: ValidatorResources resources = null;
79:
80: try {
81: in = this .getClass().getResourceAsStream(
82: "TestNumber-config.xml");
83: resources = new CustomValidatorResources(in);
84: } catch (Exception e) {
85: fail("Error loading resources: " + e);
86: } finally {
87: try {
88: if (in != null) {
89: in.close();
90: }
91: } catch (Exception e) {
92: }
93: }
94: }
95:
96: }
|