JSON Format Post Processor changed the behavior of

438 views
Skip to first unread message

wuy...@gmail.com

unread,
May 7, 2016, 6:18:03 PM5/7/16
to jmeter-plugins
I have a RESTful API, it will return HTTP status 404 in some situations. I also have a response assertion to check if its status is 200.
it works as what I expected and stop at this request because I set Jmter to stop if it has an error, 

but with JSON Format Post Processor, the test plan didn't stop. and I didn't see the result in the view result tree.
Of course if the response return 404 error, the response message is not a JSON data.

Andrey Pokhilko

unread,
May 9, 2016, 2:51:05 AM5/9/16
to jmeter-plugins, wuy...@gmail.com
Hi,

Most likely, there is some "hard" error happens, please look into jmeter.log file and post here any error with its full stacktrace and couple of lines before.

--
Andrey

воскресенье, 8 мая 2016 г., 1:18:03 UTC+3 пользователь wuy...@gmail.com написал:

Justin Wu

unread,
May 9, 2016, 2:59:43 PM5/9/16
to Andrey Pokhilko, jmeter-plugins
The jmeter log about it:

2016/05/09 14:54:11 ERROR - jmeter.threads.JMeterThread: Error while processing sampler 'get portfolio result' : net.sf.json.JSONException: A JSONObject text must begin with '{' at character 1 of <html><head><title>Apache Tomcat/7.0.55 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 404 - Not Found</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>Not Found</u></p><p><b>description</b> <u>The requested resource is not available.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.55</h3></body></html>
at net.sf.json.util.JSONTokener.syntaxError(JSONTokener.java:499)
at net.sf.json.JSONObject._fromJSONTokener(JSONObject.java:972)
at net.sf.json.JSONObject._fromString(JSONObject.java:1201)
at net.sf.json.JSONObject.fromObject(JSONObject.java:165)
at net.sf.json.JSONObject.fromObject(JSONObject.java:134)
at com.atlantbh.jmeter.plugins.jsonutils.jsonformatter.JSONFormatter.formatJSON(JSONFormatter.java:35)
at com.atlantbh.jmeter.plugins.jsonutils.jsonformatter.JSONFormatter.process(JSONFormatter.java:43)
at org.apache.jmeter.threads.JMeterThread.runPostProcessors(JMeterThread.java:750)
at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:452)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:261)
at java.lang.Thread.run(Unknown Source)

Justin Wu

unread,
May 9, 2016, 3:16:16 PM5/9/16
to Andrey Pokhilko, jmeter-plugins
My version is :
jmeter-2.13_with1.4ExtrasLibs

Andrey Pokhilko

unread,
May 10, 2016, 3:16:07 AM5/10/16
to jmeter-plugins, ap...@ya.ru, wuy...@gmail.com
You should not use JSON Format Post processor. It is not meant to change response status. It just formats JSON, and it implies that the response is JSON.

Instead, you should use JSONPath Assertion, which would change the response status: http://jmeter-plugins.org/wiki/JSONPathAssertion/

--
Andrey

понедельник, 9 мая 2016 г., 21:59:43 UTC+3 пользователь Justin Wu написал:

Wuyg719

unread,
May 10, 2016, 7:58:35 AM5/10/16
to Andrey Pokhilko, jmeter-plugins
Normally my API will return a Json data, so I will see Json data in beautiful format with this post processor. But server side sometimes screwed up, so I am asking if it is not Json data, then the processor should ignore it, not to change the behavior of assertion.
 It seems it cross multiple functions: it is post processor and result assertion.

Sent from my iPhone

Andrey Pokhilko

unread,
May 10, 2016, 9:30:49 AM5/10/16
to jmeter-plugins, ap...@ya.ru, wuy...@gmail.com
What you say makes sense. I have committed the fix for it, it will not break on invalid JSON anymore: https://github.com/undera/jmeter-plugins/commit/7cc6453be585a341aa8b1a295c363a2d3a033af2

I hope you use Plugins Manager (http://jmeter-plugins.org/wiki/PluginsManager/). This fix will appear as update for JSON plugins in 1-2 hours, you'll be able to install and use it. That's the benefit of new plugins manager, we can release changes very-very fast.

--
Andrey

вторник, 10 мая 2016 г., 14:58:35 UTC+3 пользователь Wuyg719 написал:

Wuyg719

unread,
May 10, 2016, 10:27:48 AM5/10/16
to Andrey Pokhilko, jmeter-plugins
Thanks very much.

Sent from my iPhone

Justin Wu

unread,
May 13, 2016, 11:53:47 AM5/13/16
to Andrey Pokhilko, jmeter-plugins
Hi Andrey,

I have installed JMeter Plugins Manager version 0.5, but the apply button is disabled:

Inline image 1
Do you know how to enable it?

Sincerely
Justin

Andrey Pokhilko

unread,
May 13, 2016, 2:00:47 PM5/13/16
to jmeter-plugins, ap...@ya.ru, wuy...@gmail.com
You need to choose newer version from "Versions" combo-box.

--
Andrey

пятница, 13 мая 2016 г., 18:53:47 UTC+3 пользователь Justin Wu написал:

Justin Wu

unread,
May 13, 2016, 3:40:04 PM5/13/16
to Andrey Pokhilko, jmeter-plugins
updating is working

Also  jsonFormat is fixed.


 Thanks very much!!!
Reply all
Reply to author
Forward
0 new messages