I was able to get jMeter to include a file with beanshell functions in it
automatically by using the
property:
beanshell.function.init=BeanShellFunction.bshrc
However, I have a function which I want to use that will take a SampleResult
and do some modifications (basically its an xml document but its not well
formed in that it has multiple top level nodes, I want to wrap it and modify
it.. I've got all this working but I can't get it working within a
function).
here is what I have:
print("including functions");
wrapResponse(SampleResult result, String prefix,String suffix, ) {
log.info("Calling wrapResponse");
encoding = result.getDataEncodingWithDefault();
String data = prefix + (new String(result.getResponseData())) + suffix;
result.setResponseData(data.getBytes(encoding));
}
I know that this file is being included but i can't seem to pass the result
value to the function.
This is within a BSF PostProcessor which has a prev variable which has the
response in it (like I said, i've verified this works when not in a
function).
The string values pass just fine though..
I'm calling it like this:
${__BeanShell(wrapResponse(prev\,"<tiqs>"\,"<tiqs>"))}
Here is the error message:
2009/11/05 17:04:03 WARN - jmeter.functions.BeanShell: Error running BSH
script org.apache.jorphan.util.JMeterException: Error invoking bsh method:
eval Sourced file: inline evaluation of:
``wrapResponse(prev,"<tiqs>","<tiqs>");'' : Undefined argument: prev
at
org.apache.jmeter.util.BeanShellInterpreter.bshInvoke(BeanShellInterpreter.java:192)
at
org.apache.jmeter.util.BeanShellInterpreter.eval(BeanShellInterpreter.java:198)
at org.apache.jmeter.functions.BeanShell.execute(BeanShell.java:106)
at
org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:143)
at
org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:112)
at
org.apache.jmeter.testelement.property.FunctionProperty.getStringValue(FunctionProperty.java:89)
at
org.apache.jmeter.testbeans.TestBeanHelper.prepare(TestBeanHelper.java:69)
at
org.apache.jmeter.threads.JMeterThread.runPostProcessors(JMeterThread.java:622)
at
org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:356)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:243)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.apache.jmeter.util.BeanShellInterpreter.bshInvoke(BeanShellInterpreter.java:171)
... 10 more
Caused by: Sourced file: inline evaluation of:
``wrapResponse(prev,"<tiqs>","<tiqs>");'' : Undefined argument: prev : at
Line: 1 : in file: inline evaluation of:
``wrapResponse(prev,"<tiqs>","<tiqs>");'' : ( prev , "<tiqs>" , "<tiqs>" )
at bsh.BSHArguments.getArguments(Unknown Source)
at bsh.BSHMethodInvocation.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
... 15 more
--
View this message in context:
http://old.nabble.com/How-do-I-call-function-passing-in-script-variables-tp26225188p26225188.html
Sent from the JMeter - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]