Automate APIs with Groovy Script



Similar documents
Agile Web Service and REST Service Testing with soapui

Module 4: File Reading. Module 5: Database connection

SoapUI NG Pro and Ready! API Platform Two-Day Training Course Syllabus

Chapter 1: Web Services Testing and soapui

soapui Product Comparison

Installing the ASP.NET VETtrak APIs onto IIS 5 or 6

Test Automation Integration with Test Management QAComplete

How do I Install and Configure MS Remote Desktop for the Haas Terminal Server on my Mac?

Unity Error Message: Your voic box is almost full

How do I Install and Configure MS Remote Desktop for the Haas Terminal Server on my Mac?

About This Document 3. About the Migration Process 4. Requirements and Prerequisites 5. Requirements... 5 Prerequisites... 5

TMS Phone Books Troubleshoot Guide

NEMSIS v3 Web Services Guide

Mobile Labs Plugin for IBM Urban Code Deploy

soapui Client Testing ecrv Web Services with soapui 1 9/20/2012 First edition soapui-x ecrv Development Team

Setting up a networked printer on a local PC

Using ODBC with MDaemon 6.5

Verify LDAP over SSL/TLS (LDAPS) and CA Certificate Using Ldp.exe

Avatier Identity Management Suite

Integrating Autotask Service Desk Ticketing with the Cisco OnPlus Portal

Getting started with OWASP WebGoat 4.0 and SOAPUI.

Implementing Cisco TelePresence Video Solution, Part 1

freesshd SFTP Server on Windows

Access Instructions for United Stationers ECDB (ecommerce Database) 2.0

CONTRACT MODEL IPONZ DESIGN SERVICE VERSION 2. Author: Foster Moore Date: 20 September 2011 Document Version: 1.7

XML Export Interface. IPS Light. 2 April Contact

MSSQL quick start guide

Video Administration Backup and Restore Procedures

IBM DB2 XML support. How to Configure the IBM DB2 Support in oxygen

WEB SERVICES TEST AUTOMATION

IBM InfoSphere MDM Server v9.0. Version: Demo. Page <<1/11>>

Web Services API Developer Guide

Getting Started with STATISTICA Enterprise Programming

Monitor TemPageR 4E With PageR Enterprise

Exam Name: IBM InfoSphere MDM Server v9.0

Tracking Network Changes Using Change Audit

Using Remote Desktop with the Cisco AnyConnect VPN Client in Windows Vista

DEVELOPING CONTRACT - DRIVEN WEB SERVICES USING JDEVELOPER. The purpose of this tutorial is to develop a java web service using a top-down approach.

The presentation explains how to create and access the web services using the user interface. WebServices.ppt. Page 1 of 14

OpenTOSCA Release v1.1. Contact: Documentation Version: March 11, 2014 Current version:

Implementing a Web Service Client using Java

WINGS WEB SERVICE MODULE

Spam Marshall SpamWall Step-by-Step Installation Guide for Exchange 5.5

Network Monitoring with SNMP

T320 E-business technologies: foundations and practice

CRS 4.x: Automatic Work and Wrap up Time Configuration Example

ACR Triad Site Server Click Once Software System

Open-ESB tutorials. Schema and Encoding: Import a CSV file. Paul Perez / Bruno Sinkovic. Copyright Pymma Consulting (2009)

School of Information Technology and Engineering (SITE) CEG 4395: Computer Network Management

TIBCO ActiveMatrix Management Agent for WCF Samples. Software Release July 2009

Application Note. Cacti monitoring. Document version: v1.0 Last update: 8th November 2013

Viewing and Troubleshooting Perfmon Logs

Web Service Testing. SOAP-based Web Services. Software Quality Assurance Telerik Software Academy

Active Directory Management. Agent Deployment Guide

IP Phone Services Configuration

Note: With v3.2, the DocuSign Fetch application was renamed DocuSign Retrieve.

Deploying Microsoft Operations Manager with the BIG-IP system and icontrol

SDK Code Examples Version 2.4.2

Volume AGKSOFT. Wayne Nucleus Back Office Software. Nucleus Guide

