SOA / Web Services / Java

A Technology Blog

Posts Tagged ‘testing’

SOAMOA – New kid in the block

Posted by Vivek on May 15, 2010

This is just an extension to my previous post (SOA Testing). Most of the java developers look to automate web service testing. If you are using SOAPUI, this is possible by writing junit test cases and then invoking SOAPUi projects from junit for a particular test case. It might be the case that you do not want to rely on any tool while testing and end up creating test cases that creates and invokes request for you. With the same intention, I was looking for a free tool and found this one – SOAMOA.

Still in its infancy stage, this tool may not be used for all your testing needs but some features look promising. The GUI is not too great. It doesn’t offer you to set preferences and does not support web services standards. For all this, you already have a free tool SOAPUI (not the pro version). The only striking feature is the ability to generate junit test cases and groovy script based upon your request. You just need to import your WSDL and create SOAP Request as you generally do in SOAPUI. 

If you have a request, for eg.

<SOAP-ENV:Envelope xmlns:SOAP-ENV=”http://schemas.xmlsoap.org/soap/envelope/“>
    <SOAP-ENV:Header/>
    <SOAP-ENV:Body xmlns:web=”http://webservices.service.employee.com/“>
        <web:getEmployeeDetail>
            <arg0>
                <employeeId>2000</employeeId>
                <employeeName>Monster</employeeName>
                <company>hell techologies</company>
            </arg0>
        </web:getEmployeeDetail>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Creating Groovy Script for the request will produce the following:

/* Generated GroovyWS Script by SoaMoa, :vivek at Sat May 15 10:53:13 GMT+05:30 2010 */

import groovyx.net.ws.WSClient

def proxy = new WSClient(“file:/C:/…../WEB-INF/wsdl/EmployeeService.wsdl”, this.class.classLoader)
proxy.create()
def arg0 = proxy.create(“com.employee.service.webservices.GetEmployeeDetailRequest”)
arg0.employeeId = 2000
arg0.employeeName = ‘Monster’
arg0.company = ‘hell technologies’
def getEmployeeDetailResponse = proxy.getEmployeeDetail(arg0)

A junit class will look like:

/* Generated Testcase by SoaMoa, :vivek at Sat May 15 10:59:54 GMT+05:30 2010 */

import java.util.Map;
import javax.xml.namespace.QName;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;
import javax.xml.ws.Dispatch;
import javax.xml.ws.Service;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.soap.SOAPBinding;

import java.util.Iterator;

import junit.framework.TestCase;

public class GetEmployeeDetailTest extends TestCase {
public void testGetEmployeeDetail() throws Exception {
String endpointURL = “
http://myhost:myport/MyApp/services/EmployeeService“;
QName serviceName = new QName(“
http://webservices.service.Employee.com/“, “EmployeeService”);
QName portName = new QName(“
http://webservices.service.Employee.com/“, “EmployeeServiceWSPort”);
Service service = Service.create(serviceName);
service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, endpointURL);
Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Service.Mode.MESSAGE);
MessageFactory messagefactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
SOAPMessage request = messagefactory.createMessage();
SOAPPart part = request.getSOAPPart();
SOAPEnvelope env = part.getEnvelope();
SOAPBody body = env.getBody();

body.addNamespaceDeclaration(“web”, “http://webservices.service.Employee.com/“);
    SOAPElement getEmployeeDetail = body.addChildElement(“getEmployeeDetail”, “web”);
        SOAPElement arg0 = getEmployeeDetail.addChildElement(“arg0”);
            SOAPElement employeeId = arg0.addChildElement(“employeeId”);
            employeeId.addTextNode(“2000”);
            SOAPElement employeeName = arg0.addChildElement(“employeeName”);
            appId.addTextNode(“Monster”);
            SOAPElement company = arg0.addChildElement(“company”);
            EmployeeId.addTextNode(“Hell Technologies”);           
request.saveChanges();

SOAPMessage response = dispatch.invoke(request);
SOAPBody replyBody = response.getSOAPBody();
}
}

 

Advertisements

Posted in SOA Testing | Tagged: , , , | Leave a Comment »

SOA Testing – Tools in the market

Posted by Vivek on May 9, 2010

Here is a list of the leading testing tools available in the market to test the SOA components. I believe that no tool can completely fulfill the testing requirements of an SOA but you can accomplish a lot. The tools should be intelligent enough to carry out:

i. Schema/ WSDL/ SOAP validation
ii. Simulation of webservice, both client and server  i.e., mock services
iii. Testing of web services standards such as web services addressing, security, reliable messaging etc.
iv. WS-I conformance testing
v. Testing of intermediaries
vi. Governance testing. Validation of design and run time policies and Service versioning.
vii. Asynchronous and notification framework testing
viii. Orchestration and Choreography testing
ix. Performance testing

Below is a list of tools that cover some or most of the above points:

1. Green Hat GH Tester : This tools provides comprehensive testing of SOA. Helpful in providing performance and security related testing and validation of SOA and BPM components. You can monitor SOA performance and track service invocation and response.

2. Mindreef SOAPScope Server : Acquired by progress software. Allows creation of mock services, validation and compliance checking.

3. Parasoft SOATest : Helps in performance or load and security testing. Provides governance testing by performing policy enforcement checks. Allows creation of mock services and performing regression testing.

4. Crosscheck Networks SOAPSonar : Performs functional, performance, compliance, and security testing across SOAP, XML, and REST based services.

5. iTKO Lisa : Performs UDDI test/ validation, performance , validation and compliance and mock service testing.

6. Matador Tech Tester : suitable for validation and regression testing.

7. SOAP UI: Performs functional, load/ performance and mock service testing. Also helpful in validation and compliance testing.

 

Posted in SOA Testing | Tagged: , , , , , , | 7 Comments »

Testing ESB that choreographs web services

Posted by Vivek on March 28, 2010

It is not easy to test components of a service oriented architecture. Many people use the terms SOA and Web Services interchangeably and think that SOA cannot be implemented without web services.  However, this is not true. Web Service is just a way to implement SOA. There are projects which do not use web services but still inherit merits of a SOA. Grid Computing is one such example. So if you have a project where you have used an ESB to choreograph web services to achieve a desired functionality, then testing these web services (using a tool like SOAPUI etc) is not enough. One many not be interested only in testing the business functionality but also in testing the integration logic that resides within an ESB. This may not sound feasible as in most of the cases there are more than one webservice and each will accept input in a different format. So you cannot simulate all web services. But you definitely create a wrapper service that can accept request in any format and helps you  gauge whether your ESB has performed its job before invoking the service. Now what does a wrapper service do in this case:

1. No changes required in the ESB. Just a small configuration so that when you perform a dynamic lookup of end-point, the request is always directed to the wrapper service.

2. The wrapper service does not require implementing operations for each request. One operation that takes an Object as an input can serve the purpose.

3. A SOAP Handler that validates the SOAP Header and a function call from handleRequest method of SOAP Handler to validate the SOAP Body or message payload can be implemented.

4. No testing tools required. Leverage junit and xmlunit to perform assertion. Optionally, use APIs provided by SOAPUI to invoke test cases defined within your SOAP UI project to perform service validation.

Posted in SOA Testing | Tagged: , , , , | Leave a Comment »