Differences between revisions 3 and 4
Revision 3 as of 2011-08-30 19:29:34
Size: 3895
Editor: 61
Comment: linking "extending" page + fixing typos
Revision 4 as of 2011-08-30 19:30:51
Size: 3891
Editor: 61
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
== Adding New Sample to automation Framework == == Adding New Sample to Automation Framework ==
Line 97: Line 97:

Adding New Sample to Automation Framework

Let's assume you are writing a sample to demonstrate to functionality of the new "Foo" mediator you wrote. For this quick guide, we'll assume your sample id is 999, and that your sample consumes SimpleStockQuoteService from one axis2 server instance.

1. Synpase configuration XML

This is the configuration for mediation engine. Place it in $SYNAPSE_HOME/repository/conf/sample (file name can be synapse_sample_999.xml)

2. Sample descriptor

In this file, you have to tell the framework which servers to run, which transport you want, the repository locations, synapse configuration and client configuratio.

Place it in $SYNAPSE_HOME/modules/integration/src/test/resources as sample999.xml


    <sampleName>Demonstrating Foo mediator</sampleName>
        <axis2Server id='0'>

3. Test class

Your test class for the sample have to extend from


Place it in the tests sources of integration module. The package should be org.apache.synapse.samples.framework.tests or one of its subpackage.

Pass the sample id to the parent constructor


package org.apache.synapse.samples.framework.tests.message;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.synapse.samples.framework.SampleClientResult;
import org.apache.synapse.samples.framework.SynapseTestCase;
import org.apache.synapse.samples.framework.clients.StockQuoteSampleClient;

public class Sample999 extends SynapseTestCase {

    private static final Log log = LogFactory.getLog(Sample999.class);
    SampleClientResult result;
    StockQuoteSampleClient client;

    public Sample999() {
        client = getStockQuoteClient();

    public void testFoo() {
        String trpUrl = "http://localhost:8280/services/StockQuote";

        log.info("Running test: Foo demonstration");
        result = client.requestStandardQuote(null, trpUrl, null, "IBM" ,null);
        assertTrue("Client did not get run successfully ", result.gotResponse());

Place your test class and place it in the tests sources of integration module.

SampleClientResult object will store the result from your client execution so you can assert if you got the response, which exceptions you recieved, etc.

4. Adding to maven sample automation handler

To the method populateSamplesMap() of the class



sampleClassRepo.put("999", Sample999.class);

5. Running the sample

Now your sample will be automated together with all other samples whenever you execute mvn test form integration module. Also you can use

mvn test -Dtests=999

to automate only your sample.

More Functionality

In addition to this basic functionality, the framework offers several type of servers, axis2 services, clients. Also, further configuration such as varoius transports, clustering can be made.

See FrontPage/Synapse/Samples/AutomationFramework/Extending

FrontPage/Synapse/Samples/AutomationFramework/AddingNewSample (last edited 2011-08-30 19:30:51 by 61)