1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      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.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          // Load resources
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  }