Anda di halaman 1dari 67

Basics of SOA Testing

Author : Manas Ranjan Dhal

Contents

What is SOA?
Traditional MVC vs SOA
Why SOA needed?
What is Web service and its
significance?
What is WSDL?
What is SOAP protocol and
its significance?
Introduction to SOA testing

Challenges in SOA testing


Test Approach With SOA
How we overcome the
challenges.
Introduction to Parasoft SOA
test tool.
Conclusion

J anuary25, 2012

What is SOA
Service-Oriented Architecture (SOA) is an architectural style
Applications built using an SOA style deliver functionality as services
(e.g Create Customer, Get Customer Info, Add Account functionalities
in a banking domain) that can be used or reused when building
applications or integrating within the enterprise or trading partners.
A service-oriented architecture is essentially a collection of services
which is based on heterogeneous technologies.

J anuary25, 2012

Traditional MVC vs SOA


MVC divides the application intopresentation, business functions,
and data access layers.
Presentation implemented with JSP/servlets. Business logic
implemented with POJOs or EJBs. Data access logic implemented
with JPA/Hibernate
Here each business function will have its own set of controller logic
and solely dependent on the application and technology it
implemented with.
With SOA, the business functions can be abstracted out of the core
application processes and separated as reusable services. The
services can now be used with other applications independent of
technology and platform. The services allow for much better
component creation, and allows for ease of great things like single
sign on, data syncing, security, flexibility etc

J anuary25, 2012

Why SOA
The reality in IT enterprises is that infrastructure is heterogeneous
across operating systems, applications, system software, and
application infrastructure.
Enterprises should quickly respond to business changes with agility .
But some existing applications are used to run current business
processes, so starting from scratch to build new infrastructure isn't an
option.
SOA with its loosely coupled nature allows enterprises to plug in new
services or upgrade existing services in a granular fashion to address
the new business requirements, provides the option to make the
services consumable across different channels, and exposes the
existing enterprise and legacy applications as services, thereby
safeguarding existing IT infrastructure investments.

J anuary25, 2012

Benefits Of SOA
Platform and technology independent.
Modularized and less complex.
Low integration cost.
Secure and reliable.
Loosely coupled.
Change is easy.
Re-usable across the business channels.

J anuary25, 2012

Web Service

The W3C defines a "Web service" as "a software system designed to


support interoperable machine-to-machine interaction over a
network".
It has an interface described in a machine-processable format
(specifically Web Services Description Language, known by the
acronym WSDL).
Other systems interact with the Web service in a manner prescribed
by its description using SOAP(Simple Object Access Protocol)
messages, typically conveyed using HTTP.

J anuary25, 2012

WSDL

The Web Services Description Language is an XML-based language


that is used for describing the functionality offered by a Web-Service.
A WSDL description of a web service provides a machine-readable
description of how the service can be called, what parameters it
expects, and what data structures it returns. It thus serves a roughly
similar purpose as a method signature in a programming language.
WSDL is often used in combination with SOAP and an XML Schema
to provide Web services over the Internet.
A client program connecting to a Web service can read the WSDL file
to determine what operations are available on the server. Any special
datatypes used are embedded in the WSDL file in the form of XML
Schema. The client can then use SOAP to actually call one of the
operations listed in the WSDL file using XML or HTTP.

J anuary25, 2012

WSDL Document Structure


A WSDL document describes a web service using these major elements:
<types>

A container for data type definitions used by the web service

<message> A typed definition of the data being communicated


<portType> A set of operations supported by one or more endpoints
<binding> A protocol and data format specification for a particular port
type

J anuary25, 2012

WSDL Document Structure


WSDL Ports
The <portType> element is the most important WSDL element. It describes a
web service, the operations that can be performed, and the messages that
are involved.The <portType> element can be compared to a function library
(or a module, or a class) in a traditional programming language.
WSDL Messages
The <message> element defines the data elements of an operation.Each
message can consist of one or more parts. The parts can be compared to the
parameters of a function call in a traditional programming language.
WSDL Types
The <types> element defines the data types that are used by the web service.For
maximum platform neutrality, WSDL uses XML Schema syntax to define data
types.
WSDL Bindings
The <binding> element defines the data format and protocol for each port type.
J anuary25, 2012

