Search in sources :

Example 1 with PerfTestException

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);
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) PerfTestException(org.camunda.bpm.qa.performance.engine.framework.PerfTestException) BufferedOutputStream(java.io.BufferedOutputStream) File(java.io.File) PerfTestException(org.camunda.bpm.qa.performance.engine.framework.PerfTestException)

Example 2 with PerfTestException

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);
    }
}
Also used : PerfTestException(org.camunda.bpm.qa.performance.engine.framework.PerfTestException) File(java.io.File) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) PerfTestException(org.camunda.bpm.qa.performance.engine.framework.PerfTestException)

Example 3 with PerfTestException

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);
        }
    }
}
Also used : PerfTestConfiguration(org.camunda.bpm.qa.performance.engine.framework.PerfTestConfiguration) PerfTestException(org.camunda.bpm.qa.performance.engine.framework.PerfTestException) Properties(java.util.Properties) File(java.io.File) FileInputStream(java.io.FileInputStream) PerfTestException(org.camunda.bpm.qa.performance.engine.framework.PerfTestException)

Example 4 with PerfTestException

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);
        }
    }
}
Also used : PerfTestException(org.camunda.bpm.qa.performance.engine.framework.PerfTestException) File(java.io.File) PerfTestException(org.camunda.bpm.qa.performance.engine.framework.PerfTestException)

Example 5 with PerfTestException

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();
}
Also used : StandaloneProcessEngineConfiguration(org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration) PerfTestException(org.camunda.bpm.qa.performance.engine.framework.PerfTestException) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) ProcessEnginePlugin(org.camunda.bpm.engine.impl.cfg.ProcessEnginePlugin)

Aggregations

PerfTestException (org.camunda.bpm.qa.performance.engine.framework.PerfTestException)6 File (java.io.File)4 Properties (java.util.Properties)2 BufferedOutputStream (java.io.BufferedOutputStream)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 PoolProperties (org.apache.tomcat.jdbc.pool.PoolProperties)1 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)1 ProcessEnginePlugin (org.camunda.bpm.engine.impl.cfg.ProcessEnginePlugin)1 StandaloneProcessEngineConfiguration (org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration)1 PerfTestConfiguration (org.camunda.bpm.qa.performance.engine.framework.PerfTestConfiguration)1 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)1