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 2005/11/29 10:23:28 UTC

svn commit: r349681 - in /incubator/synapse/trunk/scratch/prototype3: src/sampleMediators/ test/org/apache/axis2/ test/org/apache/axis2/META-INF/ test/org/apache/axis2/test/ test/org/apache/synapse/spi/ test/rules/

Author: saminda
Date: Tue Nov 29 01:23:09 2005
New Revision: 349681

URL: http://svn.apache.org/viewcvs?rev=349681&view=rev
Log:
This is the test case that will send the "SendOn" of Synapse. In this case we have to have two instances of 
SimpleHTTPServer. But simple server doen't allow to use multiple instances in a give VM due static components.
Until a alternative is  provided i have added resources for this test case and commented out the test.  

Added:
    incubator/synapse/trunk/scratch/prototype3/src/sampleMediators/SendOn.java
    incubator/synapse/trunk/scratch/prototype3/test/org/apache/axis2/
    incubator/synapse/trunk/scratch/prototype3/test/org/apache/axis2/META-INF/
    incubator/synapse/trunk/scratch/prototype3/test/org/apache/axis2/META-INF/services.xml
    incubator/synapse/trunk/scratch/prototype3/test/org/apache/axis2/test/
    incubator/synapse/trunk/scratch/prototype3/test/org/apache/axis2/test/Echo.java
    incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/SendOnProcessorTest.java
    incubator/synapse/trunk/scratch/prototype3/test/rules/synapse-sendon.xml

Added: incubator/synapse/trunk/scratch/prototype3/src/sampleMediators/SendOn.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype3/src/sampleMediators/SendOn.java?rev=349681&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype3/src/sampleMediators/SendOn.java (added)
+++ incubator/synapse/trunk/scratch/prototype3/src/sampleMediators/SendOn.java Tue Nov 29 01:23:09 2005
@@ -0,0 +1,30 @@
+package sampleMediators;
+
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.api.Mediator;
+/*
+* 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.
+*
+*/
+
+public class SendOn implements Mediator {
+    public boolean mediate(SynapseMessage smc) {
+        smc.setWSAAction("urn:synapse/sendon");
+        smc.setTo(new EndpointReference(
+                "http://localhost:8090/axis2/services/npe"));
+        return true;
+    }
+}

Added: incubator/synapse/trunk/scratch/prototype3/test/org/apache/axis2/META-INF/services.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype3/test/org/apache/axis2/META-INF/services.xml?rev=349681&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype3/test/org/apache/axis2/META-INF/services.xml (added)
+++ incubator/synapse/trunk/scratch/prototype3/test/org/apache/axis2/META-INF/services.xml Tue Nov 29 01:23:09 2005
@@ -0,0 +1,12 @@
+<service name="npe">
+    <description>
+        This sample stimulate the Native Provider Endpoint
+    </description>
+    <parameter name="ServiceClass" locked="false">
+        org.apache.axis2.test.Echo</parameter>
+    <operation name="echo">
+        <messageReceiver
+                class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
+        <parameter name="wsamapping">urn:synapse/sendon</parameter>
+    </operation>
+</service>
\ No newline at end of file

Added: incubator/synapse/trunk/scratch/prototype3/test/org/apache/axis2/test/Echo.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype3/test/org/apache/axis2/test/Echo.java?rev=349681&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype3/test/org/apache/axis2/test/Echo.java (added)
+++ incubator/synapse/trunk/scratch/prototype3/test/org/apache/axis2/test/Echo.java Tue Nov 29 01:23:09 2005
@@ -0,0 +1,29 @@
+package org.apache.axis2.test;
+
+import org.apache.axis2.om.OMElement;
+/*
+* 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.
+*
+*/
+
+public class Echo {
+    public OMElement echo(OMElement element) {
+        System.out.println(
+                "This is the actual service which has been redirected");
+        element.build();
+        element.detach();
+        return element;
+    }
+}

Added: incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/SendOnProcessorTest.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/SendOnProcessorTest.java?rev=349681&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/SendOnProcessorTest.java (added)
+++ incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/SendOnProcessorTest.java Tue Nov 29 01:23:09 2005
@@ -0,0 +1,63 @@
+package org.apache.synapse.spi;
+
+import junit.framework.TestCase;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.MessageSender;
+import org.apache.axis2.transport.http.SimpleHTTPServer;
+import org.apache.synapse.util.Axis2EvnSetup;
+
+import javax.xml.namespace.QName;
+/*
+* 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.
+*
+*/
+
+public class SendOnProcessorTest extends TestCase {
+    // todo: i have  to comment out this test case
+    // todo: because SimpleHTTPServer does not allow
+    // todo: to initiate multiple objects. :(
+    private SimpleHTTPServer synapseServer;
+    private SimpleHTTPServer axis2Server;
+    private EndpointReference targetEpr = new EndpointReference(
+            "http://127.0.0.1:5043/axis2/services/anonymous");
+    private QName operation = new QName("anonymous");
+
+    public void setUp() throws Exception {
+//        synapseServer = new SimpleHTTPServer("target/synapse-repository-sendon",
+//                5043);
+//        /**
+//         * axis2Server is the one who holds the actual service
+//         */
+//        axis2Server = new SimpleHTTPServer("synapse-repository-sendonAxis2",
+//                8090);
+//        synapseServer.start();
+//        axis2Server.start();
+    }
+
+    protected void tearDown() throws Exception {
+//        synapseServer.stop();
+//        axis2Server.stop();
+    }
+
+    public void testSendPrcessor() throws Exception {
+//        MessageSender msgSender = new MessageSender();
+//        msgSender.setTo(targetEpr);
+//        msgSender.setSenderTransport(Constants.TRANSPORT_HTTP);
+//        msgSender.send(operation.getLocalPart(), Axis2EvnSetup.payload());
+
+    }
+
+}

Added: incubator/synapse/trunk/scratch/prototype3/test/rules/synapse-sendon.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype3/test/rules/synapse-sendon.xml?rev=349681&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype3/test/rules/synapse-sendon.xml (added)
+++ incubator/synapse/trunk/scratch/prototype3/test/rules/synapse-sendon.xml Tue Nov 29 01:23:09 2005
@@ -0,0 +1,8 @@
+<synapse xmlns="http://ws.apache.org/ns/synapse">
+    <stage name="xpath">
+        <xpath expr="//ns:text" xmlns:ns="urn:text-body">
+            <classmediator name="sendOnHelper" class="sampleMediators.SendOn"/>
+            <send/>
+        </xpath>
+    </stage>
+</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