001: /*
002:
003: Derby - Class org.apache.derbyTesting.functionTests.harness.SpecialFlags
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to You under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derbyTesting.functionTests.harness;
023:
024: import java.util.Enumeration;
025: import java.util.Properties;
026: import java.util.StringTokenizer;
027:
028: /**
029: Parse testJavaFlags for RunTest
030: These are special properties that might be
031: set for a suite or test, and they can be
032: either ij properties or server properties
033: which is why they need to be parsed
034: */
035:
036: public class SpecialFlags {
037:
038: public static Properties getSpecialProperties(
039: Properties suiteProperties) {
040: // Save any special properties which can be used by a
041: // suite for ij or server properties (not in the usual list)
042:
043: // Define the "usual" properties to exclude from special props
044: // FIXME: These should be in a file or something to make it
045: // easier to add to this
046: String[] excludeList = new String[32];
047: excludeList[0] = "jvm";
048: excludeList[1] = "classpath";
049: excludeList[2] = "classpathServer";
050: excludeList[3] = "framework";
051: excludeList[4] = "usesystem";
052: excludeList[5] = "useprocess";
053: excludeList[6] = "outputdir";
054: excludeList[7] = "replication";
055: excludeList[8] = "keepfiles";
056: excludeList[9] = "mtestdir";
057: excludeList[10] = "suites";
058: excludeList[11] = "searchCP";
059: excludeList[12] = "useoutput";
060: excludeList[13] = "suitename";
061: excludeList[14] = "cleanfiles";
062: excludeList[15] = "systemdiff";
063: excludeList[16] = "jvmflags";
064: excludeList[17] = "testJavaFlags";
065: excludeList[18] = "ij.defaultResourcePackage";
066: excludeList[19] = "outcopy";
067: excludeList[20] = "verbose";
068: excludeList[21] = "canondir";
069: excludeList[22] = "timeout";
070: excludeList[23] = "encryption";
071: excludeList[24] = "javaCmd";
072: excludeList[25] = "topreportdir";
073: excludeList[26] = "jarfile";
074: excludeList[27] = "upgradetest";
075: excludeList[28] = "jdk12test";
076: excludeList[29] = "jdk12exttest";
077: excludeList[30] = "skipsed";
078: excludeList[31] = "sourceEnv";
079:
080: Properties p = new Properties();
081:
082: for (Enumeration e = suiteProperties.propertyNames(); e
083: .hasMoreElements();) {
084: boolean exclude = false;
085: String key = (String) e.nextElement();
086: for (int i = 0; i < excludeList.length; i++) {
087: if (excludeList[i].equals(key)) {
088: exclude = true;
089: break;
090: }
091: }
092: if (exclude == false) {
093: String value = suiteProperties.getProperty(key);
094: p.put(key, value);
095: }
096: }
097: return p;
098: }
099:
100: public static void parse(String flags, Properties ijProps,
101: Properties srvProps) {
102: // flags is a list of key-value pairs separated by a ^;
103: // to be parsed and added to either ijProps or srvProps
104: if (flags == null)
105: flags = "";
106: StringTokenizer st = new StringTokenizer(flags, "^");
107: String str = "";
108: String key = "";
109: String value = "";
110: while (st.hasMoreTokens()) {
111: str = st.nextToken();
112: // System.out.println("TOKEN:"+str);
113: key = str.substring(0, str.indexOf("="));
114: value = str.substring((str.indexOf("=") + 1));
115: if (str.startsWith("derby")) {
116: // This is a server property
117: // Note that some can have a list of values
118: if (key.equals("derby.debug.true")
119: || key.equals("derby.infolog.streams")) {
120: String currval = srvProps.getProperty(key);
121: if ((currval != null) && (currval.length() > 0)) {
122: value = value + "," + currval;
123: }
124: }
125: srvProps.put(key, value);
126: } else
127: // This is an ij property
128: ijProps.put(key, value);
129: }
130: }
131:
132: // no instances permitted.
133: private SpecialFlags() {
134: }
135: }
|