DB tool with extension tool
I am very new to SoaTest and was having difficulty utilizing the extension tool with the DB tool.
I was wanting to access the results of a db tool query within the extension tool but was having difficulty doing so. The input object just shows "text" where if i attach the extension tool to a soap response, I will recieve the soap response output. Could anyone provide a learning resource or even a simple example would be appreciated.
Here is a simple example of what i was trying.
import com.parasoft.api.*; boolean customAssertion(Object input, ScriptingContext context) { Application.showMessage("Value from SQL response is " + input) return true; }
Comments
-
Attach your Extension Tool to the "Results as XML" output of the DB Tool (right-click on DB Tool > Select Add Output... > Select Results as XML > Choose Extension Tool > Click Finish). Now the input to your Extension Tool should be an XML representation of the result set from your SQL query.
0 -
Thank you for responding. When I followed those instructions. (which seem like they should work.) I just see the output of "text" from my input object. I feel like there is something very basic I am missing. I attached a screenshot of hte test with the log output.
import com.parasoft.api.*; boolean customAssertion(Object input, ScriptingContext context) { Application.showMessage("Value from SQL response is " + input) return true; }
0 -
You are running into an inconsistency between how DBTool and SOAP Client pass the input to an Extension Tool. Modify your script like this and it will work:
import com.parasoft.api.*; boolean customAssertion(Object input, ScriptingContext context) { Application.showMessage("Value from SQL response is " + input.getText()) return true; }
1 -
That did the trick. Thank you.
Using the getText I see how the "SQL Query" extension tool shows the SQL going into the tool and the "Results as XML" extension tool shows the output coming out.
Is there a resource which outlines how the tools interact with the extension tools or is this a learn by experience ?0 -
Unfortunately this is a learn by experience - if you run into similar kinds of issues these forums are a great place to try to get answers!
0 -
Understandable. Thank you again for your help.
0