Ask a Question

Re: Groovy for assertion not contain and json path

SOLVED
master_ace85
Occasional Contributor

Re: Groovy for assertion not contain and json path

Hi ;

 

 

The code below was used to resolvean issue that I had experienced before. Now the issue is the same groovy script is not working inReadyApi groovy script but  it does and still works in SOAPUI

 

The same code is used to replicate

 

import static com.jayway.jsonpath.JsonPath.parse

def json = '''{"quote": {
	"id": "test_id",
	"amount": 100,
	"links":    [
			 {
		  "rel": "self",
		  "href": "http://localhost:8080/quote/777"
	   },
			 {
		  "rel": "customer",
		  "href": "http://localhost:8080/customer/12345"
	   }
	]
 }}
}'''

def quoteId = parse(json).read('$.quote.id')
log.info quoteId

 I get the above working fine in SOAPUI 5.3.0 but when I use the same script in ReadyAPI I get the following message: 

 

java.lang.NoClassDefFoundError: Could not initialize class net.minidev.json.JSONvalue error at ## (this would be the line that contains:

parse(json).read('$.quote.id')

 ) 

i read up another site that says it is missing the json-smart jar file but I confirmed that it is indeed in the lib installation dir of readyapi. I have even tried copying over SOAPUI's json-smart jar but it is an older version and it did not resolve my issue.

 

How can I resolve this? Surely this should be compatible or do I need to do something else?

 

7 REPLIES 7
nmrao
Community Hero

sanj
Super Contributor

Just a thought could it be a classpath issue.

master_ace85
Occasional Contributor

Thank you nmrao.

 

I have altered my script and it is working.

I was hoping to use the same code. It is strange that the original code works in SoapUI5.3.0 but refuses to workin in Ready Api

The script I provided should work in SoapUI 5.3 too. Have a check if you want.


Regards,
Rao.
master_ace85
Occasional Contributor

Hi Sanj.

 

It could possibly be an issue but I could not resolve it.

 

I have tried using the same jars that was used in Soapui but then other issues occur.

master_ace85
Occasional Contributor

The script you provided does indeed work.

 

I was just baffled why the one I had was not compatible.

You script uses "com.jayway.jsonpath.JsonPath" which is not part of native groovy-all-xxx.jar

Where as "groovy.json.JsonSlurper" is part of native groovy library. And it appears that the other library might be removed in the ReadyAPI, hence not working.


Regards,
Rao.
cancel
Showing results for 
Search instead for 
Did you mean: