KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derbyTesting > functionTests > harness > ManageSysProps


1 /*
2
3    Derby - Class org.apache.derbyTesting.functionTests.harness.ManageSysProps
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to You under the Apache License, Version 2.0
9    (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 JavaDoc;
25 import java.util.Properties JavaDoc;
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
38     private static Properties JavaDoc savedSysProps = null;
39
40     public static void saveSysProps() {
41         Properties JavaDoc sp = System.getProperties();
42         savedSysProps = new Properties JavaDoc();
43         String JavaDoc key = null;
44         for (Enumeration JavaDoc e = sp.propertyNames(); e.hasMoreElements();) {
45             key = (String JavaDoc)e.nextElement();
46             savedSysProps.put(key, sp.getProperty(key));
47         }
48     }
49
50     // reset the system properties to prevent confusion
51
// when running with java threads
52
public static void resetSysProps() {
53         String JavaDoc key = null;
54         Properties JavaDoc nup = new Properties JavaDoc();
55         for (Enumeration JavaDoc e = savedSysProps.propertyNames(); e.hasMoreElements();) {
56             key = (String JavaDoc)e.nextElement();
57             nup.put(key, savedSysProps.getProperty(key));
58         }
59         System.setProperties(nup);
60     }
61 }
62
Popular Tags