You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by irtoip <pi...@xdsnet.pl> on 2009/07/20 12:05:40 UTC

Problem with regex in beanShell and then using results

I have problem, or really don't know how to use jmeter. I have such plan:

- Mail reader sampler
   |-BeanShell Assertion
- Http Request

In BeanShell Assertion I'm reading mail and doing regexp on it. The script:

import org.apache.jmeter.samplers.SampleResult;

SampleResult[] results = Response.getSubResults(); 

vars.put("EMAIL_RESPONSE",results[0].getResponseDataAsString());
//print(vars.get("EMAIL_RESPONSE")+"===========");

${__regexFunction(<A HREF=".*uid=(.*)&token=(.*)" CLASS="aactivate",$1$
$2$,1,,NO_LINK,ACT_LINK,EMAIL_RESPONSE)};


The ACT_LINK variables then are used in HTTP request, but there are no
variables(instead of value is used ACT_LING_g1 and ACT_LINK_g2). I really
don't know why. I'm sure that there is no error in regex function, because
if I try to find (.*) then also doesn't work. I was trying to use timer etc.

What strange, when I used such plan:

- Mail reader sampler
   |-BeanShell Assertion 1
   |-BeanShell Assertion 2
- Http Request

where both assertion have the same script then it begins to work(but also
with problems).

Thanks
-- 
View this message in context: http://www.nabble.com/Problem-with-regex-in-beanShell-and-then-using-results-tp24566983p24566983.html
Sent from the JMeter - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Problem with regex in beanShell and then using results

Posted by sebb <se...@gmail.com>.
On 23/07/2009, irtoip <pi...@xdsnet.pl> wrote:
>
>  Thanks. no problem.
>  I've found my mistake. Probably I can't use jmeter function in beanshell.
>

Yes, you can use functions and variables in BeanShell, but only in the
GUI. You cannot use them in scripts read from files, because only the
GUI script is scanned to process the references.

>
>  Ok I see your problem but
>  I never used {__regexFunction.  I'm sorry but I can't help you on this kind
>  of  function problem
>
>  In my project, I used a lot of regular expression, but
>  I coded directly  in java code to execute them (see java.util.regex)
>
>  1- I write a java code with a return value by using a "BeanShell
>  Sampler"(script field).
>  2- I executed it
>  3- Display the result in a "View result tree" result.
>
>  perhaps it will help you
>
>  annie35
>
>
>
>
>
> irtoip wrote:
>  >
>  > Yes, I'm sure the response is correct, because I printed it.
>  > Even if I call function with such expresion:
>  >
>  > ${__regexFunction((.*),$1$,1,,NO_LINK,ACT_LINK,EMAIL_RESPONSE)};
>  >
>  > there is no results.
>  >
>  >
>  > annie35 wrote:
>  >>
>  >> Hi,
>  >>
>  >> Your response is Correct ?
>  >> If it is ok the you can test your regular expression on your response
>  >> data with this web site http://www.spaweditor.com/scripts/regex/index.php
>  >>
>  >> It is a free site. It enables to test regular expression on every data
>  >> then find what you want.
>  >>
>  >> good luck
>  >> annie35
>  >>
>  >>
>  >>
>  >>
>  >> irtoip wrote:
>  >>>
>  >>> I have problem, or really don't know how to use jmeter. I have such
>  >>> plan:
>  >>>
>  >>> - Mail reader sampler
>  >>>    |-BeanShell Assertion
>  >>> - Http Request
>  >>>
>  >>> In BeanShell Assertion I'm reading mail and doing regexp on it. The
>  >>> script:
>  >>>
>  >>> import org.apache.jmeter.samplers.SampleResult;
>  >>>
>  >>> SampleResult[] results = Response.getSubResults();
>  >>>
>  >>> vars.put("EMAIL_RESPONSE",results[0].getResponseDataAsString());
>  >>> //print(vars.get("EMAIL_RESPONSE")+"===========");
>  >>>
>  >>> ${__regexFunction( .*uid=(.*)&token=(.*)
>  >>>
>  >>>
>  >>
>  >>
>  >
>  >
>
>  --
>
> View this message in context: http://www.nabble.com/Problem-with-regex-in-beanShell-and-then-using-results-tp24566983p24620248.html
>
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>  For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Problem with regex in beanShell and then using results

Posted by irtoip <pi...@xdsnet.pl>.
Thanks. no problem.
I've found my mistake. Probably I can't use jmeter function in beanshell.


Ok I see your problem but
I never used {__regexFunction.  I'm sorry but I can't help you on this kind
of  function problem

In my project, I used a lot of regular expression, but
I coded directly  in java code to execute them (see java.util.regex)

1- I write a java code with a return value by using a "BeanShell
Sampler"(script field).
2- I executed it 
3- Display the result in a "View result tree" result.

perhaps it will help you

annie35




irtoip wrote:
> 
> Yes, I'm sure the response is correct, because I printed it.
> Even if I call function with such expresion:
> 
> ${__regexFunction((.*),$1$,1,,NO_LINK,ACT_LINK,EMAIL_RESPONSE)}; 
> 
> there is no results.
> 
> 
> annie35 wrote:
>> 
>> Hi,
>> 
>> Your response is Correct ?
>> If it is ok the you can test your regular expression on your response
>> data with this web site http://www.spaweditor.com/scripts/regex/index.php
>> 
>> It is a free site. It enables to test regular expression on every data
>> then find what you want.
>> 
>> good luck
>> annie35
>> 
>> 
>> 
>> 
>> irtoip wrote:
>>> 
>>> I have problem, or really don't know how to use jmeter. I have such
>>> plan:
>>> 
>>> - Mail reader sampler
>>>    |-BeanShell Assertion
>>> - Http Request
>>> 
>>> In BeanShell Assertion I'm reading mail and doing regexp on it. The
>>> script:
>>> 
>>> import org.apache.jmeter.samplers.SampleResult;
>>> 
>>> SampleResult[] results = Response.getSubResults(); 
>>> 
>>> vars.put("EMAIL_RESPONSE",results[0].getResponseDataAsString());
>>> //print(vars.get("EMAIL_RESPONSE")+"===========");
>>> 
>>> ${__regexFunction( .*uid=(.*)&token=(.*) 
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Problem-with-regex-in-beanShell-and-then-using-results-tp24566983p24620248.html
Sent from the JMeter - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Problem with regex in beanShell and then using results

Posted by annie35 <ni...@yahoo.fr>.
Ok I see your problem but
I never used {__regexFunction.  I'm sorry but I can't help you on this kind
of  function problem

In my project, I used a lot of regular expression, but
I coded directly  in java code to execute them (see java.util.regex)

1- I write a java code with a return value by using a "BeanShell
Sampler"(script field).
2- I executed it 
3- Display the result in a "View result tree" result.

perhaps it will help you

annie35




Yes, I'm sure the response is correct, because I printed it.
Even if I call function with such expresion:

${__regexFunction((.*),$1$,1,,NO_LINK,ACT_LINK,EMAIL_RESPONSE)}; 

there is no results.


annie35 wrote:
> 
> Hi,
> 
> Your response is Correct ?
> If it is ok the you can test your regular expression on your response data
> with this web site http://www.spaweditor.com/scripts/regex/index.php
> 
> It is a free site. It enables to test regular expression on every data
> then find what you want.
> 
> good luck
> annie35
> 
> 
> 
> 
> irtoip wrote:
>> 
>> I have problem, or really don't know how to use jmeter. I have such plan:
>> 
>> - Mail reader sampler
>>    |-BeanShell Assertion
>> - Http Request
>> 
>> In BeanShell Assertion I'm reading mail and doing regexp on it. The
>> script:
>> 
>> import org.apache.jmeter.samplers.SampleResult;
>> 
>> SampleResult[] results = Response.getSubResults(); 
>> 
>> vars.put("EMAIL_RESPONSE",results[0].getResponseDataAsString());
>> //print(vars.get("EMAIL_RESPONSE")+"===========");
>> 
>> ${__regexFunction( .*uid=(.*)&token=(.*) 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Problem-with-regex-in-beanShell-and-then-using-results-tp24566983p24608806.html
Sent from the JMeter - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Problem with regex in beanShell and then using results

Posted by irtoip <pi...@xdsnet.pl>.
Yes, I'm sure the response is correct, because I printed it.
Even if I call function with such expresion:

${__regexFunction((.*),$1$,1,,NO_LINK,ACT_LINK,EMAIL_RESPONSE)}; 

there is no results.


Hi,

Your response is Correct ?
If it is ok the you can test your regular expression on your response data
with this web site http://www.spaweditor.com/scripts/regex/index.php

It is a free site. It enables to test regular expression on every data then
find what you want.

good luck
annie35




irtoip wrote:
> 
> I have problem, or really don't know how to use jmeter. I have such plan:
> 
> - Mail reader sampler
>    |-BeanShell Assertion
> - Http Request
> 
> In BeanShell Assertion I'm reading mail and doing regexp on it. The
> script:
> 
> import org.apache.jmeter.samplers.SampleResult;
> 
> SampleResult[] results = Response.getSubResults(); 
> 
> vars.put("EMAIL_RESPONSE",results[0].getResponseDataAsString());
> //print(vars.get("EMAIL_RESPONSE")+"===========");
> 
> ${__regexFunction( .*uid=(.*)&token=(.*) 
> 
> 

-- 
View this message in context: http://www.nabble.com/Problem-with-regex-in-beanShell-and-then-using-results-tp24566983p24606412.html
Sent from the JMeter - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Problem with regex in beanShell and then using results

Posted by annie35 <ni...@yahoo.fr>.
Hi,

Your response is Correct ?
If it is ok the you can test your regular expression on your response data
with this web site http://www.spaweditor.com/scripts/regex/index.php

It is a free site. It enables to test regular expression on every data then
find what you want.

good luck
annie35




I have problem, or really don't know how to use jmeter. I have such plan:

- Mail reader sampler
   |-BeanShell Assertion
- Http Request

In BeanShell Assertion I'm reading mail and doing regexp on it. The script:

import org.apache.jmeter.samplers.SampleResult;

SampleResult[] results = Response.getSubResults(); 

vars.put("EMAIL_RESPONSE",results[0].getResponseDataAsString());
//print(vars.get("EMAIL_RESPONSE")+"===========");

${__regexFunction( .*uid=(.*)&token=(.*) 

-- 
View this message in context: http://www.nabble.com/Problem-with-regex-in-beanShell-and-then-using-results-tp24566983p24590177.html
Sent from the JMeter - User mailing list archive at Nabble.com.

Re: Problem with regex in beanShell and then using results

Posted by annie35 <ni...@yahoo.fr>.
Hi,

Your response is Correct ?
If it is ok the you can test your regular expression on your response data
with this web site http://www.spaweditor.com/scripts/regex/index.php

It is a free site. It enables to test regular expression on every data then
find what you want.

good luck
annie35




I have problem, or really don't know how to use jmeter. I have such plan:

- Mail reader sampler
   |-BeanShell Assertion
- Http Request

In BeanShell Assertion I'm reading mail and doing regexp on it. The script:

import org.apache.jmeter.samplers.SampleResult;

SampleResult[] results = Response.getSubResults(); 

vars.put("EMAIL_RESPONSE",results[0].getResponseDataAsString());
//print(vars.get("EMAIL_RESPONSE")+"===========");

${__regexFunction( .*uid=(.*)&token=(.*) 

-- 
View this message in context: http://www.nabble.com/Problem-with-regex-in-beanShell-and-then-using-results-tp24566983p24590176.html
Sent from the JMeter - User mailing list archive at Nabble.com.