Eviware Forum

soapUI => soapUI => Topic started by: Michael Eddington on January 11, 2008, 05:29:26 am



Title: GroovyDataSource and readLine issues
Post by: Michael Eddington on January 11, 2008, 05:29:26 am
I have a Groovy DataSource with the following script.  The script does not perform as one would expect.  Instead each call to readLine() reads a line at some random spot way down the file (assuming the file is large enough).  The expected result would be the first line, then the second, etc.

Could this be an issue with Groovy?  Or something else?

The work around is to say "readLines()" and store the result in context.  However, for large files this uses alot of memory.


// Read values from a text file.

if(context["peach"] == null)
{
   context["peach"] = new File("c:/strings.txt").newInputStream()
}

result["value1"] = context["peach"].readLine()

// end


Title: Re: GroovyDataSource and readLine issues
Post by: omatzura on January 11, 2008, 12:22:11 pm
Hi,

hmm.. sounds strange.. soapUI 2.0.1 will upgrade to groovy 1.5.1. How are you checking that the order is no ok? Directly after the read or "somewhere else"?

regards,

/Ole
eviware.com


Title: Re: GroovyDataSource and readLine issues
Post by: Michael Eddington on January 11, 2008, 08:43:02 pm
From the GroovyDataSource pane just hit the run button and say 10 iterations and look at the values produced.  The text file would have lines line:

string1
string2
string3
...

So one would expect the values displayed to be string1, string2, ... but instead you get string1 then string1000 or something.  Very strange.

mike


Title: Re: GroovyDataSource and readLine issues
Post by: omatzura on January 12, 2008, 12:09:31 am
Hi Michael,

I wonder if you could try the following initialization for peach instead:

context["peach"] = new java.io.BufferedReader( new java.io.FileReader( "c:/strings.txt"))

?

Does that help?

regards,

/Ole
eviware.com


Title: Re: GroovyDataSource and readLine issues
Post by: Michael Eddington on January 14, 2008, 10:19:23 pm
Interesting, that did work.  Wonder why...

mike