KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > validator > TestCommon


1 /*
2  * $Id: TestCommon.java 155434 2005-02-26 13:16:41Z dirkv $
3  * $Rev$
4  * $Date: 2005-02-26 05:16:41 -0800 (Sat, 26 Feb 2005) $
5  *
6  * ====================================================================
7  * Copyright 2001-2005 The Apache Software Foundation
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */

21 package org.apache.commons.validator;
22
23 import java.io.IOException JavaDoc;
24 import java.io.InputStream JavaDoc;
25
26 import junit.framework.TestCase;
27
28 import org.xml.sax.SAXException JavaDoc;
29
30 /**
31  * Consolidates reading in XML config file into parent class.
32  */

33 abstract public class TestCommon extends TestCase {
34     
35     /**
36      * Resources used for validation tests.
37      */

38     protected ValidatorResources resources = null;
39
40     public TestCommon(String JavaDoc string) {
41         super(string);
42     }
43
44     /**
45      * Load <code>ValidatorResources</code> from
46      * validator-numeric.xml.
47      */

48     protected void loadResources(String JavaDoc file) throws IOException JavaDoc, SAXException JavaDoc {
49         // Load resources
50
InputStream JavaDoc in = null;
51
52         try {
53             in = this.getClass().getResourceAsStream(file);
54             resources = new ValidatorResources(in);
55         } finally {
56             if (in != null) {
57                 in.close();
58             }
59         }
60     }
61 }
62
Popular Tags