|
Size: 3895
Comment: linking "extending" page + fixing typos
|
← Revision 4 as of 2011-08-30 19:30:51 ⇥
Size: 3891
Comment:
|
| 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
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 parent constructor
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 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
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.
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.