ContributionsMost RecentMost LikesSolutionsRe: Script assertion using regex to get a value from the response header Thanks for your reply. The trick was escaping the special characters in the regex portion & reworking the code a bit def Detail = messageExchange.responseHeaders["WEBAPI_RESPONSE_DETAIL"] log.info("Detail: "+ Detail) def regEx = ".*ProcessingMilliseconds\":([0-9\\.]*).*" slaheader = ( Detail[0] =~ regEx ) log.info ('slaheader ' + slaheader[0][1]) Script assertion using regex to get a value from the response header Hello- I have SoapUI NG & I'm attempting to extract one piece of info from the response header within an assertion script using regex, but I'm not getting the desired result. Any guidance would be great! The response header called 'WEBAPI_RESPONSE_DETAIL' contains the following: {"ProcessingMilliseconds":1.34,"ResponseCount":1,"ProcessingMachine":"QAC1","ApplicationVersion":"2.1.766.10728","BuildNumber":"2.1.766.10728","EnvironmentName":"QA","MethodName":"/MemberStore/123/2.1/Routers/QualifiedQuotas"} I'm only interested in the value for ProcessingMilliseconds (so in this example, 1.34). My assertion script is the following: def Details = messageExchange.responseHeaders["WEBAPI_RESPONSE_DETAIL"] log.info("Details: "+ Details) def regEx1 = ~/.*ProcessingMilliseconds":([0-9\.]*).*/ def sla = Details[0].replaceAll(regEx1,'') log.info("sla: " + sla) When I run the assertion, I get nothing back. Any ideas what I might be doing wrong? Feature for comparing datasources Would be helpful & efficient if there was a simpler way to compare datasources, especially when working with large data sets where multiple calls to db/json wouldnt be practical. Scenario - Taking the results of a jdbc query & putting it into a datasource file. Then taking the results of a json query & putting that into a datasource file. Now compare the 2 datasource files to make sure the values match. Re: comparing 2 datasources ~nmrao I was following your suggestion in the stackoverflow post & running into an issue with the groovy script. I have ReadyAPI Pro, and like the original person who posted, was trying to compare 2 datasources, so tried using your script to solve the issue. My test case consists of: Jdbc step called JDBCRequest (retrieving the BrandGroupID from the db which should match the data in step 2). Should this step really be the JDBC response parsed to a Datasource? Sample of response data: <Row rowNumber="1"> <BRANDGROUPID>2</BRANDGROUPID> </Row> <Row rowNumber="2"> <BRANDGROUPID>4</BRANDGROUPID> </Row> 2. Json step called GetAllBrandGroups (returns many data points but the only one i'm interested in is the BrandGroupID ). Should this step really be the Json response parsed to a Datasource? Sample of response data: { "UniqueID": "g6s6c7A072Lm2thUjFKdqk8uAE4E41107", "IsUniqueIDEncrypted": true, "BrandGroupID": 2, "Brands": [ { "Name": "WrapperUnitTest_171_17_44_17_87672_628", "BrandUniqueID": "RLHlzWV072rBuAPIFfp2tE2I4QE4E41107", "BrandID": 18685 }], "Name": "WrapperUnitTest_171_17_44_17_884", "Owner": "Wrapper.Unit.Test", "OwnerType": 1 } 3. Groovy script step Now here is the script (below) that I fashioned after yours. Few questions : - In the object model, do I have to specify all the json datapoint/tags, even though I'm only interested in the BrandGroupID one? - I've added a log.info to see if the data is writing out on the jdbc, json - jdbc is not returning data. Is this syntax correct for a JDBC step: def jdbcResponse = context.expand('${JDBCRequest#Response}') -When I try to run the script, I'm receiving: org.xml.sax.SAXParseException; Premature end of file. error at line: 42, which is the script line: def results = new XmlSlurper().parseText(jdbcResponse). This is where I'm stuck. Script: /* * Model object for comparing */ @groovy.transform.Canonical class Model { def BrandGroupID //jdbc def buildJdbcData(row) { row.with { BrandGroupID = BRANDGROUPID } } //json def buildJsonData(tagInfo){ BrandGroupID = tagInfo.@BrandGroupID } } /* * Creating the jdbcResponse from the response received, using fixed value for testing * If you want, you can assign the response received directly using below instead of current and make sure you replace the step name correctly * def jdbcResponse = context.expand('${JdbcStepName#Response}') */ def jdbcResponse = context.expand('${JDBCRequest#Response}') log.info("jdbcResponse: " + jdbcResponse) //not returning any data /* * Creating the jsonResponse from the response received, using fixed value for testing * If you want, you can assign the response received directly using below instead of current and make sure you replace the step name correctly * def jsonResponse = context.expand('${JsonStepName#Response}') */ def jsonResponse = context.expand('${GetAllBrandGroups#Response}') log.info("jsonResponse: " + jsonResponse) //returning data //Parsing the jdbc and build the jdbc model object list def results = new XmlSlurper().parseText(jdbcResponse) def jdbcDataObjects = [] results.ResultSet.Row.each { row -> jdbcDataObjects.add(new Model().buildJdbcData(row)) } //Parsing the json and build the json model object list def arrayOfTagInfo = new XmlSlurper().parseText(jsonResponse) def jsonDataObjects = [] arrayOfTagInfo.TagInfo.each { tagInfo -> jsonDataObjects.add(new Model().buildJsonData(tagInfo)) } //sorting the Data before checking for equality jdbcDataObjects.sort() jsonDataObjects.sort() if (jdbcDataObjects.size() != jsonDataObjects.size()) { System.err.println("Jdbc resultset size is : ${jdbcDataObjects.size()} and Json result size is : ${jsonDataObjects.size()}") } assert jdbcDataObjects == jsonDataObjects, "Comparison of Jdbc and Json data has failed" Re: ASSERTION ( not implemented for json error message - SOAPUI NG (ready API 1.7) I'm seeing a similar issue in 1.7, where I try to add a new assertions via the assertion tab & am presented with a popup error: Failed to add assertion This was working fine in 1.6. Seems that it might be related to a page refresh issue - as a workaround, if I close that test step/request form, and reopen, its fine. It actually created the assertion, now I just need to define it. The error log is showing: Fri May 06 10:36:07 EDT 2016:ERROR:java.lang.NullPointerException java.lang.NullPointerException at com.eviware.soapui.impl.wsdl.panels.teststeps.RestTestRequestDesktopPanel$InternalAssertionsListener.assertionAdded(RestTestRequestDesktopPanel.java:242) at com.eviware.soapui.impl.wsdl.support.assertions.AssertionsSupport.fireAssertionAdded(AssertionsSupport.java:180) at com.eviware.soapui.impl.wsdl.support.assertions.AssertionsSupport.addWsdlAssertion(AssertionsSupport.java:302) at com.eviware.soapui.impl.wsdl.teststeps.RestTestRequest.addAssertion(RestTestRequest.java:182) at com.eviware.soapui.impl.wsdl.teststeps.RestTestRequest.addAssertion(RestTestRequest.java:1) at com.eviware.soapui.impl.wsdl.panels.assertions.AddAssertionPanel.handleOk(AddAssertionPanel.java:315) at com.eviware.soapui.impl.wsdl.panels.assertions.AddAssertionPanel$AssertionListMouseAdapter.mouseClicked(AddAssertionPanel.java:525) at java.awt.AWTEventMulticaster.mouseClicked(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$500(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.WaitDispatchSupport$2.run(Unknown Source) at java.awt.WaitDispatchSupport$4.run(Unknown Source) at java.awt.WaitDispatchSupport$4.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.awt.WaitDispatchSupport.enter(Unknown Source) at java.awt.Dialog.show(Unknown Source) at java.awt.Component.show(Unknown Source) at java.awt.Component.setVisible(Unknown Source) at java.awt.Window.setVisible(Unknown Source) at java.awt.Dialog.setVisible(Unknown Source) at com.eviware.soapui.impl.wsdl.actions.project.SimpleDialog.setVisible(SimpleDialog.java:170) at com.eviware.soapui.impl.wsdl.teststeps.actions.AddAssertionAction$1.run(AddAssertionAction.java:66) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$500(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) Performance issue with large response file & subsequent calls are slow I'm using ReadyAPI 1.7 and have noticed that test steps (rest GET methods) which have a large response, where it exceeds the allotted limit for the Outline editor limit, cause the application from that point on to run extremely slow, and memory/cpu balloons. Hence all subsequent calls take forever to run. Only solution is to close & restart the application, then everything works fine until I get to that one call which returns the large response. I've done the performance tuning recommended in other posts with vmoptions, and with transaction logging (disable the log, log only errors). I also increased the Outline editor limit to see if that would help & it didnt, so I set it back to 400000. Is this a known issue? has anyone found a workaround? Re: What is best practice when trying to compare a large json response to what is in the db I've manage to put the API response into an XML Datasource, and the database portion into a JDBC Datasource. At this point, how do you compare two Datasources against each other? By the way, I'm using Ready API 1.5 PRO Re: What is best practice when trying to compare a large json response to what is in the db Correct, I want to compare the JDBC result (6000 rows) with the Rest method. For clarification, JDBC steps is getting a list of values from a type table, and the Rest method should be returning the same set of values. What would be the most efficent way of doing this? What is best practice when trying to compare a large json response to what is in the db Looking for some advice to see if there is a more efficent way to do this - comparing json object in the response to the db. I have a restful api which returns a large response (6000 objects). I need to compare the response, to what is in the database. So I created the following flow in the test case: 1. JDBC datasource - reading from the database, getting the 6000 names 2. Restful api (GET) - contained assertion is looking at the datasource to make sure it exists 3. Datasource loop So when this runs, its looping through 6000 times, running the api & making sure in each iteriation the datasource property name exists. Not very efficent. Is there a way to take the response from the api, and compare it in one shot to what is in the database? Re: Is there a way to look at SoapUI bugs that are logged/recently closed? Yes please. SOAP-3149 & SOAP-1210. And if you have any known issues pertaining to the ENV & passing property values to project vs env properties. Thanks