Forum Discussion

chikki's avatar
chikki
Contributor
17 years ago

Re: Get into String

Hi,

I have a Response file


     
         admin
         Admin
         Istrator
         2387927601777237750
         MSG_Service_Administrator
         MSG_Moderator
         MS1_OP
         MS1_P1
         STM
         55
         EP
         CC
         DL
         MK
         666
         11
         KH
         MS1_P3
         GOA
         MS1_P4
         148
         901
         TE
         TG
     

   

I have to get all the response of OrganizationUIDs in to an array how can i achieve that

I am able to get the Soap UI response  in an array.

def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = groovyUtils.getXmlHolder( "AuthenticateAdmin#Response" )

def items = holder.getNodeValues( "//ns2:GMSAdministrator/organizationUIDs")
log.info( "Found " + items.length + " items.." )
for (item in items)
{
log.info( item )
}


the same way i have to get data from DB and then compare
def sql = Sql.newInstance("jdbc:oracle:thin:@" + properties.getProperty( "databaseurl" ) + ":" + properties.getProperty( "databaseport" ) + ":" + properties.getProperty( "database" ) , properties.getProperty( "databaseuser") ,
          properties.getProperty( "databasepassword" ), "oracle.jdbc.OracleDriver")
def partnerUID =sql.eachRow("Select EXTERNAL_ORG_UNIT_UID from org_unit",{ log.info( it.EXTERNAL_ORG_UNIT_UID) }) //+ " -- ${it.EXTERNAL_ORG_UNIT_UID} --"

Please help me how do i get the values into an array  and then compare them both.

9 Replies

  • Hi,

    I am a new learner and i am using Soapui 2.5.1 Pro version.

    Regards,
    Chikki
  • Hi Chikki,

    if you are using soapUI Pro, please post in the soapUI Pro forum (you received a login when purchasing the license) so we can prioritize you!

    regards!

    /Ole
    eviware.com
  • Your code looks fine, but in the loop in which you process the response data, rather than just logging the information, simply add it in to the array in the loop.

    After you have both arrays (from the DB and the response), first compare the lengths of the two arrays, and then iterate through one of the arrays, and for each item in it, iterate through the other array to see if it exists.

    I hop that helps!
    /Nenad
    http://eviware.com
  • how do i fail step if the value of DB mismatches with value of soap Response.


    testRunner.Fail("Step Failed" ) is throwing an exception.
  • how do i Assert two arrays.

    any you give an example

    thanks in advance.
  • how do i Assert two arrays.

    any you give an example

    thanks in advance.
  • Hi chikki,


    Operators in Groovy work really nice so you can compare two arrays very easily. Since operators have been overridden, it's not necessary to compare two array's sizes and then iterate through them if they're of equal length. All you need to use is == operator.

    To get a hold of it, try this in Groovy console:

    a = [1,2,3,4]
    b = [1,2,3,1]
    c = [1,2,3,4]
    d = [1,2,3]

    println "a == c: " + (a == c)
    println "a == b: " + (a == b)
    println "a == c: " + (a == c)
    println "c == b: " + (c == b)


    Each of your test requests (SOAP, REST, HTTP) can have assertions assigned to it. Assertions are run on response message after test request has been executed and response is available.

    You should use Script Assertion for your job.


    Cheers!
    /Nenad Nikolic a.k.a. Shonzilla