On 23 September 2014 15:58, BOLB (Bohdan L Bodnar) <[email protected]> wrote: > Thank you for all who assisted me. I ended up using a Beanshell Sampler, > Regular Expression Extractor, a user-defined variable and some Java to build > a string that is given to an API call. This approach works exactly as I want > it work. For the technically curious, the key portions of the code are: > > int count = Integer.parseInt(vars.get("IDS_matchNr")); > String deletestring = ""; > for (int i = 1; i < count; i++) > { > deletestring = deletestring + vars.get("IDS_"+i) + ","; > } > deletestring = deletestring + vars.get("IDS_"+count); > vars.put("STRING1", deletestring); > > STRING1 now contains a comma-separated list of identities and ${STRING1} is > then given to the API call. > > On a related topic: > > I spent quite a while trying to figure out the differences between Beanshell > Sampler, Preprocessor, Postprocessor. Can someone please point me to an > *idiot-proof* description with, preferably, sample code?
http://jmeter.apache.org/usermanual/test_plan.html describes the different test element types > Thank you kindly, > > Bohdan > > > -----Original Message----- > From: sebb [mailto:[email protected]] > Sent: Tuesday, September 23, 2014 6:02 AM > To: JMeter Users List > Subject: Re: Requesting help with regex and string usage > > Also see the ForEach Controller: > > http://jmeter.apache.org/usermanual/component_reference.html#ForEach_Controller > > This is intended for use with the Regex Extractor. > > If it is difficult to write a single RE to both extract the string and > convert it into a a list of IDs, note that the Regex Extractor can operate on > the contents of a JMeter variable, so you can use multiple extractors in > sequence if necessary. > > > On 22 September 2014 17:26, Deepak Shetty <[email protected]> wrote: >> Hi >> see something like >> http://theworkaholic.blogspot.com/2010/03/dynamic-parameters-in-jmeter >> .html The Beanshell pre processor in the script shows how to iterate >> through the returned values extracted by regex - you can concatenate >> or manipulate this however you want in java or equivalent - if you >> need help with that as well then you probably need to give more >> details (e.g. the variable name etc) >> >> On Mon, Sep 22, 2014 at 7:12 AM, BOLB (Bohdan L Bodnar) >> <[email protected]> >> wrote: >> >>> I've a problem that apparently has occurred to other users (from an >>> internet search); however, I can't figure out how to do this in my >>> application (brain-dead?). Here's the background: >>> >>> I'm using an HTML-based API call to do a function in our product; >>> this call returns a large string that includes numeric IDs of >>> entities. I want to extract these IDs, build a string containing >>> them, and use this string in an API call. For example: >>> >>> >>> 1. API_1 call - returns "text, ID1, more text, ID2,...etc." >>> consisting of n IDs. >>> >>> 2. Regular Expression Extractor call - return variable is called >>> "ELEMENTS" >>> >>> 3. Build string that looks like "ID1,ID2,...IDn" >>> >>> 4. API_2 call with body having string defined in step 3. >>> >>> I have no problem in step 2 picking off any one element, putting it >>> in ELEMENTS and using it in step 4. I don't know how to do step 3 >>> if Match Number is set to -1 in step 2. This doesn't look like >>> rocket science, but I can't figure it out. Would someone be so kind >>> as to either show me how to do this or refer me to a script that does this? >>> >>> Best regards, >>> >>> Bohdan >>> >>> > > --------------------------------------------------------------------- > 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]
