Popular Posts

Tuesday, September 23, 2008

WSO2 Data Services plugin for Eclipse WTP

WSO2 Data Services 1.0 provides you with a IDE plugin which can be integrated to Eclipse WTP. You can create and deploy data services to a remote or local data services server from IDE. This post demonstrates how a simple MySQL data service is created and deployed using Eclipse WTP.

Pre-requisites

Download and install WSO2 Data Services 1.0
Download and install Eclipse WTP

We will create a data service using MySQL. Please follow the instructions provided in WSO2 Data Services Quick Start Guide to create a data base and populate data.

Step 1

Download wso2 data services eclipse plugin (org.wso2.ws.dataservices.ide_1.0.0) from here and copy it to Eclipse_home/plugins directory.

Start Eclipse and select a new workspace. Select Workbench to go to the work bench.

Step 2
Open the new wizard selection window (File --> New -- Other). If you have copied org.wso2.ws.dataservices.ide_1.0.0.jar to the eclipse plugins directory correctly, you will see WSO2 Data service wizard option in there.



Select wso2 dataservice creation wizard and click on Next. The initial configuration screen of the Data Service Creation wizard will be displayed as follows.



Select Try it after deploying check box.
We are going to create a data service through IDE wizard and deploy it to a wso2 dataservice server running in localhost. (You can deploy data services to a remote server as well).
Therefore, you need to provide truststore and administrator credentials in that server.

Click on Set truststore. Browse for wso2carbon.jks which is located at your WSO2DS_Home/conf directory. (WSO2DS_HOME is the location where you unzipped wso2 dataservice 1.0 binary distribution)
You will be prompted to enter password for the trust store. Enter wso2carbon and click ok.

Click on Set Credentials to enter username and password of the target data service server.
Enter admin as the user name and password.

Click on Next to proceed through the wizard.

Step 3

Now you are at the step one of data service configuration wizard.
Give a name for the service (i.e:-IDEDataService)

Click on Add button to add a new data source. Since we use MySQL data source, select RDBMS as the data source type and click ok.

You will get a message saying "Currently typed database driver class does not reside in the class path. Please provide correct path to the jar file". Click ok.

Now you will be directed to the mySQL database configuration window.



Enter the following values for MySQL database configuration.

Driver Class = com.mysql.jdbc.Driver
JDBC URL = jdbc:mysql://localhost:3306/employeedb
Enter the user name and password of your MySQL db.

Enter jar path to driver class (mysql-connector-java-*-bin.jar). Then click on Test Connection button. You should get "Test Connection Successful" message.
Click "OK" to finish the database configuration.

Click "Next" in the WSO2 Data service wizard Step one to move to the next step.

Step 4

Now you should be in the step 2 of the wizard. Click on Add New Query. Following window will be displayed.



Select default data source. Enter the follwoing values for the rest of the fields.

Query ID = allEmployees

SQL Statement = select * from employee

Grouped by Element = employees

Row name = employee

Row namespace = http://test.org

Now click on 'New' button under 'Result (Output mapping)' window. 'Add New Output Mapping' window will be popped up. Add three output mappings as follows

  1. Mapping Type = Element

    output field name = id

    SQL Column Name = id

  2. Mapping Type = Element

    output field name = name

    SQL Column Name = name

  3. Mapping Type = Attribute

    output field name = address

    SQL Column Name = address

We have added one query to our data service configuration.

Click on 'OK' button at the "Query Configuration" window. You will be directed back to the step two of data service wizard and your new query will be listed there.

Click Next button to continue. Step three of the data service configuration wizard will be displayed.

Step 5

Click on 'Add New Operation' button. Enter a name for the operation (i.e: getAll) and leave the default settings and click ok.

By now, we have completed all data service cinfiguration steps. Click Finish to deploy the service.

(Make sure wso2 data service server instance is running in your host before finishing the IDE wizard. You can start it by running wso2server.bat located at WSO2DS_HOME/bin directory)

If all are correct you will get "Data Service deployed successfully" message. Also, a browser will be popped up withTryit page where you can easily test the service.

Sunday, September 21, 2008

How to use assertions in JMeter SOAP/XML-RPC sampler

Assertions are essential components in a JMeter test plan. They are very important in regression testing in which you can compare test results with a pre-defined output. 
As I explained here, JMeter Soap/xml-rpc request sampler can be considered as an one of the easiest mechanisms to test web services. 
Lets see how assertions can be added to a Soap/xml-rpc sampler so that you can use it easily in automated web services regression testing.

Before continue with this, you may go through  the following articles.

Step 1
In this example we are going to invoke the sample version service that ships with Apache Axis2.
Therefore, please download Apache Axis2-1.4.1 binary distribution from here and extract it in your file system.

Start Axis2server by runnning axis2server.bat{sh}

Step 2
Start JMeter by running jmeter.bat or sh.
Right click on Test Plan element and add a thread group.
Then add the SOAP/XML-RPC Request sampler element to the above thread group. 
(Add --> Sampler --> SOAP/XML-RPC Request)

Paste the following soap request in the Soap/XML-RPC Data section in the sampler.

<?xml version='1.0' encoding='UTF-8'?>
   <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
        <soapenv:Body>
       <ns0:getVersion xmlns:ns0="http://axisversion.sample"/>
      </soapenv:Body>
   </soapenv:Envelope>

Enter "http://localhost:8080/axis2/services/Version" as the URL.
Enter "urn:getVersion" for "Send SOAPAction".

Step3

Right click on the SOAP/XML-RPC Request sampler element and Add --> Assertions --> Response Assertion

Enter a suitable name for the assertion. 
Enter "Hello I am Axis2 version service" as the pattern to test.
Select "Text Response" as Response Field to Test.
Select "Contains" as the pattern matching rule. 



Step 4
Now we need to visualize the result of this assertion. Therefore right click on the Thread Group element and Add --> Listener --> Assertion Results

Run the thread group. If test is successful, you will not get any errors in Assertion Results. 
Change the pattern matching rule of the assertion in to "Matches" and run the test again.

You will see the failed assertion in assertion results view.


You can extend this test with more complex web services and add assertions accordingly. Then this can be executed in regression testing of your web services. 

Friday, September 19, 2008

QA role in Hackathons and Risk based testing

A few days back, we had a hackathon at WSO2 in order to resolve a large number of open bugs and boost the schedule of Data Services 1.0 release. A set of developers and QA team sat together and went through the open issues and eventually got more than 100 defects fixed and verified.
If you are familiar with hackathons or if you are a tester, you may certainly raise the following questions.
- What is the role of QA in a Hackathon
- How to deal with the regression issues and frequent builds

It certainly is a challenge to involve in testing and quality assurance during a hackathon. There is a high risk of breaking the features in between builds. However if you manage it properly, Hackathons are good opportunities for QA and testing teams to get more familiar with the AUT (Application under test) hence uncovering more and more bugs, learn and share the knowledge of practical use cases of products etc..

Lets try to find out answers for the above questions from QA user point of view.

What is the role of QA in a hackathon?

As defined in the wikipedia, Hackathon is an event when programmers meet to do collaborative software development. Testers, BAs, PMs and other astake holders may also take part in it.

The primary role of QA/test teams in a hackaton is reproduce the issues which were reported by them. This involves functional issues, cross browser issues as well as cross platform related bugs. The reporter of the bug knows the way to recreate it than any other.
This will greatly reduce the time to reproduce bugs and help developers to get them fixed effectively.
In most occasions, the AUT is started in debug mode in testers machines and someone familiar with the code, debug the source remotely to get the issues fixed quickly.

Whenever a bug is marked as resolved, testers get an update from source repository (in our case SVN), build the source and verify and close or reopen the bug.

Hackathons are ideal places to discuss the usage scenarios/patterns of the product being developed. QA/testers can identify more and more scenarios and apply them in testing. This help to uncover a lot of hidden bugs.

It is an essential for QA/testers to have and set the source code up in their IDEs. If you are familiar with the code and know the root cause of the issue, you are free to go ahead and fix the bug by your self. We did it and worked well :)
One of the most important requirement to have source with QA during a hackathon is, QA can go through a module with some developer and try to find out the places where bugs can be introduced. This glass box testing approach is one of the most important feature in a hackathon.

During a hackathon, QA find bugs and report it immediately to the relevant developer and get it fixed. QA should make sure to track all issues using the bug tracking system though some of the issues are reported verbally.

Dealing with regression issues and frequent builds

While fixing more and more bugs it is essential to ensure that the regression issue are minimum. Regression testing is the most difficult task for QA in a hackathon. Whenever a set of bugs are fixed, you get an update from source repository and build in your machine. Then you verify the bug and close it.
When you do this, there is a high chance to missing more and more regression issues. So, as a QA tester, how do you deal with it?

