All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lazerycode.jmeter.analyzer.writer.SummaryJsonFileWriter Maven / Gradle / Ivy

Go to download

Parses JMeter result files and computes performance indicators such as average request duration

There is a newer version: 1.0.6
Show newest version
package com.lazerycode.jmeter.analyzer.writer;

import com.lazerycode.jmeter.analyzer.parser.AggregatedResponses;
import freemarker.template.TemplateException;

import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;

import static com.lazerycode.jmeter.analyzer.util.FileUtil.initializeFile;

/**
 * Writes a summary for all discovered / configured
 * {@link com.lazerycode.jmeter.analyzer.AnalyzeMojo#requestGroups RequestGroups} to a JSON file.
 */
public class SummaryJsonFileWriter extends AbstractTextWriter {

  private String jsonFilename = getFileName() + ".json";

  /**
   * Render results as text to a file
   *
   * @param testResults Map to generate output from
   * @throws java.io.IOException
   * @throws freemarker.template.TemplateException
   */
  @Override
  public void write(Map testResults) throws IOException, TemplateException {
    FileWriter out = new FileWriter(initializeFile(getTargetDirectory(), jsonFilename, getResultDataFileRelativePath()));
    PrintWriter text = new PrintWriter(out, false);

    renderText(testResults, "json/main.ftl", text);

    text.flush();
    text.close();
    out.close();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy