use of org.apache.jmeter.config.Arguments in project jmeter by apache.
the class TestTreeCloner method testCloning.
@Test
public void testCloning() throws Exception {
ListedHashTree original = new ListedHashTree();
GenericController controller = new GenericController();
controller.setName("controller");
Arguments args = new Arguments();
args.setName("args");
TestPlan plan = new TestPlan();
plan.addParameter("server", "jakarta");
original.add(controller, args);
original.add(plan);
ResultCollector listener = new ResultCollector();
listener.setName("Collector");
original.add(controller, listener);
TreeCloner cloner = new TreeCloner();
original.traverse(cloner);
ListedHashTree newTree = cloner.getClonedTree();
assertTrue(original != newTree);
assertEquals(original.size(), newTree.size());
assertEquals(original.getTree(original.getArray()[0]).size(), newTree.getTree(newTree.getArray()[0]).size());
assertTrue(original.getArray()[0] != newTree.getArray()[0]);
assertEquals(((GenericController) original.getArray()[0]).getName(), ((GenericController) newTree.getArray()[0]).getName());
assertSame(original.getTree(original.getArray()[0]).getArray()[1], newTree.getTree(newTree.getArray()[0]).getArray()[1]);
TestPlan clonedTestPlan = (TestPlan) newTree.getArray()[1];
clonedTestPlan.setRunningVersion(true);
clonedTestPlan.recoverRunningVersion();
assertTrue(!plan.getUserDefinedVariablesAsProperty().isRunningVersion());
assertTrue(clonedTestPlan.getUserDefinedVariablesAsProperty().isRunningVersion());
Arguments vars = (Arguments) plan.getUserDefinedVariablesAsProperty().getObjectValue();
PropertyIterator iter = ((CollectionProperty) vars.getProperty(Arguments.ARGUMENTS)).iterator();
while (iter.hasNext()) {
JMeterProperty argProp = iter.next();
assertTrue(!argProp.isRunningVersion());
assertTrue(argProp.getObjectValue() instanceof Argument);
Argument arg = (Argument) argProp.getObjectValue();
arg.setValue("yahoo");
assertEquals("yahoo", arg.getValue());
}
vars = (Arguments) clonedTestPlan.getUserDefinedVariablesAsProperty().getObjectValue();
iter = vars.propertyIterator();
while (iter.hasNext()) {
assertTrue(iter.next().isRunningVersion());
}
}
use of org.apache.jmeter.config.Arguments in project jmeter by apache.
the class PackageTest method testArguments.
@Test
public void testArguments() throws Exception {
Arguments args = new Arguments();
args.addArgument("arg1", "val1", "=");
TestElementProperty prop = new TestElementProperty("args", args);
ConfigTestElement te = new ConfigTestElement();
te.addProperty(prop);
te.setRunningVersion(true);
Arguments config = new Arguments();
config.addArgument("config1", "configValue", "=");
TestElementProperty configProp = new TestElementProperty("args", config);
ConfigTestElement te2 = new ConfigTestElement();
te2.addProperty(configProp);
te.addTestElement(te2);
assertEquals(2, args.getArgumentCount());
assertEquals("config1=configValue", args.getArgument(1).toString());
te.recoverRunningVersion();
te.addTestElement(te2);
assertEquals(2, args.getArgumentCount());
assertEquals("config1=configValue", args.getArgument(1).toString());
}
use of org.apache.jmeter.config.Arguments in project jmeter by apache.
the class HTTPArgumentsPanel method configure.
@Override
public void configure(TestElement el) {
super.configure(el);
if (el instanceof Arguments) {
tableModel.clearData();
HTTPArgument.convertArgumentsToHTTP((Arguments) el);
for (JMeterProperty jMeterProperty : ((Arguments) el).getArguments()) {
HTTPArgument arg = (HTTPArgument) jMeterProperty.getObjectValue();
tableModel.addRow(arg);
}
}
checkButtonsStatus();
}
use of org.apache.jmeter.config.Arguments in project jmeter by apache.
the class HTTPArgumentsPanel method getUnclonedParameters.
private Arguments getUnclonedParameters() {
stopTableEditing();
// only contains Argument (or HTTPArgument)
@SuppressWarnings("unchecked") Iterator<HTTPArgument> modelData = (Iterator<HTTPArgument>) tableModel.iterator();
Arguments args = new Arguments();
while (modelData.hasNext()) {
HTTPArgument arg = modelData.next();
args.addArgument(arg);
}
return args;
}
use of org.apache.jmeter.config.Arguments in project jmeter by apache.
the class UrlConfigGui method configure.
/**
* Set the text, etc. in the UI.
*
* @param el
* contains the data to be displayed
*/
public void configure(TestElement el) {
setName(el.getName());
Arguments arguments = (Arguments) el.getProperty(HTTPSamplerBase.ARGUMENTS).getObjectValue();
if (showRawBodyPane) {
boolean useRaw = el.getPropertyAsBoolean(HTTPSamplerBase.POST_BODY_RAW, HTTPSamplerBase.POST_BODY_RAW_DEFAULT);
if (useRaw) {
// Convert CRLF to CR, see modifyTestElement
String postBody = computePostBody(arguments, true);
postBodyContent.setInitialText(postBody);
postBodyContent.setCaretPosition(0);
argsPanel.clear();
postContentTabbedPane.setSelectedIndex(tabRawBodyIndex, false);
} else {
postBodyContent.setInitialText("");
argsPanel.configure(arguments);
postContentTabbedPane.setSelectedIndex(TAB_PARAMETERS, false);
}
}
if (showFileUploadPane) {
filesPanel.configure(el);
}
domain.setText(el.getPropertyAsString(HTTPSamplerBase.DOMAIN));
String portString = el.getPropertyAsString(HTTPSamplerBase.PORT);
// Only display the port number if it is meaningfully specified
if (portString.equals(HTTPSamplerBase.UNSPECIFIED_PORT_AS_STRING)) {
// $NON-NLS-1$
port.setText("");
} else {
port.setText(portString);
}
protocol.setText(el.getPropertyAsString(HTTPSamplerBase.PROTOCOL));
contentEncoding.setText(el.getPropertyAsString(HTTPSamplerBase.CONTENT_ENCODING));
path.setText(el.getPropertyAsString(HTTPSamplerBase.PATH));
if (notConfigOnly) {
method.setText(el.getPropertyAsString(HTTPSamplerBase.METHOD));
followRedirects.setSelected(el.getPropertyAsBoolean(HTTPSamplerBase.FOLLOW_REDIRECTS));
autoRedirects.setSelected(el.getPropertyAsBoolean(HTTPSamplerBase.AUTO_REDIRECTS));
useKeepAlive.setSelected(el.getPropertyAsBoolean(HTTPSamplerBase.USE_KEEPALIVE));
useMultipart.setSelected(el.getPropertyAsBoolean(HTTPSamplerBase.DO_MULTIPART_POST));
useBrowserCompatibleMultipartMode.setSelected(el.getPropertyAsBoolean(HTTPSamplerBase.BROWSER_COMPATIBLE_MULTIPART, HTTPSamplerBase.BROWSER_COMPATIBLE_MULTIPART_MODE_DEFAULT));
}
}
Aggregations