Hi Surya,
The same requirement i have to implement in my project.
Am following the steps which you have recommended, am having a couple of queries on this solution
* Could you please guide me where should i add below piece of code in my VSM.
req=testExec.getStateObject("lisa.vse.request");
testExec.log(testExec.getStateValue("lisa.vse.request").toString());
String payload = req.getBodyText();
payload=payload.replace(Value,New Value);
testExec.setStateValue("Request",payload);
* Should i need to inherit any classes to make the above code work?
Steps which i have followed:
1) After listen step i have added java script step and used below code
req=testExec.getStateObject("lisa.vse.request");
testExec.log(testExec.getStateValue("lisa.vse.request").toString());
String payload = req.getBodyText();
payload=payload.replace(Value,New Value);
testExec.setStateValue("Request",payload);
2) After the above step i added web service execution step to call the live system with modified request
3) After the web service execution step i added one more java script step to build the response object.
4) The response object which has been built is sent virtual Responder step.
I have kept VSM in ITR mode to test a sample request, it's throwing below exception while executing the first code.
============================================================================
| Exception:
============================================================================
| Message: Script throw an exception: bsh.EvalError: Sourced file: inline evaluation of: ``req=testExec.getStateObject("lisa.vse.request"); testExec.log(testExec.getState . . . '' : Undefined argument: BUY : at Line: 4 : in file: inline evaluation of: ``req=testExec.getStateObject("lisa.vse.request"); testExec.log(testExec.getState . . . '' : ( BUY , New_BUY )
in inline evaluation of: ``req=testExec.getStateObject("lisa.vse.request"); testExec.log(testExec.getState . . . '' at line number 4
----------------------------------------------------------------------------
| Trapped Exception: bsh.EvalError: Sourced file: inline evaluation of: ``req=testExec.getStateObject("lisa.vse.request"); testExec.log(testExec.getState . . . '' : Undefined argument: BUY : at Line: 4 : in file: inline evaluation of: ``req=testExec.getStateObject("lisa.vse.request"); testExec.log(testExec.getState . . . '' : ( BUY , New_BUY )
in inline evaluation of: ``req=testExec.getStateObject("lisa.vse.request"); testExec.log(testExec.getState . . . '' at line number 4
| Trapped Message: javax.script.ScriptException: bsh.EvalError: Sourced file: inline evaluation of: ``req=testExec.getStateObject("lisa.vse.request"); testExec.log(testExec.getState . . . '' : Undefined argument: BUY : at Line: 4 : in file: inline evaluation of: ``req=testExec.getStateObject("lisa.vse.request"); testExec.log(testExec.getState . . . '' : ( BUY , New_BUY )
in inline evaluation of: ``req=testExec.getStateObject("lisa.vse.request"); testExec.log(testExec.getState . . . '' at line number 4
----------------------------------------------------------------------------
STACK TRACE
javax.script.ScriptException: bsh.EvalError: Sourced file: inline evaluation of: ``req=testExec.getStateObject("lisa.vse.request"); testExec.log(testExec.getState . . . '' : Undefined argument: BUY : at Line: 4 : in file: inline evaluation of: ``req=testExec.getStateObject("lisa.vse.request"); testExec.log(testExec.getState . . . '' : ( BUY , New_BUY )
in inline evaluation of: ``req=testExec.getStateObject("lisa.vse.request"); testExec.log(testExec.getState . . . '' at line number 4
at bsh.BshScriptEngine.evalSource(BshScriptEngine.java:102)
at bsh.BshScriptEngine.eval(BshScriptEngine.java:61)
at javax.script.AbstractScriptEngine.eval(Unknown Source)
at com.itko.lisa.test.ScriptExecHandler.executeScript(ScriptExecHandler.java:669)
at com.itko.lisa.test.ScriptExecHandler.executeScript(ScriptExecHandler.java:426)
at com.itko.lisa.test.UserScriptNode._execute(UserScriptNode.java:202)
at com.itko.lisa.test.UserScriptNode.execute(UserScriptNode.java:172)
at com.itko.lisa.test.TestNode.executeNode(TestNode.java:981)
at com.itko.lisa.test.TestCase.execute(TestCase.java:1280)
at com.itko.lisa.test.TestCase.execute(TestCase.java:1195)
at com.itko.lisa.test.TestCase.executeNextNode(TestCase.java:1180)
at com.itko.lisa.editor.WalkThruPanel.prepAndExecNode(WalkThruPanel.java:1048)
at com.itko.lisa.editor.WalkThruPanel.access$900(WalkThruPanel.java:68)
at com.itko.lisa.editor.WalkThruPanel$10.doCallback(WalkThruPanel.java:961)
at com.itko.util.swing.panels.ProcessingDialog$2.run(ProcessingDialog.java:194)
at java.lang.Thread.run(Unknown Source)
============================================================================
Could you please help me on this?
You can also mail me at aravindtv123@gmail.com
Regards,
Aravind