RE: [Grinder-use] The Grinder 2
Distributed load testing framework - Java, Jython, or Clojure scripts.
Brought to you by:
philipa
From: Philip A. <pa...@be...> - 2004-03-16 14:34:33
|
=C9ric COQUELIN writes on 16 March 2004 11:03: > currently, I try to use "The Grinder" to test my own application. > In order to control answer from my server, I would like to test > data returned by using the HTTP plug-in and specially > "grinder.testx.parameter.ok". First of all, doing this type of thing is _much_ easier with The Grinder 3. Elegantly coping with scenarios just like this was one of the drivers for the incorporation of a full scripting engine in The Grinder 3. > You can specify a string, but in my case, I would prefer using a > string bean because data returned varie. >=20 > Example (from sourceforge) : > -------- > // MyStringBean.java > package mystuff; >=20 > import java.util.Random; >=20 > public class MyStringBean { > private Random m_random =3D new Random(); >=20 > public String getRandomInteger() { > return Integer.toString(m_random.nextInt()); > } > } >=20 > # my string bean > grinder.plugin.parameter.stringBean=3Dmystuff.MyStringBean >=20 > # the function used > grinder.test0.parameter.ok=3D<getRandomInteger> >=20 OK strings can use string beans. Using a random integer isn't particularly sensible though! > The function must return a string, but I would like to return a > list of string, how can I do it ? What does the list of strings mean? Is it that at least one of the strings is in the response, or that all of the strings are in the response? The Grinder 2 doesn't support either of these - you'd have to alter its net.grinder.plugin.http.HttpPlugin class to do so. Alternatively, perhaps you are looking to use a single OK string for a given response and it varies based on some a request parameter that your string bean also supplies? If this is the case, you can hang onto the request parameter value as a member of the string bean class and return it (or a string derived from it) from another method. For example, suppose you have a server page that adds one to a number you pass it. This might be useful. public class MyStringBean { private Random m_random =3D new Random(); private int m_lastNumber; =20 public String getRandomInteger() { m_lastNumber =3D m_random.nextInt(); return Integer.toString(m_lastNumber); } public String getLastNumberPlusOne() { return Integer.toString(m_lastNumber + 1); } } # the function used = grinder.test0.parameter.url=3Dhttp://foo/addOne.jsp?n=3D<getRandomInteger= > grinder.test0.parameter.ok=3D<getLastNumberPlusOne> Finally, if this isn't what you want then you can do most things yourself by having the string bean implement net.grinder.plugin.http.HTTPClientResponseListener. See net.grinder.plugin.http.example.ExampleStringBean3. I strongly suggest you look at moving to The Grinder 3. - Phil |