You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by sa...@apache.org on 2006/05/31 10:37:37 UTC
svn commit: r410463 - in /incubator/synapse/trunk/java/modules/core: ./
test/org/apache/synapse/n2n/ test/org/apache/synapse/utils/ test/rules/
Author: saminda
Date: Wed May 31 01:37:36 2006
New Revision: 410463
URL: http://svn.apache.org/viewvc?rev=410463&view=rev
Log:
Added n2n testcase.
Added:
incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/n2n/
incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/n2n/SynapseCommodityServiceTest.java
incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/utils/
incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/utils/Services.java
incubator/synapse/trunk/java/modules/core/test/rules/synapse_test.xml
Removed:
incubator/synapse/trunk/java/modules/core/test/rules/synapse-environmentaware.xml
incubator/synapse/trunk/java/modules/core/test/rules/synapse-fault-return.xml
incubator/synapse/trunk/java/modules/core/test/rules/synapse-httptcp.xml
incubator/synapse/trunk/java/modules/core/test/rules/synapse-send.xml
incubator/synapse/trunk/java/modules/core/test/rules/synapse-sendnow.xml
incubator/synapse/trunk/java/modules/core/test/rules/synapse-sendon.xml
Modified:
incubator/synapse/trunk/java/modules/core/maven.xml
Modified: incubator/synapse/trunk/java/modules/core/maven.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/maven.xml?rev=410463&r1=410462&r2=410463&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/maven.xml (original)
+++ incubator/synapse/trunk/java/modules/core/maven.xml Wed May 31 01:37:36 2006
@@ -50,6 +50,21 @@
</fileset>
</copy>
+
+ <echo message="-----------Creating Testing Repository [testing_repository] ----------"/>
+ <mkdir dir="target/testing_repository"/>
+ <copy file="target/synapse-${pom.currentVersion}.mar"
+ tofile="target/testing_repository/modules/synapse-${pom.currentVersion}.mar"/>
+
+ <mkdir dir="target/testing_repository/modules"/>
+ <copy file="../../repository/modules/addressing-${addressing.version}.mar"
+ tofile="target/testing_repository/modules/addressing-${addressing.version}.mar"/>
+ <copy file="../../repository/conf/axis2.xml"
+ tofile="target/testing_repository/conf/axis2.xml"/>
+ <copy file="test/rules/synapse_test.xml"
+ tofile="target/testing_repository/conf/synapse.xml"/>
+
+
<ant:delete dir="target/modules"/>
<ant:delete dir="target/services"/>
Added: incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/n2n/SynapseCommodityServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/n2n/SynapseCommodityServiceTest.java?rev=410463&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/n2n/SynapseCommodityServiceTest.java (added)
+++ incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/n2n/SynapseCommodityServiceTest.java Wed May 31 01:37:36 2006
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.n2n;
+
+import junit.framework.TestCase;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.rpc.receivers.RPCMessageReceiver;
+import org.apache.axis2.transport.http.SimpleHTTPServer;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.synapse.utils.Services;
+import org.apache.synapse.Constants;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMFactory;
+
+import javax.xml.namespace.QName;
+
+
+public class SynapseCommodityServiceTest extends TestCase {
+
+ private SimpleHTTPServer synapseServer = null;
+ private SimpleHTTPServer businessServer = null;
+
+ protected void setUp() throws java.lang.Exception {
+ // Initializing Synapse repository
+ System.setProperty(Constants.SYNAPSE_XML,
+ "target/testing_repository/conf/synapse.xml");
+ ConfigurationContext synapseConfigCtx = ConfigurationContextFactory
+ .createConfigurationContextFromFileSystem(
+ "target/testing_repository",
+ "target/testing_repository/conf/axis2.xml");
+
+
+ // Initializing Bussiness Endpoint
+ ConfigurationContext businessConfigCtx = ConfigurationContextFactory
+ .createConfigurationContextFromFileSystem(
+ "target/testing_repository",
+ "target/testing_repository/conf/axis2.xml");
+ AxisService businessService =
+ AxisService.createService(Services.class.getName(),
+ businessConfigCtx.getAxisConfiguration(),
+ RPCMessageReceiver.class,
+ "http://business.org", "http://business.org");
+ businessConfigCtx.getAxisConfiguration().addService(businessService);
+
+ synapseServer = new SimpleHTTPServer(synapseConfigCtx, 10000);
+ businessServer = new SimpleHTTPServer(businessConfigCtx, 10001);
+
+ //starting servers
+ synapseServer.start();
+ businessServer.start();
+
+
+ }
+
+ protected void tearDown() throws java.lang.Exception {
+ businessServer.stop();
+ synapseServer.stop();
+
+ }
+
+ public void testN2N() throws Exception {
+ // Creating the Simple Commodity Client
+ ServiceClient businessClient = new ServiceClient();
+ Options options = new Options();
+ options.setTo(
+ new EndpointReference("http://127.0.0.1:10000/CommodityQuote"));
+ businessClient.setOptions(options);
+
+ OMElement response = businessClient.sendReceive(commodityPayload());
+
+ assertNotNull(response);
+
+ OMElement returnEle = response.getFirstChildWithName(new QName("return"));
+
+ assertNotNull(returnEle);
+
+ assertEquals(returnEle.getText().trim(),"100");
+
+
+ }
+
+ private static OMElement commodityPayload() {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace businessNS =
+ fac.createOMNamespace("http://business.org", "ns");
+ OMNamespace emptyNS = fac.createOMNamespace("", "");
+ OMElement commodityEle = fac.createOMElement("commodity", businessNS);
+
+ OMElement realCommodity = fac.createOMElement("commodity", emptyNS);
+ realCommodity.setText("W");
+
+ commodityEle.addChild(realCommodity);
+
+ return commodityEle;
+ }
+}
Added: incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/utils/Services.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/utils/Services.java?rev=410463&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/utils/Services.java (added)
+++ incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/utils/Services.java Wed May 31 01:37:36 2006
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+/**
+ * Simple commodity services, only for testing purposes.
+ */
+package org.apache.synapse.utils;
+
+public class Services {
+ public int commodity(String commodity) {
+ return 100;
+ }
+}
Added: incubator/synapse/trunk/java/modules/core/test/rules/synapse_test.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/test/rules/synapse_test.xml?rev=410463&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/core/test/rules/synapse_test.xml (added)
+++ incubator/synapse/trunk/java/modules/core/test/rules/synapse_test.xml Wed May 31 01:37:36 2006
@@ -0,0 +1,24 @@
+<synapse xmlns="http://ws.apache.org/ns/synapse">
+
+ <definitions>
+
+ <sequence name="commodityQuote">
+ <!-- set the To address to the real endpoint -->
+ <header name="To" value="http://127.0.0.1:10001/axis2/services/Services"/>
+ <header name="Action" value="urn:commodity"/>
+
+ </sequence>
+
+ </definitions>
+
+ <rules>
+
+ <!-- Check if the URL matches the stockquote gateway/dumb case -->
+ <filter source="get-property('To')" regex=".*/CommodityQuote.*">
+ <sequence ref="commodityQuote"/>
+ </filter>
+
+ <send/>
+ </rules>
+
+</synapse>
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org