Structure of a WSDL
<definitions>
<types>
data type definitions........
</types>
<message>
definition of the data being communicated....
</message>
<portType>
set of operations......
</portType>
<binding>
protocol and data format specification....
</binding>
</definitions>
J anuary25, 2012

Typical Service Interactions

J anuary25, 2012

SOAP
SOAP stands for Simple Object Access Protocol
SOAP is a communication protocol for communication between
service based applications
SOAP is a format for sending messages
SOAP relies on other application layer protocols, like Hypertext
Transfer Protocol (HTTP) or Simple Mail Transfer Protocol (SMTP),
for message negotiation and transmission
SOAP is platform independent
SOAP is language independent
SOAP is based on XML
SOAP is simple and extensible
SOAP allows you to get around firewalls

J anuary25, 2012

Why SOAP
Today's applications communicate using Remote Procedure Calls
(RPC) between different objects.
RPC represents a compatibility and security problem; firewalls and
proxy servers will normally block this kind of traffic.
A better way to communicate between applications is over HTTP,
because HTTP is supported by all Internet browsers and servers.
SOAP was created to accomplish this.
SOAP provides a way to communicate between applications running
on different operating systems, with different technologies and
programming languages.

J anuary25, 2012

SOAP Syntax
A SOAP message is an ordinary XML document containing the following
elements:
An Envelope element that identifies the XML document as a SOAP
message
A Header element that contains header information
A Body element that contains call and response information
A Fault element containing errors and status information

J anuary25, 2012

A skeleton SOAP Message


<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Header>
...
</soap:Header>
<soap:Body>
...

<soap:Fault>

...

</soap:Fault>
</soap:Body>
</soap:Envelope>

J anuary25, 2012

SOA Test Challenges

J anuary25, 2012

Test Approach With SOA


Regular testing models require Unit, System, Integration, and
Acceptance testing at corresponding phases for a product. These are
in the same way applicable to SOA in terms of services as shown
below:

Most of the messaging and application integration in SOA is currently


designed and implemented using XML, Json, Simple Object Access
Protocol (SOAP), Web Service Description Language (WSDL) so it is
necessary that the tester is well-versed with these
languages/protocols. Also, domain knowledge expertise is very
important to design effective tests to check applications and services
involved.

J anuary25, 2012

Test Approach With SOA


SOA testing requires following types of tests to be executed including
areas which are specific to an SOA setting:
1. Governance Testing: This is carried throughout the project lifecycle
to ensure that all the policies and standards are adhered to. This
includes specific tests, monitoring tools etc.
2. Service-level testing: Each service provided by an application is
individually tested. This includes data and events testing
3. Process-level testing: This includes testing for workflows,
configurations interoperability and reusability (consumability and
composability) of service

J anuary25, 2012

Test Approach With SOA


4. Integration testing: This includes testing of Service-Application
integration and focuses on service interfaces. Communication across
layers and network protocols is verified
5. System testing: This is to verify that the SOA implementation has
met all business rules, policies and standards defined
6. Security Testing: This includes checking for vulnerabilities within
system and threats such as Denial-of-Service (DOS), unauthorized
access etc. throughout project lifecycle
7. Acceptance testing (UAT): This includes executing end to end
scenarios through key business areas of system by the end user
and/or stakeholders

J anuary25, 2012

Test Approach With SOA


7. Performance testing: This is essential to determine latency issues,
redundancy, service disruption due to synchronous transactions and
other performance bottlenecks
9. Regression testing: This is retesting of system after a bug fix to
ascertain that it functions as intended and no new defect has been
introduced due to changes

J anuary25, 2012

Test Approach With SOA


