You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by hi...@apache.org on 2011/12/08 11:10:19 UTC
svn commit: r1211800 - in /synapse/trunk/java/modules/integration/src/test:
java/org/apache/synapse/samples/framework/
java/org/apache/synapse/samples/framework/clients/
java/org/apache/synapse/samples/framework/config/
java/org/apache/synapse/samples/...
Author: hiranya
Date: Thu Dec 8 10:10:18 2011
New Revision: 1211800
URL: http://svn.apache.org/viewvc?rev=1211800&view=rev
Log:
Code refactoring
Added:
synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/config/
synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/config/Axis2ClientConfiguration.java
synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/config/Axis2ServerConfiguration.java
synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/config/DerbyConfiguration.java
synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/config/JMSBrokerConfiguration.java
synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/config/SampleConfiguration.java
synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/config/SynapseServerConfiguration.java
Removed:
synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/SampleConfiguration.java
Modified:
synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/Axis2BackEndServerController.java
synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/DerbyServerController.java
synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/JMSBrokerController.java
synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/SampleClientResult.java
synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/SynapseProcessController.java
synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/SynapseTestCase.java
synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/clients/EventSampleClient.java
synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/clients/MTOMSwASampleClient.java
synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/clients/StockQuoteSampleClient.java
synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/tests/endpoint/Sample53.java
synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/tests/endpoint/Sample55.java
synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/tests/endpoint/Sample57.java
synapse/trunk/java/modules/integration/src/test/resources/sample53.xml
Modified: synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/Axis2BackEndServerController.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/Axis2BackEndServerController.java?rev=1211800&r1=1211799&r2=1211800&view=diff
==============================================================================
--- synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/Axis2BackEndServerController.java (original)
+++ synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/Axis2BackEndServerController.java Thu Dec 8 10:10:18 2011
@@ -8,6 +8,7 @@ import org.apache.axis2.description.Tran
import org.apache.axis2.engine.ListenerManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.samples.framework.config.Axis2ServerConfiguration;
import java.util.concurrent.CountDownLatch;
@@ -23,12 +24,12 @@ public class Axis2BackEndServerControlle
private BackEndServerThread serverThread;
private ConfigurationContext configContext;
private ListenerManager listenerManager;
- private SampleConfiguration.Axis2SampleConfiguration configuration;
+ private Axis2ServerConfiguration configuration;
private CountDownLatch cdLatch;
private Exception processException;
public Axis2BackEndServerController(String serverName,
- SampleConfiguration.Axis2SampleConfiguration configuration) {
+ Axis2ServerConfiguration configuration) {
this.serverName = serverName;
this.configuration = configuration;
serverThread = new BackEndServerThread();
@@ -88,7 +89,6 @@ public class Axis2BackEndServerControlle
// setting System.setProperty does not work since this all servers are run on same jvm
configContext.setProperty("server_name", serverName);
-
TransportInDescription httpTrsIn = configContext.getAxisConfiguration().
getTransportsIn().get("http");
String httpPort = configuration.getHttpPort();
Modified: synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/DerbyServerController.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/DerbyServerController.java?rev=1211800&r1=1211799&r2=1211800&view=diff
==============================================================================
--- synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/DerbyServerController.java (original)
+++ synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/DerbyServerController.java Thu Dec 8 10:10:18 2011
@@ -4,6 +4,7 @@ import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.derby.drda.NetworkServerControl;
+import org.apache.synapse.samples.framework.config.DerbyConfiguration;
import java.io.File;
import java.net.InetAddress;
@@ -21,11 +22,10 @@ public class DerbyServerController imple
private static final Log log = LogFactory.getLog(DerbyServerController.class);
private String serverName;
- private SampleConfiguration.DerbyServerSampleConfiguration configuration;
+ private DerbyConfiguration configuration;
private NetworkServerControl server;
- public DerbyServerController(String serverName,
- SampleConfiguration.DerbyServerSampleConfiguration configuration) {
+ public DerbyServerController(String serverName, DerbyConfiguration configuration) {
this.serverName = serverName;
this.configuration = configuration;
}
Modified: synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/JMSBrokerController.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/JMSBrokerController.java?rev=1211800&r1=1211799&r2=1211800&view=diff
==============================================================================
--- synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/JMSBrokerController.java (original)
+++ synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/JMSBrokerController.java Thu Dec 8 10:10:18 2011
@@ -22,6 +22,7 @@ package org.apache.synapse.samples.frame
import org.apache.activemq.broker.BrokerService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.samples.framework.config.JMSBrokerConfiguration;
/**
* Responsible for starting up and shutting down
@@ -32,11 +33,10 @@ public class JMSBrokerController impleme
private static final Log log = LogFactory.getLog(JMSBrokerController.class);
private String serverName;
- private SampleConfiguration.JMSBrokerSampleConfiguration configuration;
+ private JMSBrokerConfiguration configuration;
private BrokerService broker;
- public JMSBrokerController(String serverName,
- SampleConfiguration.JMSBrokerSampleConfiguration configuration) {
+ public JMSBrokerController(String serverName, JMSBrokerConfiguration configuration) {
this.serverName = serverName;
this.configuration = configuration;
}
Modified: synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/SampleClientResult.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/SampleClientResult.java?rev=1211800&r1=1211799&r2=1211800&view=diff
==============================================================================
--- synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/SampleClientResult.java (original)
+++ synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/SampleClientResult.java Thu Dec 8 10:10:18 2011
@@ -19,19 +19,19 @@
package org.apache.synapse.samples.framework;
import java.util.Properties;
+import java.util.concurrent.atomic.AtomicInteger;
/**
* Stores the results after executing a client
*/
public class SampleClientResult {
- private boolean responseReceived;
- private boolean isFinished;
+ private AtomicInteger responseCount = new AtomicInteger(0);
private Exception exception;
private Properties clientProperties = new Properties();
- public void setResponseReceived(boolean responseReceived) {
- this.responseReceived = responseReceived;
+ public void incrementResponseCount() {
+ responseCount.incrementAndGet();
}
public void setException(Exception exception) {
@@ -39,21 +39,13 @@ public class SampleClientResult {
}
public boolean responseReceived() {
- return responseReceived;
+ return responseCount.get() > 0;
}
public Exception getException() {
return exception;
}
- public boolean isFinished() {
- return isFinished;
- }
-
- public void setFinished(boolean finished) {
- isFinished = finished;
- }
-
public void addProperty(String pName, String pValue){
clientProperties.setProperty(pName,pValue);
}
Modified: synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/SynapseProcessController.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/SynapseProcessController.java?rev=1211800&r1=1211799&r2=1211800&view=diff
==============================================================================
--- synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/SynapseProcessController.java (original)
+++ synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/SynapseProcessController.java Thu Dec 8 10:10:18 2011
@@ -22,6 +22,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.synapse.ServerConfigurationInformation;
import org.apache.synapse.ServerManager;
+import org.apache.synapse.samples.framework.config.SynapseServerConfiguration;
import java.util.concurrent.CountDownLatch;
@@ -34,13 +35,13 @@ public class SynapseProcessController im
private static final Log log = LogFactory.getLog(SynapseProcessController.class);
private ServerThread serverThread;
- private SampleConfiguration.SynapseSampleConfiguration configuration;
+ private SynapseServerConfiguration configuration;
private ServerConfigurationInformation information;
private ServerManager manager;
private CountDownLatch cdLatch;
private Exception processException;
- public SynapseProcessController(SampleConfiguration.SynapseSampleConfiguration configuration) {
+ public SynapseProcessController(SynapseServerConfiguration configuration) {
this.configuration = configuration;
information = new ServerConfigurationInformation();
manager = new ServerManager();
Modified: synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/SynapseTestCase.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/SynapseTestCase.java?rev=1211800&r1=1211799&r2=1211800&view=diff
==============================================================================
--- synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/SynapseTestCase.java (original)
+++ synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/SynapseTestCase.java Thu Dec 8 10:10:18 2011
@@ -29,6 +29,7 @@ import org.apache.commons.logging.LogFac
import org.apache.synapse.samples.framework.clients.EventSampleClient;
import org.apache.synapse.samples.framework.clients.MTOMSwASampleClient;
import org.apache.synapse.samples.framework.clients.StockQuoteSampleClient;
+import org.apache.synapse.samples.framework.config.SampleConfiguration;
import javax.xml.namespace.QName;
import java.io.File;
@@ -83,7 +84,7 @@ public abstract class SynapseTestCase ex
assertTrue("Could not load client configuration settings for the sample " + sampleId,
initClientConfigInfo());
- if (configuration.getSynapseConfig().isClusteringEnabled()) {
+ if (configuration.getSynapseServerConfig().isClusteringEnabled()) {
assertTrue("Could not properly configure clustering", configureClustering());
}
@@ -216,35 +217,35 @@ public abstract class SynapseTestCase ex
Boolean clusteringEnabled = Boolean.parseBoolean(
(String) synapseProperties.get(SampleConfigConstants.TAG_ENABLE_CLUSTERING));
- configuration.getSynapseConfig().setServerName("SynapseServerForSample" + sampleId);
+ configuration.getSynapseServerConfig().setServerName("SynapseServerForSample" + sampleId);
if (synapseXml == null) {
log.error("synapse config file must be specified for the sample");
return false;
} else {
- configuration.getSynapseConfig().setSynapseXml(synapseHome + synapseXml);
+ configuration.getSynapseServerConfig().setSynapseXml(synapseHome + synapseXml);
}
if (axis2Repo == null) {
- configuration.getSynapseConfig().setAxis2Repo(synapseHome +
+ configuration.getSynapseServerConfig().setAxis2Repo(synapseHome +
SampleConfigConstants.DEFAULT_SYNAPSE_CONF_AXIS2_REPO);
} else {
log.info("Using Synapse Axis2 repository: " + axis2Repo);
- configuration.getSynapseConfig().setAxis2Repo(synapseHome + axis2Repo);
+ configuration.getSynapseServerConfig().setAxis2Repo(synapseHome + axis2Repo);
}
if (axis2Xml == null) {
- configuration.getSynapseConfig().setAxis2Xml(synapseHome +
+ configuration.getSynapseServerConfig().setAxis2Xml(synapseHome +
SampleConfigConstants.DEFAULT_SYNAPSE_CONF_AXIS2_XML);
} else {
log.info("Using Synapse Axis2 XML: " + axis2Xml);
- configuration.getSynapseConfig().setAxis2Xml(synapseHome + axis2Xml);
+ configuration.getSynapseServerConfig().setAxis2Xml(synapseHome + axis2Xml);
}
- configuration.getSynapseConfig().setSynapseHome(synapseHome);
- configuration.getSynapseConfig().setClusteringEnabled(clusteringEnabled);
+ configuration.getSynapseServerConfig().setSynapseHome(synapseHome);
+ configuration.getSynapseServerConfig().setClusteringEnabled(clusteringEnabled);
- pc = new SynapseProcessController(configuration.getSynapseConfig());
+ pc = new SynapseProcessController(configuration.getSynapseServerConfig());
return true;
}
@@ -255,10 +256,10 @@ public abstract class SynapseTestCase ex
*/
private boolean initBackEndServersConfigInfo() {
OMElement bESConfigEle = null;
- Iterator itr_BEEle = sampleConfigElement.getChildrenWithLocalName(
+ Iterator itrBackEndElements = sampleConfigElement.getChildrenWithLocalName(
SampleConfigConstants.TAG_BE_SERVER_CONF);
- while (itr_BEEle.hasNext()) {
- bESConfigEle = (OMElement) itr_BEEle.next();
+ while (itrBackEndElements.hasNext()) {
+ bESConfigEle = (OMElement) itrBackEndElements.next();
}
if (bESConfigEle == null) {
log.warn("No backend servers are defined");
@@ -412,20 +413,20 @@ public abstract class SynapseTestCase ex
SampleConfigConstants.TAG_CLIENT_CONF_AXIS2_XML);
if (clientRepo == null) {
- configuration.getClientConfig().setClientRepo(FilenameUtils.normalize(
+ configuration.getAxis2ClientConfig().setClientRepo(FilenameUtils.normalize(
currentLocation + SampleConfigConstants.DEFAULT_CLIENT_CONF_REPO));
} else {
log.info("Using client Axis2 repository location: " + clientRepo);
- configuration.getClientConfig().setClientRepo(FilenameUtils.normalize(
+ configuration.getAxis2ClientConfig().setClientRepo(FilenameUtils.normalize(
currentLocation + clientRepo));
}
if (clientAxis2Xml == null) {
- configuration.getClientConfig().setAxis2Xml(FilenameUtils.normalize(
+ configuration.getAxis2ClientConfig().setAxis2Xml(FilenameUtils.normalize(
currentLocation + SampleConfigConstants.DEFAULT_CLIENT_CONF_AXIS2_XML));
} else {
log.info("Using client Axis2 XML: " + clientAxis2Xml);
- configuration.getClientConfig().setAxis2Xml(FilenameUtils.normalize(
+ configuration.getAxis2ClientConfig().setAxis2Xml(FilenameUtils.normalize(
currentLocation + clientAxis2Xml));
}
return true;
@@ -441,13 +442,13 @@ public abstract class SynapseTestCase ex
}
log.info(" Using the IP :" + ip);
- String synapseAxis2Xml = configuration.getSynapseConfig().getAxis2Xml();
+ String synapseAxis2Xml = configuration.getSynapseServerConfig().getAxis2Xml();
String axis2Config = FileUtils.readFileToString(new File(synapseAxis2Xml));
String modifiedSynapseAxis2 = SynapseTestUtils.replace(axis2Config, "${replace.me}", ip);
File tempSynapseAxis2 = File.createTempFile("axis2Syn-", "xml");
tempSynapseAxis2.deleteOnExit();
FileUtils.writeStringToFile(tempSynapseAxis2, modifiedSynapseAxis2);
- configuration.getSynapseConfig().setAxis2Xml(tempSynapseAxis2.getAbsolutePath());
+ configuration.getSynapseServerConfig().setAxis2Xml(tempSynapseAxis2.getAbsolutePath());
for (BackEndServerController controller : backendServerControllers) {
String serverName = controller.getServerName();
@@ -478,15 +479,15 @@ public abstract class SynapseTestCase ex
}
public StockQuoteSampleClient getStockQuoteClient() {
- return new StockQuoteSampleClient(configuration.getClientConfig());
+ return new StockQuoteSampleClient(configuration.getAxis2ClientConfig());
}
public EventSampleClient getEventSubscriberSampleClient() {
- return new EventSampleClient(configuration.getClientConfig());
+ return new EventSampleClient(configuration.getAxis2ClientConfig());
}
public MTOMSwASampleClient getMTOMSwASampleClient() {
- return new MTOMSwASampleClient(configuration.getClientConfig());
+ return new MTOMSwASampleClient(configuration.getAxis2ClientConfig());
}
protected void assertResponseReceived(SampleClientResult result) {
Modified: synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/clients/EventSampleClient.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/clients/EventSampleClient.java?rev=1211800&r1=1211799&r2=1211800&view=diff
==============================================================================
--- synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/clients/EventSampleClient.java (original)
+++ synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/clients/EventSampleClient.java Thu Dec 8 10:10:18 2011
@@ -33,7 +33,7 @@ import org.apache.axis2.context.MessageC
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.SampleConfiguration;
+import org.apache.synapse.samples.framework.config.Axis2ClientConfiguration;
import javax.xml.namespace.QName;
@@ -44,8 +44,7 @@ public class EventSampleClient {
private Options options;
private ServiceClient serviceClient;
- private SampleClientResult clientResult;
- private SampleConfiguration.ClientSampleConfiguration configuration;
+ private Axis2ClientConfiguration configuration;
private OMFactory factory;
private OMElement message;
private OMNamespace schemaNamespace;
@@ -53,7 +52,7 @@ public class EventSampleClient {
private OMNamespace addressingNamespace;
private OMNamespace eventingNamespace;
- public EventSampleClient(SampleConfiguration.ClientSampleConfiguration configuration) {
+ public EventSampleClient(Axis2ClientConfiguration configuration) {
this.configuration = configuration;
factory = OMAbstractFactory.getOMFactory();
schemaNamespace = factory.createOMNamespace("http://www.w3.org/2001/XMLSchema", "xmlns");
@@ -67,9 +66,6 @@ public class EventSampleClient {
private void initializeClient(String addUrl) throws Exception {
options = new Options();
- clientResult = new SampleClientResult();
- clientResult.setResponseReceived(false);
-
ConfigurationContext configContext;
configContext = ConfigurationContextFactory.
createConfigurationContextFromFileSystem(configuration.getClientRepo(),
@@ -118,8 +114,8 @@ public class EventSampleClient {
}
subscribeOm.addChild(filterOm);
-
log.info("Subscribing: " + subscribeOm.toString());
+ SampleClientResult clientResult = new SampleClientResult();
try {
initializeClient(addUrl);
options.setAction("http://schemas.xmlsoap.org/ws/2004/08/eventing/Subscribe");
@@ -141,10 +137,9 @@ public class EventSampleClient {
new QName(eventingNamespace.getNamespaceURI(), "Identifier")).getText();
log.info("Subscription identifier: " + subId);
clientResult.addProperty("subId", subId);
- clientResult.setResponseReceived(true);
+ clientResult.incrementResponseCount();
} catch (Exception e) {
log.error("Fault Received : " + e.toString(), e);
- clientResult.setResponseReceived(false);
clientResult.setException(e);
}
deInitializeClient();
@@ -184,6 +179,7 @@ public class EventSampleClient {
OMElement subscribeOm = factory.createOMElement("Unsubscribe", eventingNamespace);
log.info("UnSubscribing: " + subscribeOm.toString());
+ SampleClientResult clientResult = new SampleClientResult();
try {
initializeClient(addUrl);
options.setAction("http://schemas.xmlsoap.org/ws/2004/08/eventing/Unsubscribe");
@@ -195,10 +191,9 @@ public class EventSampleClient {
log.info("UnSubscribed to ID " + identifier);
Thread.sleep(1000);
log.info("UnSubscribe Response Received: " + response.toString());
- clientResult.setResponseReceived(true);
+ clientResult.incrementResponseCount();
} catch (Exception e) {
log.error("Fault Received : " + e.toString(), e);
- clientResult.setResponseReceived(false);
clientResult.setException(e);
}
deInitializeClient();
@@ -244,6 +239,7 @@ public class EventSampleClient {
log.info("SynapseSubscription Renew \n" + subscribeOm.toString());
+ SampleClientResult clientResult = new SampleClientResult();
try {
initializeClient(addUrl);
OMElement identifierOm = factory.createOMElement("Identifier", eventingNamespace);
@@ -258,10 +254,9 @@ public class EventSampleClient {
}
log.info("SynapseSubscription Renew Response Received: " + response.toString());
- clientResult.setResponseReceived(true);
+ clientResult.incrementResponseCount();
} catch (Exception e) {
log.error("Fault Received : " + e.toString(), e);
- clientResult.setResponseReceived(false);
clientResult.setException(e);
}
deInitializeClient();
@@ -300,6 +295,7 @@ public class EventSampleClient {
OMElement subscribeOm = factory.createOMElement("GetStatus", eventingNamespace);
log.info("GetStatus using: " + subscribeOm.toString());
+ SampleClientResult clientResult = new SampleClientResult();
try {
initializeClient(addUrl);
options.setAction("http://schemas.xmlsoap.org/ws/2004/08/eventing/GetStatus");
@@ -315,10 +311,9 @@ public class EventSampleClient {
}
log.info("GetStatus Response Received: " + response.toString());
- clientResult.setResponseReceived(true);
+ clientResult.incrementResponseCount();
} catch (Exception e) {
log.error("Fault Received : " + e.toString(), e);
- clientResult.setResponseReceived(false);
clientResult.setException(e);
}
deInitializeClient();
@@ -327,9 +322,9 @@ public class EventSampleClient {
public SampleClientResult sendEvent(String addUrl, String symbol, String price, String qty,
String topic, String topicns) {
+ SampleClientResult clientResult = new SampleClientResult();
try {
initializeClient(addUrl);
-
OMNamespace aipNamespace = factory.createOMNamespace(topicns, "aip");
// set the target topic
OMElement topicOm = factory.createOMElement("Topic", aipNamespace);
@@ -351,10 +346,9 @@ public class EventSampleClient {
serviceClient.fireAndForget(payload);
log.info("Event sent to topic " + topic);
Thread.sleep(1000);
- clientResult.setResponseReceived(true);
+ clientResult.incrementResponseCount();
} catch (Exception e) {
log.error("Fault Received : " + e.toString(), e);
- clientResult.setResponseReceived(false);
clientResult.setException(e);
}
deInitializeClient();
Modified: synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/clients/MTOMSwASampleClient.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/clients/MTOMSwASampleClient.java?rev=1211800&r1=1211799&r2=1211800&view=diff
==============================================================================
--- synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/clients/MTOMSwASampleClient.java (original)
+++ synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/clients/MTOMSwASampleClient.java Thu Dec 8 10:10:18 2011
@@ -35,7 +35,7 @@ import org.apache.axis2.wsdl.WSDLConstan
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.SampleConfiguration;
+import org.apache.synapse.samples.framework.config.Axis2ClientConfiguration;
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
@@ -46,18 +46,15 @@ import java.io.FileOutputStream;
import java.io.InputStream;
public class MTOMSwASampleClient {
+
private static final Log log = LogFactory.getLog(StockQuoteSampleClient.class);
- ConfigurationContext configContext = null;
- Options options;
SampleClientResult clientResult;
OMElement payload;
- OMElement response;
ServiceClient serviceClient;
- boolean completed;
- SampleConfiguration.ClientSampleConfiguration configuration;
+ Axis2ClientConfiguration configuration;
- public MTOMSwASampleClient(SampleConfiguration.ClientSampleConfiguration configuration) {
+ public MTOMSwASampleClient(Axis2ClientConfiguration configuration) {
this.configuration = configuration;
}
@@ -113,11 +110,9 @@ public class MTOMSwASampleClient {
dest.flush();
dest.close();
log.info("Saved response to file : " + tempFile.getAbsolutePath());
-
- clientResult.setResponseReceived(true);
+ clientResult.incrementResponseCount();
} catch (Exception e) {
log.error("Error invoking service", e);
- clientResult.setResponseReceived(false);
clientResult.setException(e);
}
@@ -183,11 +178,9 @@ public class MTOMSwASampleClient {
fos.close();
log.info("Saved response to file : " + tempFile.getAbsolutePath());
-
- clientResult.setResponseReceived(true);
+ clientResult.incrementResponseCount();
} catch (Exception e) {
log.error("Error invoking service", e);
- clientResult.setResponseReceived(false);
clientResult.setException(e);
}
Modified: synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/clients/StockQuoteSampleClient.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/clients/StockQuoteSampleClient.java?rev=1211800&r1=1211799&r2=1211800&view=diff
==============================================================================
--- synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/clients/StockQuoteSampleClient.java (original)
+++ synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/clients/StockQuoteSampleClient.java Thu Dec 8 10:10:18 2011
@@ -42,7 +42,7 @@ import org.apache.neethi.Policy;
import org.apache.neethi.PolicyEngine;
import org.apache.rampart.RampartMessageData;
import org.apache.synapse.samples.framework.SampleClientResult;
-import org.apache.synapse.samples.framework.SampleConfiguration;
+import org.apache.synapse.samples.framework.config.Axis2ClientConfiguration;
import javax.xml.namespace.QName;
import java.net.URL;
@@ -56,45 +56,36 @@ public class StockQuoteSampleClient {
private final static String COOKIE = "Cookie";
private final static String SET_COOKIE = "Set-Cookie";
- private ConfigurationContext configContext = null;
- private Options options;
+ private ConfigurationContext configContext = null;
private ServiceClient serviceClient;
- //private SampleClientResult clientResult;
private OMElement payload;
private OMElement response;
private boolean completed;
- private SampleConfiguration.ClientSampleConfiguration configuration;
+ private Axis2ClientConfiguration clientConfig;
- public StockQuoteSampleClient(SampleConfiguration.ClientSampleConfiguration configuration) {
- this.configuration = configuration;
+ public StockQuoteSampleClient(Axis2ClientConfiguration clientConfig) {
+ this.clientConfig = clientConfig;
}
- private void initializeClient(String addUrl, String trpUrl, String prxUrl,
- String svcPolicy, long timeout) throws Exception {
- log.info("initialing client config...");
- options = new Options();
- /*clientResult = new SampleClientResult();
- clientResult.setResponseReceived(false);*/
- payload = null;
+ private void init(String addUrl, String trpUrl, String prxUrl,
+ String policyKey, long timeout) throws Exception {
- log.info("creating axis2 configuration context using the repo: " + configuration.getClientRepo());
+ log.info("Initializing sample Axis2 client");
- configContext = ConfigurationContextFactory.
- createConfigurationContextFromFileSystem(configuration.getClientRepo(),
- configuration.getAxis2Xml());
+ configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(
+ clientConfig.getClientRepo(), clientConfig.getAxis2Xml());
serviceClient = new ServiceClient(configContext, null);
- log.info("setting address, transport, proxy urls where applicable");
- if (addUrl != null && !"null".equals(addUrl)) {
+ Options options = new Options();
+ if (addUrl != null && !"".equals(addUrl)) {
serviceClient.engageModule("addressing");
options.setTo(new EndpointReference(addUrl));
}
- if (trpUrl != null && !"null".equals(trpUrl)) {
+ if (trpUrl != null && !"".equals(trpUrl)) {
options.setProperty(Constants.Configuration.TRANSPORT_URL, trpUrl);
}
-
- if (prxUrl != null && !"null".equals(prxUrl)) {
+ if (prxUrl != null && !"".equals(prxUrl)) {
HttpTransportProperties.ProxyProperties proxyProperties =
new HttpTransportProperties.ProxyProperties();
URL url = new URL(prxUrl);
@@ -106,15 +97,13 @@ public class StockQuoteSampleClient {
options.setProperty(HTTPConstants.PROXY, proxyProperties);
}
- // apply any service policies if any
- if (svcPolicy != null && !"null".equals(svcPolicy) && svcPolicy.length() > 0) {
+ if (policyKey != null && !"".equals(policyKey)) {
log.info("Using WS-Security");
serviceClient.engageModule("addressing");
serviceClient.engageModule("rampart");
- StAXOMBuilder builder = new StAXOMBuilder(svcPolicy);
+ StAXOMBuilder builder = new StAXOMBuilder(policyKey);
Policy policy = PolicyEngine.getPolicy(builder.getDocumentElement());
- options.setProperty(
- RampartMessageData.KEY_RAMPART_POLICY, policy);
+ options.setProperty(RampartMessageData.KEY_RAMPART_POLICY, policy);
}
if (timeout > 0) {
@@ -125,7 +114,7 @@ public class StockQuoteSampleClient {
serviceClient.setOptions(options);
}
- private void terminateClient() {
+ private void terminate() {
if (serviceClient != null) {
try {
log.info("cleaning up client");
@@ -152,22 +141,20 @@ public class StockQuoteSampleClient {
log.info("sending standard quote request");
SampleClientResult clientResult = new SampleClientResult();
try {
- initializeClient(addUrl, trpUrl, prxUrl, svcPolicy, 10000);
+ init(addUrl, trpUrl, prxUrl, svcPolicy, 10000);
payload = StockQuoteHandler.createStandardQuoteRequest(
symbol, 1);
- options.setAction("urn:getQuote");
+ serviceClient.getOptions().setAction("urn:getQuote");
OMElement resultElement = serviceClient.sendReceive(payload);
log.info("Standard :: Stock price = $" +
StockQuoteHandler.parseStandardQuoteResponse(resultElement));
- clientResult.setResponseReceived(true);
+ clientResult.incrementResponseCount();
} catch (Exception e) {
log.error("Error invoking service", e);
- clientResult.setResponseReceived(false);
clientResult.setException(e);
}
- terminateClient();
-
+ terminate();
return clientResult;
}
@@ -176,12 +163,11 @@ public class StockQuoteSampleClient {
log.info("sending dual quote request");
SampleClientResult clientResult = new SampleClientResult();
try {
- initializeClient(addUrl, trpUrl, prxUrl, null, 10000);
+ init(addUrl, trpUrl, prxUrl, null, 10000);
payload = StockQuoteHandler.createStandardQuoteRequest(
symbol, 1);
- options.setAction("urn:getQuote");
- //serviceClient.engageModule("addressing");
+ serviceClient.getOptions().setAction("urn:getQuote");
setCompleted(false);
serviceClient.sendReceiveNonBlocking(payload, new StockQuoteCallback(this));
@@ -189,7 +175,7 @@ public class StockQuoteSampleClient {
if (isCompleted()) {
log.info("Standard dual channel :: Stock price = $" +
StockQuoteHandler.parseStandardQuoteResponse(getResponse()));
- clientResult.setResponseReceived(true);
+ clientResult.incrementResponseCount();
break;
} else {
Thread.sleep(100);
@@ -197,11 +183,9 @@ public class StockQuoteSampleClient {
}
} catch (Exception e) {
log.error("Error invoking service", e);
- clientResult.setResponseReceived(false);
clientResult.setException(e);
}
- terminateClient();
-
+ terminate();
return clientResult;
}
@@ -210,21 +194,19 @@ public class StockQuoteSampleClient {
log.info("sending custom quote request");
SampleClientResult clientResult = new SampleClientResult();
try {
- initializeClient(addUrl, trpUrl, prxUrl, null, 10000);
+ init(addUrl, trpUrl, prxUrl, null, 10000);
payload = StockQuoteHandler.createCustomQuoteRequest(symbol);
- options.setAction("urn:getQuote");
+ serviceClient.getOptions().setAction("urn:getQuote");
OMElement resultElement = serviceClient.sendReceive(payload);
log.info("Custom :: Stock price = $" +
StockQuoteHandler.parseCustomQuoteResponse(resultElement));
- clientResult.setResponseReceived(true);
+ clientResult.incrementResponseCount();
} catch (Exception e) {
log.error("Error invoking service", e);
- clientResult.setResponseReceived(false);
clientResult.setException(e);
}
- terminateClient();
-
+ terminate();
return clientResult;
}
@@ -232,26 +214,23 @@ public class StockQuoteSampleClient {
log.info("sending fire and forget (place order) request");
SampleClientResult clientResult = new SampleClientResult();
try {
- initializeClient(addUrl, trpUrl, prxUrl, null, 10000);
+ init(addUrl, trpUrl, prxUrl, null, 10000);
double price = getRandom(100, 0.9, true);
int quantity = (int) getRandom(10000, 1.0, true);
payload = StockQuoteHandler.createPlaceOrderRequest(price, quantity, symbol);
- options.setAction("urn:placeOrder");
+ serviceClient.getOptions().setAction("urn:placeOrder");
serviceClient.fireAndForget(payload);
Thread.sleep(5000);
- log.info("Order placed for " + quantity
- + " shares of stock " + symbol
+ log.info("Order placed for " + quantity + " shares of stock " + symbol
+ " at a price of $ " + price);
- clientResult.setResponseReceived(true);
+ clientResult.incrementResponseCount();
} catch (Exception e) {
log.error("Error invoking service", e);
- clientResult.setResponseReceived(false);
clientResult.setException(e);
}
- terminateClient();
-
+ terminate();
return clientResult;
}
@@ -260,25 +239,21 @@ public class StockQuoteSampleClient {
log.info("sending rest request");
SampleClientResult clientResult = new SampleClientResult();
try {
- initializeClient(addUrl, trpUrl, prxUrl, null, 10000);
-
- payload = StockQuoteHandler.createStandardQuoteRequest(
- symbol, 1);
- options.setAction("urn:getQuote");
- options.setProperty(Constants.Configuration.ENABLE_REST, Constants.VALUE_TRUE);
+ init(addUrl, trpUrl, prxUrl, null, 10000);
+ payload = StockQuoteHandler.createStandardQuoteRequest(symbol, 1);
+ serviceClient.getOptions().setAction("urn:getQuote");
+ serviceClient.getOptions().setProperty(Constants.Configuration.ENABLE_REST,
+ Constants.VALUE_TRUE);
OMElement resultElement = serviceClient.sendReceive(payload);
- log.info("Standard :: Stock price = $" +
- StockQuoteHandler.parseStandardQuoteResponse(resultElement));
- clientResult.setResponseReceived(true);
+ log.info("Standard :: Stock price = $" + StockQuoteHandler.
+ parseStandardQuoteResponse(resultElement));
+ clientResult.incrementResponseCount();
} catch (Exception e) {
log.error("Error invoking service", e);
- clientResult.setResponseReceived(false);
clientResult.setException(e);
}
- terminateClient();
-
+ terminate();
return clientResult;
-
}
@@ -290,36 +265,26 @@ public class StockQuoteSampleClient {
OMElement value = fac.createOMElement("Value", null);
value.setText("Sample string");
- initializeClient(addUrl, trpUrl, null, null, 10000);
-
- options.setAction("urn:sampleOperation");
-
+ init(addUrl, trpUrl, null, null, 10000);
+ serviceClient.getOptions().setAction("urn:sampleOperation");
String testString = "";
-
long i = 0;
while (i < iterations || infinite) {
serviceClient.getOptions().setManageSession(true);
OMElement responseElement = serviceClient.sendReceive(value);
String response = responseElement.getText();
-
- if (!clientResult.responseReceived()) {
- clientResult.setResponseReceived(true);
- }
+ clientResult.incrementResponseCount();
i++;
log.info("Request: " + i + " ==> " + response);
testString = testString.concat(":" + i + ">" + response + ":");
}
-
- clientResult.setFinished(true);
} catch (Exception e) {
log.error("Error invoking service", e);
- clientResult.setFinished(true);
clientResult.setException(e);
}
- terminateClient();
-
+ terminate();
return clientResult;
}
@@ -328,16 +293,14 @@ public class StockQuoteSampleClient {
String session = null;
SampleClientResult clientResult = new SampleClientResult();
- clientResult.setResponseReceived(false);
try {
SOAPEnvelope env1 = buildSoapEnvelope("c1", "v1");
SOAPEnvelope env2 = buildSoapEnvelope("c2", "v1");
SOAPEnvelope env3 = buildSoapEnvelope("c3", "v1");
SOAPEnvelope[] envelopes = {env1, env2, env3};
- initializeClient(addUrl, trpUrl, null, null, 10000);
-
- options.setAction("urn:sampleOperation");
+ init(addUrl, trpUrl, null, null, 10000);
+ serviceClient.getOptions().setAction("urn:sampleOperation");
int i = 0;
int sessionNumber;
@@ -372,13 +335,9 @@ public class StockQuoteSampleClient {
}
SOAPEnvelope responseEnvelope = responseContext.getEnvelope();
-
OMElement vElement =
responseEnvelope.getBody().getFirstChildWithName(new QName("Value"));
-
- if (!clientResult.responseReceived()) {
- clientResult.setResponseReceived(true);
- }
+ clientResult.incrementResponseCount();
log.info("Request: " + i + " with Session ID: " +
(httpSession ? cookie : sessionNumber) + " ---- " +
@@ -391,15 +350,11 @@ public class StockQuoteSampleClient {
"- Get a Fault : " + axisFault.getMessage(), axisFault);
}
}
-
- clientResult.setFinished(true);
} catch (Exception e) {
log.error("Error invoking service", e);
- clientResult.setFinished(true);
clientResult.setException(e);
}
- terminateClient();
-
+ terminate();
return clientResult;
}
@@ -421,7 +376,6 @@ public class StockQuoteSampleClient {
}
protected void setSessionID(MessageContext axis2MessageContext, String value) {
-
if (value == null) {
return;
}
@@ -434,7 +388,6 @@ public class StockQuoteSampleClient {
}
protected String extractSessionID(MessageContext axis2MessageContext) {
-
Object o = axis2MessageContext.getProperty(MessageContext.TRANSPORT_HEADERS);
if (o != null && o instanceof Map) {
@@ -475,10 +428,10 @@ public class StockQuoteSampleClient {
}
- private double getRandom(double base, double varience, boolean onlypositive) {
+ private double getRandom(double base, double variance, boolean positiveOnly) {
double rand = Math.random();
- return (base + ((rand > 0.5 ? 1 : -1) * varience * base * rand))
- * (onlypositive ? 1 : (rand > 0.5 ? 1 : -1));
+ return (base + ((rand > 0.5 ? 1 : -1) * variance * base * rand))
+ * (positiveOnly ? 1 : (rand > 0.5 ? 1 : -1));
}
public boolean isCompleted() {
Added: synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/config/Axis2ClientConfiguration.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/config/Axis2ClientConfiguration.java?rev=1211800&view=auto
==============================================================================
--- synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/config/Axis2ClientConfiguration.java (added)
+++ synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/config/Axis2ClientConfiguration.java Thu Dec 8 10:10:18 2011
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+*
+* WSO2 Inc. licenses this file to you under the Apache License,
+* Version 2.0 (the "License"); you may not use this file except
+* in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.synapse.samples.framework.config;
+
+public class Axis2ClientConfiguration {
+
+ private String clientRepo;
+ private String fileName;
+ private String axis2Xml;
+
+ public String getClientRepo() {
+ return clientRepo;
+ }
+
+ public void setClientRepo(String clientRepo) {
+ this.clientRepo = clientRepo;
+ }
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+
+ public String getAxis2Xml() {
+ return axis2Xml;
+ }
+
+ public void setAxis2Xml(String axis2Xml) {
+ this.axis2Xml = axis2Xml;
+ }
+}
Added: synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/config/Axis2ServerConfiguration.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/config/Axis2ServerConfiguration.java?rev=1211800&view=auto
==============================================================================
--- synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/config/Axis2ServerConfiguration.java (added)
+++ synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/config/Axis2ServerConfiguration.java Thu Dec 8 10:10:18 2011
@@ -0,0 +1,77 @@
+/*
+* Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+*
+* WSO2 Inc. licenses this file to you under the Apache License,
+* Version 2.0 (the "License"); you may not use this file except
+* in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.synapse.samples.framework.config;
+
+public class Axis2ServerConfiguration {
+
+ private String serverName;
+ private String axis2Repo;
+ private String axis2Xml;
+ private String httpPort;
+ private String httpsPort;
+ private boolean clusteringEnabled;
+
+ public String getServerName() {
+ return serverName;
+ }
+
+ public void setServerName(String serverName) {
+ this.serverName = serverName;
+ }
+
+ public String getAxis2Repo() {
+ return axis2Repo;
+ }
+
+ public void setAxis2Repo(String axis2Repo) {
+ this.axis2Repo = axis2Repo;
+ }
+
+ public String getAxis2Xml() {
+ return axis2Xml;
+ }
+
+ public void setAxis2Xml(String axis2Xml) {
+ this.axis2Xml = axis2Xml;
+ }
+
+ public String getHttpPort() {
+ return httpPort;
+ }
+
+ public void setHttpPort(String httpPort) {
+ this.httpPort = httpPort;
+ }
+
+ public String getHttpsPort() {
+ return httpsPort;
+ }
+
+ public void setHttpsPort(String httpsPort) {
+ this.httpsPort = httpsPort;
+ }
+
+ public boolean isClusteringEnabled() {
+ return clusteringEnabled;
+ }
+
+ public void setClusteringEnabled(boolean clusteringEnabled) {
+ this.clusteringEnabled = clusteringEnabled;
+ }
+}
Added: synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/config/DerbyConfiguration.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/config/DerbyConfiguration.java?rev=1211800&view=auto
==============================================================================
--- synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/config/DerbyConfiguration.java (added)
+++ synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/config/DerbyConfiguration.java Thu Dec 8 10:10:18 2011
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+*
+* WSO2 Inc. licenses this file to you under the Apache License,
+* Version 2.0 (the "License"); you may not use this file except
+* in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.synapse.samples.framework.config;
+
+public class DerbyConfiguration {
+
+ private String serverName;
+
+ public String getServerName() {
+ return serverName;
+ }
+
+ public void setServerName(String serverName) {
+ this.serverName = serverName;
+ }
+}
Added: synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/config/JMSBrokerConfiguration.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/config/JMSBrokerConfiguration.java?rev=1211800&view=auto
==============================================================================
--- synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/config/JMSBrokerConfiguration.java (added)
+++ synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/config/JMSBrokerConfiguration.java Thu Dec 8 10:10:18 2011
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+*
+* WSO2 Inc. licenses this file to you under the Apache License,
+* Version 2.0 (the "License"); you may not use this file except
+* in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.synapse.samples.framework.config;
+
+public class JMSBrokerConfiguration {
+
+ private String serverName;
+ private String providerURL;
+ private String initialNamingFactory;
+
+ public String getServerName() {
+ return serverName;
+ }
+
+ public void setServerName(String serverName) {
+ this.serverName = serverName;
+ }
+
+ public String getProviderURL() {
+ return providerURL;
+ }
+
+ public void setProviderURL(String providerURL) {
+ this.providerURL = providerURL;
+ }
+
+ public String getInitialNamingFactory() {
+ return initialNamingFactory;
+ }
+
+ public void setInitialNamingFactory(String initialNamingFactory) {
+ this.initialNamingFactory = initialNamingFactory;
+ }
+}
Added: synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/config/SampleConfiguration.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/config/SampleConfiguration.java?rev=1211800&view=auto
==============================================================================
--- synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/config/SampleConfiguration.java (added)
+++ synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/config/SampleConfiguration.java Thu Dec 8 10:10:18 2011
@@ -0,0 +1,97 @@
+/*
+* Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+*
+* WSO2 Inc. licenses this file to you under the Apache License,
+* Version 2.0 (the "License"); you may not use this file except
+* in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.synapse.samples.framework.config;
+
+import java.util.HashMap;
+import java.util.Set;
+
+public class SampleConfiguration {
+
+ private String sampleName;
+ private SynapseServerConfiguration synapseServerConfig;
+ private HashMap<String, Axis2ServerConfiguration> axis2ServerConfigs;
+ private HashMap<String, JMSBrokerConfiguration> jmsConfigs;
+ private HashMap<String, DerbyConfiguration> derbyConfigs;
+ private Axis2ClientConfiguration axis2ClientConfig;
+
+ public SampleConfiguration() {
+ this.synapseServerConfig = new SynapseServerConfiguration();
+ this.axis2ServerConfigs = new HashMap<String, Axis2ServerConfiguration>();
+ this.jmsConfigs = new HashMap<String, JMSBrokerConfiguration>();
+ this.derbyConfigs = new HashMap<String, DerbyConfiguration>();
+ this.axis2ClientConfig = new Axis2ClientConfiguration();
+ }
+
+ public String getSampleName() {
+ return sampleName;
+ }
+
+ public void setSampleName(String sampleName) {
+ this.sampleName = sampleName;
+ }
+
+ public Axis2ClientConfiguration getAxis2ClientConfig() {
+ return axis2ClientConfig;
+ }
+
+ public void setAxis2Client(Axis2ClientConfiguration axis2ClientConfig) {
+ this.axis2ClientConfig = axis2ClientConfig;
+ }
+
+ public SynapseServerConfiguration getSynapseServerConfig() {
+ return synapseServerConfig;
+ }
+
+ public void setSynapseServerConfig(SynapseServerConfiguration synapseServerConfig) {
+ this.synapseServerConfig = synapseServerConfig;
+ }
+
+ public void addNewAxis2Server(String name) {
+ axis2ServerConfigs.put(name, new Axis2ServerConfiguration());
+ }
+
+ public void addNewJMSBroker(String name) {
+ jmsConfigs.put(name, new JMSBrokerConfiguration());
+ }
+
+ public void addNewDerbyServer(String name) {
+ derbyConfigs.put(name, new DerbyConfiguration());
+ }
+
+ public Axis2ServerConfiguration getAxis2Config(String name) {
+ return axis2ServerConfigs.get(name);
+ }
+
+ public JMSBrokerConfiguration getJMSConfig(String name) {
+ return jmsConfigs.get(name);
+ }
+
+ public DerbyConfiguration getDerbyConfig(String name) {
+ return derbyConfigs.get(name);
+ }
+
+ public Set<String> getAxis2ServersList() {
+ return axis2ServerConfigs.keySet();
+ }
+
+ public int getBackEndServerCount() {
+ return axis2ServerConfigs.size() + jmsConfigs.size();
+ }
+
+}
Added: synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/config/SynapseServerConfiguration.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/config/SynapseServerConfiguration.java?rev=1211800&view=auto
==============================================================================
--- synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/config/SynapseServerConfiguration.java (added)
+++ synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/config/SynapseServerConfiguration.java Thu Dec 8 10:10:18 2011
@@ -0,0 +1,77 @@
+/*
+* Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+*
+* WSO2 Inc. licenses this file to you under the Apache License,
+* Version 2.0 (the "License"); you may not use this file except
+* in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.synapse.samples.framework.config;
+
+public class SynapseServerConfiguration {
+
+ private String serverName;
+ private String synapseHome;
+ private String axis2Repo;
+ private String axis2Xml;
+ private String synapseXml;
+ private boolean clusteringEnabled;
+
+ public String getServerName() {
+ return serverName;
+ }
+
+ public void setServerName(String serverName) {
+ this.serverName = serverName;
+ }
+
+ public String getSynapseHome() {
+ return synapseHome;
+ }
+
+ public void setSynapseHome(String synapseHome) {
+ this.synapseHome = synapseHome;
+ }
+
+ public String getAxis2Repo() {
+ return axis2Repo;
+ }
+
+ public void setAxis2Repo(String axis2Repo) {
+ this.axis2Repo = axis2Repo;
+ }
+
+ public String getAxis2Xml() {
+ return axis2Xml;
+ }
+
+ public void setAxis2Xml(String axis2Xml) {
+ this.axis2Xml = axis2Xml;
+ }
+
+ public String getSynapseXml() {
+ return synapseXml;
+ }
+
+ public void setSynapseXml(String synapseXml) {
+ this.synapseXml = synapseXml;
+ }
+
+ public boolean isClusteringEnabled() {
+ return clusteringEnabled;
+ }
+
+ public void setClusteringEnabled(boolean clusteringEnabled) {
+ this.clusteringEnabled = clusteringEnabled;
+ }
+}
Modified: synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/tests/endpoint/Sample53.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/tests/endpoint/Sample53.java?rev=1211800&r1=1211799&r2=1211800&view=diff
==============================================================================
--- synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/tests/endpoint/Sample53.java (original)
+++ synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/tests/endpoint/Sample53.java Thu Dec 8 10:10:18 2011
@@ -44,11 +44,12 @@ public class Sample53 extends SynapseTes
addUrl = "http://localhost:8280/services/LBService1";
log.info("Running test: Failover sending among 3 endpoints");
- new Thread(new Runnable() {
+ Thread t = new Thread(new Runnable() {
public void run() {
- result = client.sessionlessClient(addUrl, null, -1);
+ result = client.sessionlessClient(addUrl, null, 10000);
}
- }).start();
+ });
+ t.start();
for (int i = 0; i < 3; i++) {
try {
@@ -60,25 +61,17 @@ public class Sample53 extends SynapseTes
}
try {
- Thread.sleep(2000);
+ t.join();
} catch (InterruptedException e) {
}
- while (!result.isFinished()) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- }
- }
-
assertResponseReceived(result);
Exception resultEx = result.getException();
assertNotNull("Did not receive expected error", resultEx);
log.info("Got an error as expected: " + resultEx.getMessage());
assertTrue("Did not receive expected error", resultEx instanceof AxisFault);
- assertTrue("Did not receive expected error",
- resultEx.getMessage().indexOf(expectedError) != -1);
+ assertTrue("Did not receive expected error", resultEx.getMessage().contains(expectedError));
}
}
Modified: synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/tests/endpoint/Sample55.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/tests/endpoint/Sample55.java?rev=1211800&r1=1211799&r2=1211800&view=diff
==============================================================================
--- synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/tests/endpoint/Sample55.java (original)
+++ synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/tests/endpoint/Sample55.java Thu Dec 8 10:10:18 2011
@@ -40,31 +40,26 @@ public class Sample55 extends SynapseTes
public void testSessionFullLBFailOver() {
final String addUrl = "http://localhost:8280/services/LBService1";
log.info("Running test: Failover sending among 3 endpoints");
- new Thread(new Runnable() {
+ Thread t = new Thread(new Runnable() {
public void run() {
result = client.statefulClient(addUrl, null, 200);
}
- }).start();
+ });
+ t.start();
try {
- Thread.sleep(2000);
+ t.join();
} catch (InterruptedException e) {
}
- getBackendServerControllers().get(0).stop();
+ getBackendServerControllers().get(0).stop();
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
}
- while (!result.isFinished()) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- }
- }
assertTrue("Did not receive a response", result.responseReceived());
}
}
Modified: synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/tests/endpoint/Sample57.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/tests/endpoint/Sample57.java?rev=1211800&r1=1211799&r2=1211800&view=diff
==============================================================================
--- synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/tests/endpoint/Sample57.java (original)
+++ synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/tests/endpoint/Sample57.java Thu Dec 8 10:10:18 2011
@@ -45,43 +45,32 @@ public class Sample57 extends SynapseTes
} catch (InterruptedException e) {
}
- new Thread(new Runnable() {
+ Thread t = new Thread(new Runnable() {
public void run() {
result = client.sessionlessClient(addUrl, null, 500);
}
- }).start();
+ });
+ t.start();
try {
- Thread.sleep(3000);
+ t.join();
} catch (InterruptedException e) {
}
- while (!result.isFinished()) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- }
- }
-
- new Thread(new Runnable() {
+ t = new Thread(new Runnable() {
public void run() {
result = client.sessionlessClient(addUrl, null, 500);
}
- }).start();
+ });
+ t.start();
+
try {
- Thread.sleep(5000);
+ t.join();
} catch (InterruptedException e) {
}
- while (!result.isFinished()) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- }
- }
-
assertResponseReceived(result);
}
}
Modified: synapse/trunk/java/modules/integration/src/test/resources/sample53.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/integration/src/test/resources/sample53.xml?rev=1211800&r1=1211799&r2=1211800&view=diff
==============================================================================
--- synapse/trunk/java/modules/integration/src/test/resources/sample53.xml (original)
+++ synapse/trunk/java/modules/integration/src/test/resources/sample53.xml Thu Dec 8 10:10:18 2011
@@ -10,23 +10,23 @@
<axis2Server id='1'>
<axis2Repo>modules/integration/target/test_repos/axis2Server</axis2Repo>
<axis2Xml>modules/integration/target/test_repos/axis2Server/conf/axis2_def.xml</axis2Xml>
- <httpPort>9001</httpPort>
- <httpsPort>9005</httpsPort>
+ <httpPort>9001</httpPort>
+ <httpsPort>9005</httpsPort>
</axis2Server>
<axis2Server id='2'>
<axis2Repo>modules/integration/target/test_repos/axis2Server</axis2Repo>
<axis2Xml>modules/integration/target/test_repos/axis2Server/conf/axis2_def.xml</axis2Xml>
- <httpPort>9002</httpPort>
- <httpsPort>9006</httpsPort>
+ <httpPort>9002</httpPort>
+ <httpsPort>9006</httpsPort>
</axis2Server>
<axis2Server id='3'>
<axis2Repo>modules/integration/target/test_repos/axis2Server</axis2Repo>
<axis2Xml>modules/integration/target/test_repos/axis2Server/conf/axis2_def.xml</axis2Xml>
- <httpPort>9003</httpPort>
- <httpsPort>9007</httpsPort>
+ <httpPort>9003</httpPort>
+ <httpsPort>9007</httpsPort>
</axis2Server>
</backEndServerConfig>
<clientConfig>
- <clientRepo>modules/integration/target/test_repos/axis2Client</clientRepo>
+ <clientRepo>modules/integration/target/test_repos/axis2Client</clientRepo>
</clientConfig>
</synapseSample>