You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Mike Lee <ml...@yahoo.com> on 2008/12/18 15:42:26 UTC

file comparison

I would like to compare a part of a file to a given string. We have a web application that calls web services. It generates a log file of the send and receive xml messages. I would like to take one of these log files and create a test case from it where I can take each xml send message and use it to compare it to the receive xml log file. We cant use the web service request because I have to compare based upon what our application sends. That involves comparing the files. I can't seem to do 'contains' because it wants a regular expression and I have this huge xml. I use an HTTP Request and use the FILE protocol and load the file. I use a response assertion to try to compare an xml section from what the send or receive data should look like in the log files.

I put on the 'substring' check box and put something like this in the 'patterns to test'

            <MSGVARS>
                <VAR NAME="RESULTS">DPR0007</VAR>
                <VAR NAME="SERVERTIMESPENT">0.000</VAR>
                <ROWSET NAME="DPR0007">
                    <ROW NUM="1">
                        <VAR NAME="INIGROUP">WipData</VAR>
                        <VAR NAME="INIOPTION">Path</VAR>
                    </ROW>
                </ROWSET>
                <ROWSET NAME="ERRORS">
                    <ROW NUM="1">
                        <VAR NAME="CODE">DPR0007</VAR>
                    </ROW>
                </ROWSET>
            </MSGVARS>

but it doesnt work.
If I break up each line and put it in and do a 'contains' then it does. Problem with that is order doesn't matter and these are big files and I need to be able to compare a chunk of data as above.

Summary: How do I check if a multi-line string exists in a file?

Thanks


      

Re: file comparison

Posted by yaroslav1 <sl...@yahoo.com>.
Hi "bob bob-7"

Thx you for the tricky technique. It is useful to know.

BTW: What can "seb-2-2" answer on your final questions - "How do I check if
a multi-line string exists in a file?"

Happy New Years everybody!


bob bob-7 wrote:
> 
> I guess I've stumped everyone so I'll answer my own question;
> To compare an XML snippet against part of a file use HTTP Request with
> file protocol to load the file.
> Ad a Response Assertion.
> Check 'Text Response' and 'Contains'
> 
> In the 'pattern to test' put the xml snippet you wish to check for in your
> file.
> EXCEPT, at the very beginning of the XML, add (?s) and at the end of every
> line add (.*).
> The (?s) tells it to make it a multiline and the (.*) at the end tells it
> to ignore the end of line no matter what it format it's in (windows, unix,
> etc).
> Not too bad...a bit of monkey work, but it is the easiest way I could
> find.
> I hope this helps.
> Mike
> 
> 
> 
> 
> ________________________________
> From: Mike Lee <ml...@yahoo.com>
> To: jmeter-user@jakarta.apache.org
> Sent: Thursday, December 18, 2008 9:42:26 AM
> Subject: file comparison
> 
> I would like to compare a part of a file to a given string. We have a web
> application that calls web services. It generates a log file of the send
> and receive xml messages. I would like to take one of these log files and
> create a test case from it where I can take each xml send message and use
> it to compare it to the receive xml log file. We cant use the web service
> request because I have to compare based upon what our application sends.
> That involves comparing the files. I can't seem to do 'contains' because
> it wants a regular expression and I have this huge xml. I use an HTTP
> Request and use the FILE protocol and load the file. I use a response
> assertion to try to compare an xml section from what the send or receive
> data should look like in the log files.
> 
> I put on the 'substring' check box and put something like this in the
> 'patterns to test'
> 
>             <MSGVARS>
>                 <VAR NAME="RESULTS">DPR0007</VAR>
>                 <VAR NAME="SERVERTIMESPENT">0.000</VAR>
>                 <ROWSET NAME="DPR0007">
>                     <ROW NUM="1">
>                         <VAR NAME="INIGROUP">WipData</VAR>
>                         <VAR NAME="INIOPTION">Path</VAR>
>                     </ROW>
>                 </ROWSET>
>                 <ROWSET NAME="ERRORS">
>                     <ROW NUM="1">
>                         <VAR NAME="CODE">DPR0007</VAR>
>                     </ROW>
>                 </ROWSET>
>             </MSGVARS>
> 
> but it doesnt work.
> If I break up each line and put it in and do a 'contains' then it does.
> Problem with that is order doesn't matter and these are big files and I
> need to be able to compare a chunk of data as above.
> 
> Summary: How do I check if a multi-line string exists in a file?
> 
> Thanks
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/file-comparison-tp21074090p21237783.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: file comparison

Posted by Mike Lee <ml...@yahoo.com>.
I guess I've stumped everyone so I'll answer my own question;
To compare an XML snippet against part of a file use HTTP Request with file protocol to load the file.
Ad a Response Assertion.
Check 'Text Response' and 'Contains'

In the 'pattern to test' put the xml snippet you wish to check for in your file.
EXCEPT, at the very beginning of the XML, add (?s) and at the end of every line add (.*).
The (?s) tells it to make it a multiline and the (.*) at the end tells it to ignore the end of line no matter what it format it's in (windows, unix, etc).
Not too bad...a bit of monkey work, but it is the easiest way I could find.
I hope this helps.
Mike




________________________________
From: Mike Lee <ml...@yahoo.com>
To: jmeter-user@jakarta.apache.org
Sent: Thursday, December 18, 2008 9:42:26 AM
Subject: file comparison

I would like to compare a part of a file to a given string. We have a web application that calls web services. It generates a log file of the send and receive xml messages. I would like to take one of these log files and create a test case from it where I can take each xml send message and use it to compare it to the receive xml log file. We cant use the web service request because I have to compare based upon what our application sends. That involves comparing the files. I can't seem to do 'contains' because it wants a regular expression and I have this huge xml. I use an HTTP Request and use the FILE protocol and load the file. I use a response assertion to try to compare an xml section from what the send or receive data should look like in the log files.

I put on the 'substring' check box and put something like this in the 'patterns to test'

            <MSGVARS>
                <VAR NAME="RESULTS">DPR0007</VAR>
                <VAR NAME="SERVERTIMESPENT">0.000</VAR>
                <ROWSET NAME="DPR0007">
                    <ROW NUM="1">
                        <VAR NAME="INIGROUP">WipData</VAR>
                        <VAR NAME="INIOPTION">Path</VAR>
                    </ROW>
                </ROWSET>
                <ROWSET NAME="ERRORS">
                    <ROW NUM="1">
                        <VAR NAME="CODE">DPR0007</VAR>
                    </ROW>
                </ROWSET>
            </MSGVARS>

but it doesnt work.
If I break up each line and put it in and do a 'contains' then it does. Problem with that is order doesn't matter and these are big files and I need to be able to compare a chunk of data as above.

Summary: How do I check if a multi-line string exists in a file?

Thanks