Isolated services are tested against functional, performance,
compliance, and security related aspects.
Each service request and response are validated against
corresponding schema definitions with optional and mandatory inputs.
Each service can have different consumers and inputs for different
functional requirements.
Services can take value both from the calling applications and
databases.
Service response values are validated against expected out comes.
The services that are tested in silos are then integrated into bigger
components to ensure complete and comprehensive testing.

J anuary25, 2012

SOA Test Tools

J anuary25, 2012

How we overcome the


challenges

J anuary25, 2012

Getting started with


Parasoft SOA Test Tool 9.0

J anuary25, 2012

Creating a Workspace
Workspace is nothing but a physical folder in your local machine to
store and browse projects created with Parasoft SOA test tool.
A single workspace can contain multiple projects and there can be
multiple workspaces for different projects.
For creating a workspace we can either create a folder in our local
machine and browse it through SOA test tool or else we can create
a workspace through tool while opening it initially .

J anuary25, 2012

Creating a Blank Project


Open Parasoft SOA Test tool. Go to FileNewProject

J anuary25, 2012

Creating a Blank Project


Now expand the General node and select Project, click Next, give a
valid name to your project and click on the Finish button.

J anuary25, 2012

Adding .tst file to your project


Right click on your Project FolderAddNewTest(.tst) File

Give a name to the Test file, click Next, select Empty and click
Finish.

J anuary25, 2012

Test Suite.
Test Suite is a collection of tests designed for better maintainability.
Test Suite is used for controlling , how the datasource would be
iterated over tests and how the tests would be executed.

J anuary25, 2012

Environment
It is common for Web service applications to be developed and
maintained by different teams under different environments. For
example, a developer may start with tests on a server deployed on
his or her local machine, then as the server is deployed to a
development build server, the same tests would need to be
executed against that server, then QA and testing teams would
need to run the same regression tests on their own integration
server.
So Parasoft SOAtest includes an Environments management
feature where you can declare variables that changes with the
environment change.

J anuary25, 2012

Adding an Environment

When you add a Test file to your project a Test Suite and an
Environment structure automatically gets created.

Now right click on the Environments and select NewEnvironment.

Give a valid name and parameterize the variables.

J anuary25, 2012

SOAP Client
The SOAP Client tool sends messages to SOAP servers. It can be
used to test a Web service, test the communication between the
client and server, and check the content of the SOAP messages.
You can use the SOAP Client tool to test services with or without a
WSDL. This tool is the foundation of most test cases.
To send a message using the SOAP Client tool, you need to tell
SOAtest what message to send and how to send it. This is done by
specifying the parameters in the Project Configuration panel

J anuary25, 2012

Adding a SOAP Client


Right click on the Test Suite under which you want to add your
SOAP client. Select AddNewTestSOAP ClientFinish

J anuary25, 2012

Working with SOAP Client


For sending a request with your SOAP client, first you need to
decide the schema of your request. For defining schema either you
can define your own schema or choose a valid WSDL for your web
service.
If you have your WSDL defined in your environment, you can call
the environment variable within your SOAP client under WSDL tab.

J anuary25, 2012

Working with SOAP Client


After adding the WSDL give the Endpoint (server location where
WDL resides) to you SOAP client.

J anuary25, 2012

Working with SOAP Client


For authentication and authorization purpose we need to pass
some parameters in SOAP request header . For this we can predeclare a header in SOA test tool and can reuse that in different
SOAP clients or we can declare it at SOAP client level also.

J anuary25, 2012

Creating a Header
Right click on the outer Test
SuiteAddNewGobalPropertyExpand GlobalPropertySOAP
Headers.

Now you can add different Header properties like WS-Addressing,


SAML-Assertion,WS-Security etc.

J anuary25, 2012

Working with SOAP Client


Now select the operation(service name) for the SOAP client.
Parameterize the request nodes with fix values according to your
test cases .
Now select the SOAP client and run it.
Now open the traffic viewer under the SOAP client and check the
request and response.

J anuary25, 2012

