{{{package org.apache.jmeter;

import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.lang.Thread.UncaughtExceptionHandler; import java.security.Permission; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date; import java.util.List; import java.util.regex.Pattern;

import org.apache.commons.io.IOUtils; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.tools.ant.DirectoryScanner;

/**

private static final Pattern PAT_ERROR = Pattern.compile(".*\\s+ERROR
s+.*");

/**

/**

/**

/**

/**

/**

private File workDir;
private File saveServiceProps;
private File jmeterLog;
private DateFormat fmt = new SimpleDateFormat("yyMMdd");

/**

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 {
BufferedReader in = new BufferedReader(new FileReader(jmeterLog));
String line;
while ( (line = in.readLine()) != null) {
if (PAT_ERROR.matcher(line).find()) {
throw new MojoFailureException("There were test errors");
}
}
in.close();
} catch (IOException e) {
throw new MojoExecutionException("Can't read log file", e);
}
}

private void initSystemProps() throws MojoExecutionException {
workDir = new File("target" + File.separator + "jmeter");
workDir.mkdirs();
createSaveServiceProps();
jmeterLog = new File(workDir, "jmeter.log");
try {
System.setProperty("log_file", jmeterLog.getCanonicalPath());
} catch (IOException e) {
throw new MojoExecutionException("Can't get canonical path for log file", e);
}
}

/**

/**

private static class ExitException extends SecurityException {
private static final long serialVersionUID = 5544099211927987521L;

public int _rc;

public ExitException(int rc) {
super(Integer.toString(rc));
_rc = rc;
}

public int getCode() {
return _rc;
}
}

}
}}}