📄 runtest.java
字号:
suiteName = sp.getProperty("suitename"); if ( (suiteName != null) && (suiteName.length()>0) ) { // This is a suite run isSuiteRun = true; // If a suite, it could be part of a top suite topsuiteName = sp.getProperty("topsuitename"); topsuitedir = sp.getProperty("topsuitedir"); topreportdir = sp.getProperty("topreportdir"); } } String uscdb = sp.getProperty("useCommonDB"); if (uscdb != null && uscdb.equals("true")) useCommonDB = true; } private static String createPropString() throws ClassNotFoundException, FileNotFoundException, IOException { // Check for existence of app properties and/or derby.properties files // Copy the derby.properties to the db base directory // Then create the -p string for the test String propString = ""; // General purpose variables BufferedReader in = null; BufferedOutputStream bos = null; BufferedOutputStream bos2 = null; String str = ""; // InputStreams for all possible properties files InputStream isCl = null; // For test_derby.properties InputStream isClDef = null; // For default_derby.properties InputStream isAp = null; // For test_app.properties InputStream isApDef = null; // For default_app.properties // Resource names for locating the various properties files String clDefProp = "tests/" + testDirName + "/" + "default_derby.properties"; String apDefProp = null; if (useCommonDB) apDefProp = "tests/" + testDirName + "/" + "commonDB_app.properties"; else apDefProp = "tests/" + testDirName + "/" + "default_app.properties" ; // Properties Properties clp = new Properties(); Properties ap = new Properties(); Properties sdp = new Properties(); // If there are special flags for ij or server, load these // into properties to be merged with app and/or derby props Properties ijProps = new Properties(); Properties srvProps = new Properties(); if ( (testSpecialProps != null) && (testSpecialProps.length()>0)) { SpecialFlags.parse(testSpecialProps, ijProps, srvProps); } /* If there are more than one derby.properties, the rule is to load either the test_derby.properties or the default one, */ // Check for default_derby.properties isClDef = loadTestResource(clDefProp); // Check for test specific props isCl = loadTestResource("tests/" + testDirName + "/" + testBase + "_derby.properties");//System.out.println("**************");//System.out.println("isCl = " + isCl);//System.out.println(defaultPackageName + testBase + "_derby.properties");//System.out.println("**************"); // Now load and merge the properties based on above rules if (isCl != null) // In case there exists a test_derby.properties { clp.load(isCl);clp.list(System.out); } // Try the default_derby.properties instead else if (isClDef != null) { clp.load(isClDef); } // j9 will run out of memory with the default cache size (100), so // forcing it lower unless set in _derby.properties file for a specific test if (jvmName.startsWith("j9")) { if (clp.getProperty("derby.language.statementCacheSize")==null) clp.put("derby.language.statementCacheSize", J9_STATEMENTCACHESIZE); } // Now merge any special server props if they exist // But if clp is still empty, try using the special server props if ( clp.isEmpty() ) { // Check for srvProps from testSpecialProps if ( !srvProps.isEmpty() ) clp = srvProps; } else { // merge any special properties from testSpecialProps if ( !srvProps.isEmpty() ) { for (Enumeration e = srvProps.propertyNames(); e.hasMoreElements();) { String key = (String)e.nextElement(); String value = srvProps.getProperty(key); if (key.equals("derby.debug.true")) // Add to existing prop { String cval = clp.getProperty("derby.debug.true"); // If this property exists, edit to prepend the srvProp // but if the original property is null, just put the srvProp if (cval != null) { if (cval.length() != 0) { // debug property exists, so edit it value = value + "," + cval; } else { // if new debug property is not null, but is zero length, // assume the intention was to override the debug property. value = ""; } } } clp.put(key,value); } } } if ( !clp.isEmpty() ) { // Create and load the file // This call to getCanonicalPath catches IOExceptions as a workaround to // a bug in the EPOC jvm. try { clPropFile = new File((new File(baseDir, "derby.properties")).getCanonicalPath()); } catch (IOException e) { File f = new File(baseDir, "derby.properties"); FileWriter fw = new FileWriter(f); fw.close(); clPropFile = new File(f.getCanonicalPath()); }//System.out.println("clPropFile: " + clPropFile.getPath()); bos = new BufferedOutputStream(new FileOutputStream(clPropFile)); clp.save(bos, "Derby Properties"); bos.close(); } // --------------------------------- // Check for existence of sed properties file (test_sed.properties) // See jdbc_sed.properties // Multiple patterns for DELETE: comma separated // delete=pattern1,pattern2,...,patternn // No commas can be allowed in the patterns. // // Multiple patterns for SUBSTITUTE: comma separated <pattern;substitute> pair // substitute=pattern1;substitute1,pattern2;substitute2,...,patternn;substituten // No commas or semicolons can be allowed in the patterns/subsitutes. // isSed = loadTestResource("tests/" + testDirName + "/" + testBase + "_sed.properties");//System.out.println("**************");//System.out.println("isSed = " + isSed);//System.out.println(defaultPackageName + testBase + "_sed.properties");//System.out.println("**************"); // --------------------------------- // Check for existence of app properties file // If there is an test_app, use it to overwrite default_app // Then create the -p string for the test Properties dp = new Properties(); String testPropName = null; String testPropSDName = null; // name for shutdown properties file if needed if (useCommonDB) testPropName = "CDB" + testBase + "_app.properties"; else testPropName = testBase + "_app.properties"; // Check for default_app.properties isApDef = loadTestResource(apDefProp); // Check for test_app.properties if ( testType.equals("multi") ) isAp = loadTestResource("multi/" + testDirName + "/" + testBase + "_app.properties"); else isAp = loadTestResource("tests/" + testDirName + "/" + testBase + "_app.properties");//System.out.println("**************");//System.out.println("isAp = " + isAp);//System.out.println(defaultPackageName + testBase + "_app.properties");//System.out.println("**************"); // Try loading the ap and def properties if they exist // Merge only if the test's app properties has usedefaults property if ( isAp != null ) { ap.load(isAp); // Check for a property usedefaults; if true merge in default props for (Enumeration e = ap.propertyNames(); e.hasMoreElements(); ) { String key = (String)e.nextElement(); String value = ap.getProperty(key); if ( (key.equals("usedefaults")) && (value.equals("true")) ) { // merge in the default properties if ( isApDef != null ) { dp.load(isApDef); mergeProps(ap, dp); break; } } } } else { // Just use the default props if ( isApDef != null ) ap.load(isApDef); } // If app props are still empty, check for any special testSpecialProps if ( ap.isEmpty() ) { if ( !ijProps.isEmpty() ) ap = ijProps; } else { // merge any special properties from testSpecialProps if ( !ijProps.isEmpty() ) { for (Enumeration e = ijProps.propertyNames(); e.hasMoreElements();) { String key = (String)e.nextElement(); String value = ijProps.getProperty(key); ap.put(key,value); } } } if ( !ap.isEmpty() ) { // Create the file and load the properties // This call to getCanonicalPath catches IOExceptions as a workaround to // a bug in the EPOC jvm. try { appPropFile = new File((new File(baseDir, testPropName)).getCanonicalPath()); } catch (IOException e) { File f = new File(baseDir, testPropName); FileWriter fw = new FileWriter(f); fw.close(); appPropFile = new File(f.getCanonicalPath()); } // For IBM14 the console encoding is different from the platform // encoding on windows. We want it to be the same for our // test output like the other JDK's. String conEnc = System.getProperty("console.encoding"); String fileEnc = System.getProperty("file.encoding"); if ((conEnc != null) && (fileEnc != null ) && (ap.getProperty("derby.ui.codeset") == null) && conEnc.startsWith("Cp850")) { ap.put("derby.ui.codeset",fileEnc); } if (verbose) System.out.println("console.encoding:" + conEnc + " file.encoding:" + fileEnc + " derby.ui.codeset: " + ap.getProperty("derby.ui.codeset")); // If the initial connection is being specified as a DataSource // on the command line using -Dij.dataSource=<dsclassname> // then remove the ij.database property that comes from any // default_app or other properties file. This is because the // ij.database will override the ij.dataSource property. if (System.getProperty("ij.dataSource") != null) { ap.remove("ij.database"); ap.remove("ij.protocol"); } //System.out.println("appPropFile: " + appPropFile.getPath()); bos = new BufferedOutputStream(new FileOutputStream(appPropFile)); ap.save(bos, "App Properties"); bos.close(); // Depending on the framework, the app prop file may need editing if ( (framework.length()>0) || (encryption) ) { try { if (!framework.equals("") && !framework.equals("embedded")) frameworkProtocol(ap); else if (encryption) encryptionProtocol(ap); } catch(Exception e) { System.out.println("Exception: " + e.getMessage()); e.printStackTrace(); } // write the new properties to the appPropFile appPropFile = new File(baseDir, testBase + "_app.properties"); try { bos = new BufferedOutputStream(new FileOutputStream(appPropFile)); ap.save(bos, "Test Properties"); bos.close(); } catch(IOException ioe) { System.out.println("IOException creating prop file: " + ioe.getMessage()); } } } if ( (appPropFile != null) && (appPropFile.exists()) ) { // Create the properties string for the test propString = appPropFile.getPath(); // Check for shutdown url shutdownurl = ap.getProperty("shutdown"); // Check for jdk12test set to true String jdk12test = ap.getProperty("jdk12test"); //System.out.println("jdk12test: " + jdk12test); //System.out.println("jvmName: " + jvmName); if (jdk12test != null) { if (jdk12test.toLowerCase().equals("true")) { isjdk12test = true; //System.out.println("isjdk12test " + isjdk12test); if (jvmName.equals("currentjvm")) { // This is not at least jdk12 skiptest = true; addSkiptestReason("Test skipped: test needs jdk12, jvm is reporting currentjvm; skipping test: " + scriptFileName); } } } String srvJvm = System.getProperty("serverJvm"); if (srvJvm !=null) jvmnet = true; String excludeJcc = ap.getProperty("excludeJCC"); if ( framework.startsWith("Derby") ) { try { RunList.checkClientExclusion(excludeJcc, "JCC", jccMajor, jccMinor, javaVersion); } catch (Exception e) { skiptest = true; addSkiptestReason(e.getMessage()); } } // for now we want just want to have a single property // for all j9 versions exception j9_foundation // which we map to the generic name foundation. String testJVM = jvmName; if (jvmName.startsWith("j9")) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -