/** * Arguments match if the input name matches the corresponding pattern name * and the input value matches the pattern value, where the matching is done * first using String equals, and then Regular Expression matching if the equals test fails. * * @param arg - input Argument * @param patternArg - pattern to match against * @return true if both name and value match */ public static boolean isArgumentMatched(Argument arg, Argument patternArg) { final Perl5Matcher matcher = JMeterUtils.getMatcher(); final PatternCacheLRU patternCache = JMeterUtils.getPatternCache(); return isEqualOrMatches(arg.getName(), patternArg.getName(), matcher, patternCache) && isEqualOrMatches(arg.getValue(), patternArg.getValue(), matcher, patternCache); }
/** * Create a new Argument object. * * @return a new Argument object */ protected Argument makeNewArgument() { return new Argument("", ""); // $NON-NLS-1$ // $NON-NLS-2$ }
protected Argument createArgumentFromClipboard(String[] clipboardCols) { Argument argument = makeNewArgument(); argument.setName(clipboardCols[0]); if (clipboardCols.length > 1) { argument.setValue(clipboardCols[1]); if (clipboardCols.length > 2) { argument.setDescription(clipboardCols[2]); } } return argument; }
@Override public String toString() { final String desc = getDescription(); if (DFLT_DESCRIPTION.equals(desc)) { return getName() + getMetaData() + getValue(); } else { return getName() + getMetaData() + getValue() + " //" + getDescription(); } }
public HTTPArgument(Argument arg) { this(arg.getName(), arg.getValue(), arg.getMetaData()); }
private void modifyArgument(Argument arg, Arguments args) { if (log.isDebugEnabled()) { log.debug("Modifying argument: " + arg); } List<Argument> possibleReplacements = new ArrayList<>(); PropertyIterator iter = args.iterator(); Argument replacementArg; while (iter.hasNext()) { replacementArg = (Argument) iter.next().getObjectValue(); try { if (HtmlParsingUtils.isArgumentMatched(replacementArg, arg)) { possibleReplacements.add(replacementArg); } } catch (Exception ex) { log.error("Problem adding Argument", ex); } } if (!possibleReplacements.isEmpty()) { replacementArg = possibleReplacements.get(ThreadLocalRandom.current().nextInt(possibleReplacements.size())); arg.setName(replacementArg.getName()); arg.setValue(replacementArg.getValue()); if (log.isDebugEnabled()) { log.debug("Just set argument to values: " + arg.getName() + " = " + arg.getValue()); } args.removeArgument(replacementArg); } }
@Override public void modifyTestElement(TestElement args) { GuiUtils.stopTableEditing(table); if (args instanceof Arguments) { Arguments arguments = (Arguments) args; arguments.clear(); @SuppressWarnings("unchecked") // only contains Argument (or HTTPArgument) Iterator<Argument> modelData = (Iterator<Argument>) tableModel.iterator(); while (modelData.hasNext()) { Argument arg = modelData.next(); if(StringUtils.isEmpty(arg.getName()) && StringUtils.isEmpty(arg.getValue())) { continue; } arg.setMetaData("="); // $NON-NLS-1$ arguments.addArgument(arg); } } super.configureTestElement(args); }
/** * @return false if one argument has a name */ private boolean canSwitchToRawBodyPane() { Arguments arguments = (Arguments) argsPanel.createTestElement(); for (int i = 0; i < arguments.getArgumentCount(); i++) { if(!StringUtils.isEmpty(arguments.getArgument(i).getName())) { return false; } } return true; }
for (int i=0;i<args.getArgumentCount();i++) { Argument arg = args.getArgument(i); cmds.add(arg.getPropertyAsString(Argument.VALUE)); cmdLine.append(" "); cmdLine.append(cmds.get(i+1)); for (int i=0;i<environment.getArgumentCount();i++) { Argument arg = environment.getArgument(i); env.put(arg.getName(), arg.getPropertyAsString(Argument.VALUE));
private String buildFunctionCallString(String functionName, Arguments args) { StringBuilder functionCall = new StringBuilder("${"); functionCall.append(functionName); if (args.getArguments().size() > 0) { functionCall.append("("); PropertyIterator iter = args.iterator(); boolean first = true; while (iter.hasNext()) { Argument arg = (Argument) iter.next().getObjectValue(); if (!first) { functionCall.append(","); } functionCall.append(arg.getValue().replaceAll(",", "\\\\,")); first = false; } functionCall.append(")"); } functionCall.append("}"); return functionCall.toString(); }
/** * Gets the value of the Argument object. * * @return the attribute's value */ public String getValue() { return getPropertyAsString(VALUE); }
/** * Sets the Name attribute of the Argument object. * * @param newName * the new Name value */ @Override public void setName(String newName) { if (newName == null || !newName.equals(getName())) { super.setName(newName); } }
while (iter.hasNext()) { Argument arg = (Argument) iter.next().getObjectValue(); final String metaData = arg.getMetaData(); str.append(arg.getName()); if (metaData == null) { str.append("="); //$NON-NLS-1$ str.append(metaData); str.append(arg.getValue()); final String desc = arg.getDescription(); if (desc != null) { str.append("(");
/** * @see org.apache.jmeter.protocol.http.proxy.SamplerCreator#populateSampler(org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase, * org.apache.jmeter.protocol.http.proxy.HttpRequestHdr, java.util.Map, * java.util.Map) */ @Override public final void populateSampler(HTTPSamplerBase sampler, HttpRequestHdr request, Map<String, String> pageEncodings, Map<String, String> formEncodings) throws Exception{ computeFromHeader(sampler, request, pageEncodings, formEncodings); computeFromPostBody(sampler, request); if (log.isDebugEnabled()) { log.debug("sampler path = " + sampler.getPath()); } Arguments arguments = sampler.getArguments(); if(arguments.getArgumentCount() == 1 && arguments.getArgument(0).getName().length()==0) { sampler.setPostBodyRaw(true); } }
/** * Get the name of the Argument. * * @return the attribute's name */ @Override public String getName() { return getPropertyAsString(ARG_NAME); }
public void setHeaderFields(CollectionProperty fields) { clearHeaderFields(); for (int i = 0; i < fields.size(); i++) { Argument argument = (Argument) fields.get(i).getObjectValue(); String name = argument.getName(); JButton removeButton = addHeaderActionPerformed(null); JTextField nameTF = removeButtons.get(removeButton); nameTF.setText(name); JTextField valueTF = headerFields.get(nameTF); valueTF.setText(argument.getValue()); } validate(); }
/** * Remove the argument with the specified name. * * @param argName * the name of the argument to remove */ public void removeArgument(String argName) { PropertyIterator iter = getArguments().iterator(); while (iter.hasNext()) { Argument arg = (Argument) iter.next().getObjectValue(); if (arg.getName().equals(argName)) { iter.remove(); } } }
/** * Add a new empty argument to the list. The new argument will have the * empty string as its name and value, and null metadata. */ public void addEmptyArgument() { addArgument(new Argument("", "", null)); }