InfoQ

News

Mocking Web Services

Posted by Boris Lublinsky on May 10, 2008 04:19 PM

Community
Architecture,
SOA
Topics
Web Services
Tags
Best Practices,
Mocks,
Apache Synapse,
developerWorks,
Testing

Some of the Web services testing approaches were previously covered in an InfoQ post. They have been recently extended through usage of Web Services mocking.

Mock objects are very popular and common approach to a unit testing. According to Wikipedia

mock objects are simulated objects that mimic the behavior of real objects in controlled ways… mock objects can simulate the behavior of complex, real (non-mock) objects and are therefore useful when a real object is difficult or impossible to incorporate into a unit test. If an object has any of the following characteristics, it may be useful to use a mock object in its place:
non-deterministic results (e.g. the current time or the current temperature); has states that are difficult to create or reproduce (e.g. a network error); is slow (e.g. a complete database, which would have to be initialized before the test); does not yet exist or may change behavior; would have to include information and methods exclusively for testing purposes (and not for its actual task)

Web services introduce additional situations where usage of mock approach can be very useful:

it is necessary to write a program that depends on one or more remote Web services, which can be running in production servers, and are not readily available in test servers, or third-party services that are running behind customer’s firewall and are not available for testing; offline development, for example at home, or on the road, might require a full set of working Web services offline so that it is possible to test an implementation; offline demos when the remote Web services might be not accessible and even not running all the time. It is necessary to make sure that the demo will behave properly in all of the above situations.

A new tutorial by Upul Godage describes how to use Apache Synapse to mock web services for development and testing. Apache Synapse is a simple, lightweight, high-performance enterprise service bus (ESB). Apache Synapse can be used to filter, transform, route, manipulate, and monitor SOAP, binary, XML, and plain text messages that can be delivered by HTTP, HTTPS, Java™ Message Service (JMS), Simple Mail Transfer Protocol (SMTP), Post Office Protocol Version 3 (POP3), FTP, file systems, and many other transport mediums.

Tutorial describes how Synapse can be used to define either fixed or controlled response from services using simple configuration XML files, defining transformation, building response for a given request (set of requests). It also describes approaches to mocking mediators using the same configurations – based approach.

Another approach to mocking of Web Services is usage of a newly released SOAPSimulator from Crosscheck Networks. Its functionality is similar to the one provided by Synapse, but with the following additional capabilities:

Graphical point and click SOAP and XML simulation. Comprehensive WSDL and XSD schema support. Dynamic WSDL and Schema retrieval from simulation instance. Real-time simulation transaction monitoring. WSDL and XSD report card to measure against corporate best practices. Customizable runtime messaging governance analysis rules. Multiple simultaneous service simulations. Complex business logic simulation with runtime variable state machine. WS-Security and WS-Identity extensibility. Database and plug-in API extensibility.

Crosscheck Networks also provides a comprehensive tutorial on the product usage.

As defined in Accelerate your SOA Projects through Service Simulation white paper

Intense time pressures to build and deploy services leaves very little room for error in meeting business goals set forth for SOA projects. With IT budgets under constant pressure, tight delivery deadlines, and the drive to integrate systems within and across trading partners, SOA projects need to introduce service simulation within their environments. Service simulation decouples consumers and producer dependencies and enables them to implement independently. Web Services mocking solutions provides a "reference system in-a-box" and eliminates the expense associated with building a full-scale replica of the production system for the benefit of developers.

1 comment

Reply

Use soapUI for mocking instead by Ole Matzura Posted May 14, 2008 12:33 AM

Back to top

Use soapUI for mocking instead

May 14, 2008 12:33 AM by Ole Matzura

Use soapUI instead for mocking web services, it has far more features than SOAPSimulator, a huge user community (>70000 users) and is both free and open-source (LGPL licensed).

Check it out: http://www.soapui.org

Tutorial on mocking is at http://www.soapui.org/gettingstarted/mocking.html

Good Luck!

Exclusive Content

Operational Scalability in the Next Generation Web World

Wayne Fenton, Director of Architecture at eBay Inc., talks about the ways in which software architects can design systems for much-improved efficiency and reliability from an operational perspective.

An Overview of the eXo Platform

Mestrallet and Grall cover the eXo platform, the Portlet 1.0 (JSR 168) and 2.0 (JSR 286) specs, eXo Web 2.0 Portal, JSR 286 Inter-portlet communication, eXo JCR and eXo Enterprise Content Management.

The Top 10 Ways to Botch Enterprise Java Application Scalability and Reliability

Purdy discusses Java scaling, performance vs scaling, rewriting frameworks, databases, bottlenecks, abstractions, disaster recovery, one-size-fits-all architecture, big JVM heaps and network failures.

Building Scalability and Achieving Performance: A Virtual Panel

Our panel of leading experts explores some of the challenges and thought processes that go into making their apps as scalable and performant as possible.

Domain-Driven Design in an Evolving Architecture

Mat Wall and Nik Silver explain how their has been using Domain-Driven Design in an evolving and Agile environment, at high traffic news site guardian.co.uk.

Avi Bryant on DabbleDB, Smalltalk and Persistence

In this interview, Avi Bryant talks about the Smalltalk web framework Seaside, DabbleDB, using Smalltalk images for persistence instead of an RDBMs, GemStone and more.

Book Review: Agile Adoption Patterns, A Roadmap to Organizational Success

With Agile adoption, context is everything: this book offers patterns and tools to help determine which practices most contribute to meeting your organization's goals.

Rob Windsor on WCF with REST, JSON and RSS

WCF is not just for SOAP based services and can be used with popular protocols like RSS, REST and JSON. Join Rob Windsor as he introduces WCF 3.5 and its new native support for non-SOAP services.


You are viewing a mobilized version of this site...
View original page here

Mobilized by Mowser Mowser