Before starting a hackathon, you should have a proper idea about the most critical features of the AUT. You should identify the areas which can cause most damages to the recognition of the product as well as for your customers. Then you should keep in mind that these critical features are not regressed in any new build use for testing. In other wards, though you test 4-5 new builds per day, you must ensure that the highly risked features are verified and tested properly.
Risk based testing is the most suitable approach to ensure the critical features are not broken during a hackathon.

It is important to get a few labeled builds for testing during a hackathon. We could not do this in Data service 1.0 hackathon though. We cannot guarantee the quality of the builds taken from users local repositories. Therefore, to make sure the AUT is in a proper state, it will be essential to have a labeled QA release built from a pure build environment and release for testing.

After all, Data Service 1.0 hackathon went really well and helped to deliver the product on time with acceptable quality!

Throttling request messages with WSO2 Data Services

WSO2 Data services 1.0 has been released now. This free and open source product consists of a lot of useful features which can be used to implement your SOA based systems with minimum effort.
Access throttling can be considered as a new and vital feature included in it.
In web services interactions, we usually have requirements to restrict number of requests our web services serve for a given client. Also, we need to allow service access to a specified domain or IP range.
WSO2 Data Services provides an easily configurable UI based utility to throttle messages targeted to a particular data service or a set of services.
This post will take you through a basic throttling configuration.

Pre-requisites
Download and install WSO2 Data Services 1.0

