Bug 48331 - XpathExtractor does not return XML string representations for a Nodeset
XpathExtractor does not return XML string representations for a Nodeset
Status: RESOLVED FIXED
Product: JMeter
Classification: Unclassified
Component: Main
2.3.4
PC Windows XP
: P2 critical (vote)
: ---
Assigned To: JMeter issues mailing list
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2009-12-02 11:48 UTC by Joe Roberts
Modified: 2009-12-15 07:22 UTC (History)
0 users



Attachments
Here is the new class to use (8.95 KB, text/java)
2009-12-02 11:49 UTC, Joe Roberts
Details
The latest XPathExtractor.java from SVN with my changes ready to be commited (13.44 KB, text/java)
2009-12-07 05:51 UTC, Joe Roberts
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joe Roberts 2009-12-02 11:48:10 UTC
1 - When I have a response that contains an XML Node named TemplateList, as in this case:

<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><doGetTemplateListResponse xmlns="http://webservices.docucorp.com/ewps/schema/2005-12-01" xmlns:xmime="http://www.w3.org/2005/05/xmlmime">
    <Result>Success</Result>
    <TemplateList>
        <Story id="100100" StoryName="UL APPLICATION REJECTION NOTICE">
            <Key1 id="DOCUDEMO">
                <Key2 id="LIFE" />
            </Key1>
            <Description>UL Application Rejection</Description>
            <Props>
                <Prop name="OPTIONS">N</Prop>
                <Prop name="CATEGORY">DOCUDEMO_LIFE</Prop>
                <Prop name="VERSION">Change ME</Prop>
            </Props>
        </Story>
    </TemplateList>
    <Result>Success</Result>
....

2 - And I use an XPathExtractor as a post processor with these values:

Reference Name=templateList
XPath query=//TemplateList
Default Value=ERROR

3 - And I do not use Tidy or Namespaces, the XPathExtractor returns a blank string.

4 - I decompiled your code and modified it and now it returns the correct value.  

I would like to know if you can update your source code so my new change can be included in Jmeter in order to support returning string representations of XML fragments through XPath.  Attached is my version of XPathExtractor.java class.

5 - I have also tested with these XPath expressions with the new class and it returns the correct results:

Xpath query=//Result

returns <Result>Success</Result>

Xpath query=//Result/text()

returns Success
Comment 1 Joe Roberts 2009-12-02 11:49:13 UTC
Created attachment 24660 [details]
Here is the new class to use
Comment 2 Sebb 2009-12-02 13:10:48 UTC
Thanks for the info and the new java source.

We much prefer patches as unified diffs; since JMeter is an Apache project and therefore open source, the source is freely available, either as part of the source archive download, or directly from SVN, which is better as it will be the latest code:

http://svn.apache.org/repos/asf/jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/XPathExtractor.java

Please can you resubmit your suggested code change as a patch?
Comment 3 Joe Roberts 2009-12-03 05:02:28 UTC
I'll be glad to submit a patch for this but I have limited time and don't have time to go through a bunch of docs. to figure out how the process of submitting the patch for Jmeter works.  I am familiar with SVN and I have tried using your SVN URLs as follows but I am getting errors.  Please let me know how to proceed?

c:\devtools\tools\java-tools>svn checkout http://svn.apache.org/viewvc/jakarta/jmeter jmeter
svn: PROPFIND request failed on '/viewvc/jakarta/jmeter'
svn: PROPFIND of '/viewvc/jakarta/jmeter': could not connect to server (http://svn.apache.org)

c:\devtools\tools\java-tools>svn checkout https://svn.apache.org/repos/asf/jakarta/jmeter/trunk/ jmeter
svn: PROPFIND request failed on '/repos/asf/jakarta/jmeter/trunk'
svn: PROPFIND of '/repos/asf/jakarta/jmeter/trunk': could not connect to server (https://svn.apache.org)

c:\devtools\tools\java-tools>svn checkout https://svn.apache.org/repos/asf/jakarta/jmeter jmeter
svn: PROPFIND request failed on '/repos/asf/jakarta/jmeter'
svn: PROPFIND of '/repos/asf/jakarta/jmeter': could not connect to server (https://svn.apache.org)
Comment 4 Joe Roberts 2009-12-03 05:17:44 UTC
I was able to get SVN working.  I needed to configure the servers file for the proxy.  I should have the change in place soon.
Comment 5 Joe Roberts 2009-12-03 06:07:52 UTC
Well, now I am getting this.  I suspect it has to do with ant not being configured for a proxy server:

c:\devtools\tools\java-tools\jmeter\trunk>ant download_jars
Buildfile: build.xml

download_jars:
    [mkdir] Created dir: c:\devtools\tools\java-tools\jmeter\trunk\build

_process_all_jars:

_check_exists:

_check_jarfile:

_get_jarfile:
     [echo] Fetching: lib/bsf-2.4.0.jar
      [get] Getting: http://repo2.maven.org/maven2/bsf/bsf/2.4.0/bsf-2.4.0.jar
      [get] To: c:\devtools\tools\java-tools\jmeter\trunk\build\bsf-2.4.0.jar
      [get] Error getting http://repo2.maven.org/maven2/bsf/bsf/2.4.0/bsf-2.4.0.jar to c:\devtools\tools\java-tools\jmeter\trunk\build\bsf-2.4.0.jar

BUILD FAILED
c:\devtools\tools\java-tools\jmeter\trunk\build.xml:2011: The following error occurred while executing this line:
c:\devtools\tools\java-tools\jmeter\trunk\build.xml:1956: The following error occurred while executing this line:
c:\devtools\tools\java-tools\jmeter\trunk\build.xml:1867: The following error occurred while executing this line:
c:\devtools\tools\java-tools\jmeter\trunk\build.xml:1894: The following error occurred while executing this line:
c:\devtools\tools\java-tools\jmeter\trunk\build.xml:1923: java.net.ConnectException: Connection timed out: connect

Total time: 31 seconds
Comment 6 Joe Roberts 2009-12-07 05:47:18 UTC
Hi, I was able to obtain the JMeter project through SVN, make my changes, rebuild the project and test my changes today and I am ready to commit my changes as a patch, however I don't think this will be possible because my account has not been granted access as a committer account.  So I am including my changes here as an attachment, unless you want to grant me access as a committer.  Here is the error I received today:

c:\devtools\tools\java-tools\jmeter\trunk\src\components\org\apache\jmeter\extractor>svn commit -m "Changes to XPathNavigator to honor the XPath provided."
Authentication realm: <https://svn.apache.org:443> ASF Committers
Password for 'jroberts': ********
Authentication realm: <https://svn.apache.org:443> ASF Committers
Username: jroberts
Password for 'jroberts': ********
Authentication realm: <https://svn.apache.org:443> ASF Committers
Username: jroberts
Password for 'jroberts': ********
svn: Commit failed (details follow):
svn: MKACTIVITY of '/repos/asf/!svn/act/888d0edf-6907-f74d-bccb-44f6f0f61fdf': authorization failed (https://svn.apache.org)
Comment 7 Joe Roberts 2009-12-07 05:51:36 UTC
Created attachment 24676 [details]
The latest XPathExtractor.java from SVN with my changes ready to be commited

Attached is the XpathExtractor class I obtained and modified so it returns XML fragments in addition to text for XPath.  Would you please review it and commit it for me if it looks good to you so my changes become part of the baseline?  I do not have access as a committer so while I can checkout the code I cannot check it in myself and I do not think at this point you would want to grant me access as a committer anyway; not for such a small change.
Comment 8 Joe Roberts 2009-12-07 06:03:29 UTC
Hi, 

I have submitted the up to date XPathExtractor.java module with my code changes.  I hoping this is the correct way to submit a patch but if this is not the correct way to submit a patch for Jmeter please let me know if there is a doc. out there that I can follow on submitting a patch and I will be glad to do so.  

This issue is critical for me so please let me know as soon as you can if the patch will be accepted and when it will become part of the baseline so I can release my script to end users / customers and tell them to obtain the latest Jmeter with my changes, otherwise, the script won't run.
Comment 9 Sebb 2009-12-10 17:45:46 UTC
Thanks for the most recent attachment.

It cannot be applied as it stands, as it changes the behaviour of the test element (and causes some unit tests to fail). Current behaviour is that the query "//Result" returns "Success", i.e. the text contents, and this behaviour must be maintained.

However, there are cases where it would be useful to return the fragment, so I think the best way to solve this is to add an option for it.

Code applied to SVN:

URL: http://svn.apache.org/viewvc?rev=889487&view=rev
Log:
Bug 48331 - XpathExtractor does not return XML string representations for a Nodeset

If you want to test it out before the next release, try any nightly build after r889487.
Comment 10 Joe Roberts 2009-12-15 07:22:51 UTC
Hi,  

Thanks for adding the fix so soon.  I downloaded the nightly build and tested my script with it and it runs fine now.

Much appreciated.

Joe