Netwatch Installation For Windows

GCM for Android Setup Guide

Configure Cisco Emergency Responder Disaster Recovery System

IP phone services setup

BPM Scheduling with Job Scheduler

14.1. bs^ir^qfkd=obcib`qflk= Ñçê=emI=rkfuI=~åÇ=léÉåsjp=eçëíë

Log Analyzer Reference

MANAGING OUTLOOK PERSONAL DATA FILES

There are numerous ways to access monitors:

End of Sale/End of Life Report Tool Usage Notes for CiscoWorks NCM 1.6

MacroPhone. ISDN Call Monitor, Telephone Answering Machine and Fax-Functions over Networks

Smart Call Home Quick Start Configuration Guide

Sop U. SOAP over JMS with. Configuring soapui to test TIBCO SOAP over JMS. - Seshasai Kotipalli

Obtaining Oxford Journals usage statistics with SUSHI

PIM31 Remote Setup and Operational Procedures

ICE Futures Europe. MFT Technical Guide for Position Reporting V1.2

About This Document 3. Integration Overview 4. Prerequisites and Requirements 6

Monitor Room Alert 7E With PageR Enterprise

How To - Implement Single Sign On Authentication with Active Directory

Schematron Validation and Guidance

Quick Setup ACD (Auto Call Distribution System) 17/12/2014

17 March 2013 NIEM Web Services API Version 1.0 URI:

Scheduling Automated Outlet Control Using FineSNMPSet with Sentry Switched Power Distribution Units

How to Backup Your Eclipse.Net Database Automatically. To clearly document a specific automatic SQL database backup method for Eclipse.net.

Lab - Configure a Windows 7 Firewall

INTEGRATING MICROSOFT DYNAMICS CRM WITH SIMEGO DS3

Handle Tool. User Manual

Kuali Security Request Installation Guide

Install FileZilla Client. Connecting to an FTP server

The full setup includes the server itself, the server control panel, Firebird Database Server, and three sample applications with source code.

Background Deployment 3.1 (1003) Installation and Administration Guide

Integrating SalesForce with SharePoint 2007 via the Business Data Catalog

OCS Training Workshop LAB14. Setup

Monitoring Oracle Enterprise Performance Management System Release Deployments from Oracle Enterprise Manager 12c

CONVERTING FROM NETKEEPER ISAM v6.32 to NETKEEPER SQL

How to use FTP Commander

escan SBS 2008 Installation Guide

Transcription:

Automate APIs with Groovy Script Document ID: 119011 Contributed by Tony Pina, Cisco TAC Engineer. Jun 22, 2015 Contents Introduction Create a soapui Project Create a soapui API Request Create a soapui Test Case Introduction This document describes how to create a soapui Application Programmers Interface (API) request and how to create a soapui Test Case that loops over Test Steps which automate the API requests to Quantum Policy Suite (QPS). The example soapui Test Case in this article implementa Test Steps which read a file of subscriber IDs and then create and send a querysubscriberrequst to QPS. Create a soapui Project Before you begin this procedure, install the soapui application on your desktop. You can download the soapui installation executable from www.soapui.org. Before you create an API request or Test Case you must first create a soapui project. You need the Web Services Description Language (WSDL) file and the XML Schema Description (XSD) file in order to create the project. The WSDL specifies the supported APIs. You can normally obtain the WSDL and XSD from the QPS when you run these commands from the Load Balancer (LB): wget http://lbvip01:8080/ua/wsdl/unifiedapi.wsdl wget http://lbvip01:8080/ua/wsdl/unifiedapi.xsd Store the WSDL and XSD in the same directory on the desktop where you plan to run the soapui application. Complete these steps in order to create the soapui project: 1. Choose File > New soapui Project from the soapui window:

2. In the New soapui Project window enter a name for the project in the Project Name field and enter the location where the WSDL file is stored in the Initial WSDL/WADL field. Click OK when you are done. Create a soapui API Request Complete these steps in order to create a soapui API request: 1. Expand the soapui project you created in order to see the APIs. You can also expand one of the APIs in order to see the request. In this example, querysubscriberrequest is expanded:

2. Open the request in order to see the request window with the XML that forms the query. In the Request window edit the http:// IP address to the IP address and port. This is normally the lbvip01 IP address and port where you want to send the request as this example shows: 3. Modify the fields in the XML with the data you want to send in your request. In this example, the request is a querysubscriberrequest. Modify the subscriber ID for the subscriber you want to query and set showdetailedinformatin to false:

4. Click the green Run button at the top of the Request window in order to run the query. Create a soapui Test Case This procedure explains how to create a test suite that can automate when APIs are sent to the QPS. In this example procedure the test suite loops over a list of subscriber IDs and then uses those subscriber IDs in the querysubscriberrequest it sends to QPS. The list of subscriber IDs are each on a single line in a text file called subid.txt. Complete these steps in order to create the Test Suite: 1. In the soapui project you created, create a new Test Suite. Right click on the soapui and choose New TestSuite.

2. Right click the Test Suite and choose New TestCase.

3. Right click the Test Case and choose Add Step > Groovy Script in order to add a Groovy Script test step. Name it Data Source: 4. In the Data Source file paste this code. This code reads file C:/subid.txt which contains a subscriber ID on each line: import com.eviware.soapui.support.xmlholder def mytestcase = context.testcase def counter,next,previous,sizefile tickerenumfile = new File("C:/subid.txt") //subscriber IDs sepearted by new line (CR). List lines = tickerenumfile.readlines() size = lines.size.tointeger() propteststep = mytestcase.getteststepbyname("property Looper") // get the Property TestStep propteststep.setpropertyvalue("total", size.tostring()) counter = propteststep.getpropertyvalue("count").tostring() counter= counter.tointeger() next = (counter > size 2? 0: counter+1) tempvalue = lines[counter] propteststep.setpropertyvalue("value", tempvalue) propteststep.setpropertyvalue ("Count", next.tostring()) next++ log.info "Reading line : ${(counter+1)} / $lines.size"propteststep.setpropertyvalue("next", next.tostring()) log.info "Value '$tempvalue' updated in $propteststep.name" if (counter == size 1) { propteststep.setpropertyvalue("stoploop", "T") log.info "Setting the stoploop property n else if (counter==0) { def runner = new com.eviware.soapui.impl.wsdl.testcase.wsdltestca (testrunner.testcase, null) propteststep.setpropertyvalue("stoploop", "F") } else{ propteststep.setpropertyvalue("stoploop", "F") } 5. Right click on the Test Step and choose Add Step > Properties in order to add a Property test step

and name it Property Looper. 6. Add these user defined properties of the Looper test step: Total Value In our example this hold the subscriber ID read from the file subscriber IDs Count Next StopLoop 7. Right click on the Test Step and choose Add Step > TestRequest in order to add a Test Request Test Step and choose the request you want to invoke:

In this example, querysubscriberrequest is used.

8. In the request, the expansion code replaces the field values of what you query. In this example the? of the SubscriberId=? in the querysubscriberrequest is replaced with expansion code ${Property Looper#Value} (soap_test_req_expansion_code):

Property Looper is the name of the Property TestStep previously created and Value holds the current subscriber ID read from the file of subscriber IDs. 9. Right click on the Test Step and choose Add Step > Groovy Script and name it Data Loop:

10. Paste this code in the Groovy Script Data Loop: def mytestcase = context.testcase def runner propteststep = mytestcase.getteststepbyname("property Looper") endloop = propteststep.getpropertyvalue("stoploop").tostring() if (endloop.tostring() == "T" endloop.tostring()=="true" endloop.tostring()=="true") { log.info ("Exit Groovy Data Source Looper") assert true } else { testrunner.gotostepbyname("groovy Script DataSource") //go to the DataSource } 11. In this example procedure, a 1000 ms delay between each loop is added. This step is optional.

With the delay there are now five Test Steps: 12. Click the green Run button in order to run the five Test Steps in the TestCase window. Updated: Jun 22, 2015 Document ID: 119011