Class JMeterAdaption

java.lang.Object
Services.CorrelationsView.ScriptGeneration.JMeterAdaption

public class JMeterAdaption extends Object
Handles the adaptation of a JMeter test plan generated from a HAR conversion.

This class takes the JMX skeleton produced by the Converter and applies additional configuration defined by the tester, such as:

  • Variable substitutions
  • Web service–related parameters
  • Response handling and dependency-based adaptations

The adaptation logic is driven by a DependencyGraph, which describes relationships between requests and variables extracted during analysis.

The resulting JMX file is modified in-place or rewritten to include all required configuration elements.

  • Constructor Details

    • JMeterAdaption

      public JMeterAdaption()
  • Method Details

    • runJMeterAdaption

      public static void runJMeterAdaption(DependencyGraph dependencyGraph, String filenameJmx, String filename) throws Exception
      Throws:
      Exception
    • addRegExtractorMain

      public void addRegExtractorMain(Document doc, Node http, List<Object> dependencies, int index)
      Adds regular expression extractors based on dependency information.
      Parameters:
      doc - XML document being modified
      http - HTTP sampler node
      dependencies - list of dependency definitions
      index - index of the current request
    • replaceAdaption

      public void replaceAdaption(DependencyGraph dependencyGraph, String FILENAME_JMX, String filename) throws Exception
      Applies all adaptation rules to the JMX file based on the dependency graph.
      Parameters:
      dependencyGraph - dependency graph describing request relationships
      FILENAME_JMX - JMX file to be modified
      filename - original HAR filename
      Throws:
      Exception
    • addRegExtractor

      public void addRegExtractor(Document doc, Node hashTree, String name, String path, String defa)
      Adds a regular expression extractor to the specified sampler.
      Parameters:
      doc - XML document being modified
      hashTree - parent hash tree node
      name - variable name to store the extracted value
      path - regular expression or JSON path
      defa - default value if extraction fails
    • checkRegExtractor

      public boolean checkRegExtractor(Node http, int index_req)
      Checks whether the response for the given request index has already been saved.
      Parameters:
      index_req - request index
      Returns:
      true if the response was already saved, false otherwise
    • checkTotalSaveResponse

      public boolean checkTotalSaveResponse(int index_req)
      Checks whether the response for the given request index has already been saved.
      Parameters:
      index_req - request index
      Returns:
      true if the response was already saved, false otherwise
    • analizeHttpNode

      public void analizeHttpNode(Document doc, Node http, List<Edge> dependencies) throws MalformedURLException, URISyntaxException, org.json.simple.parser.ParseException
      Analyzes an HTTP sampler and applies dependency-based replacements.
      Parameters:
      doc - XML document being modified
      http - HTTP sampler node
      dependencies - list of dependency edges
      Throws:
      MalformedURLException
      URISyntaxException
      org.json.simple.parser.ParseException
    • replacementsInURL

      public void replacementsInURL(Node item, List<Edge> dependencies) throws MalformedURLException, URISyntaxException
      Throws:
      MalformedURLException
      URISyntaxException
    • replacementsInHeaders

      public void replacementsInHeaders(Node item, List<Edge> dependencies)
    • replacementsInQueryParameters_PostData

      public void replacementsInQueryParameters_PostData(Node item, List<Edge> dependencies, String name)
    • changeValueHeadersParameter

      public void changeValueHeadersParameter(Node elementProp, List<Edge> dependencies)
    • changeValueCookieHeaderParameter

      public void changeValueCookieHeaderParameter(Node stringvalue, org.json.simple.JSONArray cookiesReplacements, org.json.simple.JSONArray cookies, String value)
    • changeValueQueryParameter

      public void changeValueQueryParameter(Node elementProp, List<Edge> dependencies)
    • addVariableAtList

      public void addVariableAtList(ArrayList<String> varNameList, ArrayList<String> fromList, ArrayList<Integer> numReqList, String name, String from, String num_req)
    • getNameFromValue

      public String getNameFromValue(String value)
    • main

      public static void main(String[] args)