Forum Discussion

Michael_McDonal's avatar
Michael_McDonal
Occasional Contributor
16 years ago

Test step to wrap an arbitrary resource as a Request

I currently have a need to verify DB contents after submitting a request.

I know this can be done with Groovy script, but I think it would be useful to have a test step that could wrap a resource like a JDBC connection as if it was a Request and allow the standard Request assertions to be applied to the result.

I've thought about implementing in the OnRequest script of a mock service, but this would be a global resource rather than an isolated component in a script.

2 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi Michael,


    What you're looking for you can achieve by using the soapUI assertion mechanism and property expansion. More precisely, after you load your reference data from database, you could set a property that is used in assertion. You may add this snippet at the end of your Groovy script:

    someData = 'some data loaded from DB';
    context.setProperty('propertyToAssert ', someData)

    After that you would reference ${#propertyToAssert} in your assertions of your request. Start with Contains assertion that is least restrictive and is easiest to use and proceed with others if you need more control.

    I hope this helps...



    Cheers!
    /Nenad Nikolic a.k.a. Shonzilla
  • Michael_McDonal's avatar
    Michael_McDonal
    Occasional Contributor
    Nenad -

    Thanks for the reply. Perhaps I don't understand your suggestion or I wasn't clear about what I need to do.

    I need to submit a request containing lots of parameterized data, then check 3 databases to ensure that the submitted data was inserted properly. I can't query the DBs in advance.

    I have created Mock Services that return XML result sets, and then post requests to them and assert on the submitted parameters, but I thought a step that would encapsulate a simulated request functionality for different resources (eg. JDBC) would be handy.

    - Michael