Sorry but it doesnot work.

${__regexFunction(<re>([0-9]+),$1$,ALL,|,ERREUR,testVar)};

${__log(${testVar_matchNr})};
${__log(${testVar_g1})};
${__log(${testVar_1})};
${__log(${testVar_1_g1})};

2009/01/07 11:07:00 INFO  - jmeter.functions.LogFunction: Groupe de thread
1-1 : 21
2009/01/07 11:07:00 INFO  - jmeter.functions.LogFunction: Groupe de thread
1-1 : 326191
2009/01/07 11:07:00 INFO  - jmeter.functions.LogFunction: Groupe de thread
1-1 : ${testVar_1}
2009/01/07 11:07:00 INFO  - jmeter.functions.LogFunction: Groupe de thread
1-1 : ${testVar_1_g1}
2009/01/07 11:07:00 ERROR - jmeter.util.BeanShellInterpreter: Error invoking
bsh method: eval    Sourced file: inline evaluation of:
``12138|40635|43233|46001|66414|70412|78144|91563|95772|120428|126074|153317|15761
. . . '' : Attempt to access property on undefined variable or class name
2009/01/07 11:07:00 WARN  - jmeter.assertions.BeanShellAssertion:
org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval
Sourced file: inline evaluation of:
``12138|40635|43233|46001|66414|70412|78144|91563|95772|120428|126074|153317|15761
. . . '' : Attempt to access property on undefined variable or class name

Any idea ?

The next step will be : how can i do that ?

String sXml = "";
for( int i = 1 ; i <= ${testVar_matchNr}; i++ ) {
    sXml += "<a>" + kindofeval( "testVar_" + i ) + "</a>";
}

And then i will use the variable sXml in the next http sampler (request
part).

I have tried a lot of things but no success.

Thanks for your help


2009/1/7 Thomas Johnson <[email protected]>

> Sorry for the long response. The short suggestion is to try using
> "testVar_1" instead of "testVar_g1"
>
> Long Suggestion 1: Don't use BSH for this task
>
> If you've got an XML file, it would be simplest to use the XPath
> extractor with an expression such as "//re" which should find all of
> the <re>...</re> nodes in the document, regardless of nesting. You
> might have to make sure that data file is wrapped up in a top-level
> node such as "<res>...</res>" as it might not be valid XML without it.
>
> If it's really necessary to use Regular Expressions, you should use
> the Regular Expression Extractor. You will have to specify -1 for the
> Match Number (same effegt as the ALL parameter, I think), but your
> matches should become available as testVar_1, testVar_1_g1, etc.
>
> If the Regex extractor isn't enough, it might be easier to drop down
> to using JavaScript's Regular Expressions within the context of a BSF
> Postprocessor. The syntax is significantly cleaner for some cases (no
> more ${__log(...)}), and there is a lot of documentation out there.
>
>
> Long Suggestion 2: Get some debugging information
>
> I would also recommend placing a Debug Sampler in, and adding a "View
> Results In Tree" Listener to it. You'll be able to see what your
> variables are being set to on the Response Data tab.
>
> As an aside, it looks like your script is functioning properly,
> however you're referring to the wrong variable name. What you're after
> is testVar_1, testVar_2.
>
>
> Long Suggestion 3: A bit of regex background
>
> The group number is not the same as the match number -- Matches are
> chunks of text that contain the pattern you've specified, which would
> be "<re>12138" "<re>40635" and so on. The group numbers are based on
> the parentheses in the Regular Expression. In this case, group 1 is
> just the contents of the node.
>
> In a more complex regular expression, such as "(<re>)([0-9]+)(</re>)"
> there would be four groups for each match: 0=<re>12345</re>, 1=<re>,
> 2=12345, 3=</re>. This can be abused for interesting purposes if you
> decide to throw some conditionals into the mix :)
>
> Hope this helps.
>  - Thomas
>
> On Wed, Jan 7, 2009 at 9:45 AM, Laurent Michenaud <[email protected]>
> wrote:
> > Hi,
> >
> > I want to capture a list of ids (the number of ids is not fixed)
> contained
> > in an
> > xml response of an http request node.
> > I want to transform that list of ids in xml format (
> > <re>id1</re><re>id2</re>... )
> > to use it the next http request node.
> >
> > I think i have to use an bsh post processor but tell me if there is a
> better
> > way.
> >
> > Here is what i  have done for the moment :
> >
> > ${__javaScript(
> > '${__regexFunction(<re>([0-9]+),$1$,ALL,|,ERREUR,testVar)}';
> > ,resultat)};
> >
> > ${__log(${resultat})};
> > =>
> >
> 12138|40635|43233|46001|66414|70412|78144|91563|95772|120428|126074|153317|157616|205421|232214|239471|249033|257621|291566|297973|32619
> >
> > ${__log(${testVar_matchNr})};
> > => 21
> >
> > ${__log(${testVar_g1})};
> > => 32619
> >
> > ${__log(${testVar_g2})};
> > => undefined, why ? i have configured the __regexFunction with ALL.
> >
> > Now, i don't know how to transform that lists into a xml string.
> >
> > Can you help me ?
> >
> > Thanks
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to