Assume I've a main function that calls another function called "queryDB", which returns a numeric value.
Once the 'queryDB' returns the value, main has to parse the STAXResult to get the value (STAXResult returns a list) and report if the <tcstatus> is passed or not.
The problem that face here is that even though I'm able to get the value when parse like this: STAXResult[0][1], I'm unable to compare the above value against the expected value (which is either 0 or 1) to decide the status of the testcase.
Could you please advice me here? perhaps, I might need to convert the STAXResult[0][1] to other type (such as an int) before comparing.
Currently, I see the comparison fails always -even if I happen to compare STAXResult[0][1] against 1 esp., when the former resolves to be 1 too.
Thanks & Regards,
Tharma
<!--
=====================
MAIN FUNCTION
=====================
-->
<function name="main">
.....
<call function="'queryDB'">cpath, job_number, libpath</call>
Assume I've a main function that calls another function called "queryDB", which returns a numeric value.
Once the 'queryDB' returns the value, main has to parse the STAXResult to get the value (STAXResult returns a list) and report if the <tcstatus> is passed or not.
The problem that face here is that even though I'm able to get the value when parse like this: STAXResult[0][1], I'm unable to compare the above value against the expected value (which is either 0 or 1) to decide the status of the testcase.
Could you please advice me here? perhaps, I might need to convert the STAXResult[0][1] to other type (such as an int) before comparing.
Currently, I see the comparison fails always -even if I happen to compare STAXResult[0][1] against 1 esp., when the former resolves to be 1 too.
Thanks & Regards,
Tharma
<!--
=====================
MAIN FUNCTION
=====================
-->
<function name="main">
.....
<call function="'queryDB'">cpath, job_number, libpath</call>
<if expr="STAXResult[0][1] == 1"> # <= Value Compare does not work at all!!!
<tcstatus result="'pass'"/> # (Always the comparison fail.......)
<else>
<tcstatus result="'fail'"/>
</else>
</if>
.....
</function>
<!--
=====================
FUNCTION: queryDB
=====================
-->
<function name="queryDB">
.....
.....
<process>
<location>'local' </location>
<command mode="'shell'"> 'java' </command>
<parms> '%s %s %s %s %s %s' % ( className, servername, dbname, username, passwd, jobno ) </parms>
<env> 'CLASSPATH=%s' %(cpath) </env>
<returnstdout/>
</process>
<return>STAXResult</return>
</function>
Is it possible that the value is a string '1' and not the number 1? So, instead of:
<if expr="STAXResult[0][1] == 1">
try:
<if expr="STAXResult[0][1] == '1'">