Parametrize inputs
To automate execution of multiple test cases simultaneously , we
cant test those with fix values in SOAP client. Thats why, Parasoft
SOA test tool provides multiple options to parameterize you inputs
with the help of datasource .
Data sources can be added at multiple levels: TestSuite,Project &
Global. The higher the level of the data source, the more widely it
can be shared. For instance, if you want to add a data source that is
applicable only to a specific test suite, add it at the test suite level. If
you want to share it across test suites in a project, add it at the
project level. If you want to share it across multiple projects, add it at
the global level.
You can specify any number of data sources for a test suite, and
you can use any specified data source throughout a test suites
tests.
J anuary25, 2012

Adding a Datasource.
Right click on the Test Suite for which you want to add the
datasource. Select AddNewDataSourceSelect the type of
DataSource you want to addFinish.

J anuary25, 2012

Adding a Datasource
Generally we use excel as the datasource for easy upgradation and
reusability of the same excel for multiple datasources.
Once you select an excel file as your datasource, browse the excel
from your local and select the appropriate sheet. Now click on the
ShowColumns button to view the columns.

J anuary25, 2012

Parametrize inputs
Once the datasource has been added, select the datasource in your
SOAP client.

Now go to each node of you request in SOAP client and


parameterize those with respective columns.

J anuary25, 2012

Assertor
The XML Assertor is used to enforce the correctness of data in an
XML message. It is most commonly connected to a SOAP Client in
order to verify the data returned by a service.
The XML Assertor consists of three main tabs:
Summary: This tab contains a table showing the details of the XML
Assertions that have been configured.
Configuration: This tab is used to create and configure XML
Assertions.
Expected XML: Specifies the expected XML response.

J anuary25, 2012

Adding an Assertor
Right click on the SOAP clientAdd OutputSelect SOAP
Envelope under ResponseXML AssertorFinish

J anuary25, 2012

Adding an Assertor
Once the Assertor has been added, go to the Configuration
tabClick on Add..Select type of Assertor you want to use.

J anuary25, 2012

Types of Assertor
Value Assertions: The following value assertions are available:
Value Assertion: Enforce the value of a particular element.
Value Occurrence Assertion: Enforce the occurrence of a value for
an element.
Numeric Assertion: Enforce the numeric value of an element.
String Comparison Assertion: Enforce the value of the text content
of a given element.
Regular Expression Assertion: Enforce that an element matches a
regular expression.
Expression Assertion: Enforce the value of an expression
composed of elements.
Custom Assertion: Enforce custom assertion on an element.
J anuary25, 2012

Types of Assertor
Structure Assertions: The following structure assertions are
available:
Occurrence Assertion: Enforce the number of occurrences of an
element.
Has Content Assertion: Enforce that an element has text
content.
Compound Assertions: The following compound assertions are
available:
AND Assertion: Group multiple assertions that all must succeed.
OR Assertion: Group multiple assertions where at least one must
succeed.
Conditional Assertion: Enforce an assertion only if a condition is
met.
J anuary25, 2012

Types of Assertor
Difference Assertions: The following difference assertions are
available:
Numeric Difference Assertion: Enforce a numeric difference on
a value of a particular element. Assert that the numeric value of an
element differs from a user-specified base value by a user-specified
value.

Date Difference Assertion: Enforce a date difference on a value


of a particular element. Assert that an element with a date value
differs from a user-specified date by a user-specified number of
years, months, and days.

J anuary25, 2012

Types of Assertor
Range Assertions: The following difference assertions are
available:
Numeric Range Assertion: Enforce a numeric range on a value
of a particular element.
Date Range Assertion: Enforce a date range on a value of a
particular element.
DateTime Range Assertion: Enforce a date time range on a
value of a particular element

J anuary25, 2012

Comparing two values with value


Assertor
After selecting the value assertor select the value from the tree
structure of request/response which you want to compare with a fix
value.

Then in the expected value field give the expected value for the
selected node.

J anuary25, 2012

XML Data Bank


