Ask a Question

Strange behaviour with groovy script

sasiatecs
New Contributor

Strange behaviour with groovy script

 

def countries = ['IND':'India',
 'USA':'United States of America',
 'PAK':'Pakistan',
 'AUS':'Australia'
 ]
//Printing map  
log.info "Before : $countries" 
 
String countryIamLookingFor
boolean foundCountry
countryIamLookingFor = 'SIG'
foundCountry = countries.containsKey(countryIamLookingFor)  

log.info "Found Country $countryIamLookingFor : $foundCountry"

String countryName = countries.get(countryIamLookingFor)

if(foundCountry){
	log.info "Country name is $countryName"
}else{
	log.error "Sorry! Country not found"
}

//Printing map  
log.info "Before : $countries"

countries.put('NZ','Newzealand')

log.info "After : $countries"

 

 

When I run this script, "Newzealand is getting printed at "

log.info "Before : $countries"
5 REPLIES 5
nmrao
Champion Level 3

@sasiatecs,

 

What version are you using? Would you close soapui and retry?



Regards,
Rao.
PaulMS
Super Contributor

This script seems to work with a minor delay before modifying countries.

 

log.info "Before : $countries"

Thread.sleep(100)

countries.put('NZ','Newzealand')

log.info "After : $countries"

I am using SoapUI 5.3.0 version. Anyways it works perfectly with 'grooyConsole'.In real-time the delay might cause performance issues 🙂 .Any other suggestions ??

PaulMS
Super Contributor

It may be a defect or limitation of groovy script in Soap UI.

In my environment I can use a very small delay like 10 ms but you could raise the issue with SmartBear support.

nmrao
Champion Level 3

Capture.PNG

@sasiatecs, I can see desired output from the above soapui log.



Regards,
Rao.
cancel
Showing results for 
Search instead for 
Did you mean: