How to compare XQuery output with databasein SOAP UI - soap

I have written Xquery assertion in SOAP UI request its working fine. But i want to compare output of this with database. Can I add code to get the values from database in Expected panel of XQuery assertion of SOAP UI. If not is there any way where I can compare the xml response of a request with column values of a database

You can do it the following way:
Call a service with a Soap request
Make a property transfer from the service response to a test case variable, see the SoapUI docs for more information. You can use XPath or XQuery. See the picture bellow.
Make a JDBC request to your database and compare the results with the data stored in your test case variable.
This way is intuitive and effective for simple comparissons, for complex tests I would choose Groovy scripting.

Related

Routing incoming request

I am trying to create a simple API using Go that performs certain operations depending on the data provided.
I was planning to provide JSON data to this API and get details from it for further use.
Since I was trying to provide JSON data I created the routing using gorilla/mux as below:
router.HandleFunc("/msa/dom/perform-factory-reset?json={jsonData}", CallGet)
log.Fatal(http.ListenAndServe(":8080", router))
But while trying to hit the endpoint http://localhost:8080/msa/dom/perform-factory-reset?json={"vrf":"ds","ip":"45","mac":"452","method":"gfd"} I am getting 404 page not found error.
Hence I tried to change the implementation such that new routing is done as:
router.HandleFunc("/msa/dom/perform-factory-reset/json={jsonData}", CallGet)
This works absolutely fine and I am able to perform desired tasks. Could someone tell me why this is happening?
Is the router gorilla/mux? If so, you cannot add query parameters to path like that. You have to:
router.Path("/msa/dom/perform-factory-reset").
Queries("json","{jsonData}").HandlerFunc(CallGet)
If it is some other router, then you still probably have to register path without the query parameters, and then get the query parameter values in the handler from the request.

Can we iterate values from excel to POST json request one by one in SOAPUI. If yes please share a piece of code

Can we iterate values from excel to POST json request one by one in SOAPUI?
It should get the response for each and every request from iterated value.
Kindly share groovy script to achieve this.
No code is needed as such. You need to create a TestCase, in which you have:
DataSource TestStep
Rest Request TestStep
DataSource Loop TestStep
The DataSource should be set to point towards your Excel input file, and you should input the column names. Make sure your Excel file i saved in the rather ancient 97 format. (This may no longer be true, but for a long time, this has been the only type of Excel file that SoapUI was able to work with.)
Your Rest Request should naturally import and use the columns from your input file that are relevant.
Your DataSource Loop should just send the script back to your Rest Request.
This will make the script loop until it runs out of data in your input file.

Using JMeter, how to compare table data with JSON data?

I've got a task to compare all data fetched from postgreSQL table and all data located on a website that uses REST API (HTTP request with JSON data) in order to see which is missing.
I fetch data from postgreSQL using JDBC request (SELECT * FROM exampleTable), data is in standard SQL table format.
And I get REST API data using HTTP request sampler, data is in JSON format:
{"records":[{"id":"rec6iT8M0YFZc9kxf","fields":{"Birthday":"2010-09-01","Gender":"Female","Currently In Pasture":["rec7hRbjrgTaKWdCs"],"Breed":"Jersey","Weight":1800,"Name":"Jerri","Attachments":[{"id":"attbz","url":"https://IaGSYtK8SlS.jpg","filename":"Jersey_cow.jpg","size":1555316,"type":"image/jpeg","thumbnails":{"small":{"url":"https://_Jersey_cow.jpg","width":27,"height":36},"large":{"url":"https://dl/S4tl79.jpg","width":256,"height":341}}}]}
etc etc
both requests should have the same format of data (same "columns" for comparison > name, gender, breed, weight, etc)
I've tried using JSON Extractor post processor element to get individual variables from HTTP response and compare them to individual variables from JDBC request using the Response Assertion element but with no luck
I either get this error: Assertion failure message: java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.String (probably cause I am using the whole SQL data set instead of data from individual columns)
or something like:
Assertion failure message: Test failed: text expected to match /${gender}/
I dont know how to successfully assign variables to data from SQL table and JSON response and then matching those variable values (seeing which entries are absent from what REST API fetches)
is there any easy way to do this using jmeter GUI and not having to rely on beanshell/groovy or any other kind of scripting (so just by using the elements available in jmeter) ?
thank you!
Not knowing your database structure it is quite tricky to come up with exact solution, however you can convert JDBC Request output into a JSON using JSR223 PostProcessor
Example:
Given the following JDBC Request sampler configuration:
Which produces the following output:
I can convert it into JSON using the following Groovy code:
def result = vars.getObject('result')
def json = new groovy.json.JsonBuilder(result).toPrettyString()
log.info(json)
as you can see it contains column names along with the values, you should be able to use it for assertions.
More information: Debugging JDBC Sampler Results in JMeter

webservices test on JMeter

In J.meter I need to test multiple web-services in single scenario like, after successful execution of service one it will gives session-Id and this session id will take by other services and check it and complete the scenario as per business logic?
It is classic question regarding "correlation" in JMeter. Correlation stands for the process of extracting dynamic data from previous response and passing it to the next request.
Add a JSON Extractor as a child of the first request and define a JSON Path query to extract the session-Id value and and store it into a Jmeter Variable.
Use the aforementioned JMeter Variable as the session-Id for the subsequent requests.
See API Testing With JMeter and the JSON Extractor article for comprehensive instructions.

jbpm populating a data object using rest api

In jBPM I have a process that contains a human task. This human task is used to populate a custom data object.
With the jBPM REST API, you can complete a task with parameters like so:
localhost:8080/jbpm-console/rest/task/93/complete?map_price=1800
And the process will have a process variable "price" with value 1800.
But how can you send a custom data object?
My object is called "expense" and if I complete the task manually in jbpm-console using the form, the variable expense in the process has the value "expensetest.Expense#33d6ffc0"
My guess is I'll have to provide this data object in the body of my POST but I can't seem to get it working. Perhaps I'm missing a step?
The task/{id}/complete REST url only supports simple data types. To use custom data types, you should use the /execute operation. This supports (de)serializing Java Objects to XML using JAXB.