⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 runtest.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            if (jvmnetjvm == null)             {                // default to the latest one we know                 jvmnetjvm = "j9_22";            }    	    status = diff.exec(outName, outDir, pwDiff, testOutName,    		    frameworkMaster, jvmName, iminor, useprocess, systemdiff, canondir, 			    canonpath, jvmnetjvm);        }    	else      	    status = diff.exec(outName, outDir, pwDiff, testOutName,    		    frameworkMaster, jvmName, iminor, useprocess, systemdiff, canondir, 			    canonpath, null);    	if (status == true)    	{    		lastTestFailed = true;    		pwDiff.println("Test Failed.");    		System.out.println("Test Failed.");    		keepfiles = true;		    addToFailures(scriptName);		    if (useCommonDB) {	    		status = baseDir.delete();//System.out.println("basedir delete status: " + status );    		}        }        else    	{			addToSuccesses(scriptName);    		pwDiff.flush();        }		// Cleanup files		doCleanup(javaVersion);	}    private static void testRun(String propString, Properties sysProp)        throws FileNotFoundException, IOException, Exception    {        String systemHome = baseDir.getPath();        String scriptPath = null;        if (testType.startsWith("sql"))            scriptPath = script.getPath();                        // Build the test command        String[] testCmd =     		buildTestCommand(propString, systemHome, scriptPath);        	    // cleanup for all tests that re-use standard testCSHome/wombat database	    if (useCommonDB == true 	    	&& (usesystem == null || usesystem == "")	    	&& (testType.equals("sql") || testType.equals("java")			|| testType.equals("sql2"))) {	        dbcleanup.doit(dbIsNew);	    }	        // Create a process to execute the command unless useprocess is false        if ( useprocess )		{            execTestProcess(testCmd);		}        else		{            execTestNoProcess(sysProp, systemHome, propString, scriptPath);		}    }    /** This is the method which created directories and looks for script file,     * need to make OS specific paths here.     *     */    private static void setDirectories(String scriptName, Properties sp)        throws ClassNotFoundException, FileNotFoundException, IOException    {        // Get the current userdir        userdir = sp.getProperty("user.dir");                // reset defaultPackageName (for useprocess=false)        //if (useprocess == false)        //defaultPackageName = "/org/apache/derbyTesting/";                    // reset defaultPackageName (for useprocess=false)        if (useCommonDB == true)        {            defaultPackageName = "/org/apache/derbyTesting/";        }                    // Set the resourceName from the default        // If not set by user, the default is used        String resourceName = defaultPackageName + "functionTests/tests/";        // scriptName could be of these two formats:        // testdir/test.testtype (testtype is sql, java, etc.)        // test.testtype (where the defaultPackageName includes the testdir)        int index = scriptName.lastIndexOf('/');        if (index == -1) // no test directory was specified        {            if ( (!testType.equals("sql")) && (!testType.equals("java")) )            {                System.out.println("Test argument should be of the form: <dir>/<test>.<ext>");                System.exit(1);            }            else            {                scriptFileName = scriptName; // such as my.sql                resourceName += scriptName; // build the full resource name            }        }        else // the testdir was specified         {            testDirName = (index==0)?"":scriptName.substring(0,index);            //System.out.println("testDirName: " + testDirName);            scriptFileName = scriptName.substring(index+1, scriptName.length());            //System.out.println("scriptFileName: " + scriptFileName);            if (testType.equals("multi"))                defaultPackageName = defaultPackageName + "functionTests/multi/" + testDirName + "/";            else                defaultPackageName = defaultPackageName + "functionTests/tests/" + testDirName + "/";            //System.out.println("defaultPackage: " + defaultPackageName);            resourceName = defaultPackageName + scriptFileName;            //System.out.println("resource: " + resourceName);        }        // Get the test name without the extension        testBase = scriptFileName.substring(0, scriptFileName.lastIndexOf("."+testType));		if (testType.equals("java"))		{                    //get the javaPath		    String tmp = defaultPackageName.replace('/', '.');                    int tl = tmp.length()-1;		    javaPath = (tl==0)?"":tmp.substring(1, tl);		}        // Check for runDir        if ( (runningdir != null) && (runningdir.length()>0) )        {            if (File.separatorChar == '\\')            {                //need to replace / in path with \ for windows                String runningdirWin = convertPathForWin(runningdir);                runDir = new File((new File(runningdirWin)).getCanonicalPath());            }            else            {                runDir = new File((new File(runningdir)).getCanonicalPath());            }        }        // Define the outDir if not already defined from properties        File tmpoutDir;        String userdirWin = null;        if ( (outputdir == null) || (outputdir.length()==0) )        {            if (File.separatorChar == '\\')            {                //need to replace / in path with \ for windows                userdirWin = convertPathForWin(userdir);                tmpoutDir = new File((new File(userdirWin)).getCanonicalPath());            }            else            {                tmpoutDir =		        new File((new File(userdir)).getCanonicalPath());            }        }        else        {            if (File.separatorChar == '\\')            {                String outputdirWin = convertPathForWin(outputdir);                tmpoutDir =                        new File((new File(outputdirWin)).getCanonicalPath());            }            else            {                tmpoutDir =                        new File((new File(outputdir)).getCanonicalPath());            }        }        // If this is a suite run in a framework, outdir        // would already be defined to be a framework subdir        // But for RunTest, we must create the framework subdir        //if ( (!isSuiteRun) && (framework != null) && (framework.length()>0) )        if ( (!isSuiteRun) && (!framework.startsWith("embedded")) )        {            runDir = tmpoutDir;		    outDir = new File(tmpoutDir, framework);		    outDir.mkdir();		}		else // This is a Suite Run		{		    outDir = tmpoutDir;		    outDir.mkdir();		    if ( (topsuitedir != null) && (topsuitedir.length()>0) )                    {                        if (File.separatorChar == '\\')                        {                            String topsuitedirWin = convertPathForWin(topsuitedir);                            tsuiteDir =                                 new File((new File(topsuitedirWin)).getCanonicalPath());                        }                        else                        {                            tsuiteDir = new File((new File(topsuitedir)).getCanonicalPath());                        }                    }		    else                    {		        tsuiteDir = outDir;                    }		    tsuiteDir.mkdir();		    if ( (topreportdir != null) && (topreportdir.length()>0) )                    {                        if (File.separatorChar == '\\')                        {                            String topreportdirWin = convertPathForWin(topreportdir);                            rsuiteDir =                                 new File((new File(topreportdirWin)).getCanonicalPath());                        }                        else                        {                            rsuiteDir =                                 new File((new File(topreportdir)).getCanonicalPath());                        }                    }		    else                    {		        rsuiteDir = outDir;                    }		    rsuiteDir.mkdir();		    		}		        	    fileSep = File.separatorChar;        // For multi tests, the user should have specified mtestdir (full path)        // unless this is a Suite, in which case outDir is used for mtestdir        if ( testType.equals("multi") )            if ( (mtestdir == null) || (mtestdir.length()==0) )                // Use outDir for mtestdir                mtestdir = outDir.getPath();        // For certain test types, locate script file based on scriptName        // Then determine the actual test name and directory        if ( (!testType.equals("java")) &&              (!testType.equals("unit")) &&              (!testType.equals("multi")) )         {            // NOTE: cannot use getResource because the urls returned            // are not the same between different java environments            InputStream is =                loadTestResource("tests/" + testDirName + "/" + scriptFileName); 			if (is == null)			{			    System.out.println("Could not locate " + scriptName);			    addToFailures(scriptName);				throw new FileNotFoundException(resourceName);			}            // Read the test file and copy it to the outDir            // except for multi tests (for multi we just need to locate it)            BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8"));            if (upgradetest)		                //these calls to getCanonicalPath catch IOExceptions as a workaround to                //a bug in the EPOC jvm.                 try { script = new File((new File(userdir, scriptFileName)).getCanonicalPath()); }                catch (IOException e) {                    File f = new File(userdir, scriptFileName);        		    FileWriter fw = new FileWriter(f);                    fw.close();                    script = new File(f.getCanonicalPath());                }			// else is probably only multi test            else                try { script = new File((new File(outDir, scriptFileName)).getCanonicalPath()); }                 catch (IOException e) {                    File f = new File(outDir, scriptFileName);                    FileWriter fw = new FileWriter(f);                    fw.close();                    script = new File(f.getCanonicalPath());                }            PrintWriter pw = null;            pw = new PrintWriter( new BufferedWriter                (new FileWriter(script.getPath()), 10000), true );                            String str = "";            while ( (str = in.readLine()) != null )            {                pw.println(str);            }            pw.close();            pw = null;            in = null;        }        // This is the base directory for creating a database (under the outDir)        baseDir = null;    	if (useCommonDB == true)        {            if (File.separatorChar == '\\')            {                String commonDBHomeWin = convertPathForWin(commonDBHome);                baseDir = new File(userdirWin, commonDBHomeWin);            }            else            {    		baseDir = new File(userdir, commonDBHome);            }        }        else if ( (usesystem != null) && (usesystem.length()>0) )        {            if (File.separatorChar == '\\')            {                String usesystemWin = convertPathForWin(usesystem);                if (upgradetest == true)                    baseDir = new File(userdirWin, usesystemWin);                else                    baseDir = new File(outDir, usesystemWin);            }            else            {                if (upgradetest == true)                    baseDir = new File(userdir, usesystem);                else                    baseDir = new File(outDir, usesystem);            }        }        else        {            if (File.separatorChar == '\\')            {                String testBaseWin = convertPathForWin(testBase);                baseDir = new File(outDir, testBaseWin);            }            else            {                baseDir = new File(outDir, testBase);            }        }        // clean up old db dirs        // (except for special cases such as nist, commonDB).        // In the case of useCommonDB == true, the baseDir (commonDBHome) only gets        // cleaned up if the last test was a failure.  Further refinements may        // follow, since many test failures probably do not require such drastic        // action.        if (baseDir.exists())        {            if (useCommonDB == false || lastTestFailed == true) {                cleanupBaseDir(baseDir);                lastTestFailed = false;            }            else if (useCommonDB == true)                 dbIsNew = false; // dbcleanup may be needed        }        else {                        boolean created = baseDir.mkdir();            dbIsNew = true; // dbcleanup not needed on new database        }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -