You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Karthik110885 <ka...@gmail.com> on 2011/09/14 17:16:16 UTC

Issue with Response assertion for HTTP Request Sampler

Hi All,

I am a newbie so please tolerate with my ignorance :)

I have installed JMeter 2.5 version and have configured HTTP Request sampler
to send a request. I receive the response successfully without any issues.
Now, i have to verify that the response contains a particular block of xml
(multiple lines) to make sure that i have received the proper response. So i
have added response assertion to the HTTP Request sampler and copied the
block of xml to it

Now, When i send HTTP request to a server in non-windows platform everything
works fine. But when i send the same request to a server in windows
platform, the response assertion fails even though the response contains the
block of xml verified through response assertion. But if i give a one line
text or one line xml from the block of xml in response assertion it is
passed.

Please let me know if i am doing anything wrong. Is multiple line comparison
allowed in response assertion?

Thanks in advance.

--
View this message in context: http://jmeter.512774.n5.nabble.com/Issue-with-Response-assertion-for-HTTP-Request-Sampler-tp4803205p4803205.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: Issue with Response assertion for HTTP Request Sampler

Posted by Karthik110885 <ka...@gmail.com>.
Hi ZK,

Thanks for the options. After trying all the options, i think the best way
would to give the major elements of the xml as separate patters to be
matched with the response.


Thanks all for your help. I really appreciate it. :)

--
View this message in context: http://jmeter.512774.n5.nabble.com/Issue-with-Response-assertion-for-HTTP-Request-Sampler-tp4803205p4818602.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: Issue with Response assertion for HTTP Request Sampler

Posted by sebb <se...@gmail.com>.
On 15 September 2011 16:30, Karthik110885 <ka...@gmail.com> wrote:
> Hi ZK,
>
> Thanks for the response. I googled for the special characters and found a
> list of 11
>
> [ \ ^ $ . | ? * + ( )
>
> I have escaped . with a backslash. But the response assertion takes that too
> in a literal way.

Have you read the documentation on Response Assertion?

http://jakarta.apache.org/jmeter/usermanual/component_reference.html#Response_Assertion

I suspect the problem is that the end of line characters are not being
stored correctly.
It's quite difficult to match multiple lines correctly, so I suggest
you just add multiple single-line patterns; they all have to match.

If you want to match the whole contents, then consider using the Size
and MD5Hex Assertions; they will be quicker.

Or you can use the Save Responses to a file Listener to capture the
sample data and complete the comparison after the test run.
You should probably use that anyway.

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


Re: Issue with Response assertion for HTTP Request Sampler

Posted by ZK <st...@gmail.com>.
Hi,
could you post a sample of the *full * xml assertion you use?
Otherwise we all all shooting in the dark!

ZK

--
View this message in context: http://jmeter.512774.n5.nabble.com/Issue-with-Response-assertion-for-HTTP-Request-Sampler-tp4803205p4809760.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: Issue with Response assertion for HTTP Request Sampler

Posted by Deepak Shetty <sh...@gmail.com>.
hi
what options have you chosen for Response Assertion?


   - Contains - true if the text contains the regular expression pattern
   - Matches - true if the whole text matches the regular expression pattern

   - Equals - true if the whole text equals the pattern string
   (case-sensitive)
   - Substring - true if the text contains the pattern string
   (case-sensitive)

Equals and Substring patterns are plain strings, not regular expressions.

Note that what you are trying to do resembles the "Equals" or "Substring"
usecase. However as sebb points out , it is important that the string then
be an exact match (including the line endings or spaces or whatever) and it
is very hard to visually check whitespace characters.

However such a thing is rarely needed in a test (and has the added
consequence of making your test very brittle). It's usually easier to
compare specific data points than the entire response.

regards
deepak

On Thu, Sep 15, 2011 at 8:30 AM, Karthik110885 <ka...@gmail.com>wrote:

> Hi ZK,
>
> Thanks for the response. I googled for the special characters and found a
> list of 11
>
> [ \ ^ $ . | ? * + ( )
>
> I have escaped . with a backslash. But the response assertion takes that
> too
> in a literal way.
>
> *Assertion error: false
> Assertion failure: true
> Assertion failure message: Test failed: text expected to contain
> /&lt;CompanyCode\.GetDetail\.Response
> xmlns=&quot;urn:sap-com:document:sap:business\.response&quot;&gt;
>
>      0000000121
>      Firma
>      Ides AG
>      Martin Steiner, Kathrin Walther,
>      Bernd Zecha, Dondogmaa Lchamdondog
>      IDES intern
>
>      Frankfurt
>
>
>      60441
>      60070
>
>      160529
>
>
>      Lyoner Stern 231
>
>
>
>
>
>
>
>
>
>      DE
>      D
>      06
>      IDES
>
>      CET
>
>
>
>
>
>
>
>
>
>      1000
>      IDES AG
>      Frankfurt
>      DE
>      EUR
>      D
>      INT
>      K4
>      DE123456789
>      001000
>      0000000121
>      DE
>      EUR
>      DE
>
>
>
>
>
>
>      000000
>
>
>
>
>
> &lt;/CompanyCode\.GetDetail\.Response&gt;/*
>
>
> Please let me know if i am doing anything wrong.
>
> Thanks again.
>
> --
> View this message in context:
> http://jmeter.512774.n5.nabble.com/Issue-with-Response-assertion-for-HTTP-Request-Sampler-tp4803205p4807268.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>

Re: Issue with Response assertion for HTTP Request Sampler

Posted by Karthik110885 <ka...@gmail.com>.
Hi ZK,

Thanks for the response. I googled for the special characters and found a
list of 11

[ \ ^ $ . | ? * + ( )

I have escaped . with a backslash. But the response assertion takes that too
in a literal way.

*Assertion error: false
Assertion failure: true
Assertion failure message: Test failed: text expected to contain
/&lt;CompanyCode\.GetDetail\.Response
xmlns=&quot;urn:sap-com:document:sap:business\.response&quot;&gt;
   
      0000000121
      Firma
      Ides AG
      Martin Steiner, Kathrin Walther,
      Bernd Zecha, Dondogmaa Lchamdondog
      IDES intern
      
      Frankfurt
      
      
      60441
      60070
      
      160529
      
      
      Lyoner Stern 231
      
      
      
      
      
      
      
      
      
      DE
      D
      06
      IDES
      
      CET
      
      
      
      
      
      
      
   
   
      1000
      IDES AG
      Frankfurt
      DE
      EUR
      D
      INT
      K4
      DE123456789
      001000
      0000000121
      DE
      EUR
      DE
   
   
      
      
      
      
      000000
      
      
      
      
   
&lt;/CompanyCode\.GetDetail\.Response&gt;/*


Please let me know if i am doing anything wrong.

Thanks again.

--
View this message in context: http://jmeter.512774.n5.nabble.com/Issue-with-Response-assertion-for-HTTP-Request-Sampler-tp4803205p4807268.html
Sent from the JMeter - User mailing list archive at Nabble.com.

Re: Issue with Response assertion for HTTP Request Sampler

Posted by Karthik110885 <ka...@gmail.com>.
Hi Sebb,

Thanks a lot for the response.

Response match between the OSes. I haven't defined any regular expressions.
I have just copied the block of xml that is expected to be present in the
response (and it indeed is present in the response) into response assertion.

Is there anything that i should do with regex?

Please clarify. thanks once again..

--
View this message in context: http://jmeter.512774.n5.nabble.com/Issue-with-Response-assertion-for-HTTP-Request-Sampler-tp4803205p4806342.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: Issue with Response assertion for HTTP Request Sampler

Posted by sebb <se...@gmail.com>.
On 14 September 2011 16:16, Karthik110885 <ka...@gmail.com> wrote:
> Hi All,
>
> I am a newbie so please tolerate with my ignorance :)
>
> I have installed JMeter 2.5 version and have configured HTTP Request sampler
> to send a request. I receive the response successfully without any issues.
> Now, i have to verify that the response contains a particular block of xml
> (multiple lines) to make sure that i have received the proper response. So i
> have added response assertion to the HTTP Request sampler and copied the
> block of xml to it
>
> Now, When i send HTTP request to a server in non-windows platform everything
> works fine. But when i send the same request to a server in windows
> platform, the response assertion fails even though the response contains the
> block of xml verified through response assertion. But if i give a one line
> text or one line xml from the block of xml in response assertion it is
> passed.
>
> Please let me know if i am doing anything wrong. Is multiple line comparison
> allowed in response assertion?

That sounds like an issue with end-of-line matching.

I would expect the response to not vary between OSes, but perhaps the
regex processing might.

You can save the input XML using this Listener:

http://jakarta.apache.org/jmeter/usermanual/component_reference.html#Save_Responses_to_a_file

and make sure they are the same on both OSes.

If so, then it must be an issue with the way the regex is defined or processed.

> Thanks in advance.
>
> --
> View this message in context: http://jmeter.512774.n5.nabble.com/Issue-with-Response-assertion-for-HTTP-Request-Sampler-tp4803205p4803205.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: Issue with Response assertion for HTTP Request Sampler

Posted by ZK <st...@gmail.com>.
Hi,
Do the values change of the response stay the same? or do they change?
If they change you should consider using regEx (I recommend a program called
regexbuddy... but you have to pay for this), anyways I have given you 2
options below (both work for me as a response assertion) although there are
other ways to check an xml response (such as XPath Assertion)
Option 1:
&lt;CompanyCode\.GetDetail\.Response
xmlns=&quot;urn:sap-com:document:sap:business\.response&quot;&gt;
   <COMPANYCODE_ADDRESS>
      <ADDR_NO>0000000121</ADDR_NO>
      <FORMOFADDR>Firma</FORMOFADDR>
      <NAME>Ides AG</NAME>
      <NAME_2>Martin Steiner, Kathrin Walther,</NAME_2>
      <NAME_3>Bernd Zecha, Dondogmaa Lchamdondog</NAME_3>
      <NAME_4>IDES intern</NAME_4>
      <C_O_NAME/>
      <CITY>Frankfurt</CITY>
      <DISTRICT/>
      <CITY_NO/>
      <POSTL_COD1>60441</POSTL_COD1>
      <POSTL_COD2>60070</POSTL_COD2>
      <POSTL_COD3/>
      <PO_BOX>160529</PO_BOX>
      <PO_BOX_CIT/>
      <DELIV_DIS/>
      <STREET>Lyoner Stern 231</STREET>
      <STREET_NO/>
      <STR_ABBR/>
      <HOUSE_NO/>
      <STR_SUPPL1/>
      <STR_SUPPL2/>
      <LOCATION/>
      <BUILDING/>
      <FLOOR/>
      <ROOM_NO/>
      <COUNTRY>DE</COUNTRY>
      <LANGU>D</LANGU>
      <REGION>06</REGION>
      <SORT1>IDES</SORT1>
      <SORT2/>
      <TIME_ZONE>CET</TIME_ZONE>
      <TAXJURCODE/>
      <ADR_NOTES/>
      <COMM_TYPE/>
      <TEL1_NUMBR/>
      <TEL1_EXT/>
      <FAX_NUMBER/>
      <FAX_EXTENS/>
   </COMPANYCODE_ADDRESS>
   <COMPANYCODE_DETAIL>
      <COMP_CODE>1000</COMP_CODE>
      <COMP_NAME>IDES AG</COMP_NAME>
      <CITY>Frankfurt</CITY>
      <COUNTRY>DE</COUNTRY>
      <CURRENCY>EUR</CURRENCY>
      <LANGU>D</LANGU>
      <CHRT_ACCTS>INT</CHRT_ACCTS>
      <FY_VARIANT>K4</FY_VARIANT>
      <VAT_REG_NO>DE123456789</VAT_REG_NO>
      <COMPANY>001000</COMPANY>
      <ADDR_NO>0000000121</ADDR_NO>
      <COUNTRY_ISO>DE</COUNTRY_ISO>
      <CURRENCY_ISO>EUR</CURRENCY_ISO>
      <LANGU_ISO>DE</LANGU_ISO>
   </COMPANYCODE_DETAIL>
   <RETURN>
      <TYPE/>
      <CODE/>
      <MESSAGE/>
      <LOG_NO/>
      <LOG_MSG_NO>000000</LOG_MSG_NO>
      <MESSAGE_V1/>
      <MESSAGE_V2/>
      <MESSAGE_V3/>
      <MESSAGE_V4/>
   </RETURN>
&lt;/CompanyCode\.GetDetail\.Response&gt;



Option2 (More generic... not perfect but just to give you an idea):
&lt;CompanyCode\.GetDetail\.Response
xmlns=&quot;urn:sap-com:document:sap:business\.response&quot;&gt;
   <COMPANYCODE_ADDRESS>
      <ADDR_NO>[\d]*</ADDR_NO>
      <FORMOFADDR>[\w]*</FORMOFADDR>
      <NAME>[^>]*</NAME>
      <NAME_2>[^>]*</NAME_2>
      <NAME_3>[^>]*</NAME_3>
      <NAME_4>[^>]*</NAME_4>
      <C_O_NAME/>
      <CITY>[^>]*</CITY>
      <DISTRICT/>
      <CITY_NO/>
      <POSTL_COD1>[\d]*</POSTL_COD1>
      <POSTL_COD2>[\d]*</POSTL_COD2>
      <POSTL_COD3/>
      <PO_BOX>[\d]*</PO_BOX>
      <PO_BOX_CIT/>
      <DELIV_DIS/>
      <STREET>[^>]*</STREET>
      <STREET_NO/>
      <STR_ABBR/>
      <HOUSE_NO/>
      <STR_SUPPL1/>
      <STR_SUPPL2/>
      <LOCATION/>
      <BUILDING/>
      <FLOOR/>
      <ROOM_NO/>
      <COUNTRY>[^>]*</COUNTRY>
      <LANGU>[^>]*</LANGU>
      <REGION>[\d]*</REGION>
      <SORT1>[^>]*</SORT1>
      <SORT2/>
      <TIME_ZONE>[^>]*</TIME_ZONE>
      <TAXJURCODE/>
      <ADR_NOTES/>
      <COMM_TYPE/>
      <TEL1_NUMBR/>
      <TEL1_EXT/>
      <FAX_NUMBER/>
      <FAX_EXTENS/>
   </COMPANYCODE_ADDRESS>
   <COMPANYCODE_DETAIL>
      <COMP_CODE>[\d]*</COMP_CODE>
      <COMP_NAME>[^>]*</COMP_NAME>
      <CITY>[^>]*</CITY>
      <COUNTRY>[^>]*</COUNTRY>
      <CURRENCY>[^>]*</CURRENCY>
      <LANGU>[^>]*</LANGU>
      <CHRT_ACCTS>[^>]*</CHRT_ACCTS>
      <FY_VARIANT>[^>]*</FY_VARIANT>
      <VAT_REG_NO>[^>]*</VAT_REG_NO>
      <COMPANY>[\d]*</COMPANY>
      <ADDR_NO>[\d]*</ADDR_NO>
      <COUNTRY_ISO>[^>]*</COUNTRY_ISO>
      <CURRENCY_ISO>[^>]*</CURRENCY_ISO>
      <LANGU_ISO>[^>]*</LANGU_ISO>
   </COMPANYCODE_DETAIL>
   <RETURN>
      <TYPE/>
      <CODE/>
      <MESSAGE/>
      <LOG_NO/>
      <LOG_MSG_NO>[\d]*</LOG_MSG_NO>
      <MESSAGE_V1/>
      <MESSAGE_V2/>
      <MESSAGE_V3/>
      <MESSAGE_V4/>
   </RETURN>
&lt;/CompanyCode\.GetDetail\.Response&gt;


As I say these both work for me!!

ZK

--
View this message in context: http://jmeter.512774.n5.nabble.com/Issue-with-Response-assertion-for-HTTP-Request-Sampler-tp4803205p4810110.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: Issue with Response assertion for HTTP Request Sampler

Posted by Karthik110885 <ka...@gmail.com>.
Hi Deepak / ZK,

Thanks for the response.

@ Deepak - Yes, what you said is correct. Am trying to accomplish something
like Substring. Should have used Substring only :) I tried using it now, but
still facing with the same error :(

@ ZK - 

Actual response:

"
						
                     
Response in 547 msecs
 <textarea name="output" rows="10" cols="35"
disable="true"><CompanyCode.GetDetail.Response
xmlns="urn:sap-com:document:sap:business.response">
   <COMPANYCODE_ADDRESS>
      <ADDR_NO>0000000121</ADDR_NO>
      <FORMOFADDR>Firma</FORMOFADDR>
      <NAME>Ides AG</NAME>
      <NAME_2>Martin Steiner, Kathrin Walther,</NAME_2>
      <NAME_3>Bernd Zecha, Dondogmaa Lchamdondog</NAME_3>
      <NAME_4>IDES intern</NAME_4>
      <C_O_NAME/>
      <CITY>Frankfurt</CITY>
      <DISTRICT/>
      <CITY_NO/>
      <POSTL_COD1>60441</POSTL_COD1>
      <POSTL_COD2>60070</POSTL_COD2>
      <POSTL_COD3/>
      <PO_BOX>160529</PO_BOX>
      <PO_BOX_CIT/>
      <DELIV_DIS/>
      <STREET>Lyoner Stern 231</STREET>
      <STREET_NO/>
      <STR_ABBR/>
      <HOUSE_NO/>
      <STR_SUPPL1/>
      <STR_SUPPL2/>
      <LOCATION/>
      <BUILDING/>
      <FLOOR/>
      <ROOM_NO/>
      <COUNTRY>DE</COUNTRY>
      <LANGU>D</LANGU>
      <REGION>06</REGION>
      <SORT1>IDES</SORT1>
      <SORT2/>
      <TIME_ZONE>CET</TIME_ZONE>
      <TAXJURCODE/>
      <ADR_NOTES/>
      <COMM_TYPE/>
      <TEL1_NUMBR/>
      <TEL1_EXT/>
      <FAX_NUMBER/>
      <FAX_EXTENS/>
   </COMPANYCODE_ADDRESS>
   <COMPANYCODE_DETAIL>
      <COMP_CODE>1000</COMP_CODE>
      <COMP_NAME>IDES AG</COMP_NAME>
      <CITY>Frankfurt</CITY>
      <COUNTRY>DE</COUNTRY>
      <CURRENCY>EUR</CURRENCY>
      <LANGU>D</LANGU>
      <CHRT_ACCTS>INT</CHRT_ACCTS>
      <FY_VARIANT>K4</FY_VARIANT>
      <VAT_REG_NO>DE123456789</VAT_REG_NO>
      <COMPANY>001000</COMPANY>
      <ADDR_NO>0000000121</ADDR_NO>
      <COUNTRY_ISO>DE</COUNTRY_ISO>
      <CURRENCY_ISO>EUR</CURRENCY_ISO>
      <LANGU_ISO>DE</LANGU_ISO>
   </COMPANYCODE_DETAIL>
   <RETURN>
      <TYPE/>
      <CODE/>
      <MESSAGE/>
      <LOG_NO/>
      <LOG_MSG_NO>000000</LOG_MSG_NO>
      <MESSAGE_V1/>
      <MESSAGE_V2/>
      <MESSAGE_V3/>
      <MESSAGE_V4/>
   </RETURN>
</CompanyCode.GetDetail.Response></textarea>"

Value in Response Assertion:

"<CompanyCode.GetDetail.Response
xmlns="urn:sap-com:document:sap:business.response">
   <COMPANYCODE_ADDRESS>
      <ADDR_NO>0000000121</ADDR_NO>
      <FORMOFADDR>Firma</FORMOFADDR>
      <NAME>Ides AG</NAME>
      <NAME_2>Martin Steiner, Kathrin Walther,</NAME_2>
      <NAME_3>Bernd Zecha, Dondogmaa Lchamdondog</NAME_3>
      <NAME_4>IDES intern</NAME_4>
      <C_O_NAME/>
      <CITY>Frankfurt</CITY>
      <DISTRICT/>
      <CITY_NO/>
      <POSTL_COD1>60441</POSTL_COD1>
      <POSTL_COD2>60070</POSTL_COD2>
      <POSTL_COD3/>
      <PO_BOX>160529</PO_BOX>
      <PO_BOX_CIT/>
      <DELIV_DIS/>
      <STREET>Lyoner Stern 231</STREET>
      <STREET_NO/>
      <STR_ABBR/>
      <HOUSE_NO/>
      <STR_SUPPL1/>
      <STR_SUPPL2/>
      <LOCATION/>
      <BUILDING/>
      <FLOOR/>
      <ROOM_NO/>
      <COUNTRY>DE</COUNTRY>
      <LANGU>D</LANGU>
      <REGION>06</REGION>
      <SORT1>IDES</SORT1>
      <SORT2/>
      <TIME_ZONE>CET</TIME_ZONE>
      <TAXJURCODE/>
      <ADR_NOTES/>
      <COMM_TYPE/>
      <TEL1_NUMBR/>
      <TEL1_EXT/>
      <FAX_NUMBER/>
      <FAX_EXTENS/>
   </COMPANYCODE_ADDRESS>
   <COMPANYCODE_DETAIL>
      <COMP_CODE>1000</COMP_CODE>
      <COMP_NAME>IDES AG</COMP_NAME>
      <CITY>Frankfurt</CITY>
      <COUNTRY>DE</COUNTRY>
      <CURRENCY>EUR</CURRENCY>
      <LANGU>D</LANGU>
      <CHRT_ACCTS>INT</CHRT_ACCTS>
      <FY_VARIANT>K4</FY_VARIANT>
      <VAT_REG_NO>DE123456789</VAT_REG_NO>
      <COMPANY>001000</COMPANY>
      <ADDR_NO>0000000121</ADDR_NO>
      <COUNTRY_ISO>DE</COUNTRY_ISO>
      <CURRENCY_ISO>EUR</CURRENCY_ISO>
      <LANGU_ISO>DE</LANGU_ISO>
   </COMPANYCODE_DETAIL>
   <RETURN>
      <TYPE/>
      <CODE/>
      <MESSAGE/>
      <LOG_NO/>
      <LOG_MSG_NO>000000</LOG_MSG_NO>
      <MESSAGE_V1/>
      <MESSAGE_V2/>
      <MESSAGE_V3/>
      <MESSAGE_V4/>
   </RETURN>
</CompanyCode.GetDetail.Response>"

I have tried using Substring as Deepak suggested. But it still throws an
error.

Thanks again for your response and help

--
View this message in context: http://jmeter.512774.n5.nabble.com/Issue-with-Response-assertion-for-HTTP-Request-Sampler-tp4803205p4809834.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