1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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.main(new String[] {ValidatorResultsTest.class.getName()});
47 }
48
49 /***
50 * Create a Test Suite
51 * @return a test suite (<code>TestSuite</code>) that includes all methods
52 * starting with "test"
53 */
54 public static Test suite() {
55 return new TestSuite(CustomValidatorResourcesTest.class);
56 }
57
58 /***
59 * Set up.
60 */
61 protected void setUp() {
62 }
63
64 /***
65 * Tear Down
66 */
67 protected void tearDown() {
68 }
69
70 /***
71 * Test creating a custom validator resources.
72 */
73 public void testCustomResources() {
74
75 InputStream in = null;
76 ValidatorResources resources = null;
77
78 try {
79 in = this.getClass().getResourceAsStream("TestNumber-config.xml");
80 resources = new CustomValidatorResources(in);
81 } catch(Exception e) {
82 fail("Error loading resources: " + e);
83 } finally {
84 try {
85 if (in != null) {
86 in.close();
87 }
88 } catch(Exception e) {
89 }
90 }
91 }
92
93 }