Forum Discussion

Xour's avatar
Xour
Occasional Contributor
8 years ago

Is it possible to transfer the results of a JDBC step to an array or list?

Hello all. I'm not sure what I'm trying to do can be accomplished on the free version. Here's what I would like to do:

 

- Get some results using a JDBC step as XML

- Transfer all these nodes to a list

- Read from that list

 

For example I got this:

 

<Results>
    <ResultSet fetchSize="128">
        <Row rowNumber="1">
            <TYPE>somevalue</TYPE>
            <SUBTYPE>somevalue</SUBTYPE>
            <ID>somevalue</ID>
        </Row>
        <Row rowNumber="2">
            <TYPE>somevalue</TYPE>
            <SUBTYPE>somevalue</SUBTYPE>
            <ID>somevalue</ID>
        </Row>
        <Row rowNumber="3">
            <TYPE>somevalue</TYPE>
            <SUBTYPE>somevalue</SUBTYPE>
            <ID>somevalue</ID>
        </Row>
        <Row rowNumber="4">
            <TYPE>somevalue</TYPE>
            <SUBTYPE>somevalue</SUBTYPE>
            <ID>somevalue</ID>
        </Row>
    </ResultSet>
</Results>

Then I would like to insert the Type, SubType and ID on each index of the list so later I can get the nth index of that list and retrieve these three values.

 

I'm terrible sorry if I'm not being clear enough, as I'm really newbie when it comes to SoapUI and testing in general. Thanks for reading so far.

    • Xour's avatar
      Xour
      Occasional Contributor

      I'm really sorry about that. I'm sure is because I'm totally clueless about SoapUI, testing and programming in general, and English not being my mother tongue does not help either.

       

      I'll try to formulate in another way: I have a JDBC step which returns several nodes with child-nodes as an XML response. I want to store this information into an 'arrays of arrays' so later I can access this data from a Groovy Script.

       

      Perhaps this piece of code can help me to explain what I'm trying to do:

       

       

      // Create an empty list to store csv file info
      def testDataSet = []
      
      // Load the csv file
      def fileName = "C://SoapUI Projects//Data//test.csv"
      
      // Opens the file, iterates through each line and splits the line on the commas into an array
      new File(fileName).eachLine { line -> testDataSet.add( line.split(",") ) }
      
       // Select a random line 
      def index = (int)Math.random()*testDataSet.size() 
      def testDataLine = testDataSet[index]
      
      // Assign their value to the Test Case Property fields
      def props = testRunner.testCase;
      props.setPropertyValue("valueOne", testDataLine[0])
      props.setPropertyValue("valueTwo", testDataLine[1])
      props.setPropertyValue("valueThree", testDataLine[2])

       

       

      In that particular case, the index is randomly selected which won't work for me. I need some way to store the information in a list so later I can access all the values that are stores on the nth index. I hope this clears up what I'm trying to do.

       

      Anyways, thank you so much for your reply! I appreciate it!

      • nmrao's avatar
        nmrao
        Champion Level 3
        Hmm. would it be possible to show the screen shots of test case structure, and the request you want to use retrieved values from jdbc step response.