You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ws.apache.org by Apache Wiki <wi...@apache.org> on 2011/08/30 16:22:05 UTC

[Ws Wiki] Update of "FrontPage/Synapse/Samples/AutomationFramework/AddingNewSample" by AmilaManoj

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Ws Wiki" for change notification.

The "FrontPage/Synapse/Samples/AutomationFramework/AddingNewSample" page has been changed by AmilaManoj:
http://wiki.apache.org/ws/FrontPage/Synapse/Samples/AutomationFramework/AddingNewSample

Comment:
Initial post

New page:
== Adding New Sample to automation Framework ==
Let's say you are writing a sample to demonstrate to fucntionality 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.

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

=== 2. Sample descriptor file ===
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'''

e.g.

{{{
<synapseSample>
    <sampleID>999</sampleID>
    <sampleName>Demonstrating Foo mediator</sampleName>
    <synapseConfig>
        <axis2Repo>repository/samples/synapseConfigs</axis2Repo>
        <axis2Xml>repository/samples/synapseConfigs/synapseAxis2/axis2_def.xml</axis2Xml>
        <synapseXml>repository/conf/sample/synapse_sample_999.xml</synapseXml>
    </synapseConfig>
    <backEndServerConfig>
        <axis2Server id='0'>
            <axis2Repo>repository/samples/axis2Configs</axis2Repo>
            <axis2Xml>repository/samples/axis2Configs/axis2_def.xml</axis2Xml>
        </axis2Server>
    </backEndServerConfig>
    <clientConfig>
    <clientRepo>repository/samples/client_repo</clientRepo>
    </clientConfig>
</synapseSample>
}}}
=== 3. Test class ===
Your test class for the sample have to extend from

{{{
org.apache.synapse.samples.framework.SynapseTestCase
}}}
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 constructor of parent class

e.g.

{{{
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() {
        super(999);
        client = getStockQuoteClient();
    }

    public void testDumbClientMode() {
        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

{{{
org.apache.synapse.samples.framework.TestSamplesHandlerSuite
}}}
Add,

{{{
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.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ws.apache.org
For additional commands, e-mail: dev-help@ws.apache.org