Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

SOATEST returning error when trying to update the Xpath with string functions

Testuser
Testuser Posts: 41
edited March 2017 in SOAtest

I was asserting on the below response against my database value which is supposed to be
Response from the service for scoreDate: 2017-03-16T12:45:25-04:00
Database value for scoreDate: 2017-03-16 12:45:25 (Expected value)
I am passing the List name as a parameter from my Datasource excel sheet('ExpectedIPList' column).

So I created a Value assertion for the above element and updated my xpath as below to match the response to my database value and when I ran it , it gave me an error
Xpath: replace(substring-before(/root/item[name="${ExpectedIPList}"]/scoreDate/text(),"-04:00"),"T"," ")

Error Message:
DataSource: ModelScore (row 1): An error occurred while processing an assertion:
net.sf.saxon.trans.XPathException: Required item type of first operand of '/' is node(); supplied
value has item type xs:string

My response looks like as below:
[
{
"scoreDate" : "2017-03-16T12:47:35-04:00",
"Listname" : "List1",
}
{
"scoreDate" : "2017-03-16T12:47:35-04:00",
"Listname" : "List2",
}
]

Note: when I didnt add any Xpath function and ran it , it failed with an error saying (which is a right kind of error)
Value Assertion failed. Expected: 2017-03-16 12:45:25.0 but ACtual was 2017-03-16T12:45:25-04:00

My question is why is it throwing Xpath exception for the above Xpath I updated ?
Am I doing anything wrong ?

Tagged:

Comments

  • Testuser
    Testuser Posts: 41

    Any help with this one ?

  • jakubiak
    jakubiak Posts: 798 admin

    Unfortunately the Assertor tools require the XPath to return a node as opposed to a string. So for now you need use additional XPath functions wrap the string you are producing into a node and return that. Additionally, to get your example to work I had to slightly modify the selector on item. Here is how I modified the XPath to get your example to work:

    /parse-xml(concat("",replace(substring-before(/root/item[Listname/text()="${ExpectedIPList}"]/scoreDate/text(),"-04:00"),"T"," "),""))/elem/text()

  • Testuser
    Testuser Posts: 41

    Thanks Jakubiak. This info was very useful because really had no idea what this error meant. But I copied the above Xpath into my Xpath editor and ran the test and gave me the below error:
    Error Message:
    DataSource: ModelScore (row 1): An error occurred while processing an assertion:
    net.sf.saxon.trans.XPathException: org.xml.sax.SAXParseException; systemId:
    file:///C:/Program%20Files/Parasoft/SOAtest/9.9/; lineNumber: 1; columnNumber: 1; Premature end of
    file.

    Is there something missing ?

  • jakubiak
    jakubiak Posts: 798 admin

    Hmmm, looks like I pasted the wrong thing. Try this one:

    /parse-xml(concat("",replace(substring-before(/root/item[Listname/text()="${ExpectedIPList}"]/scoreDate/text(),"-04:00"),"T"," "),""))/elem/text()

  • jakubiak
    jakubiak Posts: 798 admin

    Actually - the forum is messing up the Xpath. Here's another try:

    /parse-xml(concat("<elem>",replace(substring-before(/root/item[Listname/text()="${ExpectedIPList}"]/scoreDate/text(),"-04:00"),"T"," "),"</elem>"))/elem/text()

  • Testuser
    Testuser Posts: 41

    Awesome. Thanks a lot. It worked like a charm.Appreciate your help.

  • atulsharma1989
    atulsharma1989 Posts: 5

    getting following error while running functional test through soatestcli on linux machine
    Please look and confirm the issue please
    default workspace: /root/parasoft/workspace/

    [root@gcs-build-doc 9.7]# ./soatestcli -data /root/parasoft/workspace/gcs-aws-usps-av-ss-func -Zjava_home /opt/jdk1.8.0_101

    soatestcli: Version 9.7.0.20140227 -- Copyright (C) 2003-2014 Parasoft Corporation
    soatestcli: Using non default java: /opt/jdk1.8.0_101
    Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=160m; support was removed in 8.0
    ERROR: Error: Missing parameter: -config
    Exception in thread "Thread-10" java.lang.IllegalStateException: Store for:env.preferences not registered

  • Ireneusz Szmigiel
    Ireneusz Szmigiel Posts: 227 ✭✭✭

    Hi atulsharma1989

    as you are trying to start test in command line you have to include additional parameter with -config option. You can try this one:

    ./soatestcli -data /root/parasoft/workspace/gcs-aws-usps-av-ss-func -Zjava_home /opt/jdk1.8.0_101 -config "buildin://Demo Configuration"

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭

    Unfortunately the Assertor tools require the XPath to return a node as opposed to a string. So for now you need use additional XPath functions wrap the string you are producing into a node and return that

    For the next release, XPaths that return non-nodes like strings or lists of strings will work as expected. Using "parse-xml" to convert strings to text nodes will no longer be needed.