01: /*
02:
03: Derby - Class org.apache.derbyTesting.functionTests.harness.ManageSysProps
04:
05: Licensed to the Apache Software Foundation (ASF) under one or more
06: contributor license agreements. See the NOTICE file distributed with
07: this work for additional information regarding copyright ownership.
08: The ASF licenses this file to You under the Apache License, Version 2.0
09: (the "License"); you may not use this file except in compliance with
10: the License. You may obtain a copy of the License at
11:
12: http://www.apache.org/licenses/LICENSE-2.0
13:
14: Unless required by applicable law or agreed to in writing, software
15: distributed under the License is distributed on an "AS IS" BASIS,
16: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: See the License for the specific language governing permissions and
18: limitations under the License.
19:
20: */
21:
22: package org.apache.derbyTesting.functionTests.harness;
23:
24: import java.util.Enumeration;
25: import java.util.Properties;
26:
27: /*
28: **
29: ** Keeps a copy of the system properties saved at a critical early
30: ** point during the running of the test harness. Uses this copy
31: ** to create new copies which can then be mussed up and thrown
32: ** away, as needed.
33: */
34:
35: public class ManageSysProps {
36:
37: private static Properties savedSysProps = null;
38:
39: public static void saveSysProps() {
40: Properties sp = System.getProperties();
41: savedSysProps = new Properties();
42: String key = null;
43: for (Enumeration e = sp.propertyNames(); e.hasMoreElements();) {
44: key = (String) e.nextElement();
45: savedSysProps.put(key, sp.getProperty(key));
46: }
47: }
48:
49: // reset the system properties to prevent confusion
50: // when running with java threads
51: public static void resetSysProps() {
52: String key = null;
53: Properties nup = new Properties();
54: for (Enumeration e = savedSysProps.propertyNames(); e
55: .hasMoreElements();) {
56: key = (String) e.nextElement();
57: nup.put(key, savedSysProps.getProperty(key));
58: }
59: System.setProperties(nup);
60: }
61: }
|