• Save
Groovy in SOAP UI
Upcoming SlideShare
Loading in...5

Like this? Share it with your network


Groovy in SOAP UI

Uploaded on

Tutorials to write Restful service integration test using Groovy in SOAP UI

Tutorials to write Restful service integration test using Groovy in SOAP UI

More in: Technology , Business
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
No Downloads


Total Views
On Slideshare
From Embeds
Number of Embeds



Embeds 631

http://ravireddyjsf.blogspot.com 261
http://www.ravireddyjsf.blogspot.com 121
http://ravireddyjsf.blogspot.in 112
http://ravireddyjsf.blogspot.ru 31
http://ravireddyjsf.blogspot.co.uk 30
http://www.ravireddyjsf.blogspot.in 20
http://ravireddyjsf.blogspot.ca 9
http://ravireddyjsf.blogspot.de 9
http://www.ravireddyjsf.blogspot.fr 4
http://ravireddyjsf.blogspot.fr 4
http://ravireddyjsf.blogspot.com.au 4
http://ravireddyjsf.blogspot.co.nz 4
http://www.ravireddyjsf.blogspot.com.br 4
http://ravireddyjsf.blogspot.nl 3
http://ravireddyjsf.blogspot.com.br 2
http://ravireddyjsf.blogspot.com.es 2
http://ravireddyjsf.blogspot.be 2
http://ravireddyjsf.blogspot.sg 2
http://ravireddyjsf.blogspot.se 2
http://ravireddyjsf.blogspot.ch 1
http://ravireddyjsf.blogspot.kr 1
http://ravireddyjsf.blogspot.hu 1
http://www.linkedin.com 1
http://ravireddyjsf.blogspot.no 1

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide


  • 1. Groovy Tutorials With SOAP UI 1(C ) All copy rights to Ravi Reddy, Dilip & Abdur (ravireddy76@gmail.com)
  • 2. Presentation to illustrate to write web service integration test usinggroovy in soap UI. I’m unable to find a valuable solutions in online forums to write a simple integration tests for web services. Here I want demonstrate how to write services integration test for restful end points using groovy in SOAP UI for simple CRUD operations.Tools 2 Use C:Program Files (x86)SmartBearsoapUI-4.0.1 • SOAP-UI • Jersey (JAX-RS) API’s • jersey-client-1.8 • jersey-core-1.8 • jersey-server-1.8 • jersey-test-framework- • SOAPRestClient (Custom jar file)Download and copy above jars (libraries) to lib of Soap UIinstallation folder show in the image.** Note : Ping me @: ravireddy76@gmail.com SOAPRestClient is custom jar file which consists of wrapper class to consume REST end points for POST/PUT/DELETE/GET operations.(C ) All copy rights to Ravi Reddy, Dilip (ravireddy76@gmail.com) 2
  • 3. » Create a REST end point project in SOAP UI tool which is shown in below image  Create a Test Suite called “ServiceIntegration-TestSuite”.  Create a test case (Example: CustomerService-IntegrationTest show in image)  Create a new Groovy script as a test case. In above example I’m showing a example for CRUD (Create, Read, Update, Delete) operations for a customer service.(C ) All copy rights to Ravi Reddy, Dilip (ravireddy76@gmail.com) 3
  • 4. Below examples presenting CRUD operations for customer service integration test using groovy script in SOAP UI ** Note : use your REST end point with appropriate input either JSON/XML format.  Create Customer def CREATE_CUSTOMER_ENDPOINT = "http://mlaptop.ravi.net:8080/JerseyRestFul-DBCRUD- POC/services/customerService/addCustomer"; def createCustomerLogRef = "Create Customer Information::"; def customerJsonInput = buildJsonInput(); ClientResponse createCustomerResponse = serviceResoruces.postResponse(CREATE_CUSTOMER_ENDPOINT,customerJsonInput); log.info(createCustomerLogRef+"Response Status = "+createCustomerResponse.getStatus()); assert createCustomerResponse.getStatus() == 204 log.info("----------------------------------------------------------------------------------------------");  Update Customer def UPDATE_CUSTOMER_ENDPOINT = "http://mlaptop.ravi.net:8080/JerseyRestFul-DBCRUD- POC/services/customerService/updateCustomer"; def updateStepLogRef = "Update Customer Step::"; ClientResponse searchCustomerForUpdate = getCustomerSearchResponse(); /* Validate for whether customer information found or not for the given the ID to update.*/ if(searchCustomerForUpdate.getStatus() == 204){ log.info("No Customer found for the given id to update."); }else { log.info("~~~~!!!! Customer Information is Updated !!!!~~~~"); /* Format the json structure for update operation.*/ String searchByIdForUpdate = searchCustomerForUpdate.getEntity(String.class); def jsonForUpdate = formatJsonStructure(searchByIdForUpdate); ClientResponse updateCustomerResponse = serviceResoruces.putResponse(UPDATE_CUSTOMER_ENDPOINT,jsonForUpdate); log.info(updateStepLogRef+"Response Status = "+updateCustomerResponse.getStatus()); assert updateCustomerResponse.getStatus() == 204 } 4(C ) All copy rights to Ravi Reddy, Dilip (ravireddy76@gmail.com)
  • 5.  Delete Customerdef deleteCustomerLogRef = "Delete Customer::";def DELETE_CUSTOMER_ENDPOINT = "http://mlaptop.ravi.net:8080/JerseyRestFul-DBCRUD- POC/services/customerService/deleteCustomer?customerId"+ IntegrationTestUtils.generateRangeRandomNumber(103,400);ClientResponse deleteCustomerResponse = serviceResoruces.deleteResponse(DELETE_CUSTOMER_ENDPOINT);log.info(deleteCustomerLogRef+"Response Status = "+deleteCustomerResponse.getStatus());if(deleteCustomerResponse.getStatus() == 204){ log.info("Customer Found To Delete."); assert deleteCustomerResponse.getStatus() == 204}else{ log.info("Customer Not Found To Delete."); assert deleteCustomerResponse.getStatus() == 500} Find Customerdef searchByIdLogRef = "Search Customer By Id::";ClientResponse customerSearchResponse = getCustomerSearchResponse();/* Validate for whether customer information found or not for the given the ID.*/if(customerSearchResponse.getStatus() == 204){ log.info("No Customer found for the given id.");}else { String searchByIdResponseXml = customerSearchResponse.getEntity(String.class); log.info(searchByIdResponseXml); assert customerSearchResponse.getStatus() == 200} 5(C ) All copy rights to Ravi Reddy, Dilip (ravireddy76@gmail.com)
  • 6.  Find All Customer def SEARCH_ALL_CUSTOMERS_ENDPOINT = "http://mlaptop.ravi.net:8080/JerseyRestFul-DBCRUD- POC/services/customerService/getAllCustomers"; def searchAllLogRef = "Search All Customers::"; ClientResponse searchAllResponse = serviceResoruces.getResponse(SEARCH_ALL_CUSTOMERS_ENDPOINT); log.info(searchAllLogRef+"Response Status = "+searchAllResponse.getStatus()); assert searchAllResponse.getStatus() == 200 String searchResponseXml = searchAllResponse.getEntity(String.class); log.info("~~!!!! RESPONSE XML For All Customers !!!!~~~~"); log.info(searchResponseXml); ** If you want full groovy script and SOAPRestClient jar please send me e-mail to ravireddy76@gmail.com. Also mean time I will try to upload the required libraries (jar) and code in GitHub. Authors Ravi Reddy Dilip Ladhani 6(C ) All copy rights to Ravi Reddy, Dilip (ravireddy76@gmail.com)