Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
.idea
target
123 changes: 123 additions & 0 deletions jmeter/bin/upgrade.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Class, property and value upgrade equivalences.

## Licensed to the Apache Software Foundation (ASF) under one or more
## contributor license agreements. See the NOTICE file distributed with
## this work for additional information regarding copyright ownership.
## The ASF licenses this file to You under the Apache License, Version 2.0
## (the "License"); you may not use this file except in compliance with
## the License. You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.

#
# Format is as follows --
# for renamed test element & GUI classes:
# old.class.Name=new.class.Name
# old.class.Name|guiClassName=new.class.Name
# (e.g. for ConfigTestElement)
#
# for renamed / deleted properties:
# class.Name/Old.propertyName=newPropertyName
# if newPropertyName is omitted, then property is deleted
#
# for renamed values:
# old.class.Name.old.propertyName/oldValue=newValue
#

org.apache.jmeter.protocol.http.config.gui.UrlConfigGui=org.apache.jmeter.protocol.http.config.gui.HttpDefaultsGui
org.apache.jmeter.assertions.Assertion=org.apache.jmeter.assertions.ResponseAssertion
org.apache.jmeter.protocol.http.sampler.HTTPSamplerFull=org.apache.jmeter.protocol.http.sampler.HTTPSampler
org.apache.jmeter.control.gui.RecordController=org.apache.jmeter.protocol.http.control.gui.RecordController

org.apache.jmeter.timers.gui.ConstantThroughputTimerGui=org.apache.jmeter.testbeans.gui.TestBeanGUI
org.apache.jmeter.timers.ConstantThroughputTimer/ConstantThroughputTimer.throughput=throughput

org.apache.jmeter.protocol.jdbc.control.gui.JdbcTestSampleGui=org.apache.jmeter.testbeans.gui.TestBeanGUI
org.apache.jmeter.protocol.jdbc.sampler.JDBCSampler/JDBCSampler.query=query
#org.apache.jmeter.protocol.jdbc.sampler.JDBCSampler.JDBCSampler.dataSource/NULL=

# Convert DBconfig
org.apache.jmeter.protocol.jdbc.config.gui.DbConfigGui=org.apache.jmeter.testbeans.gui.TestBeanGUI
org.apache.jmeter.config.ConfigTestElement|org.apache.jmeter.protocol.jdbc.config.gui.DbConfigGui=org.apache.jmeter.protocol.jdbc.config.DataSourceElement
org.apache.jmeter.protocol.jdbc.config.DataSourceElement/JDBCSampler.url=dbUrl
org.apache.jmeter.protocol.jdbc.config.DataSourceElement/JDBCSampler.driver=driver
org.apache.jmeter.protocol.jdbc.config.DataSourceElement/JDBCSampler.query=query
org.apache.jmeter.protocol.jdbc.config.DataSourceElement/ConfigTestElement.username=username
org.apache.jmeter.protocol.jdbc.config.DataSourceElement/ConfigTestElement.password=password

# Convert PoolConfig
org.apache.jmeter.protocol.jdbc.config.gui.PoolConfigGui=org.apache.jmeter.testbeans.gui.TestBeanGUI
org.apache.jmeter.config.ConfigTestElement|org.apache.jmeter.protocol.jdbc.config.gui.PoolConfigGui=org.apache.jmeter.protocol.jdbc.config.DataSourceElement
org.apache.jmeter.protocol.jdbc.config.DataSourceElement/JDBCSampler.connections=
org.apache.jmeter.protocol.jdbc.config.DataSourceElement/JDBCSampler.connPoolClass=
org.apache.jmeter.protocol.jdbc.config.DataSourceElement/JDBCSampler.maxuse=poolMax

# SQL Config
org.apache.jmeter.config.ConfigTestElement/JDBCSampler.query=query
org.apache.jmeter.protocol.http.control.Header/TestElement.name=Header.name

# Upgrade AccessLogSampler
org.apache.jmeter.protocol.http.control.gui.AccessLogSamplerGui=org.apache.jmeter.testbeans.gui.TestBeanGUI
org.apache.jmeter.protocol.http.sampler.AccessLogSampler/AccessLogSampler.log_file=logFile
org.apache.jmeter.protocol.http.sampler.AccessLogSampler/HTTPSampler.port=portString
#Is the following used now?
#org.apache.jmeter.protocol.http.sampler.AccessLogSampler/AccessLogSampler.generator_class_name=
#Looks to be a new field
#filterClassName
org.apache.jmeter.protocol.http.sampler.AccessLogSampler/HTTPSampler.domain=domain
org.apache.jmeter.protocol.http.sampler.AccessLogSampler/AccessLogSampler.parser_class_name=parserClassName
org.apache.jmeter.protocol.http.sampler.AccessLogSampler/HTTPSampler.image_parser=imageParsing

# Renamed class
org.apache.jmeter.protocol.jms.control.gui.JMSConfigGui=org.apache.jmeter.protocol.jms.control.gui.JMSSamplerGui

# These classes have been deleted; there's no defined replacement
org.apache.jmeter.protocol.jdbc.config.gui.SqlConfigGui=org.apache.jmeter.config.gui.ObsoleteGui
org.apache.jmeter.protocol.jms.control.gui.JndiDefaultsGui=org.apache.jmeter.config.gui.ObsoleteGui
# Should probably map to something other than ObsoleteGui...
org.apache.jmeter.threads.ReflectionThreadGroup=org.apache.jmeter.config.gui.ObsoleteGui

# Convert BSFSamplerGui
org.apache.jmeter.protocol.java.control.gui.BSFSamplerGui=org.apache.jmeter.testbeans.gui.TestBeanGUI
org.apache.jmeter.protocol.java.sampler.BSFSampler/BSFSampler.filename=filename
org.apache.jmeter.protocol.java.sampler.BSFSampler/BSFSampler.language=scriptLanguage
org.apache.jmeter.protocol.java.sampler.BSFSampler/BSFSampler.parameters=parameters
org.apache.jmeter.protocol.java.sampler.BSFSampler/BSFSampler.query=script

# Obsolete Http user Parameters modifier test element
# Note: ConfigTestElement is the test element associated with ObsoleteGui
org.apache.jmeter.protocol.http.modifier.UserParameterModifier=org.apache.jmeter.config.ConfigTestElement
org.apache.jmeter.protocol.http.modifier.gui.UserParameterModifierGui=org.apache.jmeter.config.gui.ObsoleteGui

# Obsolete Graph Full Results listener
org.apache.jmeter.visualizers.GraphAccumVisualizer=org.apache.jmeter.config.gui.ObsoleteGui
# removed in 3.0, class was deleted in r1722757
org.apache.jmeter.protocol.http.sampler.WebServiceSampler=org.apache.jmeter.config.ConfigTestElement
# removed in 3.0, class was deleted in r1722757
org.apache.jmeter.protocol.http.control.gui.WebServiceSamplerGui=org.apache.jmeter.config.gui.ObsoleteGui
# removed in 3.0, class was deleted in r1722757
org.apache.jmeter.protocol.http.modifier.ParamModifier=org.apache.jmeter.config.ConfigTestElement
# removed in 3.0, class was deleted in r1722962
org.apache.jmeter.protocol.http.modifier.ParamMask=org.apache.jmeter.config.ConfigTestElement
# removed in 3.0, class was deleted in r1722757
org.apache.jmeter.protocol.http.modifier.gui.ParamModifierGui=org.apache.jmeter.config.gui.ObsoleteGui

# removed in 3.1, class was deleted in r1774947
org.apache.jmeter.visualizers.SplineVisualizer=org.apache.jmeter.config.gui.ObsoleteGui
# removed in 3.1 class was deleted in r1763837
org.apache.jmeter.visualizers.DistributionGraphVisualizer=org.apache.jmeter.config.gui.ObsoleteGui

# removed in 3.2 class was deleted in r1771608
org.apache.jmeter.visualizers.MonitorStats=org.apache.jmeter.config.ConfigTestElement
org.apache.jmeter.visualizers.MonitorHealthVisualizer=org.apache.jmeter.config.gui.ObsoleteGui

# removed in 3.2 class was deleted in r1783280
org.apache.jmeter.protocol.http.sampler.HTTPSampler2=org.apache.jmeter.config.ConfigTestElement
org.apache.jmeter.protocol.http.sampler.SoapSampler=org.apache.jmeter.config.ConfigTestElement
org.apache.jmeter.protocol.http.control.gui.SoapSamplerGui=org.apache.jmeter.config.gui.ObsoleteGui
9 changes: 8 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@
<artifactId>jackson-databind</artifactId>
<version>2.9.10.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>

<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_http</artifactId>
<version>4.0</version>
<version>5.4.3</version>
<exclusions>
<exclusion>
<groupId>commons-math3</groupId>
Expand Down Expand Up @@ -116,6 +121,7 @@
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<executions>
Expand All @@ -141,6 +147,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>copy-dependencies</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import com.loadium.postman2jmx.model.jmx.*;
import com.loadium.postman2jmx.model.postman.PostmanCollection;
import com.loadium.postman2jmx.model.postman.PostmanItem;
import org.apache.jmeter.config.Argument;
import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.control.LoopController;
import org.apache.jmeter.extractor.json.jsonpath.JSONPostProcessor;
import org.apache.jmeter.protocol.http.control.HeaderManager;
Expand All @@ -19,12 +17,7 @@
import org.apache.jorphan.collections.ListedHashTree;

