Saturday, November 29, 2014

Synapse Handler

Synapse handler is similar to axis2 handler , that can be used in RESTAPIs to handle incoming request and the responses.

Sample handler ;

package test;

import org.apache.synapse.MessageContext;

public class TestSynapseHandler extends AbstractHandler {
public boolean handleRequest(MessageContext messageContext) {
String idKey = "idKey";
String idValue = "abc";
messageContext.setProperty(idKey, idValue);
return true;

public boolean handleResponse(MessageContext messageContext) {
// TODO Response handling
return true;


Handler has to be registered in the RESTAPI configuration.

Sample configuration;

<api xmlns="" name="calAPI" context="/cal">
   <resource methods="GET">
               <address uri="http://localhost:9763/services/calservice"/>
        < handler class="test.TestSynapseHandler"/>

Tuesday, November 11, 2014

Debugging tests in maven project

If we use 'maven' as build tool for java projects, to run test cases we might use Surefire plugin. Plugin can be added in pom.xml like

To debug testcases; run
# mvn -Dmaven.surefire.debug test

Which will make the debugger to run port 5005