Forum Discussion

max1965's avatar
max1965
Contributor
13 years ago

delete properties

With the following groovy script, soapui delete, from testcase, all the properties beginning with cseq, callid, ...

def delete_properties_udb = context.expand( '${#Global#delete_properties_udb_tc}' )
if ( delete_properties_udb == "Y" )
{
def propertyNames = testCase.getPropertyNames()
for(name in propertyNames){
if ( (name.toString().startsWith("cseq")) || (name.toString().startsWith("callid")) || (name.toString().startsWith("contactUri")) || (name.toString().startsWith("nc")) || (name.toString().startsWith("nonce")) || (name.toString().startsWith("status")) ){
testCase.removeProperty(name);
}
}
}

There is an option to not remove the properties if beginning with a string (i.e: cseq) ?

Thanks

6 Replies

  • I may misunderstand your question but, if you want to not remove the property's where the name start with "cseq", then you just need to remove that condition from your if check :

    if ( (name.toString().startsWith("cseq")) ||
    (name.toString().startsWith("callid")) ||
    (name.toString().startsWith("contactUri")) ||
    (name.toString().startsWith("nc")) ||
    (name.toString().startsWith("nonce")) ||
    (name.toString().startsWith("status")) ) {
    testCase.removeProperty(name);
    }
  • I wrote the question not very well. I have the following problem: in testsuites and testcases properties I have a lot of entry that I want to remove each time I execute the test. The in the testsuite and testcase have differnet names.

    Between these properties, in all testsuites and testcases, I have the same properties that must not be removed.

    With the above script the properties that begin with the strings specified in the test case are removed; I asked if there is an option to specify in the if case the strings of the properties that must not be removed.
  • HammerTime's avatar
    HammerTime
    Occasional Contributor
    Can't you just do:

    if ( (!name.toString().startsWith("cseq")) ||
    (!name.toString().startsWith("callid")) ||
    (!name.toString().startsWith("contactUri")) ||
    (!name.toString().startsWith("nc")) ||
    (!name.toString().startsWith("nonce")) ||
    (!name.toString().startsWith("status")) ) {
    testCase.removeProperty(name);
    }
  • I modify the script:

    def propertyNames = testCase.getPropertyNames()
    for(name in propertyNames){
    if ( (!name.toString().startsWith("QC_")) & (!name.toString()=="synced") ){
    testCase.removeProperty(name);
    }
    }

    In the testCase, for example, I have the following properties: QC_id, synced, testId1, testId2.

    When I execute the script, the properties testId1 and testId2 are not removed. I'am not able to identify how modify the script to works correctly.

    I would like insert in the script only the properties that must not be removed, because are the same in all the testCases.
  • I found the solution:

    if ( (!name.toString().startsWith("QC_")) & (!name.toString().startsWith("synced")) ){