Class JMeterAdaption
java.lang.Object
Services.CorrelationsView.ScriptGeneration.JMeterAdaption
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a regular expression extractor to the specified sampler.voidaddRegExtractorMain(Document doc, Node http, List<Object> dependencies, int index) Adds regular expression extractors based on dependency information.voidaddVariableAtList(ArrayList<String> varNameList, ArrayList<String> fromList, ArrayList<Integer> numReqList, String name, String from, String num_req) voidanalizeHttpNode(Document doc, Node http, List<Edge> dependencies) Analyzes an HTTP sampler and applies dependency-based replacements.voidchangeValueCookieHeaderParameter(Node stringvalue, org.json.simple.JSONArray cookiesReplacements, org.json.simple.JSONArray cookies, String value) voidchangeValueHeadersParameter(Node elementProp, List<Edge> dependencies) voidchangeValueQueryParameter(Node elementProp, List<Edge> dependencies) booleancheckRegExtractor(Node http, int index_req) Checks whether the response for the given request index has already been saved.booleancheckTotalSaveResponse(int index_req) Checks whether the response for the given request index has already been saved.getNameFromValue(String value) static voidvoidreplaceAdaption(DependencyGraph dependencyGraph, String FILENAME_JMX, String filename) Applies all adaptation rules to the JMX file based on the dependency graph.voidreplacementsInHeaders(Node item, List<Edge> dependencies) voidreplacementsInQueryParameters_PostData(Node item, List<Edge> dependencies, String name) voidreplacementsInURL(Node item, List<Edge> dependencies) static voidrunJMeterAdaption(DependencyGraph dependencyGraph, String filenameJmx, String filename)
-
Constructor Details
-
JMeterAdaption
public JMeterAdaption()
-
-
Method Details
-
runJMeterAdaption
public static void runJMeterAdaption(DependencyGraph dependencyGraph, String filenameJmx, String filename) throws Exception - Throws:
Exception
-
addRegExtractorMain
Adds regular expression extractors based on dependency information.- Parameters:
doc- XML document being modifiedhttp- HTTP sampler nodedependencies- list of dependency definitionsindex- 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 relationshipsFILENAME_JMX- JMX file to be modifiedfilename- original HAR filename- Throws:
Exception
-
addRegExtractor
Adds a regular expression extractor to the specified sampler.- Parameters:
doc- XML document being modifiedhashTree- parent hash tree nodename- variable name to store the extracted valuepath- regular expression or JSON pathdefa- default value if extraction fails
-
checkRegExtractor
Checks whether the response for the given request index has already been saved.- Parameters:
index_req- request index- Returns:
trueif the response was already saved,falseotherwise
-
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:
trueif the response was already saved,falseotherwise
-
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 modifiedhttp- HTTP sampler nodedependencies- list of dependency edges- Throws:
MalformedURLExceptionURISyntaxExceptionorg.json.simple.parser.ParseException
-
replacementsInURL
public void replacementsInURL(Node item, List<Edge> dependencies) throws MalformedURLException, URISyntaxException -
replacementsInHeaders
-
replacementsInQueryParameters_PostData
-
changeValueHeadersParameter
-
changeValueCookieHeaderParameter
-
changeValueQueryParameter
-
addVariableAtList
-
getNameFromValue
-
main
-