https://bz.apache.org/bugzilla/show_bug.cgi?id=60883
Bug ID: 60883
Summary: Add ${__escapeXml()} function
Product: JMeter
Version: 3.1
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P2
Component: Main
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---
Add a counterpart for __escapeHtml for XML too: __escapeXml
Simple impl based off __escapeHtml:
> import java.util.Collection;
> import java.util.LinkedList;
> import java.util.List;
>
> import org.apache.commons.lang3.StringEscapeUtils;
> import org.apache.jmeter.engine.util.CompoundVariable;
> import org.apache.jmeter.functions.AbstractFunction;
> import org.apache.jmeter.functions.InvalidVariableException;
> import org.apache.jmeter.samplers.SampleResult;
> import org.apache.jmeter.samplers.Sampler;
>
> public class EscapeXml extends AbstractFunction {
>
> private static final List<String> desc = new LinkedList<String>();
>
> private static final String KEY = "__escapeXml"; //$NON-NLS-1$
>
> static {
> desc.add("Escape XML string"); //$NON-NLS-1$
> }
>
> private Object[] values;
>
> public EscapeXml() {
> }
>
> /** {@inheritDoc} */
> @Override
> public String execute(SampleResult previousResult, Sampler
> currentSampler)
> throws InvalidVariableException {
>
> String rawString = ((CompoundVariable) values[0]).execute();
> return StringEscapeUtils.escapeXml10(rawString);
>
> }
>
> /** {@inheritDoc} */
> @Override
> public void setParameters(Collection<CompoundVariable> parameters)
> throws InvalidVariableException {
> checkParameterCount(parameters, 1);
> values = parameters.toArray();
> }
>
> /** {@inheritDoc} */
> @Override
> public String getReferenceKey() {
> return KEY;
> }
>
> /** {@inheritDoc} */
> public List<String> getArgumentDesc() {
> return desc;
> }
> }
--
You are receiving this mail because:
You are the assignee for the bug.