Source Code Cross Referenced for RunList.java in  » Database-DBMS » db-derby-10.2 » org » apache » derbyTesting » functionTests » harness » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database DBMS » db derby 10.2 » org.apache.derbyTesting.functionTests.harness 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /* 
0002:
0003:           Derby - Class org.apache.derbyTesting.functionTests.harness.RunList
0004:
0005:           Licensed to the Apache Software Foundation (ASF) under one or more
0006:           contributor license agreements.  See the NOTICE file distributed with
0007:           this work for additional information regarding copyright ownership.
0008:           The ASF licenses this file to You under the Apache License, Version 2.0
0009:           (the "License"); you may not use this file except in compliance with
0010:           the License.  You may obtain a copy of the License at
0011:
0012:              http://www.apache.org/licenses/LICENSE-2.0
0013:
0014:           Unless required by applicable law or agreed to in writing, software
0015:           distributed under the License is distributed on an "AS IS" BASIS,
0016:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0017:           See the License for the specific language governing permissions and
0018:           limitations under the License.
0019:
0020:         */
0021:
0022:        package org.apache.derbyTesting.functionTests.harness;
0023:
0024:        //import org.apache.derby.tools.sysinfo;
0025:        import java.io.File;
0026:        import java.io.InputStream;
0027:        import java.io.InputStreamReader;
0028:        import java.io.BufferedReader;
0029:        import java.io.FileReader;
0030:        import java.io.FileWriter;
0031:        import java.io.FileInputStream;
0032:        import java.io.FileOutputStream;
0033:        import java.io.BufferedOutputStream;
0034:        import java.io.BufferedWriter;
0035:        import java.io.FileWriter;
0036:        import java.io.PrintWriter;
0037:        import java.io.PrintStream;
0038:        import java.io.IOException;
0039:        import java.io.FileNotFoundException;
0040:        import java.lang.ClassNotFoundException;
0041:        import java.lang.reflect.Method;
0042:        import java.util.Enumeration;
0043:        import java.util.Properties;
0044:        import java.util.Vector;
0045:        import java.util.StringTokenizer;
0046:        import java.sql.DriverManager;
0047:        import java.sql.SQLException;
0048:
0049:        import org.apache.derbyTesting.functionTests.util.TestUtil;
0050:
0051:        public class RunList {
0052:
0053:            static String jvmName = "currentjvm";
0054:            static String javaCmd = "java";
0055:            static String javaArgs;
0056:            static jvm jvm;
0057:            static String javaVersion; // System.getProperty("java.version")
0058:            static String majorVersion;
0059:            static String minorVersion;
0060:            static String jversion; // to pass jvm to RunTest as -Djvm=1.2 etc.
0061:            static int iminor;
0062:            static int imajor;
0063:            static boolean skip = false;
0064:            static boolean driverNotFound = false;
0065:            static boolean needSync = false;
0066:            static boolean needJdk12 = false;
0067:            static boolean needJdk12ext = false;
0068:            static boolean excludedFromJCC = false;
0069:            static String clientExclusionMessage;
0070:            static Boolean needIBMjvm = null;
0071:            static boolean needEncryption = false;
0072:            static String jvmflags;
0073:            static String testJavaFlags;
0074:            static String classpath;
0075:            static String classpathServer;
0076:            static String framework;
0077:            static String usesystem;
0078:            static String upgradetest;
0079:            static String jarfile;
0080:            static String useoutput;
0081:            static String keepfiles = "false";
0082:            static String encryption;
0083:            static String testEncryptionProvider;
0084:            static String testEncryptionAlgorithm;
0085:            static String jdk12test;
0086:            static String jdk12exttest;
0087:            static String runwithibmjvm = null;
0088:            static String runwithj9;
0089:            static String runwithjvm;
0090:            static String excludeJCC;
0091:            static boolean useprocess = true;
0092:            static String skipsed = "false";
0093:            static boolean fw_set = false;
0094:            static String systemdiff = "false";
0095:            static String suiteName = "";
0096:            static String fullsuiteName = "";
0097:            static String topSuiteName = ""; // The very top suite creating RunLists
0098:            static String topParentSuite = ""; // The "subparent" of the very top suite
0099:            static String topSpecialProps = ""; // special properties at the top suite
0100:            static String otherSpecialProps = ""; // special properties (individual suite)
0101:            static String ijdefaultResourcePackage; // for ij tests, the package resource
0102:            static String outcopy; // cases where copyfiles should go to outDir
0103:            static String userdir; // current user directory
0104:            static String mtestdir; // required by multi tests
0105:            static boolean verbose = false; // for debug output
0106:            static String reportstderr;
0107:            static String timeout;
0108:            static String shutdownurl;
0109:            static PrintWriter pwOut; // for writing suite output
0110:            static String outputdir; // location of output (default is userdir)
0111:            static String topsuitedir; // for nested suites, need top output location
0112:            static String topreportdir; // where to place the .pass and .fail files
0113:            static String canondir; // location of masters (default is master)
0114:            static String bootcp; // for j9 bootclasspath
0115:            static String serverJvm; // for starting another jvm for networkserver, j9 default.
0116:            static String serverJvmName; // for starting another jvm for networkserver, j9_22 default.
0117:            static File outDir; // test out dir
0118:            static File outFile; // suite output file
0119:            static File runDir; // location of suite.runall (list of tests)
0120:            static File runFile; // suite.runall file
0121:            static Properties suiteProperties;
0122:            static Properties specialProperties; // for testSpecialProps
0123:            static BufferedReader runlistFile;
0124:            static String hostName;
0125:            static String testEncoding; // Encoding used for child jvm and to read the test output 
0126:            static String upgradejarpath; // Encoding used for child jvm and to read the test output 
0127:            static String derbyTestingXaSingle;// Run junit test cases with under 
0128:            // single branck xa transaction
0129:
0130:            static String[] clientExclusionKeywords = new String[] {
0131:                    "at-or-before:", "at-or-after:", "when-at-or-before:jdk",
0132:                    "when-at-or-after:jdk", "when:jdk" };
0133:
0134:            public RunList() {
0135:            }
0136:
0137:            /**
0138:             * RunList
0139:             * suitesToRun: a Vector of suites from RunSuite
0140:             * outDir: The output directory for the suite(s)
0141:             * pwOut: The output for writing suite and test results
0142:             * suiteProperties: From RunSuite for the top suite
0143:             * (individual suites in the vector may have their own
0144:             * properties which must also be located and applied)
0145:             */
0146:
0147:            public RunList(Vector suitesToRun, File runDir, File outDir,
0148:                    PrintWriter pwOut, Properties suiteProperties,
0149:                    Properties specialProperties, String topParentSuite)
0150:                    throws ClassNotFoundException, IOException, Exception {
0151:                this .runDir = runDir;
0152:                this .outDir = outDir;
0153:                this .pwOut = pwOut;
0154:                this .suiteProperties = suiteProperties; // usual suite props
0155:                this .specialProperties = specialProperties; // for special test Flags
0156:                this .topSuiteName = suiteProperties.getProperty("suitename");
0157:                //System.out.println("----------------------------------------");
0158:                //System.out.println("RunList topSuiteName= " + topSuiteName);
0159:                this .topParentSuite = topParentSuite;
0160:                //System.out.println("topParentSuite= " + topParentSuite);
0161:
0162:                // Run the suites
0163:                runSuites(suitesToRun);
0164:            }
0165:
0166:            private static void runSuites(Vector suitesToRun)
0167:                    throws ClassNotFoundException, FileNotFoundException,
0168:                    IOException, Exception {
0169:                // For each suite, locate its properties and runall files
0170:                // which should be in the "suites" dir or user.dir
0171:                String suiteName = "";
0172:                userdir = System.getProperty("user.dir");
0173:                //System.out.println("Number of suites in list = " + suitesToRun.size());
0174:                Properties p = null;
0175:
0176:                // First get the top level suiteProperties since some
0177:                // special properties might need to be used by all sub-suites
0178:                setTopSuiteProperties();
0179:                // Now set the properties for the topParentSuite (a sub-parent of the top)
0180:                Properties topParentSuiteProps = locateSuiteProperties(
0181:                        topParentSuite, suiteProperties, true, true);
0182:                setSuiteProperties(topParentSuiteProps, topParentSuite,
0183:                        suiteProperties, true, true);
0184:
0185:                // Now handle the list of child suites under this parent
0186:                for (int i = 0; i < suitesToRun.size(); i++) {
0187:                    /* Note: nesting of suites can be complex, especially if the
0188:                     subsuites of the top suite also contain subsuites; we must take
0189:                     care in setting of special properties like framework which may
0190:                     need to propagate to its subsuites, but not back to the very top
0191:                     */
0192:                    Properties subProps = null;
0193:                    fullsuiteName = (String) suitesToRun.elementAt(i);
0194:                    //System.out.println("fullsuiteName: " + fullsuiteName);
0195:                    String subSuite = fullsuiteName.substring(0, fullsuiteName
0196:                            .lastIndexOf(":"));
0197:                    //System.out.println("subSuite: " + subSuite);
0198:                    if (!subSuite.equals(topParentSuite)) {
0199:                        subProps = locateSuiteProperties(subSuite,
0200:                                topParentSuiteProps, true, false);
0201:                    } else {
0202:                        // reset in case a previous subsuite had set framework, etc
0203:                        subProps = topParentSuiteProps;
0204:                    }
0205:                    setSuiteProperties(subProps, subSuite, topParentSuiteProps,
0206:                            true, false);
0207:
0208:                    // Now handle the child suite of this subSuite
0209:                    suiteName = fullsuiteName.substring(fullsuiteName
0210:                            .lastIndexOf(":") + 1);
0211:                    //System.out.println("child suiteName: " + suiteName);
0212:
0213:                    p = locateSuiteProperties(suiteName, subProps, false, false);
0214:                    setSuiteProperties(p, suiteName, subProps, false, false);
0215:
0216:                    // Now locate the suite runall file containing the tests
0217:                    String runfile = "suites" + '/' + suiteName + ".runall";
0218:
0219:                    InputStream is = org.apache.derbyTesting.functionTests.harness.RunTest
0220:                            .loadTestResource(runfile);
0221:                    if (is == null) {
0222:                        // Look in userdir
0223:                        is = org.apache.derbyTesting.functionTests.harness.RunTest
0224:                                .loadTestResource(userdir + '/' + suiteName
0225:                                        + ".runall");
0226:                    }
0227:                    if (is == null) {
0228:                        System.out.println("Suite runall file not found for "
0229:                                + suiteName);
0230:                        continue;
0231:                    }
0232:
0233:                    // Create a BufferedReader to read the list of tests to run
0234:                    runlistFile = new BufferedReader(new InputStreamReader(is,
0235:                            "UTF-8"));
0236:                    if (runlistFile == null) {
0237:                        System.out
0238:                                .println("The suite runall file could not be read.");
0239:                    } else {
0240:                        String startTime = CurrentTime.getTime();
0241:                        pwOut.println("**** Start SubSuite: " + fullsuiteName
0242:                                + " jdk" + javaVersion + " " + startTime
0243:                                + " ****");
0244:                        if ((framework != null) && (framework.length() > 0)) {
0245:                            pwOut.println("Framework: " + framework);
0246:                        } else
0247:                            pwOut.println("Framework: No special framework.");
0248:
0249:                        // Create the file to list the suites that get skipped
0250:                        File f = new File(outDir, topSuiteName);
0251:                        File skipFile = new File(f, topSuiteName + ".skip");
0252:
0253:                        //we catch an IOException here to work around a jvm bug on the Psion.
0254:                        PrintStream ps = null;
0255:                        try {
0256:                            ps = new PrintStream(new FileOutputStream(skipFile
0257:                                    .getCanonicalPath(), true));
0258:                        } catch (IOException e) {
0259:                            FileWriter fw = new FileWriter(skipFile);
0260:                            fw.close();
0261:                            ps = new PrintStream(new FileOutputStream(skipFile
0262:                                    .getCanonicalPath(), true));
0263:                        }
0264:
0265:                        // Due to autoloading of JDBC drivers introduced in JDBC4
0266:                        // (see DERBY-930) the embedded driver and Derby engine
0267:                        // might already have been loaded.  To ensure that the
0268:                        // embedded driver and engine used by the tests run in
0269:                        // this suite are configured to use the correct
0270:                        // property values we try to unload the embedded driver
0271:                        if (useprocess == false) {
0272:                            unloadEmbeddedDriver();
0273:                        }
0274:
0275:                        System.out.println("Now run the suite's tests");
0276:                        //System.out.println("shutdownurl: " + shutdownurl);
0277:
0278:                        if (skip) // Skip a suite under certain environments
0279:                        {
0280:                            addToSkipFile(topSuiteName + ":" + fullsuiteName,
0281:                                    ps);
0282:                            if (driverNotFound)
0283:                                pwOut
0284:                                        .println("Cannot run the suite, framework driver not found");
0285:                            else if (needSync)
0286:                                pwOut
0287:                                        .println("Cannot run the suite, sync product not found");
0288:                            else if (needJdk12ext)
0289:                                pwOut
0290:                                        .println("Cannot run the suite, requires jdk12 or higher with extensions");
0291:                            else if (needJdk12)
0292:                                pwOut
0293:                                        .println("Cannot run the suite, requires jdk12 or higher, have jdk"
0294:                                                + javaVersion);
0295:                            else if (excludedFromJCC)
0296:                                pwOut.println(clientExclusionMessage);
0297:                            else if ((needIBMjvm == null || needIBMjvm
0298:                                    .booleanValue() == false))
0299:                                pwOut
0300:                                        .println("Cannot run the suite, requires IBM jvm, jvm vendor is "
0301:                                                + System
0302:                                                        .getProperty("java.vendor"));
0303:                            else
0304:                                pwOut.println("Cannot run the suite, have jdk"
0305:                                        + javaVersion);
0306:                        } else {
0307:                            System.out.println("Run the tests...");
0308:                            // Unjar any jarfile define for an upgrade suite
0309:                            //System.out.println("jarfile: " + jarfile);
0310:                            if (jarfile != null) {
0311:                                //System.out.println("unjar jar file...");
0312:                                UnJar uj = new UnJar();
0313:                                uj.unjar(jarfile, outDir.getCanonicalPath(),
0314:                                        true);
0315:                                if ((upgradetest.equals("true"))
0316:                                        && (suiteName.startsWith("convert"))) {
0317:                                    // need to rename the directory
0318:                                    // such as kimono -- rename to convertKimono
0319:                                    String tmpname = jarfile.substring(0,
0320:                                            jarfile.indexOf("JAR"));
0321:                                    File tmp = new File(outDir, tmpname);
0322:                                    File convert = new File(outDir, usesystem);
0323:                                    boolean renamed = tmp.renameTo(convert);
0324:                                    //System.out.println("renamed: " + renamed);
0325:                                }
0326:                            }
0327:
0328:                            // Run the tests for this suite
0329:                            runTests(p, fullsuiteName);
0330:                        }
0331:
0332:                        String endTime = CurrentTime.getTime();
0333:                        pwOut.println("**** End SubSuite: " + fullsuiteName
0334:                                + " jdk" + javaVersion + " " + endTime
0335:                                + " ****");
0336:                        //System.out.println("--------------------------------------");
0337:                        ps.close();
0338:                    }
0339:                }
0340:            }
0341:
0342:            private static void runTests(Properties suiteProps, String suite)
0343:                    throws IOException, Exception {
0344:                // save a copy of the system properties at this point; when runing with
0345:                // java threads we need to reset the system properties to this list;
0346:                // otherwise we start to accumulate extraneous properties from
0347:                // individual tests (does not happen with exec (useprocess==true)
0348:                // because each test case has its own fresh VM
0349:                ManageSysProps.saveSysProps();
0350:
0351:                // Build command string for RunTest()
0352:                StringBuffer sb = new StringBuffer();
0353:                jvm = jvm.getJvm(jvmName);
0354:                Vector jvmProps = new Vector();
0355:                if ((javaCmd.length() > 0)) {
0356:                    jvm.setJavaCmd(javaCmd);
0357:                    jvmProps.addElement("javaCmd=" + javaCmd);
0358:                }
0359:                if ((testJavaFlags != null) && (testJavaFlags.length() > 0))
0360:                    jvmProps.addElement("testJavaFlags=" + testJavaFlags);
0361:                if (classpath != null)
0362:                    jvmProps.addElement("classpath=" + classpath);
0363:                if (classpathServer != null)
0364:                    jvmProps.addElement("classpathServer=" + classpathServer);
0365:                if (jversion != null)
0366:                    jvmProps.addElement("jvm=" + jversion);
0367:                if (framework != null)
0368:                    jvmProps.addElement("framework=" + framework);
0369:                if (usesystem != null)
0370:                    jvmProps.addElement("usesystem=" + usesystem);
0371:                if (shutdownurl != null)
0372:                    jvmProps.addElement("shutdownurl=" + shutdownurl);
0373:                if (upgradetest != null)
0374:                    jvmProps.addElement("upgradetest=" + upgradetest);
0375:                if (outcopy != null)
0376:                    jvmProps.addElement("outcopy=" + outcopy);
0377:                if (useoutput != null)
0378:                    jvmProps.addElement("useoutput=" + useoutput);
0379:                if (verbose == true)
0380:                    jvmProps.addElement("verbose=true");
0381:                if ((reportstderr != null) && (reportstderr.length() > 0))
0382:                    jvmProps.addElement("reportstderr=" + reportstderr);
0383:
0384:                if ((jvmflags != null) && (jvmflags.length() > 0)) {
0385:                    // We want to pass this down to RunTest so it will
0386:                    // run an individual test with jvmflags like -nojit
0387:                    jvmProps.addElement("jvmflags=" + jvmflags);
0388:                }
0389:
0390:                if ((timeout != null) && (timeout.length() > 0)) {
0391:                    if (useprocess) {
0392:                        jvmProps.addElement("timeout=" + timeout);
0393:                    } else {
0394:                        org.apache.derbyTesting.functionTests.harness.RunTest.timeoutStr = timeout;
0395:                    }
0396:                }
0397:                if (Boolean.getBoolean("listOnly"))
0398:                    jvmProps.addElement("listOnly=true");
0399:
0400:                if (encryption != null)
0401:                    jvmProps.addElement("encryption=" + encryption);
0402:                if (testEncryptionProvider != null)
0403:                    jvmProps.addElement("testEncryptionProvider="
0404:                            + testEncryptionProvider);
0405:                if (testEncryptionAlgorithm != null)
0406:                    jvmProps.addElement("testEncryptionAlgorithm="
0407:                            + testEncryptionAlgorithm);
0408:                if (jdk12test != null)
0409:                    jvmProps.addElement("jdk12test=" + jdk12test);
0410:                if (jdk12exttest != null)
0411:                    jvmProps.addElement("jdk12exttest=" + jdk12exttest);
0412:                if (keepfiles != null)
0413:                    jvmProps.addElement("keepfiles=" + keepfiles);
0414:                if ((outputdir != null) && (outputdir.length() > 0)) {
0415:                    jvmProps.addElement("outputdir=" + outputdir);
0416:                }
0417:                if ((topsuitedir != null) && (topsuitedir.length() > 0))
0418:                    jvmProps.addElement("topsuitedir=" + topsuitedir);
0419:                else
0420:                    jvmProps.addElement("topsuitedir=" + outputdir);
0421:                if (topreportdir != null)
0422:                    jvmProps.addElement("topreportdir=" + topreportdir);
0423:                else
0424:                    jvmProps.addElement("topreprtdir=" + topsuitedir);
0425:                if ((runDir != null) && (runDir.exists()))
0426:                    jvmProps.addElement("rundir=" + runDir.getCanonicalPath());
0427:                if ((bootcp != null) && (bootcp.length() > 0))
0428:                    jvmProps.addElement("bootcp=" + bootcp);
0429:                if ((serverJvm != null) && (serverJvm.length() > 0))
0430:                    jvmProps.addElement("serverJvm=" + serverJvm);
0431:                if ((serverJvmName != null) && (serverJvmName.length() > 0))
0432:                    jvmProps.addElement("serverJvmName=" + serverJvmName);
0433:                if (testEncoding != null)
0434:                    jvmProps
0435:                            .addElement("derbyTesting.encoding=" + testEncoding);
0436:                if (upgradejarpath != null)
0437:                    jvmProps.addElement("derbyTesting.jar.path="
0438:                            + upgradejarpath);
0439:                if ((hostName != null) && (hostName.length() > 0))
0440:                    jvmProps.addElement("hostName=" + hostName);
0441:                if (useprocess == false)
0442:                    jvmProps.addElement("useprocess=false");
0443:                if (skipsed.equals("true"))
0444:                    jvmProps.addElement("skipsed=true");
0445:                if (systemdiff != null)
0446:                    jvmProps.addElement("systemdiff=" + systemdiff);
0447:                if (ijdefaultResourcePackage != null)
0448:                    jvmProps.addElement("ij.defaultResourcePackage="
0449:                            + ijdefaultResourcePackage);
0450:                if (mtestdir != null)
0451:                    jvmProps.addElement("mtestdir=" + mtestdir);
0452:                if (topSpecialProps.length() > 0) {
0453:                    jvmProps
0454:                            .addElement("testSpecialProps="
0455:                                    + topSpecialProps
0456:                                    + ((otherSpecialProps.length() > 0) ? ("^" + otherSpecialProps)
0457:                                            : ""));
0458:                } else if (otherSpecialProps.length() > 0)
0459:                    jvmProps
0460:                            .addElement("testSpecialProps=" + otherSpecialProps);
0461:
0462:                if (derbyTestingXaSingle != null)
0463:                    jvmProps.addElement("derbyTesting.xa.single="
0464:                            + derbyTestingXaSingle);
0465:
0466:                // Ensure any properties that define the default connection
0467:                // for the tests to use a DataSource are passed from the
0468:                // command line onto the RunTest invoked. These properties are
0469:                //
0470:                // ij.dataSource=<classname of datasource>
0471:                //
0472:                // any number of
0473:                // ij.dataSource.<datasource property>=<value>
0474:
0475:                Properties sysProps = System.getProperties();
0476:                for (Enumeration e = sysProps.keys(); e.hasMoreElements();) {
0477:                    String key = (String) e.nextElement();
0478:                    if (key.startsWith("ij.dataSource"))
0479:                        jvmProps.addElement(key + "="
0480:                                + sysProps.getProperty(key));
0481:                }
0482:
0483:                jvmProps.addElement("suitename=" + suite);
0484:
0485:                if ((topSuiteName != null) && (topSuiteName.length() > 0))
0486:                    jvmProps.addElement("topsuitename=" + topSuiteName);
0487:
0488:                if (classpath != null)
0489:                    jvm.setClasspath(classpath);
0490:
0491:                jvm.setD(jvmProps);
0492:                Vector v = jvm.getCommandLine();
0493:                v
0494:                        .addElement("org.apache.derbyTesting.functionTests.harness.RunTest");
0495:
0496:                String str = "";
0497:                String lastTest = null;
0498:                String skipTo = System.getProperties()
0499:                        .getProperty("skipToFile");
0500:                String stopAfter = System.getProperties().getProperty(
0501:                        "stopAfterFile");
0502:                // Read the individual tests
0503:                // Example: "lang/avg.sql" or "conn/resultset.java"
0504:                while ((str = runlistFile.readLine()) != null) {
0505:                    // skip tests if specified
0506:                    if (skipTo != null && !str.equals(skipTo))
0507:                        continue;
0508:                    else
0509:                        skipTo = null;
0510:                    if (stopAfter != null && lastTest != null
0511:                            && lastTest.equals(stopAfter))
0512:                        break;
0513:                    // Create the command for RunTest
0514:                    // Create a string array from the vector
0515:                    String testCmd[] = new String[v.size() + 1];
0516:                    StringBuffer verboseSb = new StringBuffer();
0517:                    int i = 0;
0518:                    for (i = 0; i < v.size(); i++) {
0519:                        testCmd[i] = (String) v.elementAt(i);
0520:                        verboseSb.append(testCmd[i] + " ");
0521:                    }
0522:                    testCmd[i++] = str;
0523:                    verboseSb.append(str + " ");
0524:                    //if (verbose) 
0525:                    //System.out.println("Execute command: " + verboseSb.toString());
0526:
0527:                    String uc = System.getProperties().getProperty(
0528:                            "useCommonDB");
0529:                    if (uc == null)
0530:                        uc = "false";
0531:                    if (useprocess == true && uc.equals("true") == false) {
0532:                        System.out.println("Execute command: "
0533:                                + verboseSb.toString());
0534:
0535:                        // Now execute the command to run the test
0536:                        Process pr = null;
0537:                        try {
0538:                            pr = Runtime.getRuntime().exec(testCmd);
0539:
0540:                            // We need the process inputstream to capture into the output file
0541:                            BackgroundStreamDrainer stdout = new BackgroundStreamDrainer(
0542:                                    pr.getInputStream(), null);
0543:                            BackgroundStreamDrainer stderr = new BackgroundStreamDrainer(
0544:                                    pr.getErrorStream(), null);
0545:
0546:                            pr.waitFor();
0547:
0548:                            String result = HandleResult.handleResult(pr
0549:                                    .exitValue(), stdout.getData(), stderr
0550:                                    .getData(), pwOut, testEncoding);
0551:                            pr.destroy();
0552:                        } catch (Throwable t) {
0553:                            System.out.println("Process exception: "
0554:                                    + t.getMessage());
0555:                            if (pr != null) {
0556:                                pr.destroy();
0557:                                pr = null;
0558:                            }
0559:                        }
0560:                    } else {
0561:                        // if useprocess=false, we cannot pass properties on a commandline,
0562:                        // instead we pass absolutely necessary properties directly to RunTest.
0563:                        // At the very minimum, we need to know:
0564:                        // 0. the test 
0565:                        // 1. resourcepackage - the base for loading functionTests Resources
0566:                        // 2. whether or not to use a specific system & the usesystem flag (like for nist)
0567:                        // 3. useprocess flag
0568:                        // 4. shutdown url 
0569:                        // 5. name of the suite
0570:                        // 6. the framework, or subsuites might default back to embedded
0571:                        // if a test needs a jvm process started with more/other properties than these, 
0572:                        // it will not run well with useprocess=false or not in the same way as with
0573:                        // useprocess=true
0574:                        String[] args = new String[7];
0575:                        args[0] = str; // the test name
0576:                        if (ijdefaultResourcePackage != null)
0577:                            args[1] = ijdefaultResourcePackage;
0578:                        else
0579:                            args[1] = "/org/apache/derbyTesting/functionTests/";
0580:                        if (usesystem != null)
0581:                            args[2] = usesystem;
0582:                        else
0583:                            args[2] = "";
0584:                        args[3] = "noprocess";
0585:                        if (shutdownurl != null)
0586:                            args[4] = shutdownurl;
0587:                        else
0588:                            args[4] = "";
0589:                        args[5] = suite;
0590:                        args[6] = framework;
0591:                        org.apache.derbyTesting.functionTests.harness.RunTest
0592:                                .main(args);
0593:                        // Write any diff to the suite's output
0594:                        String tmp = str.substring(str.indexOf("/") + 1, str
0595:                                .lastIndexOf("."));
0596:                        String diffname = tmp + "." + "diff";
0597:                        File diffFile = new File(outDir, diffname);
0598:                        if ((diffFile != null) && (diffFile.exists())) {
0599:                            BufferedReader inFile = new BufferedReader(
0600:                                    new FileReader(diffFile));
0601:                            String diffLine = "";
0602:                            while ((diffLine = inFile.readLine()) != null) {
0603:                                pwOut.println(diffLine);
0604:                            }
0605:                        }
0606:
0607:                    }
0608:                    // reset the system properties to prevent confusion
0609:                    // when running with java threads
0610:                    ManageSysProps.resetSysProps();
0611:                    lastTest = str;
0612:                }
0613:
0614:                // If useprocess is false, and this is a networkserver test,
0615:                // we can speed up the test run by not starting and stopping networkserver
0616:                // for every test (and waiting for it to be up), as we're using the same 
0617:                // directory for all test files (instead of creating each test's files in a new dir). 
0618:                // NetworkServer will get started through RunTest if it's not running, but
0619:                // at the end of a suite run, we need to make sure we shutdown network server
0620:                if ((!useprocess)
0621:                        && ((framework != null) && (framework
0622:                                .startsWith("DerbyNet")))) {
0623:                    try {
0624:                        String stopCmd = javaCmd
0625:                                + " org.apache.derby.drda.NetworkServerControl shutdown";
0626:                        Process prstop = Runtime.getRuntime().exec(stopCmd);
0627:                    } catch (Exception e) {
0628:                    } // ignore
0629:                }
0630:            }
0631:
0632:            /**
0633:             * Locate the suite's properties file
0634:             */
0635:            public static Properties locateSuiteProperties(String suiteName,
0636:                    Properties parentProps, boolean isParent, boolean isTop)
0637:                    throws ClassNotFoundException, IOException, Exception {
0638:                // Check for suite properties
0639:                //System.out.println("Checking for suite properties");
0640:                String suitePropsName = "suites" + '/' + suiteName
0641:                        + ".properties";
0642:
0643:                InputStream is = org.apache.derbyTesting.functionTests.harness.RunTest
0644:                        .loadTestResource(suitePropsName);
0645:                if (is == null) {
0646:                    // Look in userdir
0647:                    suitePropsName = userdir + '/' + suiteName + ".properties";
0648:                    is = org.apache.derbyTesting.functionTests.harness.RunTest
0649:                            .loadTestResource(suitePropsName);
0650:                }
0651:                Properties p = new Properties();
0652:                // Reset these properties
0653:                if (isParent) {
0654:                    usesystem = null;
0655:                    upgradetest = null;
0656:                    jarfile = null;
0657:                    outcopy = null;
0658:                    useoutput = null;
0659:                    mtestdir = null;
0660:                    skipsed = "false";
0661:                    //outputdir = outDir.getCanonicalPath();
0662:                }
0663:                if (is != null) {
0664:                    p.load(is);
0665:                    is = null;
0666:                } else {
0667:                    // Reset framework to the parent suite's framework, if any
0668:                    // because framework may have been set by previous suite
0669:                    testEncoding = parentProps
0670:                            .getProperty("derbyTesting.encoding");
0671:                    upgradejarpath = parentProps
0672:                            .getProperty("derbyTesting.jar.path");
0673:                    framework = parentProps.getProperty("framework");
0674:                    serverJvm = parentProps.getProperty("serverJvm");
0675:                    serverJvmName = parentProps.getProperty("serverJvmName");
0676:                    // Do the same for ij.defaultResourcePackage
0677:                    ijdefaultResourcePackage = parentProps
0678:                            .getProperty("ij.defaultResourcePackage");
0679:                    // And do the same for encryption
0680:                    encryption = parentProps.getProperty("encryption");
0681:                    testEncryptionProvider = parentProps
0682:                            .getProperty("testEncryptionProvider");
0683:                    testEncryptionAlgorithm = parentProps
0684:                            .getProperty("testEncryptionAlgorithm");
0685:                    // And do the same for jdk12test
0686:                    jdk12test = parentProps.getProperty("jdk12test");
0687:                    jdk12exttest = parentProps.getProperty("jdk12exttest");
0688:                    runwithj9 = parentProps.getProperty("runwithj9");
0689:                    runwithibmjvm = parentProps.getProperty("runwithibmjvm");
0690:                    String testJVM = jvmName;
0691:                    if (jvmName.startsWith("j9"))
0692:                        testJVM = (jvmName.equals("j9_foundation") ? "foundation"
0693:                                : "j9");
0694:                    runwithjvm = parentProps.getProperty("runwith" + testJVM);
0695:                    excludeJCC = parentProps.getProperty("excludeJCC");
0696:                }
0697:                return p;
0698:            }
0699:
0700:            /**
0701:             * Properties which may be defined for all suites
0702:             * at the top level suite (such as "nightly")
0703:             */
0704:            private static void setTopSuiteProperties()
0705:                    throws ClassNotFoundException, IOException {
0706:                framework = suiteProperties.getProperty("framework");
0707:
0708:                jversion = suiteProperties.getProperty("jversion");
0709:                //System.out.println("RunList top jversion= " + jversion);
0710:
0711:                jvmName = suiteProperties.getProperty("jvm");
0712:                String j9config = System
0713:                        .getProperty("com.ibm.oti.configuration");
0714:                if (j9config != null)
0715:                    if (j9config.equals("foun10"))
0716:                        jvmName = "j9_foundation";
0717:                    else if (j9config.equals("max"))
0718:                        jvmName = "j9_13";
0719:                if (jversion == null)
0720:                    javaVersion = System.getProperty("java.version");
0721:                else
0722:                    javaVersion = jversion;
0723:
0724:                //System.out.println("RunList setTopSuiteProperties javaVersion: " + javaVersion);
0725:
0726:                javaCmd = suiteProperties.getProperty("javaCmd");
0727:                if (javaCmd == null)
0728:                    javaCmd = "java";
0729:                else if (javaCmd.equals("jview"))
0730:                    jvmName = "jview";
0731:
0732:                // if j9, we need to check further
0733:                String javavmVersion;
0734:                if (System.getProperty("java.vm.name").equals("J9"))
0735:                    javavmVersion = (System.getProperty("java.vm.version"));
0736:                else
0737:                    javavmVersion = javaVersion;
0738:
0739:                JavaVersionHolder jvh = new JavaVersionHolder(javavmVersion);
0740:                majorVersion = jvh.getMajorVersion();
0741:                minorVersion = jvh.getMinorVersion();
0742:                iminor = jvh.getMinorNumber();
0743:                imajor = jvh.getMajorNumber();
0744:
0745:                if ((jvmName == null) || (jvmName.equals("jview"))) {
0746:                    if ((iminor < 2) && (imajor < 2))
0747:                        jvmName = "currentjvm";
0748:                    else
0749:                        jvmName = "jdk" + majorVersion + minorVersion;
0750:                }
0751:
0752:                if (jvmName.equals("j9_13")) {
0753:                    javaVersion = javaVersion + " - " + majorVersion + "."
0754:                            + minorVersion;
0755:                    System.out.println("javaVersion now: " + javaVersion);
0756:                    // up to j9 2.1 (jdk 1.3.1. subset) the results are the same for all versions, or
0757:                    // we don't care about it anymore. So switch back to 1.3 (java.version values).
0758:                    if ((imajor <= 2) && (iminor < 2)) {
0759:                        majorVersion = "1";
0760:                        minorVersion = "3";
0761:                        imajor = 1;
0762:                        iminor = 3;
0763:                    } else
0764:                        jvmName = "j9_" + majorVersion + minorVersion;
0765:                }
0766:
0767:                jvmflags = suiteProperties.getProperty("jvmflags");
0768:                testJavaFlags = suiteProperties.getProperty("testJavaFlags");
0769:                classpath = suiteProperties.getProperty("classpath");
0770:                classpathServer = suiteProperties
0771:                        .getProperty("classpathServer");
0772:                usesystem = suiteProperties.getProperty("usesystem");
0773:                upgradetest = suiteProperties.getProperty("upgradetest");
0774:                outcopy = suiteProperties.getProperty("outcopy");
0775:                useoutput = suiteProperties.getProperty("useoutput");
0776:                encryption = suiteProperties.getProperty("encryption");
0777:                testEncryptionProvider = suiteProperties
0778:                        .getProperty("testEncryptionProvider");
0779:                testEncryptionAlgorithm = suiteProperties
0780:                        .getProperty("testEncryptionAlgorithm");
0781:                jdk12test = suiteProperties.getProperty("jdk12test");
0782:                jdk12exttest = suiteProperties.getProperty("jdk12exttest");
0783:                runwithibmjvm = suiteProperties.getProperty("runwithibmjvm");
0784:                runwithj9 = suiteProperties.getProperty("runwithj9");
0785:                derbyTestingXaSingle = suiteProperties
0786:                        .getProperty("derbyTesting.xa.single");
0787:                String testJVM = jvmName;
0788:                if (jvmName.startsWith("j9"))
0789:                    testJVM = (jvmName.equals("j9_foundation") ? "foundation"
0790:                            : "j9");
0791:                runwithjvm = suiteProperties.getProperty("runwith" + testJVM);
0792:                excludeJCC = suiteProperties.getProperty("excludeJCC");
0793:                keepfiles = suiteProperties.getProperty("keepfiles");
0794:                systemdiff = suiteProperties.getProperty("systemdiff");
0795:                outputdir = suiteProperties.getProperty("outputdir");
0796:                if (outputdir == null)
0797:                    outputdir = userdir;
0798:                topsuitedir = suiteProperties.getProperty("topsuitedir");
0799:                if (topsuitedir == null)
0800:                    topsuitedir = outputdir;
0801:                bootcp = suiteProperties.getProperty("bootcp");
0802:                serverJvm = suiteProperties.getProperty("serverJvm");
0803:                serverJvmName = suiteProperties.getProperty("serverJvmName");
0804:                hostName = suiteProperties.getProperty("hostName");
0805:                testEncoding = suiteProperties
0806:                        .getProperty("derbyTesting.encoding");
0807:                upgradejarpath = suiteProperties
0808:                        .getProperty("derbyTesting.jar.path");
0809:                canondir = suiteProperties.getProperty("canondir");
0810:                mtestdir = suiteProperties.getProperty("mtestdir");
0811:                String usepr = suiteProperties.getProperty("useprocess");
0812:                if ((usepr != null) && (usepr.equals("false")))
0813:                    useprocess = false;
0814:                skipsed = suiteProperties.getProperty("skipsed");
0815:                String dbug = suiteProperties.getProperty("verbose");
0816:                if ((dbug != null) && (dbug.equals("true")))
0817:                    verbose = true;
0818:                reportstderr = suiteProperties.getProperty("reportstderr");
0819:                timeout = suiteProperties.getProperty("timeout");
0820:                shutdownurl = suiteProperties.getProperty("shutdownurl");
0821:                topSuiteName = suiteProperties.getProperty("suitename");
0822:                ijdefaultResourcePackage = suiteProperties
0823:                        .getProperty("ij.defaultResourcePackage");
0824:                // The top level suiteProperties may have special
0825:                // properties which need to be added to testSpecialProps
0826:                if ((specialProperties != null)
0827:                        && (!specialProperties.isEmpty())) {
0828:                    //System.out.println("Top suite has special props");
0829:                    setSpecialProps(specialProperties, true);
0830:                }
0831:            }
0832:
0833:            /**
0834:             * Properties for nested suites
0835:             */
0836:            private static void setSuiteProperties(Properties p,
0837:                    String suiteName, Properties parentProperties,
0838:                    boolean isParent, boolean isTop)
0839:                    throws ClassNotFoundException, IOException {
0840:                // Some properties may have been set by the top suite
0841:                // jvm, jvmflags, classpath, systemdiff, verbose, etc.
0842:                // In that case, these will be preserved for the rest
0843:                if (jversion != null)
0844:                    p.put("jvm", jversion);
0845:                if (jvmName == null)
0846:                    jvmName = "currentjvm";
0847:                else
0848:                    p.put("jvm", jvmName);
0849:
0850:                if (javaCmd == null)
0851:                    javaCmd = "java";
0852:                else
0853:                    p.put("javaCmd", javaCmd);
0854:
0855:                // all jvmflags should get appended, with command line overwrite top suite 
0856:                // properties overwrite lower level suite properties
0857:                // but we're letting the jvm handle that by putting the cmdline last.
0858:                // note that at this point, the parentproperties already should have appended the
0859:                // jvmflags from the command line and the top suite properties file
0860:                // only need to add the lower suite properties in the mix
0861:                String totaljvmflags = jvmflags;
0862:                String subjvmflags = p.getProperty("jvmflags");
0863:                String parentjvmflags = parentProperties
0864:                        .getProperty("jvmflags");
0865:                if ((subjvmflags != null) && (parentjvmflags != null)
0866:                        && (!subjvmflags.equals(parentjvmflags))) {
0867:                    totaljvmflags = subjvmflags + "^" + totaljvmflags;
0868:                }
0869:                if (totaljvmflags != null) {
0870:                    jvmflags = totaljvmflags;
0871:                }
0872:
0873:                if (classpath != null)
0874:                    p.put("classpath", classpath);
0875:                if (classpathServer != null)
0876:                    p.put("classpathServer", classpathServer);
0877:                if (systemdiff != null)
0878:                    p.put("systemdiff", systemdiff);
0879:                if (verbose == true)
0880:                    p.put("verbose", "true");
0881:                if (bootcp != null)
0882:                    p.put("bootcp", "bootcp");
0883:                if (canondir != null)
0884:                    p.put("canondir", canondir);
0885:
0886:                if ((outputdir == null) || (outputdir.length() == 0)) {
0887:                    outputdir = p.getProperty("outputdir");
0888:                    if (outputdir == null)
0889:                        outputdir = userdir;
0890:                }
0891:
0892:                // framework may be set at the top, or just
0893:                // set for individual suites
0894:                if (parentProperties.getProperty("framework") != null)
0895:                    p.put("framework", framework);
0896:                else
0897:                    framework = p.getProperty("framework");
0898:
0899:                // same for serverJvm and serverJvmName
0900:                if (parentProperties.getProperty("serverJvm") != null)
0901:                    p.put("serverJvm", serverJvm);
0902:                else
0903:                    serverJvm = p.getProperty("serverJvm");
0904:                if (parentProperties.getProperty("serverJvmName") != null)
0905:                    p.put("serverJvmName", serverJvmName);
0906:                else
0907:                    serverJvmName = p.getProperty("serverJvmName");
0908:
0909:                // derbyTesting.encoding may be set at the top, or just
0910:                // set for individual suites
0911:                if (parentProperties.getProperty("derbyTesting.encoding") != null)
0912:                    p.put("derbyTesting.encoding", testEncoding);
0913:                else
0914:                    testEncoding = p.getProperty("derbyTesting.encoding");
0915:
0916:                if (parentProperties.getProperty("derbyTesting.jar.path") != null)
0917:                    p.put("derbyTesting.jar.path", upgradejarpath);
0918:                else
0919:                    upgradejarpath = p.getProperty("derbyTesting.jar.path");
0920:
0921:                if (hostName != null)
0922:                    p.put("hostName", hostName);
0923:                else
0924:                    p.put("hostName", "localhost");
0925:                // Encryption may be set at the top or just for a subsuite
0926:                if (parentProperties.getProperty("encryption") != null)
0927:                    p.put("encryption", encryption);
0928:                else
0929:                    encryption = p.getProperty("encryption");
0930:
0931:                // Encryption provider may be set at the top or just for a subsuite
0932:                if (parentProperties.getProperty("testEncryptionProvider") != null)
0933:                    p.put("testEncryptionProvider", testEncryptionProvider);
0934:                else
0935:                    testEncryptionProvider = p
0936:                            .getProperty("testEncryptionProvider");
0937:
0938:                // Encryption algorithm may be set at the top or just for a subsuite
0939:                if (parentProperties.getProperty("testEncryptionAlgorithm") != null)
0940:                    p.put("testEncryptionAlgorithm", testEncryptionAlgorithm);
0941:                else
0942:                    testEncryptionAlgorithm = p
0943:                            .getProperty("testEncryptionAlgorithm");
0944:
0945:                // jdk12test may be set at the top or just for a subsuite
0946:                if (parentProperties.getProperty("jdk12test") != null)
0947:                    p.put("jdk12test", jdk12test);
0948:                else
0949:                    jdk12test = p.getProperty("jdk12test");
0950:
0951:                // jdk12exttest may be set at the top or just for a subsuite
0952:                if (parentProperties.getProperty("jdk12exttest") != null)
0953:                    p.put("jdk12exttest", jdk12exttest);
0954:                else
0955:                    jdk12exttest = p.getProperty("jdk12exttest");
0956:
0957:                // runwithibmjvm may be set at the top or just for a subsuite
0958:                if (parentProperties.getProperty("runwithibmjvm") != null)
0959:                    p.put("runwithibmjvm", runwithibmjvm);
0960:                else
0961:                    runwithibmjvm = p.getProperty("runwithibmjvm");
0962:
0963:                // runwithjvm may be set at the top or just for a subsuite
0964:                String testJVM = jvmName;
0965:                if (jvmName.startsWith("j9"))
0966:                    testJVM = (jvmName.equals("j9_foundation") ? "foundation"
0967:                            : "j9");
0968:                if (parentProperties.getProperty("runwith" + testJVM) != null)
0969:                    p.put("runwith" + testJVM, runwithjvm);
0970:                else
0971:                    runwithjvm = p.getProperty("runwith" + testJVM);
0972:
0973:                // runwithj9 may be set at the top or just for a subsuite
0974:                if (parentProperties.getProperty("runwithj9") != null)
0975:                    p.put("runwithj9", runwithj9);
0976:                else
0977:                    runwithj9 = p.getProperty("runwithj9");
0978:
0979:                // excludeJCC may be set at the top or just for a subsuite
0980:                if (parentProperties.getProperty("excludeJCC") != null)
0981:                    p.put("excludeJCC", excludeJCC);
0982:                else
0983:                    excludeJCC = p.getProperty("excludeJCC");
0984:
0985:                // useprocess may be set at the top or just for a subsuite
0986:                String upr = parentProperties.getProperty("useprocess");
0987:                if (upr != null)
0988:                    p.put("useprocess", upr);
0989:                else {
0990:                    upr = p.getProperty("useprocess");
0991:                    if (upr == null)
0992:                        useprocess = true;
0993:                    else if (upr.equals("false"))
0994:                        useprocess = false;
0995:                    else
0996:                        useprocess = true;
0997:                }
0998:                // properties specific to a single suite
0999:                usesystem = p.getProperty("usesystem");
1000:                shutdownurl = p.getProperty("shutdownurl");
1001:                upgradetest = p.getProperty("upgradetest");
1002:                jarfile = p.getProperty("jarfile");
1003:                skipsed = p.getProperty("skipsed");
1004:                if (skipsed == null)
1005:                    skipsed = "false";
1006:                if ("true".equals(keepfiles))
1007:                    p.put("keepfiles", keepfiles);
1008:
1009:                // testJavaFlags should get appended
1010:
1011:                String testflags = p.getProperty("testJavaFlags");
1012:                if (parentProperties.getProperty("testJavaFlags") != null) {
1013:                    if ((testflags != null)
1014:                            && (!testflags.equals(testJavaFlags))) {
1015:                        testJavaFlags = testJavaFlags + "^" + testflags;
1016:                    }
1017:                    p.put("testJavaFlags", testJavaFlags);
1018:                } else
1019:                    testJavaFlags = p.getProperty("testJavaFlags");
1020:
1021:                // The following could change between suites or
1022:                // may be set for the whole set of suites
1023:
1024:                if (parentProperties.getProperty("reportstderr") != null)
1025:                    p.put("reportstderr", reportstderr);
1026:                else
1027:                    reportstderr = p.getProperty("reportstderr");
1028:
1029:                if (parentProperties.getProperty("timeout") != null)
1030:                    p.put("timeout", timeout);
1031:                else
1032:                    timeout = p.getProperty("timeout");
1033:
1034:                // outcopy is very specific to a single suite
1035:                outcopy = p.getProperty("outcopy");
1036:
1037:                // useoutput is very specific to a single suite
1038:                useoutput = p.getProperty("useoutput");
1039:
1040:                // mtestdir is very specific to a multi suite
1041:                mtestdir = p.getProperty("mtestdir");
1042:
1043:                // ijdefaultResourcePackage is specific for a suite
1044:                ijdefaultResourcePackage = p
1045:                        .getProperty("ij.defaultResourcePackage");
1046:
1047:                if (topSuiteName == null)
1048:                    topSuiteName = p.getProperty("suitename");
1049:                else
1050:                    p.put("suitename", topSuiteName);
1051:
1052:                skip = shouldSkipTest();
1053:
1054:                // Set the suite subdir under top outputdir
1055:                setSuiteDir(suiteName, isParent, isTop);
1056:
1057:                // This individual suite may also have special flags
1058:                // Reset otherSpecialProps in case another suite had any set
1059:                otherSpecialProps = "";
1060:                Properties specialProps = SpecialFlags.getSpecialProperties(p);
1061:                if ((specialProps != null) && (!specialProps.isEmpty()))
1062:                    // Add any special properties to suiteJavaFlags string
1063:                    setSpecialProps(specialProps, false);
1064:            }
1065:
1066:            /**
1067:            	Determine if a test should be skipped or not.
1068:            	These are ad-hoc rules, see comments within for details.
1069:            	Examples of what is checked: JVM version, framework,
1070:            	encryption, jdk12test, 
1071:            	Sets some global variables so that skip reporting is clearer.
1072:
1073:            	@return true if test should not be run.
1074:             */
1075:            private static boolean shouldSkipTest() {
1076:                boolean result = false;
1077:
1078:                // figure out if suite should be skipped ... adhoc rules
1079:                boolean isJdk12 = false; // really now 'isJdk12orHigher'
1080:                boolean isJdk118 = false;
1081:                boolean isJdk117 = false;
1082:                boolean isEncryption = false;
1083:                boolean isJdk12Test = false;
1084:                boolean isJdk12ExtTest = false;
1085:                boolean isSyncTest = false;
1086:                boolean isSyncProduct = false;
1087:                boolean isExcludeJCC = false;
1088:                // runwithibmjvm is really tri-state. null = run-anywhere,
1089:                // true = only ibm jvms, false = only non-IBM jvms.
1090:
1091:                // reset skip reason parameters
1092:                driverNotFound = false;
1093:                needSync = false;
1094:                needJdk12 = false;
1095:                needJdk12ext = false;
1096:                excludedFromJCC = false;
1097:                needIBMjvm = null;
1098:
1099:                // Determine if this is jdk12 or higher (with or without extensions)
1100:                if (iminor >= 2)
1101:                    isJdk12 = true;
1102:                if (System.getProperty("java.version").startsWith("1.1.8"))
1103:                    isJdk118 = true;
1104:                if (System.getProperty("java.version").startsWith("1.1.7"))
1105:                    isJdk117 = true;
1106:
1107:                // if a test needs an ibm jvm, skip if runwithibmjvm is true.
1108:                // if a test needs to not run in an ibm jvm, skip if runwithibmjvm is false.
1109:                // if null, continue in all cases.
1110:                if (runwithibmjvm != null) {
1111:                    if (runwithibmjvm.equals("")) {
1112:                        needIBMjvm = null;
1113:                    } else {
1114:                        needIBMjvm = new Boolean(runwithibmjvm);
1115:                    }
1116:                }
1117:                if (runwithibmjvm == null) {
1118:                    needIBMjvm = null;
1119:                }
1120:                if (needIBMjvm != null) {
1121:                    boolean needsibm = needIBMjvm.booleanValue();
1122:                    boolean ibmjvm = false;
1123:                    String vendor = System.getProperty("java.vendor");
1124:                    if (vendor.startsWith("IBM")) {
1125:                        ibmjvm = true;
1126:                    }
1127:                    if (!needsibm && ibmjvm) {
1128:                        return true;
1129:                    }
1130:                    if (needsibm && !ibmjvm) {
1131:                        return true;
1132:                    }
1133:                }
1134:
1135:                if (runwithjvm != null && runwithjvm.equals("false")) {
1136:                    return true;
1137:                }
1138:
1139:                if ((framework != null) && (framework.length() > 0)) {
1140:                    if (framework.equals("DerbyNet")) {
1141:                        // skip if the derbynet.jar is not in the Classpath
1142:                        try {
1143:                            Class
1144:                                    .forName("org.apache.derby.drda.NetworkServerControl");
1145:                        } catch (ClassNotFoundException cnfe) {
1146:                            driverNotFound = true;
1147:                            result = true;
1148:                        }
1149:
1150:                        // skip if the IBM Universal JDBC Driver is not in the Classpath
1151:                        // note that that driver loads some javax.naming.* classes which may not
1152:                        // be present at runtime, and thus we need to catch a possible error too 
1153:                        try {
1154:                            Class.forName("com.ibm.db2.jcc.DB2Driver");
1155:                        } catch (ClassNotFoundException cnfe) {
1156:                            driverNotFound = true;
1157:                            result = true;
1158:                        } catch (NoClassDefFoundError err) {
1159:                            driverNotFound = true;
1160:                            result = true;
1161:                        }
1162:                    }
1163:                }
1164:
1165:                if (result)
1166:                    return true; // stop looking once know should skip
1167:
1168:                if ((encryption != null) && (encryption.length() > 0))
1169:                    if ("true".equalsIgnoreCase(encryption))
1170:                        isEncryption = true;
1171:                if ((jdk12test != null) && (jdk12test.length() > 0))
1172:                    if ("true".equalsIgnoreCase(jdk12test))
1173:                        isJdk12Test = true;
1174:                if ((jdk12exttest != null) && (jdk12exttest.length() > 0))
1175:                    if ("true".equalsIgnoreCase(jdk12exttest))
1176:                        isJdk12ExtTest = true;
1177:
1178:                // Skip any suite if jvm is not jdk12 or higher for encryption, jdk12test or jdk12exttest
1179:                if (!isJdk12) {
1180:                    if ((isEncryption) || (isJdk12Test) || (isJdk12ExtTest)) {
1181:                        needJdk12 = true;
1182:                        result = true; // Can't run in this combination
1183:                    }
1184:                    if (result)
1185:                        return true; // stop looking once know should skip
1186:                }
1187:
1188:                // Also require jdk12 extensions for encryption and jdk12exttest
1189:                if ((isEncryption) || (isJdk12ExtTest)) {
1190:                    needJdk12ext = true;
1191:                    // Check for extensions
1192:                    try {
1193:                        Class jtaClass = Class
1194:                                .forName("javax.transaction.xa.Xid");
1195:                        Class jdbcClass = Class.forName("javax.sql.RowSet");
1196:                    } catch (ClassNotFoundException cnfe) {
1197:                        // at least one of the extension classes was not found
1198:                        result = true; // skip this test
1199:                    }
1200:                    if (result)
1201:                        return true; // stop looking once know should skip
1202:                }
1203:
1204:                if (isEncryption) // make sure encryption classes are available
1205:                {
1206:                    needEncryption = true;
1207:                    try {
1208:                        Class jceClass = Class.forName("javax.crypto.Cipher");
1209:                    } catch (ClassNotFoundException cnfe) {
1210:                        result = true;
1211:                    }
1212:                    if (result)
1213:                        return true;
1214:                }
1215:
1216:                if (excludeJCC != null) {
1217:                    Class c = null;
1218:                    Method m = null;
1219:                    Object o = null;
1220:                    Integer i = null;
1221:                    int jccMajor = 0;
1222:                    int jccMinor = 0;
1223:                    try {
1224:                        c = Class.forName("com.ibm.db2.jcc.DB2Driver");
1225:                        o = c.newInstance();
1226:                        m = c.getMethod("getMajorVersion", null);
1227:                        i = (Integer) m.invoke(o, null);
1228:                        jccMajor = i.intValue();
1229:                        m = c.getMethod("getMinorVersion", null);
1230:                        i = (Integer) m.invoke(o, null);
1231:                        jccMinor = i.intValue();
1232:                    } catch (Exception e) {
1233:                        if (verbose)
1234:                            System.out.println("Exception in shouldSkipTest: "
1235:                                    + e);
1236:                    }
1237:
1238:                    try {
1239:                        checkClientExclusion(excludeJCC, "JCC", jccMajor,
1240:                                jccMinor, javaVersion);
1241:                    } catch (Exception e) {
1242:                        excludedFromJCC = true;
1243:                        clientExclusionMessage = e.getMessage();
1244:                        return true;
1245:                    }
1246:                }
1247:
1248:                return result; // last test result is returned
1249:            }
1250:
1251:            public static void setSuiteDir(String suiteName, boolean isParent,
1252:                    boolean isTop) throws IOException {
1253:                if (isTop) // This is the very top suite for this RunList
1254:                {
1255:                    // Here we want to set the topsuitedir
1256:                    if ((topsuitedir == null) || (topsuitedir.length() == 0)) {
1257:                        topsuitedir = userdir;
1258:                        outputdir = topsuitedir;
1259:                    } else
1260:                        outputdir = topsuitedir;
1261:
1262:                    // Create the topsuite directory under the outputdir
1263:                    File topdir = new File(outputdir, topSuiteName);
1264:                    topdir.mkdir();
1265:                    if (!topParentSuite.equals(topSuiteName)) {
1266:                        File topparent = new File(topdir, topParentSuite);
1267:                        topparent.mkdir();
1268:                        outputdir = topparent.getCanonicalPath();
1269:                    } else
1270:                        outputdir = topdir.getCanonicalPath();
1271:                    topreportdir = outputdir;
1272:                    //System.out.println("RunList topsuitedir: " + outputdir);
1273:                    //System.out.println("RunList outputdir: " + outputdir);
1274:                    //System.out.println("RunList topreportdir: " + topreportdir);
1275:
1276:                    // Modify outputdir for special framework
1277:                    if ((framework != null) && (framework.length() > 0)) {
1278:                        File f = new File(outputdir, framework);
1279:                        f.mkdir();
1280:                        outputdir = f.getCanonicalPath();
1281:                        fw_set = true; // framework dir set at top level
1282:                        //System.out.println("RunList for framework outputdir: " + outputdir);
1283:                    }
1284:                    topsuitedir = outputdir;
1285:                } else if (isParent) // reset outputdir to topsuitedir for a new parent
1286:                {
1287:                    outputdir = topsuitedir;
1288:                    //System.out.println("outputdir reset for parent: " + outputdir);
1289:                    if (!suiteName.equals(topParentSuite)) {
1290:                        File suitedir = new File(outputdir, suiteName);
1291:                        suitedir.mkdir();
1292:                        outputdir = suitedir.getCanonicalPath();
1293:                    }
1294:                    // Modify outputdir for special framework (if not already set)
1295:                    if (!fw_set) {
1296:                        if ((framework != null) && (framework.length() > 0)) {
1297:                            File f = new File(outputdir, framework);
1298:                            f.mkdir();
1299:                            outputdir = f.getCanonicalPath();
1300:                        }
1301:                    }
1302:                }
1303:
1304:                else if (upgradetest == null) // this is a child suite of a parent
1305:                {
1306:                    File suitedir = new File(outputdir, suiteName);
1307:                    suitedir.mkdir();
1308:                    outputdir = suitedir.getCanonicalPath();
1309:                    //System.out.println("Child outputdir: " + outputdir);
1310:                }
1311:            }
1312:
1313:            private static void setSpecialProps(Properties p, boolean isTop) {
1314:                // Just build  string for RunTest to parse (^ is the separator)
1315:                // and determine which special flags are for ij or for server
1316:                // These special flags come from specialProperties, not from
1317:                // the usual properties (RunSuite will give these for the top suite)
1318:                String tmp = "";
1319:                for (Enumeration e = p.propertyNames(); e.hasMoreElements();) {
1320:                    String key = (String) e.nextElement();
1321:                    // Note: RunSuite will already have excluded
1322:                    // suites, useoutput, usesystem,keepfiles from these
1323:                    tmp += key + "=" + p.getProperty(key) + "^";
1324:                }
1325:                if (tmp.length() > 0) {
1326:                    if (isTop == true) // This is the top level suite
1327:                        topSpecialProps = tmp
1328:                                .substring(0, tmp.lastIndexOf('^'));
1329:                    else
1330:                        // This is a nested suite, do not apply to all the suites
1331:                        otherSpecialProps = tmp.substring(0, tmp
1332:                                .lastIndexOf('^'));
1333:                }
1334:            }
1335:
1336:            static void addToSkipFile(String suiteName, PrintStream ps)
1337:                    throws IOException {
1338:                ps.println(suiteName);
1339:                ps.flush();
1340:            }
1341:
1342:            /* ****
1343:             * Look at the received exclusion property and use it to
1344:             * figure out if this test/suite should be skipped based
1345:             * on the actual client and JVM versions in question.
1346:             * @param exclusion The harness property indicating the
1347:             *  rules for skipping this test.  For example:
1348:             *  "at-or-before:2.0,when-at-or-after:jdk1.5.1".
1349:             * @param clientName Name of the client being used.
1350:             * @param clientMajor The 'major' part of the client version
1351:             *  that is actually being used for the test.
1352:             * @param clientMinor The 'minor' part of the client version
1353:             *  that is actually being used for the test.
1354:             * @param javaVersion JVM being used, as a string.
1355:             * @return Exception is thrown if this test/suite should
1356:             *  be skipped; else we simply return.
1357:             */
1358:            public static void checkClientExclusion(String exclusion,
1359:                    String clientName, int clientMajor, int clientMinor,
1360:                    String javaVersion) throws Exception {
1361:
1362:                if (exclusion == null)
1363:                    // we already know the test isn't excluded.
1364:                    return;
1365:
1366:                // These tell us whether we want to 1) exclude version
1367:                // numbers that are lower than the target version, or
1368:                // 2) exclude version numbers that are higher than the
1369:                // target version.
1370:                int clientComparisonType = 0;
1371:                int jvmComparisonType = 0;
1372:
1373:                exclusion = exclusion.toLowerCase();
1374:                String clientVersion = null;
1375:
1376:                // Figure out what kind of comparison we need for the client version.
1377:                int comma = exclusion.indexOf(",");
1378:                if (comma != -1)
1379:                    clientVersion = exclusion.substring(0, comma);
1380:                else
1381:                    clientVersion = exclusion;
1382:
1383:                try {
1384:                    clientComparisonType = getVersionCompareType(clientVersion);
1385:                } catch (Exception e) {
1386:                    System.out.println("exclusion property poorly formatted: "
1387:                            + exclusion);
1388:                    return;
1389:                }
1390:
1391:                // Figure out what kind of comparison we need for the JVM version.
1392:                boolean jvmDependent;
1393:                if (comma == -1)
1394:                    jvmDependent = false;
1395:                else {
1396:                    jvmDependent = true;
1397:                    // "+6" in next line is length of ",when-", which is the
1398:                    // keyword used to begin the jvm exclusion string.
1399:                    String jvmVersion = exclusion.substring(comma + 6);
1400:                    try {
1401:                        jvmComparisonType = getVersionCompareType(jvmVersion);
1402:                    } catch (Exception e) {
1403:                        System.out
1404:                                .println("exclusion property poorly formatted: "
1405:                                        + exclusion);
1406:                        return;
1407:                    }
1408:                }
1409:
1410:                // Load the client and JVM target versions.  The "5" in the
1411:                // next line means that we want to parse out 5 numbers from
1412:                // the property: 2 numbers for the client version (ex. "2.0")
1413:                // and 3 numbers for the JVM version (ex. "1.5.1").
1414:                int[] excludeInfo = null;
1415:                try {
1416:                    excludeInfo = getVersionArray(exclusion, 5);
1417:                } catch (Exception e) {
1418:                    System.out
1419:                            .println("Unexpected text in exclusion property: "
1420:                                    + e.getMessage());
1421:                    return;
1422:                }
1423:
1424:                // Now check to see if this test/suite should be excluded.
1425:                // First check the client version.
1426:                if (versionExcluded(new int[] { clientMajor, clientMinor }, 0,
1427:                        excludeInfo, 0, 2, clientComparisonType)) {
1428:
1429:                    if (!jvmDependent) {
1430:                        // then skip it regardless of JVM.
1431:                        throw new Exception(
1432:                                "This test/suite is excluded from running with "
1433:                                        + clientName
1434:                                        + " versions at or "
1435:                                        + (clientComparisonType == -1 ? "before "
1436:                                                : "after ") + excludeInfo[0]
1437:                                        + "." + excludeInfo[1] + ".");
1438:                    }
1439:
1440:                    // Now check the JVM version.
1441:                    int[] jvmInfo = null;
1442:                    try {
1443:                        jvmInfo = getVersionArray(javaVersion, 3);
1444:                    } catch (Exception e) {
1445:                        System.out
1446:                                .println("Unexpected text in exclusion property: "
1447:                                        + e.getMessage());
1448:                        return;
1449:                    }
1450:
1451:                    if (versionExcluded(jvmInfo, 0, excludeInfo, 2, 3,
1452:                            jvmComparisonType)) {
1453:                        throw new Exception(
1454:                                "This test/suite is excluded from running with "
1455:                                        + clientName
1456:                                        + " versions at or "
1457:                                        + (clientComparisonType == -1 ? "before "
1458:                                                : "after ")
1459:                                        + excludeInfo[0]
1460:                                        + "."
1461:                                        + excludeInfo[1]
1462:                                        + " when JVM versions at or "
1463:                                        + (jvmComparisonType == -1 ? "before "
1464:                                                : "after ") + excludeInfo[2]
1465:                                        + "." + excludeInfo[3] + "."
1466:                                        + excludeInfo[4] + " are being used.");
1467:                    }
1468:                }
1469:
1470:            }
1471:
1472:            /* ****
1473:             * Parses a versionString property and returns the specified
1474:             * number of integers as found in that string.  If the number
1475:             * of integers requested is larger than the number of integers
1476:             * found in the version string, -1 will be used as filler.
1477:             *
1478:             * An example versionString might be any of the following:
1479:             * "2.4" or "at-or-after:2.4" or "when:jdk1.3.1" or 
1480:             * "when-at-or-after:jdk1.3.1", etc.  In these examples,
1481:             * the resultant int arrays would be:
1482:             *
1483:             * "2.4"                        ==> [2,4]         // if resultSize == 2.
1484:             * "at-or-after:2.4"            ==> [2.4]         // if resultSize == 2.
1485:             * "when:jdk1.3.1"              ==> [1,3,1]       // if resultSize == 3.
1486:             * "when-at-or-after:jdk1.3.1"  ==> [1,3,1,-1]    // if resultSize == 4.
1487:             *
1488:             * @param versionString The version string to parse.
1489:             * @param resultSize The number of integers to parse out of the
1490:             *   received version string.
1491:             * @return An integer array holding resultSize integers as parsed
1492:             *   from the version string (with -1 as a filler if needed).
1493:             */
1494:            private static int[] getVersionArray(String versionString,
1495:                    int resultSize) throws Exception {
1496:
1497:                if (versionString == null)
1498:                    // Use an empty string so that tokenizer will still work;
1499:                    // result will be an array of "-1" values.
1500:                    versionString = "";
1501:
1502:                int[] result = new int[resultSize];
1503:
1504:                String tok = null;
1505:                String text = null;
1506:                StringTokenizer st = new StringTokenizer(versionString, ".,_");
1507:                for (int i = 0; i < resultSize; i++) {
1508:
1509:                    if (!st.hasMoreTokens()) {
1510:                        // if we're out of integers, use -1 as a filler.
1511:                        result[i] = -1;
1512:                        continue;
1513:                    }
1514:
1515:                    // Get the token and parse out an integer.
1516:                    tok = st.nextToken();
1517:                    int pos = 0;
1518:                    for (; !Character.isDigit(tok.charAt(pos)); pos++)
1519:                        ;
1520:                    text = tok.substring(0, pos);
1521:
1522:                    // If we have text, make sure it's a valid keyword
1523:                    // and then move past it.
1524:                    if ((text.length() > 0) && !isClientExclusionKeyword(text))
1525:                        throw new Exception(text);
1526:
1527:                    // Load the int.
1528:                    tok = tok.substring(pos);
1529:                    if (tok.length() == 0) {
1530:                        // no integer found, so don't count this iteration.
1531:                        i--;
1532:                        continue;
1533:                    }
1534:
1535:                    result[i] = Integer.parseInt(tok);
1536:
1537:                }
1538:
1539:                return result;
1540:
1541:            }
1542:
1543:            /* ****
1544:             * Looks at a version string and searches for an indication
1545:             * of what kind of versions (lower or higher) need to be
1546:             * excluded.  This method just looks for the keywords
1547:             * "at-or-before" and "at-or-after", and then returns
1548:             * a corresponding value.  If neither of those keywords
1549:             * is found, the default is to exclude versions that are
1550:             * lower (i.e. "at-or-before").
1551:             * @param versionString The version string in question,
1552:             *  for example "2.4" or "jdk1.3.1" or "at-or-before:jdk1.3.1".
1553:             * @return -1 if we want to exclude versions that come
1554:             *  before the target, 1 if we want to exclude versions
1555:             *  that come after the target.  Default is -1.
1556:             */
1557:            private static int getVersionCompareType(String versionString)
1558:                    throws Exception {
1559:
1560:                if (versionString == null)
1561:                    // just return the default.
1562:                    return -1;
1563:
1564:                int colon = versionString.indexOf(":");
1565:                if (colon != -1) {
1566:                    if (versionString.startsWith("at-or-before"))
1567:                        return -1;
1568:                    else if (versionString.startsWith("at-or-after"))
1569:                        return 1;
1570:                    else
1571:                        throw new Exception("bad exclusion property format");
1572:                }
1573:
1574:                return -1;
1575:
1576:            }
1577:
1578:            /* ****
1579:             * Takes two versions, each of which is an array of integers,
1580:             * and determines whether or not the first (actual) version
1581:             * should be excluded from running based on the second (target)
1582:             * version and on the received comparisonType.
1583:             * 
1584:             * For example, let vActual be [2,1] and vTarget be [2,4]. Then
1585:             * if comparisonType indicates that versions "at or before" the
1586:             * the target version (2.4) should be excluded, this method
1587:             * would return true (because 2.1 is before 2.4); if comparisonType
1588:             * indicates that versions "at or after" the target type should
1589:             * be excluded, this method would return false (because 2.1 is
1590:             * NOT at or after 2.4).
1591:             *
1592:             * @param vActual The actual version, as an int array.
1593:             * @param vTarget The target version, as an int array.
1594:             * @param offset1 Offset into vActual at which to start the
1595:             *  comparison.
1596:             * @param offset2 Offset into vTarget at which to start the
1597:             *  comparison.
1598:             * @param numParts The maximum number of integer parts to compare.
1599:             * @param comparisonType -1 if we want to exclude versions
1600:             *  at or before the target; 1 if we want to exclude versions
1601:             *  at or after the target.
1602:             * @return True if the actual version should be excluded from
1603:             *  running, false otherwise.
1604:             */
1605:            private static boolean versionExcluded(int[] vActual, int offset1,
1606:                    int[] vTarget, int offset2, int numParts, int comparisonType) {
1607:
1608:                // Figure out how many integer parts we can actually compare.
1609:                // The max is "len", but if len is greater than the length of
1610:                // either of the versions, then we have to compensate for
1611:                // the shortest version.
1612:                int compareLen = (vActual.length >= vTarget.length ? vTarget.length
1613:                        : vActual.length);
1614:                compareLen = (compareLen <= numParts ? compareLen : numParts);
1615:
1616:                // Now do the comparison.
1617:                for (int i = 0; i < compareLen; i++) {
1618:
1619:                    if (comparisonType * vActual[offset1] > comparisonType
1620:                            * vTarget[offset2])
1621:                        return true;
1622:
1623:                    if (comparisonType * vActual[offset1] < comparisonType
1624:                            * vTarget[offset2])
1625:                        return false;
1626:
1627:                    offset1++;
1628:                    offset2++;
1629:
1630:                }
1631:
1632:                // If we get here, the two versions are the same thru
1633:                // compareLen parts.  If that's as far as we're supposed
1634:                // to compare, then we treat them as equal.  Else, we take
1635:                // the version having more parts as the greater of the two.
1636:
1637:                if (compareLen == numParts)
1638:                    // treat them as equal.
1639:                    return true;
1640:
1641:                return (comparisonType * vActual.length > comparisonType
1642:                        * vTarget.length);
1643:
1644:            }
1645:
1646:            /* ****
1647:             * Checks to see if the received string is a recognized
1648:             * keyword for an exclusion property.
1649:             * @param text The string in question.
1650:             * @return True if the received text is a valid keyword
1651:             *  for exclusion properties; false otherwise.
1652:             */
1653:            private static boolean isClientExclusionKeyword(String text) {
1654:
1655:                for (int i = 0; i < clientExclusionKeywords.length; i++) {
1656:                    if (clientExclusionKeywords[i].equals(text))
1657:                        return true;
1658:                }
1659:
1660:                return false;
1661:
1662:            }
1663:
1664:            /**
1665:             * Unloads the embedded JDBC driver and Derby engine in case
1666:             * is has already been loaded. 
1667:             * The purpose for doing this is that using an embedded engine
1668:             * that already is loaded makes it impossible to set new 
1669:             * system properties for each individual suite or test.
1670:             */
1671:            private static void unloadEmbeddedDriver() {
1672:                // Attempt to unload the embedded driver and engine
1673:                // but only if we're not having a J2ME configuration i.e. no DriverManager, so check...
1674:                if (TestUtil.HAVE_DRIVER_CLASS)
1675:                    try {
1676:                        DriverManager
1677:                                .getConnection("jdbc:derby:;shutdown=true");
1678:                    } catch (SQLException se) {
1679:                        // Ignore any exception thrown
1680:                    }
1681:
1682:                // Call the garbage collector as spesified in the Derby doc
1683:                // for how to get rid of the classes that has been loaded
1684:                System.gc();
1685:            }
1686:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.