Forum Discussion

Bryan_Nahrwold's avatar
Bryan_Nahrwold
Contributor
16 years ago

asserting and xml response against a property expansion

First, let me say that your documentation is very extensive but difficult to implement.  Your docs may work well for people well versed in soap but for those of us trying to adopt this technology, this is very frustrating.  You give details about inserting code but you fail to give the details of exactly where to insert code you are recommending.  Most of use don't have time to reverse engineer your recommendations.  Explicit details would be greatly appreciated.

Anyway, here is my issue:

I have a test cases created from soap operations that Set and then Get  proxy information from parameters that are populated from properties imported from an external file.

The test steps for these Set/Get operations are in different test cases for a reason I don't want to take time to explain but please don't recommend using a signle test case with multiple test steps because that worn't work for my test.

Anyway, one of the property expansions used is :${ProxyProperties#proxyaddress}.  There are more, but we can focus on this one because whatever works for it will work for the rest.


The GetProxyInfo operation returns the following:


 
     
        <?xml version="1.0" encoding="UTF-8"?>
<proxyinfo address="slc-labproxy.test.lab" host="" password="*******" port="8080" requiresLogin="false" useProxy="true" userID=""/>

     

 


If I try to create a property for this output, it creates:
declare namespace ns1='http://amp.avocent.com/licensing';
//ns1:GetProxyInfoResponse[1]/ns1:out[1]/text()

which does not give me granular control over comparing the individual parameters of the response.

I need this granular control because sometimes some of the returned values will be empty and sometimes not (depending on whether or not I select "requireslogin")


The first problem with this is, I no sooner create this, using soapUI, than I get the error:
XPathContains assertion failed for path [declare namespace licact='http://amp.avocent.com/licensing';
//licact:GetProxyInfoResponse[1]/licact:out[1]/text()] : Exception:org.custommonkey.xmlunit.Diff
[different] Expected namespace URI 'null' but was 'http://amp.avocent.com/licensing' - comparing at /proxyinfo[1] to at /out[1]

I get this error as soon as I create the Property Transfer or Property( I can't remember which).  As this pertains to the source, why is the XPath,  CREATED BY soapUI, producing an error?  shouldn'tt your code create this XPath so that it passes your validation?

As a result, I tried another approach. I created a second Assert "for Content matching RegEx" and this one passed immediately, so I decided to focus my efforts on this Assert.

It create a Declare section:
declare namespace soapenv='http://schemas.xmlsoap.org/soap/envelope/';
//soapenv:Envelope[1]

And an Expected Result section:

 
   
      <?xml version="1.0" encoding="UTF-8"?>
<proxyinfo address="slc-labproxy.test.lab" host="" password="*******" port="8080" requiresLogin="false" useProxy="true" userID=""/>

   

 


I have selected "Allow Wildcards" and tried to change:
address="slc-labproxy.test.lab"
to
address=*
or
address="*"
or
address=${ProxyProperties#proxyaddress}
or
address="${ProxyProperties#proxyaddress}"

In all cases, the Match content fails as soon as I change it, but passes as long as it contains:
address="slc-labproxy.test.lab"

What is the best way to perform an assertion that allows me to specify the result of the GetProxyInfo TestCase and compare it against the PropertyExpansion I created in an earlier testCase?

Thanks.

1 Reply

  • omatzura's avatar
    omatzura
    Super Contributor
    Hi Bryan

    thanks for your post and sorry for the delayed response. You've stumbled on to a bit of an unusual situation which soapUI obviously doesn't handle very well; the content of the out element is just a string that happens to contain XML, but soapUI tries to assert as if it were actually XML (which it isn't from a document-point-of-view). I've fixed this so that the created assertion will pass instead of fail now (ie soapUI handles the expected content as a string and not as XML).

    Since the content is a string, the wildcard feature will not work inside the content of it (this only works on an element/attribute level), but the example you gave with the property-expansion should work, ie specifying an expected result as

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
      <soapenv:Body>
        <GetProxyInfoResponse xmlns="http://amp.avocent.com/licensing">
          <out><?xml version="1.0" encoding="UTF-8"?>
    <proxyinfo address="${ProxyProperties#proxyaddress}" host="" password="*******" port="8080" requiresLogin="false" useProxy="true" userID=""/></out>
        </GetProxyInfoResponse>
      </soapenv:Body>
    </soapenv:Envelope>


    should pass provided that the referenced property contains the same value as the underlying response. If this is still not working could you please mail me your project file so I can have a more detailed look? (ole@eviware.com)

    Also, if you want to try out the fix I mentioned above, let me know and I'll make it available to you.

    Sorry for this inconvenience!

    regards,

    /Ole
    eviware.com