KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2
3    Derby - Class org.apache.derbyTesting.functionTests.harness.SpecialFlags
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 import java.util.StringTokenizer JavaDoc;
27
28 /**
29     Parse testJavaFlags for RunTest
30     These are special properties that might be
31     set for a suite or test, and they can be
32     either ij properties or server properties
33     which is why they need to be parsed
34 */

35
36 public class SpecialFlags
37 {
38
39     public static Properties JavaDoc getSpecialProperties(Properties JavaDoc suiteProperties)
40     {
41         // Save any special properties which can be used by a
42
// suite for ij or server properties (not in the usual list)
43

44         // Define the "usual" properties to exclude from special props
45
// FIXME: These should be in a file or something to make it
46
// easier to add to this
47
String JavaDoc[] excludeList = new String JavaDoc[32];
48         excludeList[0] = "jvm";
49         excludeList[1] = "classpath";
50         excludeList[2] = "classpathServer";
51         excludeList[3] = "framework";
52         excludeList[4] = "usesystem";
53         excludeList[5] = "useprocess";
54         excludeList[6] = "outputdir";
55         excludeList[7] = "replication";
56         excludeList[8] = "keepfiles";
57         excludeList[9] = "mtestdir";
58         excludeList[10] = "suites";
59         excludeList[11] = "searchCP";
60         excludeList[12] = "useoutput";
61         excludeList[13] = "suitename";
62         excludeList[14] = "cleanfiles";
63         excludeList[15] = "systemdiff";
64         excludeList[16] = "jvmflags";
65         excludeList[17] = "testJavaFlags";
66         excludeList[18] = "ij.defaultResourcePackage";
67         excludeList[19] = "outcopy";
68         excludeList[20] = "verbose";
69         excludeList[21] = "canondir";
70         excludeList[22] = "timeout";
71         excludeList[23] = "encryption";
72         excludeList[24] = "javaCmd";
73         excludeList[25] = "topreportdir";
74         excludeList[26] = "jarfile";
75         excludeList[27] = "upgradetest";
76         excludeList[28] = "jdk12test";
77         excludeList[29] = "jdk12exttest";
78         excludeList[30] = "skipsed";
79         excludeList[31] = "sourceEnv";
80
81         Properties JavaDoc p = new Properties JavaDoc();
82
83         for (Enumeration JavaDoc e = suiteProperties.propertyNames(); e.hasMoreElements();)
84         {
85             boolean exclude = false;
86             String JavaDoc key = (String JavaDoc)e.nextElement();
87             for ( int i = 0; i < excludeList.length; i++ )
88             {
89                 if ( excludeList[i].equals(key) )
90                 {
91                     exclude = true;
92                     break;
93                 }
94             }
95             if ( exclude == false )
96             {
97                 String JavaDoc value = suiteProperties.getProperty(key);
98                 p.put(key,value);
99             }
100         }
101         return p;
102     }
103
104     public static void parse(String JavaDoc flags,
105         Properties JavaDoc ijProps, Properties JavaDoc srvProps)
106     {
107         // flags is a list of key-value pairs separated by a ^;
108
// to be parsed and added to either ijProps or srvProps
109
if (flags == null)
110             flags = "";
111         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(flags, "^");
112         String JavaDoc str = "";
113         String JavaDoc key = "";
114         String JavaDoc value = "";
115         while (st.hasMoreTokens())
116         {
117             str = st.nextToken();
118             // System.out.println("TOKEN:"+str);
119
key = str.substring( 0, str.indexOf("=") );
120             value = str.substring( (str.indexOf("=") + 1) );
121             if ( str.startsWith("derby") )
122             {
123                 // This is a server property
124
// Note that some can have a list of values
125
if ( key.equals("derby.debug.true") ||
126                      key.equals("derby.infolog.streams") )
127                 {
128                     String JavaDoc currval = srvProps.getProperty(key);
129                     if ( (currval != null) && (currval.length()>0) )
130                     {
131                         value = value + "," + currval;
132                     }
133                 }
134                 srvProps.put(key,value);
135             }
136             else
137                 // This is an ij property
138
ijProps.put(key,value);
139         }
140     }
141
142     // no instances permitted.
143
private SpecialFlags(){}
144 }
145
Popular Tags