On 28/10/2008, Hiro Protagonist <[EMAIL PROTECTED]> wrote:
> Hi all,
>
>  I have searched for a solution (or building blocks to a solution) to
>  this, but haven't found anything so far, and all my attempts to solve
>  this problem elegantly have failed - perhaps you can help...
>
>  I am trying to send a request, which contains within it some search
>  criteria, that can narrow down a search result when submitted.
>  Let's say, for argument's sake, there are 3 terms that can be used to
>  restrict what comes back. Any combination of these 3 terms can be used -
>  and herein lies the problem. I can, using a regex and random controller,
>  send a request that randomly picks from one of those 3 terms (by
>  creating 3 child requests of the random controller), but what I can't do
>  is pick a random COMBINATION of these values.
>
>  Furthermore, following the 'regex-and-random-controller' approach, I end
>  up having to manually create a request for each of the possible
>  combinations ( => cartesian product).
>  In case I haven't been clear, an example:
>
>  For a pet shop, you can display what kinds of aninmals you would like to
>  see, e.g. 'dog','cat','bird'.
>  I can randomise and send requests using either only dog, or only cat, or
>  only bird, but I can't figure out how to send requests for a random
>  combination of any of those three:
>
>  <criteria>DOG</criteria>
>
>  or
>
>  <criteria>DOG+CAT</criteria>
>
>  or
>
>  <criteria>DOG+CAT+BIRD</criteria>
>
>  I hope I have explained this sufficiently... Thanks for your help.

Is the list known in advance, or is it only known by extraction from a
previous result?

If the list is known in advance, then the easiest would be to write a
script to create a file containing all the combinations.

If you don't care if the criteria contain duplicates (e.g. DOG+CAT+DOG
or DOG+DOG+DOG et.) then just concatenate the 3 random selections - no
need for the random controllers.

Otherwise, you will have to write some code (jexl, javascript or
beanshell) to generate the criteria, in which case use the match-all
Regex feature.

Or it may be easier to write code to remove the duplicates from the
concatenation.

Something like:
- split string on '+'
- save unique values
- join values using '+'

If the order of items is not relevant then you can use a hash to
eliminate duplicates.
Otherwise you could use something like ListOrderedSet from Commons
Collections (JMeter already includes the collections jar).

If you use the Match-All Regex, then instead of splitting the string
you can read the variables in turn into a Hash or a Set as above.

>  Regards,
>  hiro
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to