import java.io.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public abstract class AbstractJmxFileBuilder implements IJmxFileBuilder {

Expand All @@ -49,54 +42,32 @@ protected JmxFile buildJmxFile(PostmanCollection postmanCollection, String jmxOu
// ThreadGroup
ThreadGroup threadGroup = JmxThreadGroup.newInstance(loopController);

// HTTPSamplerProxy
List<HTTPSamplerProxy> httpSamplerProxies = new ArrayList<>();
List<HeaderManager> headerManagers = new ArrayList<>();

for (PostmanItem item : postmanCollection.getItems()) {
/* if (!item.getEvent().isEmpty()) {
continue;
}*/

IJmxBodyBuilder bodyBuilder = JmxBodyBuilderFactory.getJmxBodyBuilder(item);
HTTPSamplerProxy httpSamplerProxy = bodyBuilder.buildJmxBody(item);
httpSamplerProxies.add(httpSamplerProxy);

headerManagers.add(JmxHeaderManager.newInstance(item.getName(), item.getRequest().getHeaders()));
}

// Create TestPlan hash tree
HashTree testPlanHashTree = new ListedHashTree();
testPlanHashTree.add(testPlan);

// Add ThreadGroup to TestPlan hash tree
HashTree threadGroupHashTree = new ListedHashTree();
threadGroupHashTree = testPlanHashTree.add(testPlan, threadGroup);
HashTree threadGroupHashTree = testPlanHashTree.add(testPlan, threadGroup);

// Add Http Cookie Manager
threadGroupHashTree.add(JmxCookieManager.newInstance());

// Add Http Sampler to ThreadGroup hash tree
HashTree httpSamplerHashTree = new ListedHashTree();

// Add header manager hash tree
HashTree headerHashTree = null;

// Add Java Sampler to ThreadGroup hash tree
for (int i = 0; i < httpSamplerProxies.size(); i++) {
HTTPSamplerProxy httpSamplerProxy = httpSamplerProxies.get(i);
HeaderManager headerManager = headerManagers.get(i);

httpSamplerHashTree = threadGroupHashTree.add(httpSamplerProxy);

headerHashTree = new HashTree();
headerHashTree = httpSamplerHashTree.add(headerManager);
for (PostmanItem item : postmanCollection.getItems()) {
IJmxBodyBuilder bodyBuilder = JmxBodyBuilderFactory.getJmxBodyBuilder(item);
HTTPSamplerProxy httpSamplerProxy = bodyBuilder.buildJmxBody(item);

PostmanItem postmanItem = postmanCollection.getItems().get(i);
if (!postmanItem.getEvents().isEmpty()) {
List<JSONPostProcessor> jsonPostProcessors = JmxJsonPostProcessor.getJsonPostProcessors(postmanItem);
// Add Http Sampler to ThreadGroup hash tree
HashTree httpSamplerHashTree = threadGroupHashTree.add(httpSamplerProxy);
if (!item.getEvents().isEmpty()) {
List<JSONPostProcessor> jsonPostProcessors = JmxJsonPostProcessor.getJsonPostProcessors(item);
httpSamplerHashTree.add(jsonPostProcessors);
}

// Add HTTP Header Manager (if headers are defined)
if (!item.getRequest().getHeaders().isEmpty()) {
HeaderManager headerManager = JmxHeaderManager.newInstance(item.getName(), item.getRequest().getHeaders());
httpSamplerHashTree.add(headerManager);
}
}

File file = new File(jmxOutputFilePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@
import com.loadium.postman2jmx.utils.ResponseBodyMode;

public class JmxBodyBuilderFactory {

private static JmxRawBodyBuilder jmxRawBodyFileBuilder;

private static JmxFormDataBodyBuilder jmxFormDataBodyFileBuilder;

private static JmxUrlEncodedBodyBuilder jmxUrlEncodedBodyFileBuilder;

private static JmxBinaryBodyBuilder jmxBinaryBodyFileBuilder;

private static JmxEmptyBodyBuilder jmxEmptyBodyBuilder;

private static JmxGraphQLBodyBuilder jmxGraphQLBodyFileBuilder;


public static IJmxBodyBuilder getJmxBodyBuilder(PostmanItem postmanItem) throws UnsupportedJmxFileBuilderException {
String responseBodyMode = null;
Expand All @@ -30,6 +37,11 @@ public static IJmxBodyBuilder getJmxBodyBuilder(PostmanItem postmanItem) throws
jmxRawBodyFileBuilder = new JmxRawBodyBuilder();
}
return jmxRawBodyFileBuilder;
} else if (ResponseBodyMode.GRAPHQL.getMode().equals(responseBodyMode)) {
if (jmxGraphQLBodyFileBuilder == null) {
jmxGraphQLBodyFileBuilder = new JmxGraphQLBodyBuilder();
}
return jmxGraphQLBodyFileBuilder;
} else if (ResponseBodyMode.FORM_DATA.getMode().equals(responseBodyMode)) {
if (jmxFormDataBodyFileBuilder == null) {
jmxFormDataBodyFileBuilder = new JmxFormDataBodyBuilder();
Expand All @@ -49,4 +61,5 @@ public static IJmxBodyBuilder getJmxBodyBuilder(PostmanItem postmanItem) throws
throw new UnsupportedJmxFileBuilderException("There is no Jxm builder for response body type: " + responseBodyMode);
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.loadium.postman2jmx.builder;

import com.loadium.postman2jmx.model.jmx.JmxHTTPSamplerProxy;
import com.loadium.postman2jmx.model.postman.PostmanGraphQLBody;
import com.loadium.postman2jmx.model.postman.PostmanItem;
import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.protocol.http.config.gui.GraphQLUrlConfigGui;
import org.apache.jmeter.protocol.http.control.gui.GraphQLHTTPSamplerGui;
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy;
import org.apache.jmeter.protocol.http.util.HTTPArgument;
import org.apache.jmeter.protocol.http.util.HTTPConstants;
import org.apache.jmeter.testelement.TestElement;

public class JmxGraphQLBodyBuilder extends AbstractJmxBodyBuilder {

@Override
public HTTPSamplerProxy buildJmxBody(PostmanItem postmanItem) {

HTTPSamplerProxy sampler = JmxHTTPSamplerProxy.newInstance(postmanItem);

if (HTTPConstants.POST.equalsIgnoreCase(sampler.getMethod()) || HTTPConstants.PUT.equalsIgnoreCase(sampler.getMethod()) || HTTPConstants.DELETE.equalsIgnoreCase(sampler.getMethod())) {
sampler.setPostBodyRaw(true);
sampler.setFollowRedirects(false);

// Set GraphQL request parameters
PostmanGraphQLBody graphql = postmanItem.getRequest().getBody().getGraphql();
sampler.setProperty(TestElement.GUI_CLASS, GraphQLHTTPSamplerGui.class.getName());
sampler.setProperty(GraphQLUrlConfigGui.OPERATION_NAME, graphql.getOperationName());
sampler.setProperty(GraphQLUrlConfigGui.QUERY, graphql.getQuery());
sampler.setProperty(GraphQLUrlConfigGui.VARIABLES, graphql.getVariables());

// Add GraphQL arguments
Arguments arguments = new Arguments();
if (graphql.getQuery() != null && !graphql.getQuery().isEmpty()) {
HTTPArgument argument = new HTTPArgument();
argument.setEnabled(true);
argument.setAlwaysEncoded(false);
argument.setAlwaysEncoded(false);
argument.setMetaData("=");
argument.setUseEquals(true);
argument.setValue(graphql.toJsonString());
arguments.addArgument(argument);
}
sampler.setArguments(arguments);
}

return sampler;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy;
import org.apache.jmeter.protocol.http.util.HTTPArgument;

import javax.ws.rs.HttpMethod;
import org.apache.jmeter.protocol.http.util.HTTPConstants;

public class JmxRawBodyBuilder extends AbstractJmxBodyBuilder {

Expand All @@ -17,7 +16,7 @@ public HTTPSamplerProxy buildJmxBody(PostmanItem postmanItem) {

HTTPSamplerProxy httpSamplerProxy = JmxHTTPSamplerProxy.newInstance(postmanItem);

if (HttpMethod.POST.equalsIgnoreCase(httpSamplerProxy.getMethod()) || HttpMethod.PUT.equalsIgnoreCase(httpSamplerProxy.getMethod()) || HttpMethod.DELETE.equalsIgnoreCase(httpSamplerProxy.getMethod())) {
if (HTTPConstants.POST.equalsIgnoreCase(httpSamplerProxy.getMethod()) || HTTPConstants.PUT.equalsIgnoreCase(httpSamplerProxy.getMethod()) || HTTPConstants.DELETE.equalsIgnoreCase(httpSamplerProxy.getMethod())) {
httpSamplerProxy.setPostBodyRaw(true);
Arguments arguments = new Arguments();
PostmanRawBody raw = postmanItem.getRequest().getBody().getRaw();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public class PostmanBody {
@JsonProperty("raw")
private PostmanRawBody raw;

@JsonProperty("graphql")
private PostmanGraphQLBody graphql;

@JsonProperty("formdata")
private List<PostmanFormDataBody> formDataList = new ArrayList<>();

Expand Down Expand Up @@ -70,4 +73,13 @@ public List<PostmanFormDataBody> getFormDataList() {
public void setFormDataList(List<PostmanFormDataBody> formDataList) {
this.formDataList = formDataList;
}

public PostmanGraphQLBody getGraphql() {
return graphql;
}

public void setGraphql(PostmanGraphQLBody graphql) {
this.graphql = graphql;
}

}
Loading