com.lazerycode.jmeter.analyzer.config.Environment Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jmeter-analysis-maven-plugin Show documentation
Show all versions of jmeter-analysis-maven-plugin Show documentation
Parses JMeter result files and computes performance indicators such as average request duration
package com.lazerycode.jmeter.analyzer.config;
import com.lazerycode.jmeter.analyzer.writer.Writer;
import freemarker.ext.beans.BeansWrapper;
import freemarker.template.Configuration;
import org.apache.maven.plugin.logging.Log;
import java.io.File;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Properties;
import java.util.Set;
/**
* Stores information used by several objects
*
* @author Arne Franken
*/
public enum Environment {
/**
* This is the only instance of this enum.
*/
ENVIRONMENT;
/**
* Example from JMeter results file:
*
*
* According to the documentation, the two possible node names are
* {@link #HTTPSAMPLE_ELEMENT_NAME} and {@link #SAMPLE_ELEMENT_NAME}:
* http://jmeter.apache.org/usermanual/listeners.html
*/
public static final String HTTPSAMPLE_ELEMENT_NAME = "httpSample";
public static final String SAMPLE_ELEMENT_NAME = "sample";
public static final int DEFAULT_MAXSAMPLES = 50000;
public static final String ISO8601_FORMAT = "yyyyMMdd'T'HHmmssZ";
/**
* true, if charts should be generated
*/
private boolean generateCharts;
/**
* true, if response sizes and response durations should be provided for each uri
*/
private boolean generateDetails;
/**
* Template directory where custom freemarker templates are stored.
*/
private File templateDirectory;
private Properties remoteResources;
private Set sampleNames;
@SuppressWarnings("all") // avoid "Loose coupling" violation. LinkedHashMap is used to keep order
private LinkedHashMap requestGroups;
private int maxSamples = DEFAULT_MAXSAMPLES;
private Configuration configuration;
private File targetDirectory;
private Log log;
private List writers;
/**
* If true, preserve the relative part of the result file's path
*/
private boolean preserveDirectories;
/**
* Clear all fields that are re-assigned during tests
*/
public void clear() {
this.templateDirectory = null;
this.remoteResources = null;
this.requestGroups = null;
this.maxSamples = 0;
this.configuration = null;
this.targetDirectory = null;
}
public File getTargetDirectory() {
return targetDirectory;
}
public void setTargetDirectory(File targetDirectory) {
this.targetDirectory = targetDirectory;
}
public boolean isGenerateCharts() {
return generateCharts;
}
public void setGenerateCharts(boolean generateCharts) {
this.generateCharts = generateCharts;
}
public boolean isGenerateDetails() {
return generateDetails;
}
public void setGenerateDetails(boolean generateDetails) {
this.generateDetails = generateDetails;
}
public File getTemplateDirectory() {
return templateDirectory;
}
public void setTemplateDirectory(File templateDirectory) {
this.templateDirectory = templateDirectory;
}
public Properties getRemoteResources() {
return remoteResources;
}
public void setRemoteResources(Properties remoteResources) {
this.remoteResources = remoteResources;
}
@SuppressWarnings("all") // avoid "Loose coupling" violation. LinkedHashMap is used to keep order
public LinkedHashMap getRequestGroups() {
return requestGroups;
}
@SuppressWarnings("all") // avoid "Loose coupling" violation. LinkedHashMap is used to keep order
public void setRequestGroups(LinkedHashMap requestGroups) {
this.requestGroups = requestGroups;
}
public int getMaxSamples() {
return maxSamples;
}
public void setMaxSamples(int maxSamples) {
this.maxSamples = maxSamples;
}
public Configuration getConfiguration() {
return configuration;
}
public boolean isPreserveDirectories() {
return preserveDirectories;
}
public void setPreserveDirectories(boolean preserveDirectories) {
this.preserveDirectories = preserveDirectories;
}
public Log getLog() {
return log;
}
public void setLog(Log log) {
this.log = log;
}
public Set getSampleNames() {
return sampleNames;
}
public void setSampleNames(Set sampleNames) {
this.sampleNames = sampleNames;
}
/**
* Initialize Freemarker Configuration
*/
public void initializeFreemarkerConfiguration() {
configuration = new Configuration();
//make maps work in Freemarker when map key is not a String
BeansWrapper beansWrapper = BeansWrapper.getDefaultInstance();
beansWrapper.setSimpleMapWrapper(true);
configuration.setObjectWrapper(beansWrapper);
//make sure that numbers are not formatted as 1,000 but as 1000 instead
configuration.setNumberFormat("computer");
//TODO: make configurable?
configuration.setDateFormat(ISO8601_FORMAT);
configuration.setAutoFlush(true);
}
public List getWriters() {
return writers;
}
public void setWriters(List writers) {
this.writers = writers;
}
}