sivaraj_r
14 years agoOccasional Contributor
Unexpected Behavior from Groovy Script
Hi,
for the above piece of code in Groovy Script step type I expecting the following output
But I got the following output
Similarly If I use the following code
I am getting the following output
Kindly let me know Does this expecting Behavior of Groovy Script ?
Tested in the following versions
SoapUI 3.6.1 Build dist-111-2010-10-18, Build Date 2010/10/18 14:57
SoapUI Pro 4.0.1 Build dist-142-2011-09-14, Build Date 2011/09/14 13:38
Thanks,
Siva
import java.util.Random;
Random obj = new Random();
def list1 = []
for(int j=0;j<4;j++)
{
limit = obj.nextInt(7)
list1.clear()
log.info "List Limit = "+limit
for(int i=0;i<limit;i++)
{
list1[i] = i.toString()
}
log.info "List Size = "+list1.size()
log.info list1
}
for the above piece of code in Groovy Script step type I expecting the following output
Mon Feb 13 15:26:19 IST 2012:INFO:List Limit = 4
Mon Feb 13 15:26:19 IST 2012:INFO:List Size = 4
Mon Feb 13 15:26:19 IST 2012:INFO:[0,1,2,3]
Mon Feb 13 15:26:19 IST 2012:INFO:List Limit = 3
Mon Feb 13 15:26:19 IST 2012:INFO:List Size = 3
Mon Feb 13 15:26:19 IST 2012:INFO:[0,1,2]
Mon Feb 13 15:26:19 IST 2012:INFO:List Limit = 5
Mon Feb 13 15:26:19 IST 2012:INFO:List Size = 5
Mon Feb 13 15:26:19 IST 2012:INFO:[0,1,2,3,4]
Mon Feb 13 15:26:19 IST 2012:INFO:List Limit = 1
Mon Feb 13 15:26:19 IST 2012:INFO:List Size = 1
Mon Feb 13 15:26:19 IST 2012:INFO:[0]
But I got the following output
Mon Feb 13 15:26:19 IST 2012:INFO:List Limit = 4
Mon Feb 13 15:26:19 IST 2012:INFO:List Size = 4
Mon Feb 13 15:26:19 IST 2012:INFO:[0]
Mon Feb 13 15:26:19 IST 2012:INFO:List Limit = 3
Mon Feb 13 15:26:19 IST 2012:INFO:List Size = 3
Mon Feb 13 15:26:19 IST 2012:INFO:[0]
Mon Feb 13 15:26:19 IST 2012:INFO:List Limit = 5
Mon Feb 13 15:26:19 IST 2012:INFO:List Size = 5
Mon Feb 13 15:26:19 IST 2012:INFO:[0]
Mon Feb 13 15:26:19 IST 2012:INFO:List Limit = 1
Mon Feb 13 15:26:19 IST 2012:INFO:List Size = 1
Mon Feb 13 15:26:19 IST 2012:INFO:[0]
Similarly If I use the following code
import java.util.Random;
Random obj = new Random();
def list1 = []
for(int j=0;j<4;j++)
{
limit = obj.nextInt(7)
list1.clear()
log.info "List Limit = "+limit
for(int i=0;i<limit;i++)
{
list1[i] = i.toString()
}
log.info "List Size = "+list1.size()
log.info list1
list1.clear()
}
I am getting the following output
Mon Feb 13 15:26:19 IST 2012:INFO:List Limit = 4
Mon Feb 13 15:26:19 IST 2012:INFO:List Size = 4
Mon Feb 13 15:26:19 IST 2012:INFO:[]
Mon Feb 13 15:26:19 IST 2012:INFO:List Limit = 3
Mon Feb 13 15:26:19 IST 2012:INFO:List Size = 3
Mon Feb 13 15:26:19 IST 2012:INFO:[]
Mon Feb 13 15:26:19 IST 2012:INFO:List Limit = 5
Mon Feb 13 15:26:19 IST 2012:INFO:List Size = 5
Mon Feb 13 15:26:19 IST 2012:INFO:[]
Mon Feb 13 15:26:19 IST 2012:INFO:List Limit = 1
Mon Feb 13 15:26:19 IST 2012:INFO:List Size = 1
Mon Feb 13 15:26:19 IST 2012:INFO:[]
Kindly let me know Does this expecting Behavior of Groovy Script ?
Tested in the following versions
SoapUI 3.6.1 Build dist-111-2010-10-18, Build Date 2010/10/18 14:57
SoapUI Pro 4.0.1 Build dist-142-2011-09-14, Build Date 2011/09/14 13:38
Thanks,
Siva