Revision 1 as of 2011-08-30 13:34:44
|Deletions are marked like this.||Additions are marked like this.|
|Line 101:||Line 101:|
|==== Additional Servers ====
You can add additional servers to the framwork by writing your own server controller, implementing org.apache.synapse.samples.framework.!ProcessController.
Extending Synapse Sample Automation Framework
The framework will do tasks such as starting Syanpse with a provided configuration, starting back end servers such as Axis2, JMS broker, Derby server prior to the test and shutting down them after the test. It will also handle the requests from clients for currently implemented sample services.
The configuration for a sample is provided to the framework through a descriptor file.
The file name of the descriptor should be the Sample<sample-number>.xml and it should be placed in test resources direcotry: SYNAPSE_HOME/modules/integration/src/test/resources
The structure of the descriptor is as follows,
<synapseSample> <sampleID>999</sampleID> <sampleName>Foo</sampleName> <synapseConfig> ... </synapseConfig> <backEndServerConfig> ... </backEndServerConfig> <clientConfig> ... </clientConfig> </synapseSample>
The framework will start synapse server before running a sample. Synapse specific configuration is defined in <synapseConfig> element in the descriptor. Here, Synapse configuration xml file for your sample is mandatory. Others are optional. You can specify the repository location for synapse (where addressing module, etc. is located), Axis2 Xml for synapse can also be specified. This is useful when your sample require configuring transports, clustering, etc.
The framework provides pre-configured axis2.xml files for default http/https transport (axis2_def.xml), jms, tcp, udp transports and axis2 clustering (. You can either choose to specify one of those or give your own customized axis2.xml location. The paths specified here are relative to synapse home.
<synapseConfig> <axis2Repo>repository/samples/synapseConfigs</axis2Repo> <axis2Xml>repository/samples/synapseConfigs/severalsynapseAxis2/axis2_jms.xml</axis2Xml> <synapseXml>repository/conf/sample/synapse_sample_250.xml</synapseXml> </synapseConfig>
You can start any number of backend servers for your sample. Currently Axis2, JMS Server and Derby Server are supported.
Configuration relevant to all the back end servers are given in <backEndServerConfig> in the descriptor file
<backEndServerConfig> <axis2Server id='0'> ... </axis2Server> <axis2Server id='1'> ... </axis2Server> <axis2Server id='2'> ... </axis2Server> ... ... <jmsBroker id='3'> ... </jmsBroker> ... ... <derbyServer id='5' /> ... </backEndServerConfig>
You can define a new axis2 server using <axis2Server> and specify the configuration similar to <synapseConfig>
<axis2Server id='0'> <axis2Repo>repository/samples/axis2Configs</axis2Repo> <axis2Xml>repository/samples/axis2Configs/axis2_def.xml</axis2Xml> </axis2Server>
Here again, framework provides preconfigured axis2 xml files with default http/https transport(axis2_def.xml), for clustering (axis2_clustering.xml) and jms transport (axis2_jms.xml)
By default, following axis2 services used for existing samples are deployed in Axis2 Server
If want use an Axis2 service other than those, you can create the service, create the aar file and copy to SYNAPSE_HOME/repository/samples/axis2Configs/services direcotry.
If you want JMS transport, you can use apache ActiveMQ as the JMS broker. This can be defined under <backEndServerConfig> in the descriptor file.
<jmsBroker id='0'> <providerURL>tcp://localhost:61616</providerURL> <initialNamingFactory>org.apache.activemq.jndi.ActiveMQInitialContextFactory</initialNamingFactory> </jmsBroker>
If your samples interacts with some database, you can use Apache Derby as the database server. It can be configured as,
<derbyServer id='1' />
You can add additional servers to the framwork by writing your own server controller, implementing org.apache.synapse.samples.framework.ProcessController.
In addition to Synapse and Back-end servers, certain properties specific to clients can also be given in the descriptor
<clientConfig> <clientRepo>repository/samples/client_repo</clientRepo> <axis2Xml>repository/samples/client_repo/conf/axis2_jms.xml</axis2Xml> </clientConfig>
The framework provides several clients for existing samples,
StockQuoteSampleClient - Creates and sends a stock quote request, consumer of SimpleStockQuoteService
- MTOMSwASampleClient - Sends binary content using MTOM and SwA optimizations
- JMSSampleClient - Posts a raw JMS text or binary message
EventSampleClient - Does Synapse event source related operations such as subscribing, unsubscribing. event sending
If you want your custom client for your own axis2 or other services, you can create the client and add it to the package: