You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Ivan Rancati <iv...@sharpmind.de> on 2007/01/11 18:10:06 UTC

Matching one of several strings in Response Assertion

An API I am testing can return one of several strings, that look like this

61A6C22QXPUZA6G2XD
FJKTCS7597QWBZ29Y9
8PGUE8J7NM72AWMA8H
DQS23CB9J4MXJ4NWGW
CBMX24WPUKJHW32FFS
AQ4PA3VGAGJRB2A191
8BF98WM3RFYT4J6ZJ9

I have a variable for each of these possible matches, and in the Response
Assertion, I want the test to pass if one of the above 7 strings is
returned.
So my regex looks like

${mn6ac1}|${mn6ac2}|${mn6ac3}|${mn6ac4}|${mn6ac5}|${mn6ac6}|${mn6ac7}

If I run it, however, it looks like the pipe characters are not interpreted
as "alternation" 
(see http://www.regular-expressions.com/alternation.html)
but are literally interpreted, as the Assertion Results listener shows 

Test failed, text expected to match
/61A6C22QXPUZA6G2XD|FJKTCS7597QWBZ29Y9|8PGUE8J7NM72AWMA8H|.....

I have tried to group with parenthesis too, but that does not work either. 

All suggestions welcome
Ivan
-- 
View this message in context: http://www.nabble.com/Matching-one-of-several-strings-in-Response-Assertion-tf2959081.html#a8278091
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: Matching one of several strings in Response Assertion

Posted by Ivan Rancati <iv...@sharpmind.de>.


JMeter does not limit data lengths or variable content, but of course
Java and memory limits will eventually have an effect...

I suggest you use the Save Responses Post-Processor to check that the
content really is as you expect.

You can check your RE using:

http://jakarta.apache.org/oro/demo.html

It turns out that there was an application bug, so at times a CR was
inserted at the end of the string. 
I have changed the assertion from "matches" to "contains" and everything
works

Apologies for the noise and thanks for the support. In particular the ORO
online demo is very useful.
-- 
View this message in context: http://www.nabble.com/Matching-one-of-several-strings-in-Response-Assertion-tf2959081.html#a8393525
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: Matching one of several strings in Response Assertion

Posted by sebb <se...@gmail.com>.
JMeter does not limit data lengths or variable content, but of course
Java and memory limits will eventually have an effect...

I suggest you use the Save Responses Post-Processor to check that the
content really is as you expect.

You can check your RE using:

http://jakarta.apache.org/oro/demo.html

One other possibility - are you sure that the pipe really is a pipe?
I've seen problems on DOS where the keyboard mapping was incorrect,
and what looked like a pipe was actually something else...

You could use a hex editor to check the contents of the JMX.

On 12/01/07, Ivan Rancati <iv...@sharpmind.de> wrote:
>
> Yes, the output is correct. Could there be a limitation/bug on the length of
> the data or the variable name? (my variable names are actually 6 character
> longer than in my sample, there was a company name that I removed for
> compactness in my original mail)
> I will try with shorter variable names and see if it makes a difference
>
>
>
> sebb-2 wrote:
> >
> > Works fine for me using
> >
> > ${A}|${B}|c
> >
> > where A=a and b=b with input of either a (succeeds) or d (fails)
> >
> > Are you sure the output contains the correct data?
> >
> >
> > On 11/01/07, Ivan Rancati <iv...@sharpmind.de> wrote:
> >>
> >> An API I am testing can return one of several strings, that look like
> >> this
> >>
> >> 61A6C22QXPUZA6G2XD
> >> FJKTCS7597QWBZ29Y9
> >> 8PGUE8J7NM72AWMA8H
> >> DQS23CB9J4MXJ4NWGW
> >> CBMX24WPUKJHW32FFS
> >> AQ4PA3VGAGJRB2A191
> >> 8BF98WM3RFYT4J6ZJ9
> >>
> >> I have a variable for each of these possible matches, and in the Response
> >> Assertion, I want the test to pass if one of the above 7 strings is
> >> returned.
> >> So my regex looks like
> >>
> >> ${mn6ac1}|${mn6ac2}|${mn6ac3}|${mn6ac4}|${mn6ac5}|${mn6ac6}|${mn6ac7}
> >>
> >> If I run it, however, it looks like the pipe characters are not
> >> interpreted
> >> as "alternation"
> >> (see http://www.regular-expressions.com/alternation.html)
> >> but are literally interpreted, as the Assertion Results listener shows
> >>
> >> Test failed, text expected to match
> >> /61A6C22QXPUZA6G2XD|FJKTCS7597QWBZ29Y9|8PGUE8J7NM72AWMA8H|.....
> >>
> >> I have tried to group with parenthesis too, but that does not work
> >> either.
> >>
> >> All suggestions welcome
> >> Ivan
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Matching-one-of-several-strings-in-Response-Assertion-tf2959081.html#a8278091
> >> 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
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Matching-one-of-several-strings-in-Response-Assertion-tf2959081.html#a8296534
> 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: Matching one of several strings in Response Assertion

Posted by Ivan Rancati <iv...@sharpmind.de>.
Yes, the output is correct. Could there be a limitation/bug on the length of
the data or the variable name? (my variable names are actually 6 character
longer than in my sample, there was a company name that I removed for
compactness in my original mail)
I will try with shorter variable names and see if it makes a difference



sebb-2 wrote:
> 
> Works fine for me using
> 
> ${A}|${B}|c
> 
> where A=a and b=b with input of either a (succeeds) or d (fails)
> 
> Are you sure the output contains the correct data?
> 
> 
> On 11/01/07, Ivan Rancati <iv...@sharpmind.de> wrote:
>>
>> An API I am testing can return one of several strings, that look like
>> this
>>
>> 61A6C22QXPUZA6G2XD
>> FJKTCS7597QWBZ29Y9
>> 8PGUE8J7NM72AWMA8H
>> DQS23CB9J4MXJ4NWGW
>> CBMX24WPUKJHW32FFS
>> AQ4PA3VGAGJRB2A191
>> 8BF98WM3RFYT4J6ZJ9
>>
>> I have a variable for each of these possible matches, and in the Response
>> Assertion, I want the test to pass if one of the above 7 strings is
>> returned.
>> So my regex looks like
>>
>> ${mn6ac1}|${mn6ac2}|${mn6ac3}|${mn6ac4}|${mn6ac5}|${mn6ac6}|${mn6ac7}
>>
>> If I run it, however, it looks like the pipe characters are not
>> interpreted
>> as "alternation"
>> (see http://www.regular-expressions.com/alternation.html)
>> but are literally interpreted, as the Assertion Results listener shows
>>
>> Test failed, text expected to match
>> /61A6C22QXPUZA6G2XD|FJKTCS7597QWBZ29Y9|8PGUE8J7NM72AWMA8H|.....
>>
>> I have tried to group with parenthesis too, but that does not work
>> either.
>>
>> All suggestions welcome
>> Ivan
>> --
>> View this message in context:
>> http://www.nabble.com/Matching-one-of-several-strings-in-Response-Assertion-tf2959081.html#a8278091
>> 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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Matching-one-of-several-strings-in-Response-Assertion-tf2959081.html#a8296534
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: Matching one of several strings in Response Assertion

Posted by sebb <se...@gmail.com>.
Works fine for me using

${A}|${B}|c

where A=a and b=b with input of either a (succeeds) or d (fails)

Are you sure the output contains the correct data?


On 11/01/07, Ivan Rancati <iv...@sharpmind.de> wrote:
>
> An API I am testing can return one of several strings, that look like this
>
> 61A6C22QXPUZA6G2XD
> FJKTCS7597QWBZ29Y9
> 8PGUE8J7NM72AWMA8H
> DQS23CB9J4MXJ4NWGW
> CBMX24WPUKJHW32FFS
> AQ4PA3VGAGJRB2A191
> 8BF98WM3RFYT4J6ZJ9
>
> I have a variable for each of these possible matches, and in the Response
> Assertion, I want the test to pass if one of the above 7 strings is
> returned.
> So my regex looks like
>
> ${mn6ac1}|${mn6ac2}|${mn6ac3}|${mn6ac4}|${mn6ac5}|${mn6ac6}|${mn6ac7}
>
> If I run it, however, it looks like the pipe characters are not interpreted
> as "alternation"
> (see http://www.regular-expressions.com/alternation.html)
> but are literally interpreted, as the Assertion Results listener shows
>
> Test failed, text expected to match
> /61A6C22QXPUZA6G2XD|FJKTCS7597QWBZ29Y9|8PGUE8J7NM72AWMA8H|.....
>
> I have tried to group with parenthesis too, but that does not work either.
>
> All suggestions welcome
> Ivan
> --
> View this message in context: http://www.nabble.com/Matching-one-of-several-strings-in-Response-Assertion-tf2959081.html#a8278091
> 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