Author: pmouawad
Date: Wed Oct 21 21:26:58 2015
New Revision: 1709921
URL: http://svn.apache.org/viewvc?rev=1709921&view=rev
Log:
Bug 58515 - New JSON related components : JSON-PATH Extractor and JSON-PATH Renderer in View Results Tree
Bugzilla Id: 58515
Added:
jmeter/trunk/docs/images/screenshots/json-post-processor.png (with props)
jmeter/trunk/licenses/bin/json-path-2.0.0.txt (with props)
jmeter/trunk/licenses/bin/json-smart-2.2.txt (with props)
jmeter/trunk/src/components/org/apache/jmeter/extractor/json/
jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/
jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/JSONManager.java (with props)
jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/JSONPostProcessor.java (with props)
jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/gui/
jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/gui/JSONPostProcessorGui.java (with props)
jmeter/trunk/src/components/org/apache/jmeter/extractor/json/render/
jmeter/trunk/src/components/org/apache/jmeter/extractor/json/render/RenderAsJsonRenderer.java (with props)
jmeter/trunk/xdocs/images/screenshots/json-post-processor.png (with props)
Modified:
jmeter/trunk/bin/saveservice.properties
jmeter/trunk/build.properties
jmeter/trunk/build.xml
jmeter/trunk/eclipse.classpath
jmeter/trunk/res/maven/ApacheJMeter_parent.pom
jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsJSON.java
jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties
jmeter/trunk/src/core/org/apache/jmeter/save/SaveService.java
jmeter/trunk/test/src/org/apache/jmeter/visualizers/TestRenderAsJson.java
jmeter/trunk/xdocs/changes.xml
jmeter/trunk/xdocs/usermanual/component_reference.xml
Modified: jmeter/trunk/bin/saveservice.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/bin/saveservice.properties?rev=1709921&r1=1709920&r2=1709921&view=diff
==============================================================================
--- jmeter/trunk/bin/saveservice.properties (original)
+++ jmeter/trunk/bin/saveservice.properties Wed Oct 21 21:26:58 2015
@@ -54,7 +54,8 @@ _file_version=$Revision$
# 2.6 = 2.11
# 2.7 = 2.12
# 2.8 = 2.13
-_version=2.8
+# 2.9 = 2.14
+_version=2.9
#
#
# Character set encoding used to read and write JMeter XML files and CSV results
@@ -182,6 +183,8 @@ JMSPublisherGui=org.apache.jmeter.protoc
JMSSampler=org.apache.jmeter.protocol.jms.sampler.JMSSampler
JMSSamplerGui=org.apache.jmeter.protocol.jms.control.gui.JMSSamplerGui
JMSSubscriberGui=org.apache.jmeter.protocol.jms.control.gui.JMSSubscriberGui
+JSONPostProcessor=org.apache.jmeter.extractor.json.jsonpath.JSONPostProcessor
+JSONPostProcessorGui=org.apache.jmeter.extractor.json.jsonpath.gui.JSONPostProcessorGui
# Removed in r545311 as Jndi no longer present; keep for compat.
JndiDefaultsGui=org.apache.jmeter.protocol.jms.control.gui.JndiDefaultsGui
JSR223Assertion=org.apache.jmeter.assertions.JSR223Assertion
Modified: jmeter/trunk/build.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/build.properties?rev=1709921&r1=1709920&r2=1709921&view=diff
==============================================================================
--- jmeter/trunk/build.properties (original)
+++ jmeter/trunk/build.properties Wed Oct 21 21:26:58 2015
@@ -234,6 +234,16 @@ jodd-log.jar = jodd-log-${
jodd-log.loc = ${maven2.repo}/org/jodd/jodd-log/${jodd-log.version}
jodd-log.md5 = b5ac69fae957991bc55384f234873d4b
+json-path.version = 2.0.0
+json-path.jar = json-path-${json-path.version}.jar
+json-path.loc = ${maven2.repo}/com/jayway/jsonpath/json-path/${json-path.version}
+json-path.md5 = 8e3e62c8e450cfa66d4bd90f1fb553d8
+
+json-smart.version = 2.2
+json-smart.jar = json-smart-${json-smart.version}.jar
+json-smart.loc = ${maven2.repo}/net/minidev/json-smart/${json-smart.version}
+json-smart.md5 = 0575a23ab41e00cd1cb12a87537fcb8b
+
jsoup.version = 1.8.2
jsoup.jar = jsoup-${jsoup.version}.jar
jsoup.loc = ${maven2.repo}/org/jsoup/jsoup/${jsoup.version}
Modified: jmeter/trunk/build.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/build.xml?rev=1709921&r1=1709920&r2=1709921&view=diff
==============================================================================
--- jmeter/trunk/build.xml (original)
+++ jmeter/trunk/build.xml Wed Oct 21 21:26:58 2015
@@ -391,6 +391,8 @@
<include name="${lib.dir}/${jodd-core.jar}"/>
<include name="${lib.dir}/${jodd-lagarto.jar}"/>
<include name="${lib.dir}/${jodd-log.jar}"/>
+ <include name="${lib.dir}/${json-path}"/>
+ <include name="${lib.dir}/${json-smart}"/>
<include name="${lib.dir}/${jsoup.jar}"/>
<include name="${lib.dir}/${junit.jar}"/>
<include name="${lib.dir}/${logkit.jar}"/>
@@ -466,6 +468,8 @@
<pathelement location="${lib.dir}/${jodd-core.jar}"/>
<pathelement location="${lib.dir}/${jodd-lagarto.jar}"/>
<pathelement location="${lib.dir}/${jodd-log.jar}"/>
+ <pathelement location="${lib.dir}/${json-path.jar}"/>
+ <pathelement location="${lib.dir}/${json-smart}"/>
<pathelement location="${lib.dir}/${jsoup.jar}"/>
<pathelement location="${lib.dir}/${junit.jar}"/>
<pathelement location="${lib.dir}/${logkit.jar}"/>
@@ -2846,6 +2850,8 @@ run JMeter unless all the JMeter jars ar
<process_jarfile jarname="jodd-core"/>
<process_jarfile jarname="jodd-lagarto"/>
<process_jarfile jarname="jodd-log"/>
+ <process_jarfile jarname="json-path"/>
+ <process_jarfile jarname="json-smart"/>
<process_jarfile jarname="jsoup"/>
<process_jarfile jarname="junit"/>
<process_jarfile jarname="logkit"/>
Added: jmeter/trunk/docs/images/screenshots/json-post-processor.png
URL: http://svn.apache.org/viewvc/jmeter/trunk/docs/images/screenshots/json-post-processor.png?rev=1709921&view=auto
==============================================================================
Binary file - no diff available.
Propchange: jmeter/trunk/docs/images/screenshots/json-post-processor.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: jmeter/trunk/eclipse.classpath
URL: http://svn.apache.org/viewvc/jmeter/trunk/eclipse.classpath?rev=1709921&r1=1709920&r2=1709921&view=diff
==============================================================================
--- jmeter/trunk/eclipse.classpath (original)
+++ jmeter/trunk/eclipse.classpath Wed Oct 21 21:26:58 2015
@@ -75,6 +75,8 @@
<classpathentry kind="lib" path="lib/jodd-core-3.6.6.jar"/>
<classpathentry kind="lib" path="lib/jodd-lagarto-3.6.6.jar"/>
<classpathentry kind="lib" path="lib/jodd-log-3.6.6.jar"/>
+ <classpathentry kind="lib" path="lib/json-path-2.0.0.jar"/>
+ <classpathentry kind="lib" path="lib/json-smart-2.2.jar"/>
<classpathentry kind="lib" path="lib/jsoup-1.8.2.jar"/>
<classpathentry kind="lib" path="lib/jtidy-r938.jar"/>
<classpathentry kind="lib" path="lib/junit-4.12.jar"/>
Added: jmeter/trunk/licenses/bin/json-path-2.0.0.txt
URL: http://svn.apache.org/viewvc/jmeter/trunk/licenses/bin/json-path-2.0.0.txt?rev=1709921&view=auto
==============================================================================
--- jmeter/trunk/licenses/bin/json-path-2.0.0.txt (added)
+++ jmeter/trunk/licenses/bin/json-path-2.0.0.txt Wed Oct 21 21:26:58 2015
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
Propchange: jmeter/trunk/licenses/bin/json-path-2.0.0.txt
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jmeter/trunk/licenses/bin/json-smart-2.2.txt
URL: http://svn.apache.org/viewvc/jmeter/trunk/licenses/bin/json-smart-2.2.txt?rev=1709921&view=auto
==============================================================================
--- jmeter/trunk/licenses/bin/json-smart-2.2.txt (added)
+++ jmeter/trunk/licenses/bin/json-smart-2.2.txt Wed Oct 21 21:26:58 2015
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
\ No newline at end of file
Propchange: jmeter/trunk/licenses/bin/json-smart-2.2.txt
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: jmeter/trunk/res/maven/ApacheJMeter_parent.pom
URL: http://svn.apache.org/viewvc/jmeter/trunk/res/maven/ApacheJMeter_parent.pom?rev=1709921&r1=1709920&r2=1709921&view=diff
==============================================================================
--- jmeter/trunk/res/maven/ApacheJMeter_parent.pom (original)
+++ jmeter/trunk/res/maven/ApacheJMeter_parent.pom Wed Oct 21 21:26:58 2015
@@ -86,6 +86,8 @@ under the License.
<jodd-core.version>3.6.6</jodd-core.version>
<jodd-lagarto.version>3.6.6</jodd-lagarto.version>
<jodd-log.version>3.6.6</jodd-log.version>
+ <json-path.version>2.0.0</json-path.version>
+ <json-smart.version>2.2</json-smart.version>
<jsoup.version>1.8.2</jsoup.version>
<rhino.version>1.7.7</rhino.version>
<junit.version>4.12</junit.version>
@@ -375,6 +377,16 @@ under the License.
<version>${jms.version}</version>
</dependency>
<dependency>
+ <groupId>com.jayway.jsonpath</groupId>
+ <artifactId>json-path</artifactId>
+ <version>${json-path.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>net.minidev</groupId>
+ <artifactId>json-smart</artifactId>
+ <version>${json-smart.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>${jsoup.version}</version>
Added: jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/JSONManager.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/JSONManager.java?rev=1709921&view=auto
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/JSONManager.java (added)
+++ jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/JSONManager.java Wed Oct 21 21:26:58 2015
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.extractor.json.jsonpath;
+
+import java.text.ParseException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.jayway.jsonpath.JsonPath;
+
+/**
+ * Handles the extractions
+ * https://github.com/jayway/JsonPath/blob/master/json-path/src/test/java/com/jayway/jsonpath/ComplianceTest.java
+ * @since 2.14
+ */
+public class JSONManager {
+ /**
+ * This Map can hardly grow above 10 elements as it is used within JSONPostProcessor to
+ * store the computed JsonPath for the set of JSON Path Expressions.
+ * Usually there will be 1 to Maximum 10 elements
+ */
+ private Map<String, JsonPath> expressionToJsonPath = new HashMap<String, JsonPath>(
+ 2);
+
+ private JsonPath getJsonPath(String jsonPathExpression) {
+ JsonPath jsonPath = expressionToJsonPath.get(jsonPathExpression);
+ if (jsonPath == null) {
+ jsonPath = JsonPath.compile(jsonPathExpression);
+ expressionToJsonPath.put(jsonPathExpression, jsonPath);
+ }
+
+ return jsonPath;
+ }
+
+ public void reset() {
+ expressionToJsonPath.clear();
+ }
+
+ /**
+ *
+ * @param jsonString JSON String from which data is extracted
+ * @param jsonPath JSON-PATH expression
+ * @return List of String extracted data
+ * @throws ParseException
+ */
+ public List<String> extractWithJsonPath(String jsonString, String jsonPath)
+ throws ParseException {
+ JsonPath jsonPathParser = getJsonPath(jsonPath);
+ return jsonPathParser.read(jsonString);
+ }
+}
Propchange: jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/JSONManager.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/JSONPostProcessor.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/JSONPostProcessor.java?rev=1709921&view=auto
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/JSONPostProcessor.java (added)
+++ jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/JSONPostProcessor.java Wed Oct 21 21:26:58 2015
@@ -0,0 +1,240 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.extractor.json.jsonpath;
+
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.jmeter.processor.PostProcessor;
+import org.apache.jmeter.samplers.SampleResult;
+import org.apache.jmeter.testelement.AbstractScopedTestElement;
+import org.apache.jmeter.testelement.ThreadListener;
+import org.apache.jmeter.threads.JMeterContext;
+import org.apache.jmeter.threads.JMeterVariables;
+import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.jorphan.util.JOrphanUtils;
+import org.apache.log.Logger;
+
+/**
+ * JSON-PATH based extractor
+ * @since 2.14
+ */
+public class JSONPostProcessor extends AbstractScopedTestElement implements Serializable, PostProcessor, ThreadListener{
+
+ private static final long serialVersionUID = 1320798545214331506L;
+ private static final Logger log = LoggingManager.getLoggerForClass();
+
+ private static final String JSON_PATH_EXPRESSIONS = "JSONPostProcessor.jsonPathExprs"; // $NON-NLS-1$
+ private static final String REFERENCE_NAMES = "JSONPostProcessor.referenceNames"; // $NON-NLS-1$
+ private static final String DEFAULT_VALUES = "JSONPostProcessor.defaultValues"; // $NON-NLS-1$
+ private static final String MATCH_NUMBERS = "JSONPostProcessor.match_numbers"; // $NON-NLS-1$
+ private static final String COMPUTE_CONCATENATION = "JSONPostProcessor.compute_concat"; // $NON-NLS-1$
+ private static final String REF_MATCH_NR = "_matchNr"; // $NON-NLS-1$
+ private static final String ALL_SUFFIX = "_ALL"; // $NON-NLS-1$
+
+ private static final String JSON_CONCATENATION_SEPARATOR = ","; //$NON-NLS-1$
+ private static final String SEPARATOR = ";"; // $NON-NLS-1$
+ public static final boolean COMPUTE_CONCATENATION_DEFAULT_VALUE = false;
+
+ private static final ThreadLocal<JSONManager> localMatcher = new ThreadLocal<JSONManager>() {
+ @Override
+ protected JSONManager initialValue() {
+ return new JSONManager();
+ }
+ };
+ public void process() {
+ JMeterContext context = getThreadContext();
+ JMeterVariables vars = context.getVariables();
+ String jsonResponse = "";
+ if (isScopeVariable()){
+ jsonResponse = vars.get(getVariableName());
+ if(log.isDebugEnabled()) {
+ log.debug("JSON Extractor is using variable:"+getVariableName()+" which content is:"+jsonResponse);
+ }
+ } else {
+ SampleResult previousResult = context.getPreviousResult();
+ if (previousResult == null) {
+ return;
+ }
+ jsonResponse = previousResult.getResponseDataAsString();
+ if(log.isDebugEnabled()) {
+ log.debug("JSON Extractor "+getName()+" working on Response:"+jsonResponse);
+ }
+ }
+ String[] refNames = getRefNames().split(SEPARATOR);
+ String[] jsonPathExpressions = getJsonPathExpressions().split(SEPARATOR);
+ String[] defaultValues = getDefaultValues().split(SEPARATOR);
+ int[] matchNumbers = getMatchNumbersAsInt(defaultValues.length);
+
+ //jsonResponse = jsonResponse.replaceAll("'", "\""); // $NON-NLS-1$ $NON-NLS-2$
+
+ if (refNames.length != jsonPathExpressions.length ||
+ refNames.length != defaultValues.length) {
+ log.error("Number of JSON Path variables must match number of default values and json-path expressions, check you use separator ';' if you have many values"); // $NON-NLS-1$
+ throw new IllegalArgumentException(JMeterUtils.getResString("jsonpp_error_number_arguments_mismatch_error")); // $NON-NLS-1$
+ } else {
+ for (int i = 0; i < jsonPathExpressions.length; i++) {
+ int matchNumber = matchNumbers[i];
+ String currentRefName = refNames[i].trim();
+ String currentJsonPath = jsonPathExpressions[i].trim();
+ try {
+ if(jsonResponse.isEmpty()) {
+ vars.put(currentRefName, defaultValues[i]);
+ } else {
+
+ List<String> extractedValues = localMatcher.get().extractWithJsonPath(jsonResponse, currentJsonPath);
+ // if no values extracted, default value added
+ if (extractedValues.isEmpty()) {
+ vars.put(currentRefName, defaultValues[i]);
+ vars.put(currentRefName+REF_MATCH_NR, "0"); //$NON-NLS-1$
+ if(matchNumber<0 && getComputeConcatenation()) {
+ log.debug("No value extracted, storing empty in :"+currentRefName + ALL_SUFFIX); //$NON-NLS-1$
+ vars.put(currentRefName + ALL_SUFFIX, "");
+ }
+ } else {
+ // if more than one value extracted, suffix with
+ // "_index"
+ if (extractedValues.size() > 1) {
+ if(matchNumber<0) {
+ // Extract all
+ int index = 1;
+ StringBuilder concat = new StringBuilder(getComputeConcatenation()?extractedValues.size()*20:1);
+ for (String stringExtracted : extractedValues) {
+ vars.put(currentRefName + "_" + index, stringExtracted);
+ if(getComputeConcatenation()) {
+ concat.append(stringExtracted).append(JSONPostProcessor.JSON_CONCATENATION_SEPARATOR);
+ }
+ index++;
+ }
+ if(getComputeConcatenation()) {
+ concat.setLength(concat.length()-1);
+ vars.put(currentRefName + ALL_SUFFIX, concat.toString());
+ }
+ } else if (matchNumber == 0) {
+ // Random extraction
+ int matchSize = extractedValues.size();
+ vars.put(currentRefName, extractedValues.get(JMeterUtils.getRandomInt(matchSize)));
+ } else {
+ // extract at position
+ if(matchNumber>extractedValues.size()) {
+ if(log.isDebugEnabled()) {
+ log.debug("matchNumber("+matchNumber + ") exceeds number of items found("+extractedValues.size()+"), default value will be used");
+ }
+ vars.put(currentRefName, defaultValues[i]);
+ } else {
+ vars.put(currentRefName, extractedValues.get(matchNumber-1));
+ }
+ }
+ }
+ else {
+ // else just one value extracted
+ vars.put(currentRefName, extractedValues.get(0));
+ if(matchNumber<0 && getComputeConcatenation()) {
+ vars.put(currentRefName + ALL_SUFFIX, extractedValues.get(0));
+ }
+ }
+ vars.put(currentRefName+REF_MATCH_NR, Integer.toString(extractedValues.size()));
+ }
+ }
+ } catch (Exception e) {
+ // if something wrong, default value added
+ if (log.isDebugEnabled()) {
+ log.error("Error processing JSON content in "+ getName()+", message:"+e.getLocalizedMessage(),e);
+ } else {
+ log.error("Error processing JSON content in "+ getName()+", message:"+e.getLocalizedMessage());
+
+ }
+ vars.put(currentRefName, defaultValues[i]);
+ continue;
+ }
+ }
+ }
+ }
+
+
+ public String getJsonPathExpressions() {
+ return getPropertyAsString(JSON_PATH_EXPRESSIONS);
+ }
+
+ public void setJsonPathExpressions(String jsonPath) {
+ setProperty(JSON_PATH_EXPRESSIONS, jsonPath);
+ }
+
+ public String getRefNames() {
+ return getPropertyAsString(REFERENCE_NAMES);
+ }
+
+ public void setRefNames(String refName) {
+ setProperty(REFERENCE_NAMES, refName);
+ }
+
+ public String getDefaultValues() {
+ return getPropertyAsString(DEFAULT_VALUES);
+ }
+
+ public void setDefaultValues(String defaultValue) {
+ setProperty(DEFAULT_VALUES, defaultValue, ""); // $NON-NLS-1$
+ }
+
+
+ public boolean getComputeConcatenation() {
+ return getPropertyAsBoolean(COMPUTE_CONCATENATION, COMPUTE_CONCATENATION_DEFAULT_VALUE);
+ }
+
+ public void setComputeConcatenation(boolean computeConcatenation) {
+ setProperty(COMPUTE_CONCATENATION, computeConcatenation, COMPUTE_CONCATENATION_DEFAULT_VALUE);
+ }
+
+ @Override
+ public void threadStarted() {
+ // NOOP
+ }
+
+ @Override
+ public void threadFinished() {
+ localMatcher.get().reset();
+ }
+
+
+ public void setMatchNumbers(String matchNumber) {
+ setProperty(MATCH_NUMBERS, matchNumber);
+ }
+
+ public String getMatchNumbers() {
+ return getPropertyAsString(MATCH_NUMBERS);
+ }
+
+ public int[] getMatchNumbersAsInt(int arraySize) {
+
+ String matchNumbersAsString = getMatchNumbers();
+ int[] result = new int[arraySize];
+ if(JOrphanUtils.isBlank(matchNumbersAsString)) {
+ Arrays.fill(result, 0);
+ } else {
+ String[] matchNumbersAsStringArray =
+ matchNumbersAsString.split(SEPARATOR);
+ for (int i = 0; i < matchNumbersAsStringArray.length; i++) {
+ result[i] = Integer.parseInt(matchNumbersAsStringArray[i].trim());
+ }
+ }
+ return result;
+ }
+}
Propchange: jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/JSONPostProcessor.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/gui/JSONPostProcessorGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/gui/JSONPostProcessorGui.java?rev=1709921&view=auto
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/gui/JSONPostProcessorGui.java (added)
+++ jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/gui/JSONPostProcessorGui.java Wed Oct 21 21:26:58 2015
@@ -0,0 +1,186 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.extractor.json.jsonpath.gui;
+
+import java.awt.BorderLayout;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.util.List;
+
+import javax.swing.Box;
+import javax.swing.JCheckBox;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+
+import org.apache.jmeter.extractor.json.jsonpath.JSONPostProcessor;
+import org.apache.jmeter.processor.gui.AbstractPostProcessorGui;
+import org.apache.jmeter.testelement.TestElement;
+import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jorphan.gui.JLabeledTextField;
+
+/**
+ * GUI for {@link JSONPostProcessor}
+ * @since 2.14
+ */
+public class JSONPostProcessorGui extends AbstractPostProcessorGui {
+
+ private static final long serialVersionUID = -2845056031828291476L;
+
+ private JLabeledTextField defaultValuesField;
+ private JLabeledTextField jsonPathExpressionsField;
+ private JLabeledTextField refNamesField;
+ private JLabeledTextField matchNumbersField;
+ private JCheckBox computeConcatenationField;
+
+ public JSONPostProcessorGui() {
+ super();
+ init();
+ }
+
+
+ @Override
+ public String getLabelResource() {
+ return "json_post_processor_title";//$NON-NLS-1$
+ }
+
+ @Override
+ public void configure(TestElement element) {
+ super.configure(element);
+ JSONPostProcessor config = (JSONPostProcessor) element;
+ showScopeSettings(config, true);
+ refNamesField.setText(config.getRefNames());
+ jsonPathExpressionsField.setText(config.getJsonPathExpressions());
+ matchNumbersField.setText(config.getMatchNumbers());
+ defaultValuesField.setText(config.getDefaultValues());
+ computeConcatenationField.setSelected(config.getComputeConcatenation());
+ }
+
+ /**
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
+ */
+ @Override
+ public TestElement createTestElement() {
+ JSONPostProcessor config = new JSONPostProcessor();
+ modifyTestElement(config);
+ return config;
+ }
+
+ /**
+ * Modifies a given TestElement to mirror the data in the gui components.
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
+ */
+ @Override
+ public void modifyTestElement(TestElement c) {
+ super.configureTestElement(c);
+ if (c instanceof JSONPostProcessor) {
+ JSONPostProcessor config = (JSONPostProcessor) c;
+ saveScopeSettings(config);
+ config.setRefNames(refNamesField.getText());
+ config.setJsonPathExpressions(jsonPathExpressionsField.getText());
+ config.setDefaultValues(defaultValuesField.getText());
+ config.setMatchNumbers(matchNumbersField.getText());
+ config.setComputeConcatenation(computeConcatenationField.isSelected());
+ }
+ }
+
+ /**
+ * Implements JMeterGUIComponent.clearGui
+ */
+ @Override
+ public void clearGui() {
+ super.clearGui();
+ refNamesField.setText(""); //$NON-NLS-1$
+ jsonPathExpressionsField.setText(""); //$NON-NLS-1$
+ matchNumbersField.setText(""); //$NON-NLS-1$
+ defaultValuesField.setText(""); //$NON-NLS-1$
+ computeConcatenationField.setSelected(JSONPostProcessor.COMPUTE_CONCATENATION_DEFAULT_VALUE);
+ }
+
+ private void init() {
+
+ setLayout(new BorderLayout());
+ setBorder(makeBorder());
+
+ Box box = Box.createVerticalBox();
+ box.add(makeTitlePanel());
+ box.add(createScopePanel(true));
+ add(box, BorderLayout.NORTH);
+ add(makeParameterPanel(), BorderLayout.CENTER);
+
+ }
+
+ private JPanel makeParameterPanel() {
+ refNamesField = new JLabeledTextField(JMeterUtils.getResString("jsonpp_variable_names"));//$NON-NLS-1$
+ jsonPathExpressionsField = new JLabeledTextField(JMeterUtils.getResString("jsonpp_json_path_expressions"));//$NON-NLS-1$
+ matchNumbersField = new JLabeledTextField(JMeterUtils.getResString("jsonpp_match_numbers"));//$NON-NLS-1$
+ defaultValuesField = new JLabeledTextField(JMeterUtils.getResString("jsonpp_default_values"));//$NON-NLS-1$
+ computeConcatenationField = new JCheckBox();//$NON-NLS-1$
+ JPanel panel = new JPanel(new GridBagLayout());
+ GridBagConstraints gbc = new GridBagConstraints();
+ initConstraints(gbc);
+ addField(panel, refNamesField, gbc);
+ nextLine(gbc);
+ addField(panel, jsonPathExpressionsField, gbc);
+ nextLine(gbc);
+ addField(panel, matchNumbersField, gbc);
+ nextLine(gbc);
+ addField(panel, new JLabel(JMeterUtils.getResString("jsonpp_compute_concat")) ,computeConcatenationField, gbc);
+ nextLine(gbc);
+ gbc.weighty = 1;
+ addField(panel, defaultValuesField, gbc);
+ return panel;
+ }
+
+ private void addField(JPanel panel, JLabeledTextField field, GridBagConstraints gbc) {
+ List<JComponent> item = field.getComponentList();
+ panel.add(item.get(0), gbc.clone());
+ gbc.gridx++;
+ gbc.weightx = 1;
+ gbc.fill=GridBagConstraints.HORIZONTAL;
+ panel.add(item.get(1), gbc.clone());
+ }
+
+ private void addField(JPanel panel, JLabel label, JCheckBox checkBox, GridBagConstraints gbc) {
+ panel.add(label, gbc.clone());
+ gbc.gridx++;
+ gbc.weightx = 1;
+ gbc.fill=GridBagConstraints.HORIZONTAL;
+ panel.add(checkBox, gbc.clone());
+ }
+
+ private void nextLine(GridBagConstraints gbc) {
+ gbc.gridx = 0;
+ gbc.gridy++;
+ gbc.weightx = 0;
+ gbc.fill=GridBagConstraints.NONE;
+ }
+
+ private void initConstraints(GridBagConstraints gbc) {
+ gbc.anchor = GridBagConstraints.NORTHWEST;
+ gbc.fill = GridBagConstraints.NONE;
+ gbc.gridheight = 1;
+ gbc.gridwidth = 1;
+ gbc.gridx = 0;
+ gbc.gridy = 0;
+ gbc.weightx = 0;
+ gbc.weighty = 0;
+ }
+}
\ No newline at end of file
Propchange: jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/gui/JSONPostProcessorGui.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jmeter/trunk/src/components/org/apache/jmeter/extractor/json/render/RenderAsJsonRenderer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/extractor/json/render/RenderAsJsonRenderer.java?rev=1709921&view=auto
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/extractor/json/render/RenderAsJsonRenderer.java (added)
+++ jmeter/trunk/src/components/org/apache/jmeter/extractor/json/render/RenderAsJsonRenderer.java Wed Oct 21 21:26:58 2015
@@ -0,0 +1,255 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.extractor.json.render;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.text.ParseException;
+import java.util.List;
+
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
+import javax.swing.JTabbedPane;
+import javax.swing.JTextArea;
+import javax.swing.border.Border;
+import javax.swing.border.EmptyBorder;
+
+import org.apache.jmeter.extractor.json.jsonpath.JSONManager;
+import org.apache.jmeter.samplers.SampleResult;
+import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jmeter.visualizers.RenderAsJSON;
+import org.apache.jmeter.visualizers.ResultRenderer;
+import org.apache.jmeter.visualizers.ViewResultsFullVisualizer;
+import org.apache.jorphan.gui.GuiUtils;
+import org.apache.jorphan.gui.JLabeledTextField;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
+
+
+/**
+ * Implement ResultsRender for JSON Path tester
+ * @since 2.14
+ */
+public class RenderAsJsonRenderer implements ResultRenderer, ActionListener {
+
+ private static final Logger LOGGER = LoggingManager.getLoggerForClass();
+
+ private static final String TAB_SEPARATOR = " "; //$NON-NLS-1$
+
+ private static final String JSONPATH_TESTER_COMMAND = "jsonpath_tester"; // $NON-NLS-1$
+
+ private JPanel jsonWithJSonPathPanel;
+
+ private JTextArea jsonDataField;
+
+ private JLabeledTextField jsonPathExpressionField;
+
+ private JTextArea jsonPathResultField;
+
+ private JTabbedPane rightSide;
+
+ private SampleResult sampleResult;
+
+ private JScrollPane jsonDataPane;
+
+
+ /** {@inheritDoc} */
+ public void clearData() {
+ this.jsonDataField.setText(""); // $NON-NLS-1$
+ // don't set empty to keep json path
+ this.jsonPathResultField.setText(""); // $NON-NLS-1$
+ }
+
+ /** {@inheritDoc} */
+ public void init() {
+ // Create the panels for the json tab
+ jsonWithJSonPathPanel = createJSonPathExtractorPanel();
+ }
+
+ /**
+ * Display the response as text or as rendered HTML. Change the text on the
+ * button appropriate to the current display.
+ *
+ * @param e the ActionEvent being processed
+ */
+ public void actionPerformed(ActionEvent e) {
+ String command = e.getActionCommand();
+ if ((sampleResult != null) && (JSONPATH_TESTER_COMMAND.equals(command))) {
+ String response = jsonDataField.getText();
+ executeAndShowXPathTester(response);
+ }
+ }
+
+ /**
+ * Launch json path engine to parse a input text
+ * @param textToParse
+ */
+ private void executeAndShowXPathTester(String textToParse) {
+ if (textToParse != null && textToParse.length() > 0
+ && this.jsonPathExpressionField.getText().length() > 0) {
+ this.jsonPathResultField.setText(process(textToParse));
+ this.jsonPathResultField.setCaretPosition(0); // go to first line
+ }
+ }
+
+ private String process(String textToParse) {
+ try {
+ List<String> matchStrings = extractWithJSonPath(textToParse, jsonPathExpressionField.getText());
+ if(matchStrings.size()==0) {
+ return "NO MATCH";
+ }
+ else {
+ StringBuilder builder = new StringBuilder();
+ int i=0;
+ for (String text : matchStrings) {
+ builder.append("Result[").append(i++).append("]=").append(text).append("\n");
+ }
+
+ return builder.toString();
+ }
+ } catch (Exception e) {
+ return "Exception:"+ e.getMessage();
+ }
+ }
+
+ private List<String> extractWithJSonPath(String textToParse, String expression) throws ParseException {
+ JSONManager jsonManager = new JSONManager();
+ return jsonManager.extractWithJsonPath(textToParse, expression);
+ }
+
+ /*================= internal business =================*/
+
+
+
+ /** {@inheritDoc} */
+ public void renderResult(SampleResult sampleResult) {
+ String response = ViewResultsFullVisualizer.getResponseAsString(sampleResult);
+ try {
+ jsonDataField.setText(response == null ? "" : RenderAsJSON.prettyJSON(response, TAB_SEPARATOR));
+ jsonDataField.setCaretPosition(0);
+ } catch (Exception e) {
+ LOGGER.error("Exception converting to XML:"+response+ ", message:"+e.getMessage(),e);
+ jsonDataField.setText("Exception converting to XML:"+response+ ", message:"+e.getMessage());
+ jsonDataField.setCaretPosition(0);
+ }
+ }
+
+
+ /** {@inheritDoc} */
+ @Override
+ public String toString() {
+ return JMeterUtils.getResString("jsonpath_renderer"); // $NON-NLS-1$
+ }
+
+
+ /** {@inheritDoc} */
+ public void setupTabPane() {
+ // Add json-path tester pane
+ if (rightSide.indexOfTab(JMeterUtils.getResString("jsonpath_tester_title")) < 0) { // $NON-NLS-1$
+ rightSide.addTab(JMeterUtils.getResString("jsonpath_tester_title"), jsonWithJSonPathPanel); // $NON-NLS-1$
+ }
+ clearData();
+ }
+
+ /**
+ * @return JSON PATH Tester panel
+ */
+ private JPanel createJSonPathExtractorPanel() {
+
+ jsonDataField = new JTextArea();
+ jsonDataField.setEditable(false);
+ jsonDataField.setLineWrap(true);
+ jsonDataField.setWrapStyleWord(true);
+
+ this.jsonDataPane = GuiUtils.makeScrollPane(jsonDataField);
+ jsonDataPane.setMinimumSize(new Dimension(0, 400));
+
+ JPanel panel = new JPanel(new BorderLayout(0, 5));
+
+ JSplitPane mainSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
+ jsonDataPane, createJSonPathExtractorTasksPanel());
+ mainSplit.setDividerLocation(400);
+ panel.add(mainSplit, BorderLayout.CENTER);
+ return panel;
+ }
+
+ /**
+ * Create the JSON PATH task pane
+ *
+ * @return JSON PATH task pane
+ */
+ private JPanel createJSonPathExtractorTasksPanel() {
+ JPanel jsonPathActionPanel = new JPanel();
+ jsonPathActionPanel.setLayout(new BoxLayout(jsonPathActionPanel, BoxLayout.X_AXIS));
+ Border margin = new EmptyBorder(5, 5, 0, 5);
+ jsonPathActionPanel.setBorder(margin);
+ jsonPathExpressionField = new JLabeledTextField(JMeterUtils.getResString("jsonpath_tester_field")); // $NON-NLS-1$
+ jsonPathActionPanel.add(jsonPathExpressionField, BorderLayout.WEST);
+
+ JButton xpathTester = new JButton(JMeterUtils.getResString("jsonpath_tester_button_test")); // $NON-NLS-1$
+ xpathTester.setActionCommand(JSONPATH_TESTER_COMMAND);
+ xpathTester.addActionListener(this);
+ jsonPathActionPanel.add(xpathTester, BorderLayout.EAST);
+
+ jsonPathResultField = new JTextArea();
+ jsonPathResultField.setEditable(false);
+ jsonPathResultField.setLineWrap(true);
+ jsonPathResultField.setWrapStyleWord(true);
+
+ JPanel xpathTasksPanel = new JPanel(new BorderLayout(0, 5));
+ xpathTasksPanel.add(jsonPathActionPanel, BorderLayout.NORTH);
+ xpathTasksPanel.add(GuiUtils.makeScrollPane(jsonPathResultField), BorderLayout.CENTER);
+
+ return xpathTasksPanel;
+ }
+
+ /** {@inheritDoc} */
+ public synchronized void setRightSide(JTabbedPane side) {
+ rightSide = side;
+ }
+
+ /** {@inheritDoc} */
+ public synchronized void setSamplerResult(Object userObject) {
+ if (userObject instanceof SampleResult) {
+ sampleResult = (SampleResult) userObject;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void setLastSelectedTab(int index) {
+ // nothing to do
+ }
+
+ /** {@inheritDoc} */
+ public void renderImage(SampleResult sampleResult) {
+ clearData();
+ jsonDataField.setText(JMeterUtils.getResString("jsonpath_render_no_text")); // $NON-NLS-1$
+ }
+
+ /** {@inheritDoc} */
+ public void setBackgroundColor(Color backGround) {
+ }
+
+}
Propchange: jmeter/trunk/src/components/org/apache/jmeter/extractor/json/render/RenderAsJsonRenderer.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsJSON.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsJSON.java?rev=1709921&r1=1709920&r2=1709921&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsJSON.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsJSON.java Wed Oct 21 21:26:58 2015
@@ -26,6 +26,7 @@ import org.apache.jmeter.samplers.Sample
import org.apache.jmeter.util.JMeterUtils;
public class RenderAsJSON extends SamplerResultTab implements ResultRenderer {
+ private static final String TAB_SEPARATOR = ": "; //$NON-NLS-1$
private static final String ESC_CHAR_REGEX = "\\\\[\"\\\\/bfnrt]|\\\\u[0-9A-Fa-f]{4}"; // $NON-NLS-1$
@@ -56,10 +57,25 @@ public class RenderAsJSON extends Sample
// It might be useful also to make this available in the 'Request' tab, for
// when posting JSON.
- private static String prettyJSON(String json) {
+ /**
+ * Pretty-print JSON text
+ * @param json input text
+ * @return prettyfied json
+ */
+ public static String prettyJSON(String json) {
+ return prettyJSON(json, RenderAsJSON.TAB_SEPARATOR);
+ }
+
+ /**
+ * Pretty-print JSON text
+ * @param json input text
+ * @param tabSeparator String tab separator
+ * @return prettyfied json
+ */
+ public static String prettyJSON(String json, String tabSeparator) {
StringBuilder pretty = new StringBuilder(json.length() * 2); // Educated guess
- final String tab = ": "; // $NON-NLS-1$
+ final String tab = tabSeparator; // $NON-NLS-1$
StringBuilder index = new StringBuilder();
String nl = ""; // $NON-NLS-1$
Modified: jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties?rev=1709921&r1=1709920&r2=1709921&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties Wed Oct 21 21:26:58 2015
@@ -520,6 +520,18 @@ jndi_method_remote_parms=Remote Method P
jndi_method_title=Remote Method Configuration
jndi_testing_title=JNDI Request
jndi_url_jndi_props=JNDI Properties
+jsonpath_renderer=JSON Path Tester
+jsonpath_tester_title=JSON Path Tester
+jsonpath_tester_field=JSON Path Expression
+jsonpath_tester_button_test=Test
+jsonpath_render_no_text=No Text
+json_post_processor_title=JSON Path PostProcessor
+jsonpp_variable_names=Variable names
+jsonpp_json_path_expressions=JSON Path expressions
+jsonpp_default_values=Default Values
+jsonpp_match_numbers=Match Numbers
+jsonpp_compute_concat=Compute concatenation var (suffix _ALL)
+jsonpp_error_number_arguments_mismatch_error=Mismatch between number of variables, json expressions and default values
junit_append_error=Append assertion errors
junit_append_exception=Append runtime exceptions
junit_constructor_error=Unable to create an instance of the class
Modified: jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties?rev=1709921&r1=1709920&r2=1709921&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties Wed Oct 21 21:26:58 2015
@@ -513,6 +513,18 @@ jndi_method_remote_parms=Param\u00E8tres
jndi_method_title=Configuration m\u00E9thode remote
jndi_testing_title=Requ\u00EAte JNDI
jndi_url_jndi_props=Propri\u00E9t\u00E9s JNDI
+jsonpath_renderer=Testeur JSON Path
+jsonpath_tester_title=Testeur JSON Path
+jsonpath_tester_field=Expression JSON Path
+jsonpath_tester_button_test=Tester
+jsonpath_render_no_text=Pas de Texte
+json_post_processor_title=Extracteur JSON Path
+jsonpp_variable_names=Noms des variables
+jsonpp_json_path_expressions=Expressions JSON Path
+jsonpp_default_values=Valeure par d\u00E9fault
+jsonpp_match_numbers=Nombre de correspondances
+jsonpp_compute_concat=Calculer la variable de concat\u00E9nation (suffix _ALL)
+jsonpp_error_number_arguments_mismatch_error=D\u00E9calage entre nombre de variables, expressions et valeurs par d\u00E9faut
junit_append_error=Concat\u00E9ner les erreurs d'assertion
junit_append_exception=Concat\u00E9ner les exceptions d'ex\u00E9cution
junit_constructor_error=Impossible de cr\u00E9er une instance de la classe
Modified: jmeter/trunk/src/core/org/apache/jmeter/save/SaveService.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/save/SaveService.java?rev=1709921&r1=1709920&r2=1709921&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/save/SaveService.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/save/SaveService.java Wed Oct 21 21:26:58 2015
@@ -177,7 +177,7 @@ public class SaveService {
// Must match _version property value in saveservice.properties
// used to ensure saveservice.properties and SaveService are updated simultaneously
- static final String PROPVERSION = "2.8";// Expected version $NON-NLS-1$
+ static final String PROPVERSION = "2.9";// Expected version $NON-NLS-1$
// Internal information only
private static String fileVersion = ""; // read from saveservice.properties file// $NON-NLS-1$
Modified: jmeter/trunk/test/src/org/apache/jmeter/visualizers/TestRenderAsJson.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/visualizers/TestRenderAsJson.java?rev=1709921&r1=1709920&r2=1709921&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/visualizers/TestRenderAsJson.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/visualizers/TestRenderAsJson.java Wed Oct 21 21:26:58 2015
@@ -57,7 +57,7 @@ public class TestRenderAsJson extends Te
}
@Test
- public void testRenderResultSimpleStructur() throws Exception {
+ public void testRenderResultSimpleStructure() throws Exception {
assertEquals(
"{\n" + TAB + "\"Hello\": \"World\", \n" + TAB + "\"more\": \n"
+ TAB + "[\n" + TAB + TAB + "\"Something\", \n" + TAB
Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1709921&r1=1709920&r2=1709921&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Wed Oct 21 21:26:58 2015
@@ -110,6 +110,7 @@ Summary
<h3>Timers, Assertions, Config, Pre- & Post-Processors</h3>
<ul>
<li><bug>58303</bug>Change usage of bouncycastle api in SMIMEAssertion to get rid of deprecation warnings.</li>
+ <li><bug>58515</bug>New JSON related components : JSON-PATH Extractor and JSON-PATH Renderer in View Results Tree</li>
</ul>
<h3>Functions</h3>
Added: jmeter/trunk/xdocs/images/screenshots/json-post-processor.png
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/images/screenshots/json-post-processor.png?rev=1709921&view=auto
==============================================================================
Binary file - no diff available.
Propchange: jmeter/trunk/xdocs/images/screenshots/json-post-processor.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: jmeter/trunk/xdocs/usermanual/component_reference.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=1709921&r1=1709920&r2=1709921&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jmeter/trunk/xdocs/usermanual/component_reference.xml Wed Oct 21 21:26:58 2015
@@ -2957,6 +2957,9 @@ may download images, style-sheets, etc.
<tr><td><code>JSON</code></td>
<td>The <i>JSON view</i> will show the response in tree style (also handles JSON embedded in JavaScript).
<br/></td></tr>
+<tr><td><code>JSON Path Tester</code></td>
+<td>The <i>JSON Path Tester view</i> will let you test your JSON-PATH expressions and see the extracted data from a particular response.
+<br/></td></tr>
<tr><td><code>Regexp Tester</code></td>
<td>The <i>Regexp Tester view</i> only works for text responses. It shows the plain text in the upper panel.
The "<code>Test</code>" button allows the user to apply the Regular Expression to the upper panel and the results
@@ -6078,6 +6081,33 @@ In the linked test plan, "<code>JDBC Pos
</p>
<figure width="818" height="399" image="jdbc-post-processor.png">JDBC PostProcessor</figure>
</component>
+
+<component name="JSON Path PostProcessor" index="§-num;.8.9">
+<description>
+<p>
+The JSON PostProcessor enables you extract data from JSON responses using JSON-PATH syntax. This post processor is very similar to Regular expression extractor.
+It must be placed as a child of HTTP Sampler or any other sampler that has responses.
+It will alow you to extract in a very easy way text content, see <a href="http://goessner.net/articles/JsonPath/" >JSON Path syntax</a>.
+
+</p>
+</description>
+<properties>
+ <property name="Name" required="No">Descriptive name for this element that is shown in the tree.</property>
+ <property name="Variable Names" required="Yes">Semi-colon separated names of variables that will contain the results of JSON-PATH expressions (must match number of JSON-PATH expressions)</property>
+ <property name="JSON Path Expressions" required="Yes">Semi-colon separated JSON-PATH expressions (must match number of variables)</property>
+ <property name="Default Values" required="No">Semi-colon separated default values if JSON-PATH expressions do not return any result(must match number of variables)</property>
+ <property name="Match Numbers" required="No">If the JSON Path query leads to many results, you can choose which one(s) to extract as Variables:
+ <ul>
+ <li><code>0</code> : means random (Default Value)</li>
+ <li><code>-1</code> means extract all results, they will be named as <code><em>variable name</em>_N</code> (where N goes from 1 to Number of results</li>
+ <li><code>X</code> : means extract the X<sup>th</sup> result. If this X<sup>th</sup> is greater than number of matches, then nothing is returned. Default value will be used</li>
+ </ul>
+ </property>
+ <property name="Compute concatenation var" required="No">If many results are found, plugin will concat them using â,â separator and store it a var named <code><em><variable name></em>_ALL</code></property>
+</properties>
+<figure width="855" height="276" image="json-post-processor.png">JSON PostProcessor</figure>
+</component>
+
</section>
<section name="§-num;.9 Miscellaneous Features" anchor="Miscellaneous_Features">
|