Dear Wiki user, You have subscribed to a wiki page or wiki category on "Jakarta-jmeter Wiki" for change notification.
The following page has been changed by borja: http://wiki.apache.org/jakarta-jmeter/MeterMojo ------------------------------------------------------------------------------ /** * Run all JMeter tests. */ - public void execute() throws MojoExecutionException, MojoFailureException { - initSystemProps(); - try { - DirectoryScanner scanner = new DirectoryScanner(); - scanner.setBasedir(srcDir); - scanner.setIncludes(includes == null ? new String[] { "**/*.jmx" } - : includes.toArray(new String[] {})); - if (excludes != null) { - scanner.setExcludes(excludes.toArray(new String[] {})); - } - scanner.scan(); - for (String file : scanner.getIncludedFiles()) { - executeTest(new File(srcDir, file)); - } - checkForErrors(); - } finally { - saveServiceProps.delete(); - } - } + private void executeTest(File test) throws MojoExecutionException { + /... cut out from mail + try { + // This mess is necessary because the only way to know when JMeter + // is done is to wait for all of the threads that it spawned to exit. + new JMeter().start(args.toArray(new String[]{})); + BufferedReader in = new BufferedReader(new FileReader(jmeterLog)); + while (!checkForEndOfTest(in)) { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + break; + } + } + in.close(); + } catch (ExitException e) { + if (e.getCode() != 0) { + throw new MojoExecutionException("Test failed", e); + } + } finally { + System.setSecurityManager(oldManager); + Thread.setDefaultUncaughtExceptionHandler(oldHandler); + } + } catch (IOException e) { + throw new MojoExecutionException("Can't execute test", e); + } + } + + private boolean checkForEndOfTest(BufferedReader in) throws MojoExecutionException { + boolean testEnded = false; + try { + String line; + while ( (line = in.readLine()) != null) { + if (line.indexOf("Test has ended") != -1) { + testEnded = true; + break; + } + } + } catch (IOException e) { + throw new MojoExecutionException("Can't read log file", e); + } + return testEnded; + } + private void checkForErrors() throws MojoExecutionException, MojoFailureException { try { --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]