Step 1
Start server by running WSO2DS_HOME/bin/wso2server.bat{sh}
Access wso2 data service management console (https://localhost:9443/ds)
Log in to console with default admin credentials (admin/admin)
Select Data Services link in the left navigation menu. You will be directed to the Deployed Services page.
Click on the default service, CustomerService
You will see the following page.



Step 2

Click on Throttling link which is placed under Quality of Service in the above page.
Throttling Configuration for CustomerService Service page will be displayed.
Select "Yes" from Enable Throttling drop down.
Default throttling configuration will be displayed as follows.



In the above table, Range denotes the IP addresses and domains to be restricted.
Remove the second row of configuration table.
In this demonstration we will restrict accessing the default CustomerService to the requests originating from local host. Therefore you can leave "other" as the range "IP" as type.

There are three access levels.
Allow - All requests are allowed without applying any restriction for the specified range
Deny - Access is denied for all requests comes from the given range
Control - Restrictions are applied based on the given constraints (Max Request Count, unit time and prohibit time period)

In this demonstration, we are going to use "Control" access level. Hence, Change the Access level to "Control". Max Request Count, Unit time and prohibit time period text boxes will be enabled.

Enter 10 as Max Request Count. 100000 as Unit time and 20000 as prohibit time period.
This means, our sample data service (CustomerService) accepts only 10 requests from localhost during 100 seconds (100000ms) . If all 10 requests hits the server before unit time expires (before 100 seconds), no more requests are allowed in to the service within 20 seconds (20000ms) as specified in prohibit time period.

A more detailed explanation on these terms can be found in the inline help of WSO2 Data services management console.

Click on Finish button to save the throttle configuration.


Step 3

Our throttling configuration is over by now. Lets invoke the sample service 10 times and see how throttling works.
Go back to the service management page of the CustomerService and click on Try this Service link.
Select "customersInBoston" operation and click on "customersinBoston" button. Hit this button 10 times to send 10 requests to CustomerService.
Send one more request. You will receive a fault similar to the below.

Fault: Access deny for a caller with IP 127.0.0.1 : Reason : You cannot access this service since you have exceeded the allocated quota.

Monday, September 15, 2008

Getting started with WSO2 Data Services

As I mentioned in a previous post, WSO2 Data Services is now available for you to download and try out. WSO2 Data Services is an open source product and it is available under apache license.

The objective of this post is to get you start with WSO2 Data Services with minimum configuration steps. You can find more details of WSO2 Data Services solution from wso2.org online documentation

Step 1
Download and install wso2 data service solution. You may download the latest beta2 version from here. Just extract wso2-dataservices-1.0-xx.zip in to a directory in your file system.
We refer this directory as WSO2DS_HOME.

Step 2
Start wso2 data services solution. Go to WSO2DS_HOME/bin and run wso2server.bat{sh}

Step 3
WSO2 Data services provides a web service interface for data stored in relational data bases, csv or Microsoft Excel files. Since our intention is to get our first data service running as quicker as possible I will use a simple csv file as the data source.
Open a text editor and create a csv file as follows.

id,name,address
01,charitha,colombo

02,Michel,Dallas

03,John,Westborough


Save this file as employee.csv.

Step 4
Access WSO2 Data Services management console. Open a browser and go to http://localhost:9443/ds
Click on Sign-in link at the top right corner. Enter username = admin and password = admin as login credentials.
You will be directed to the home page of Data Services management console.



Step 5

Click on Add from the left navigation menu. The step one of data service creation wizard will be shown.
Enter csvservice as the Service name and click on Next.

Step 6

Select csv as the data source type and click on Add.


Step 7

In CSV Data source configuration window, enter the following values.
Id = 1
CSV File location = D:\temp\employee.csv
Column Seperator = ,
Starting Row = 2
Max. no of rows to read = -1
Headers Available = TRUE
Column Selection (You can click on the column names specified in the drop down. Then it will add column numbers according to the sequence of selection)
id as column no:1
name as column no:2
address as column no:3



Step 8

Click "Next" from the data service wizard step 2. You will be directed to the step 3 where you can create queries for the service.
Click on "New Query" button.
Add New Query window will be popped up. Enter the following values.

QueryID = q1
DataSource = 1
Grouped by element = emps
Rowname = emp

Click on "Add New output mapping" button. In "Add new Output mapping" window, enter the followings. (Repeat this with name and address columns as well)
Mapping Type = Element
Output field name = id
CSV Column ordinal = 1



Step 9

If query is configured as in the previous step, you should notice the following elements in the "Preview of Data service configuration" section.
<query id="q1" useConfig="1">
<result element="emps" rowName="emp">
<element name="id" column="1" />
<element name="name" column="2" />
<element name="address" column="3" />
</result>
</query>

Click on next button of the Data Service Step 3 to continue with the wizard. Step 4 will be displayed where the service operations are configured.

Click on Add New Operation button.
"Add New Operation" pop-up window will be displayed. Enter the following values.
Operation name = op1
Query = q1
Click OK

Now all the data service configuration steps are done. Click on Finsh button to deploy our CSV data service.

Step 10
csvservice will be added to the deployed services list in Deployed Services page.
Lets invoke our data service using the simplest service invocation mechanism and see we get the data stored in csv file as the output.

Click on csvservice. Service Management page will be displayed.
Select Try this service link.
Click on op1 button and you will get the results as follows.

Friday, September 5, 2008

How to avoid OutofMemory error when building projects with Maven2

You may have encountered outofMemory issues when building source with Maven2. This normally happens when Maven runs out of available system memory.
In such case you have to set MAVEN_OPTS environment variable to increase the available memory.

In Windows
Open a command prompt in which you build the source and enter the following options. (Change the memory size according to the amount of memory in your system)
SET MAVEN_OPTS=-Xmx1024m

In Linux
Open a shell and set the options as follows.
export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=128m"

Thursday, September 4, 2008

Data Services-1.0Beta - The latest member of WSO2 SOA middleware suite

We have been working hard over the last few weeks to launch the newset addition to the WSO2's SOA middleware platform, WSO2 Data Services -1.0beta. Now you can download it and explore the power of web services with relational data, data stored in csv or Microsoft Excel files. 
WSO2 Data Services provides a convenient and user-friendly mechanism to expose data as web services and utilize a lot of QOS features such as WS-Reliable Messaging, WS-Security etc..
It consists of a management UI which allows you to create, deploy and invoke data services without writing a line of code. Also, Eclipse IDE plugin brings the Data servce functionality into Eclipse IDE in which you can configure data services very easily. 

There are lot more things you can do with this new product and some of the helpful references were already published. You may begin with quick start guide.
Stay tuned. This blog will be updated with many how-tos on WSO2 data services soon.

Tuesday, September 2, 2008

One more browser to test against!

Browser compatibility issues are annoying. You cannot guarantee an application behaves similarly in all popular browsers without repeating the same set of tests in each of them. It is a headache!
To make the things worst for developers as well as testers, yet another browser has been added to the list.

Google recently announced the launch of their open source browser called Chrome. So, we now have one more browser to make our applications compatible with. Applications need to be designed in a way so that they work properly in all major browsers. Testers need to put some extra effort to make sure cross-browser issues are minimum. Also, UI automation tool kits should be made compatible with this new browser.

Google has released the beta on Windows first. Lets see what difference will this new browser make.