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.

Parameterized XPath values?

Options
LegacyForum
LegacyForum Posts: 1,664 ✭✭
Hi,

Is there a way in SOATest 5.5.2, SP4 to use parameterized XPath values in XML Data Bank, XMLTransformer etc. tools?
It did not worked for me, but maybe my syntax was wrong (I used the usual $[VARIABLE_NAME] pattern)

Andras

Comments

  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Options
    Hello Andras,

    I am not quite certain what you mean by using "parameterized XPath values in XML Data Bank, XMLTransformer". Where are the XPath values being populated, and how are you planning on using the values within the XML Data Bank and the XMLTransformer? Are you trying to use the stored XML elements from an XML Data Bank within a Method tool? In that case, the following forum post will describe how to do so:

    http://forums.parasoft.com/index.php?showtopic=1769

    If you can include a sample .tst file with some screenshots of what you are trying to do, it would help me a lot in understanding your test case.

    Regards,
    ~Joseph
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Options
    Hello Joseph,

    Let suppose that I want to test a WS method that returns the following structure from a data store for a given AuthorID:
    Author (AuthorID, Name)
    - Book (BookID, Title)
    - Book (BookID, Title)
    - ..(sequence of Book)

    For this, I create a test scenario that first creates this structure in the data store, then call the method.
    Set-up:
    1. Create Author (save AuthorID)
    2. Create Book1 (save BookID_1 to a writable data store as BookID_1)
    3. Create Book2 (save BookID_2 )
    Test:
    1. Call the WS method with AuthorID

    Now I want to check both books are returned correctly.
    Unfortunately it is not guarantied that Book1 and Book2 will always be returned in the same order.
    For this I planned to attach an XMLTransformer to the method, selecting Book1 with BookID_1 then check its values with a Diff Tool. Same for Book2.
    In the XMLTransformer I tried to used a parameterized XPATH, something like this: /Author/Book[BookID=$[BookID_1]].
    Unfortunately this throws an XPATH validation error (with a fixed value, the XPATH is valid).

    Would you advise please what is the best practice for this scenario with SOATest?
    You may also check some screen shots of our test suite (Carrier Services and Carrier Service Postcode Maps are used instead of Authors and Books).

    Regards,
    Andras
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    edited July 2008
    Options
    Good morning Andras,

    I believe what you are looking for is the XML Assertor, which can allow you to check for the occurrence of a value as well as the value of a specific element. To do so, follow these steps:

    1. Chain an XML Assertor to the response of your BookID
    2. Go to the Configuration tab of the XML Assertor and hit "Add..."
    3. Select Value Assertions > Value Occurrence Assertion
    4. Select the element you want (any copy is fine, if there are multiple instances)
    5. Select the "Apply to All "...." " option (the second option) to reference all instances
    6. Now fill in the Expected Value and the number of Expected Occurrences with the parameterized values of Book1 and Book2

    The XML Assertor will act as a regression tool in causing your test to fail if the expected value/occurrences are not met. I have attached a sample .tst file that demonstrates this functionality. Hopefully, this will help your testing situation.

    Regards,
    Joseph
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Options
    Hello Joseph,

    Thank you for the example.
    I knew that I can check the occurrence the BookID_1 with XMLAssertor, but I did not know how to step a bit further and use it to check a sub-tree.

    In my example, I want to check, that the method returns a Book with BookID_1 and Title_1.
    (A simple AND Assertor, with a second occurrence check to Title_1 is not enough, I want to check that they belong to the same Book as well).

    Would you please add this also to your example?

    Regards,
    Andras
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Options
    Hello Andras,

    In this case, I believe using the Multiple Regression Controls option is the best. To create one, simply right-click on the "folder" that contains your test and select "Create Regression Controls." If you have multiple rows, then you have a choice of "Single" or "Multiple" controls. Once the automatically created Diff tool is added, you can change the Diff Options to "Ignore Element Order." This way, the Diff tool will check for element occurrence, but ignore order.

    I have attached another sample .tst file for your perusal.

    Regards,
    Joseph
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Options
    Joseph,

    The "Ignore Element Order" would be great, but it does not work for the values that are Parameterized - and I need it for BookID_1.

    The multiple regression control is not needed, I do not run this scenario for many inputs (yet). And you search for the exact title which always returns one book.
    In my scenario there are many books returned, and I need to check, that there is one with BookID_1 (this has to be referred as a variable!), and Title_1.

    Your first attached example was exactly this, I just need a way to ensure, that in the "Test2: getItemByTitle" there is a book with id=11 and title="How to Use the XML Assertor" (that you created in Test1).

    Regards,
    Andras
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Options
    Upps, sorry, the "Ignore Element Order" works with parameterized values as well (it was another error previously).
    Joseph, thank you for your help, issue solved.