KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > xml > driver > TestProperties


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  *
21  * $Id: TestProperties.java,v 1.2 2005/01/26 08:29:24 jkjome Exp $
22  */

23
24 package org.enhydra.xml.driver;
25 import java.io.File JavaDoc;
26 import java.util.Properties JavaDoc;
27
28 // FIXME: should validate string properties on get and set
29

30 /**
31  * Definition and access to properies used by the tests.
32  */

33 public class TestProperties {
34     /** Property names (keep doc updated in package.html) */
35     public static final String JavaDoc XMLC_TEST_ROOT = "xmlc.test.root";
36     public static final String JavaDoc XMLC_TEST_UPDATE = "xmlc.test.update";
37     public static final String JavaDoc XMLC_TEST_VERBOSE = "xmlc.test.verbose";
38     public static final String JavaDoc XMLC_TEST_PARSER = "xmlc.test.parser";
39     public static final String JavaDoc XMLC_TEST_DOM = "xmlc.test.dom";
40     public static final String JavaDoc XMLC_TEST_RELOADING = "xmlc.test.reloading";
41     public static final String JavaDoc XMLC_TEST_DEFERREDPARSING = "xmlc.test.deferredparsing";
42     public static final String JavaDoc XMLC_TEST_JAVAC_CLASSPATH
43         = "xmlc.test.javac.classpath";
44
45     /** Get a boolean system property */
46     private static boolean getBooleanProp(String JavaDoc name) {
47         Properties JavaDoc props = System.getProperties();
48         String JavaDoc val = props.getProperty(name, Boolean.FALSE.toString());
49         if (val == null) {
50             return false;
51         } else if (val.equalsIgnoreCase("true")
52                    || val.equalsIgnoreCase("on")
53                    || val.equalsIgnoreCase("1")) {
54             return true;
55         } else {
56             return false;
57         }
58     }
59
60     /** Set a boolean system property */
61     private static void setBooleanProp(String JavaDoc name,
62                                        boolean val) {
63         Properties JavaDoc props = System.getProperties();
64         props.setProperty(name, (val ? Boolean.TRUE.toString()
65                                  : Boolean.FALSE.toString()));
66     }
67
68     /**
69      * Set the test case root directory. If not defined, the current
70      * directory is returned.
71      */

72     public static void setTestRoot(String JavaDoc dir) {
73         Properties JavaDoc props = System.getProperties();
74         props.setProperty(XMLC_TEST_ROOT, dir);
75     }
76
77     /**
78      * Get the test case root directory. If not defined, the current
79      * directory is returned.
80      */

81     public static File JavaDoc getTestRoot() {
82         Properties JavaDoc props = System.getProperties();
83         String JavaDoc dir = props.getProperty(XMLC_TEST_ROOT);
84         if (dir == null) {
85             dir = ".";
86         }
87         return new File JavaDoc(dir);
88     }
89     
90     /** Get the update property. */
91     public static boolean getUpdate() {
92         return getBooleanProp(XMLC_TEST_UPDATE);
93     }
94
95     /** Set the update property. */
96     public static void setUpdate(boolean val) {
97         setBooleanProp(XMLC_TEST_UPDATE, val);
98     }
99
100     /** Get the verbose property. */
101     public static boolean getVerbose() {
102         return getBooleanProp(XMLC_TEST_VERBOSE);
103     }
104
105     /** Set the verbose property. */
106     public static void setVerbose(boolean val) {
107         setBooleanProp(XMLC_TEST_VERBOSE, val);
108     }
109
110     /** Get the parser property */
111     public static String JavaDoc getParser(String JavaDoc defVal) {
112         Properties JavaDoc props = System.getProperties();
113         return props.getProperty(XMLC_TEST_PARSER, defVal);
114     }
115
116     /** Set the parser property */
117     public static void setParser(String JavaDoc val) {
118         Properties JavaDoc props = System.getProperties();
119         props.setProperty(XMLC_TEST_PARSER, val);
120     }
121
122     /** Get the DOM property */
123     public static String JavaDoc getDom(String JavaDoc defVal) {
124         Properties JavaDoc props = System.getProperties();
125         return props.getProperty(XMLC_TEST_DOM, defVal);
126     }
127     
128     /** Set the DOM property */
129     public static void setDom(String JavaDoc val) {
130         Properties JavaDoc props = System.getProperties();
131         props.setProperty(XMLC_TEST_DOM, val);
132     }
133     
134     /** Get the reloading property. */
135     public static boolean getReloading() {
136         return getBooleanProp(XMLC_TEST_RELOADING);
137     }
138
139     /** Set the reloading property. */
140     public static void setReloading(boolean val) {
141         setBooleanProp(XMLC_TEST_RELOADING, val);
142     }
143
144     /** Get the deferred parsing property. */
145     public static boolean getDeferredParsing() {
146         return getBooleanProp(XMLC_TEST_DEFERREDPARSING);
147     }
148
149     /** Set the deferred parsing property. */
150     public static void setDeferredParsing(boolean val) {
151         setBooleanProp(XMLC_TEST_DEFERREDPARSING, val);
152     }
153
154     /** Get the javac classpath property */
155     public static String JavaDoc getJavacClassPath() {
156         Properties JavaDoc props = System.getProperties();
157         return props.getProperty(XMLC_TEST_JAVAC_CLASSPATH);
158     }
159     
160     /** Set the javac classpath property */
161     public static void setJavacClassPath(String JavaDoc val) {
162         Properties JavaDoc props = System.getProperties();
163         props.setProperty(XMLC_TEST_JAVAC_CLASSPATH, val);
164     }
165 }
166
Popular Tags