The XML Data Bank tool enables you to extract certain parameters
from one test in a test suite, and input those parameters into another
test.
The XML Data Bank can be chained to any SOAtest tool that
outputs XML. A common example is a scenario wherein an element
from the response of one test is used to populate the value of an
element in the request of another test. Data in the XML Data Bank
can be sent to a Writable Data Source and accessed in the
Extension Tool.

J anuary25, 2012

Adding XML Data Bank


Right click on the SOAP ClientAdd OutputSelect
request/response envelope depending upon the node from where
you want to capture the value for databankSelect XML Data Bank.

J anuary25, 2012

Configuring XML Data Bank


Once you add a XML data bank, add the X-Path of the node whose
value you want to keep in the data bank . For adding X-path select
the node from response/request and click the add X-Path button or
you can also manually customize the X-Path of the node.

J anuary25, 2012

XML Transformer
The XML Transformer gives you XSLT-like functionality to transform
any XML. This is very useful if you would like to create a regression
control using only a few elements of the SOAP response or request.
Any time you would like to pass a particular subset of an XML
response to a chained tool, the XML Transformer is the tool for the
job.
We can chain all most all types of tools to XML Transformer. The
input to the tool chained to the transformer is taken from the node
trapped by the transformer.

J anuary25, 2012

Adding XML Transformer


Right click on the SOAP ClientAdd OutputSelect
request/response envelope depending upon the node from where
you want to capture the value for transformer Select XML
Transformer.

J anuary25, 2012

Chaining other tools to Transformer


Once you added the transformer, you chain other tools under it to
manipulate the node values captured by transformer.
E.g: If you add an a data bank under the transformer it can store any
node value captured by the transformer.

J anuary25, 2012

Write file
To provide the proof of our test execution, we need a method by
which we can store the request/response in a local file. Hence
Parasoft SOA test tool has the write file tool.
The Write File tool converts output data to files and is typically
added as an output to an existing tool. The file can be named with a
number of wildcards that include date, time, test name, and a unique
ID.

J anuary25, 2012

Adding Write File


Right click on the SOAP ClientAdd OutputSelect
request/response envelope depending upon from where you want to
capture the value for write fileSelect write fileClick Finish

J anuary25, 2012

Configuring Write File


Once the write file is added it will automatically take input from the
tool under which it has been added. Now give the target name and
target directory for the file. Target name should be followed by
proper file extension.

J anuary25, 2012

Extension Tool
It is he primary tool for interfacing with the Extensibility API. It allows
for extending tests with actions that may not be directly supported
by built-in features. Supports Java, JavaScript and Python/Jython
for writing custom scripts that address unique system needs. This
tool permits users to perform complex validation or transformation
operations on tool outputs, or execute any custom actions as part of
test scenarios. For examples, check out http://forums.parasoft.com
and navigate to the SOAtest Scripting Examples forum. You can
also refer to the Extensibility API, found under the Help menu.

J anuary25, 2012

Jython Scripts

J anuary25, 2012

About Jython
Jython is an implementation of Python scripting language
for the JVM.
Jython takes the Python programming language syntax
and enables it to run on the Java platform.
This allows seamless integration with the use of Java
libraries and other Java-based applications.

J anuary25, 2012

Jython Scripting in Parasoft SOA


Test
Importing Package com.parasoft.api :Used to add external Java classes to be used in the tool.
Provides a Java application programming interface for
customizing Parasoft products.
from com.parasoft.api import *

Define the method:def myMethod{input, context}

J anuary25, 2012

Jython Scripting continue

Declaring variable:a=5
b=7
name=manas
x=[7,1,9]

Showing Message in console:Application.showMessage(text)

Getting Variable from environment :VaribleName = context.getEnvironmentVariableValue(Environment)

J anuary25, 2012

Jython Scripting continue


Conditional stmt(if,else)
if a>b:
Application.showMessage(a greater.)
else:
Application.showMessage(b greater.)
Looping:for I in range (0,len(x)):
Application.showMessage(str(i)+th Element is : +str(x[i]))

J anuary25, 2012

Thank You

J anuary25, 2012

Anda mungkin juga menyukai