xframium / xframium-java

xFramium - Rapid unified test case development
http://www.xframium.org
GNU General Public License v3.0
12 stars 18 forks source link

Restful service with JSON response throwing Classcastexception #52

Closed shivajibr closed 7 years ago

shivajibr commented 7 years ago

On calling a restful service with a JSON response get below class cast exception on processing JSON response

Caused by: java.lang.ClassCastException: net.minidev.json.JSONArray cannot be cast to java.lang.String at org.xframium.utility.WebServiceClientUtil.processResult(WebServiceClientUtil.java:544) at org.xframium.utility.WebServiceClientUtil.callWebService(WebServiceClientUtil.java:83) ... 20 more

Below is the sample test against which the error is happening:

If the below code is type casted then the error goes off

String value = ctx.read( param.path ); contextMap.put( param.name, value );

Changing it to below code has resolved the issue:

JSONArray value = (JSONArray)ctx.read( param.path ); contextMap.put( param.name, value.toJSONString() );

xframium commented 7 years ago

Resolved