use of org.camunda.bpm.qa.performance.engine.framework.PerfTestException in project camunda-bpm-platform by camunda.
the class FileUtil method writeStringToFile.
public static void writeStringToFile(String value, String filePath, boolean deleteFile) {
BufferedOutputStream outputStream = null;
try {
File file = new File(filePath);
if (file.exists() && deleteFile) {
file.delete();
}
outputStream = new BufferedOutputStream(new FileOutputStream(file, true));
outputStream.write(value.getBytes());
outputStream.flush();
} catch (Exception e) {
throw new PerfTestException("Could not write report to file", e);
} finally {
IoUtil.closeSilently(outputStream);
}
}
use of org.camunda.bpm.qa.performance.engine.framework.PerfTestException in project camunda-bpm-platform by camunda.
the class JsonUtil method writeObjectToFile.
public static void writeObjectToFile(String filename, Object object) {
final ObjectMapper mapper = getMapper();
try {
File resultFile = new File(filename);
if (resultFile.exists()) {
resultFile.delete();
}
resultFile.createNewFile();
mapper.writerWithDefaultPrettyPrinter().writeValue(resultFile, object);
} catch (Exception e) {
throw new PerfTestException("Cannot write object to file " + filename, e);
}
}
use of org.camunda.bpm.qa.performance.engine.framework.PerfTestException in project camunda-bpm-platform by camunda.
the class PerfTestConfigurationRule method starting.
@Override
protected void starting(Description description) {
if (perfTestConfiguration == null) {
File file = IoUtil.getFile(PROPERTY_FILE_NAME);
if (!file.exists()) {
throw new PerfTestException("Cannot load file '" + PROPERTY_FILE_NAME + "': file does not exist.");
}
FileInputStream propertyInputStream = null;
try {
propertyInputStream = new FileInputStream(file);
Properties properties = new Properties();
properties.load(propertyInputStream);
perfTestConfiguration = new PerfTestConfiguration(properties);
} catch (Exception e) {
throw new PerfTestException("Cannot load properties from file " + PROPERTY_FILE_NAME + ": " + e);
} finally {
IoUtil.closeSilently(propertyInputStream);
}
}
}
use of org.camunda.bpm.qa.performance.engine.framework.PerfTestException in project camunda-bpm-platform by camunda.
the class PerfTestResultRecorderRule method succeeded.
@Override
protected void succeeded(Description description) {
if (results != null) {
results.setTestName(description.getTestClass().getSimpleName() + "." + description.getMethodName());
LOG.log(Level.INFO, results.toString());
String resultFileName = formatResultFileName(description);
try {
// create file:
File directory = new File(formatResultFileDirName());
if (!directory.exists()) {
directory.mkdir();
}
JsonUtil.writeObjectToFile(resultFileName, results);
} catch (Exception e) {
throw new PerfTestException("Could not record results to file " + resultFileName, e);
}
}
}
use of org.camunda.bpm.qa.performance.engine.framework.PerfTestException in project camunda-bpm-platform by camunda.
the class PerfTestProcessEngine method createProcessEngine.
protected static ProcessEngine createProcessEngine(javax.sql.DataSource datasource, Properties properties) {
ProcessEngineConfigurationImpl processEngineConfiguration = new StandaloneProcessEngineConfiguration();
processEngineConfiguration.setDataSource(datasource);
processEngineConfiguration.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
processEngineConfiguration.setHistory(properties.getProperty("historyLevel"));
processEngineConfiguration.setJdbcBatchProcessing(Boolean.valueOf(properties.getProperty("jdbcBatchProcessing")));
// load plugins
String processEnginePlugins = properties.getProperty("processEnginePlugins", "");
for (String pluginName : processEnginePlugins.split(",")) {
if (pluginName.length() > 1) {
Object pluginInstance = ReflectUtil.instantiate(pluginName);
if (!(pluginInstance instanceof ProcessEnginePlugin)) {
throw new PerfTestException("Plugin " + pluginName + " is not an instance of ProcessEnginePlugin");
} else {
List<ProcessEnginePlugin> plugins = processEngineConfiguration.getProcessEnginePlugins();
if (plugins == null) {
plugins = new ArrayList<ProcessEnginePlugin>();
processEngineConfiguration.setProcessEnginePlugins(plugins);
}
plugins.add((ProcessEnginePlugin) pluginInstance);
}
}
}
return processEngineConfiguration.buildProcessEngine();
}
Aggregations