public int run ( ) { try { if ( compile ) { compile ( ) ; } String separator = "/" ; String cpseperator = ":" ; if ( System . getProperty ( "os.name" ) . contains ( "indows" ) ) { separator = "\\" ; cpseperator = ";" ; } String s = fileName . replace ( separator , "." ) ; if ( ".java" . equals ( s . substring ( s . length ( ) - 5 ) ) ) { s = s . substring ( 0 , s . length ( ) - 5 ) ; // .java Entfernen } else { s = s . substring ( 0 , s . length ( ) - 6 ) ; // .class entfernen } String localClasspath = classpath ; if ( compileFolder != null ) localClasspath = localClasspath + cpseperator + compileFolder ; String command = "java -cp " + localClasspath ; if ( libraryPath != null && libraryPath != "" ) command += "-Djava.library.path=" + libraryPath ; command = command + " de.kopeme.testrunner.PerformanceTestRunner " + s ; // System.out.println(command); Process p = Runtime . getRuntime ( ) . exec ( command ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( p . getInputStream ( ) ) ) ; String line ; BufferedWriter bw = null ; // System.out.println("ExternalOutputFile: " + externalOutputFile); if ( externalOutputFile != null && externalOutputFile != "" ) { File output = new File ( externalOutputFile ) ; try { bw = new BufferedWriter ( new FileWriter ( output ) ) ; } catch ( IOException e1 ) { // TODO Automatisch generierter Erfassungsblock e1 . printStackTrace ( ) ; } } while ( ( line = br . readLine ( ) ) != null ) { if ( bw == null ) { System . out . println ( line ) ; } else { bw . write ( line + "\n" ) ; } } br = new BufferedReader ( new InputStreamReader ( p . getErrorStream ( ) ) ) ; while ( ( line = br . readLine ( ) ) != null ) { if ( bw == null ) { System . out . println ( line ) ; } else { bw . write ( line + "\n" ) ; } } if ( bw != null ) bw . close ( ) ; int returnValue = p . waitFor ( ) ; // System.out.println("Returnvalue: " + returnValue); return returnValue ; } catch ( IOException e ) { // TODO Automatisch generierter Erfassungsblock e . printStackTrace ( ) ; } catch ( InterruptedException e ) { // TODO Automatisch generierter Erfassungsblock e . printStackTrace ( ) ; } return 1 ; }
Runs KoPeMe and returns 0 if everything works allright