You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by pz...@apache.org on 2005/11/30 18:40:05 UTC

svn commit: r350001 [48/48] - in /incubator/synapse/trunk/java: ./ SpringMediator/ SpringMediator/META-INF/ SpringMediator/META-INF/services/ SpringMediator/org/ SpringMediator/org/apache/ SpringMediator/org/apache/synapse/ SpringMediator/org/apache/sy...

Added: incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/ClassMediatorProcessorTest.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/ClassMediatorProcessorTest.java?rev=350001&view=auto
==============================================================================
--- incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/ClassMediatorProcessorTest.java (added)
+++ incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/ClassMediatorProcessorTest.java Wed Nov 30 09:26:22 2005
@@ -0,0 +1,36 @@
+package org.apache.synapse.spi.processors;
+
+import junit.framework.TestCase;
+import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.Processor;
+import org.apache.synapse.processors.mediatortypes.ClassMediatorProcessor;
+import org.apache.synapse.util.Axis2EvnSetup;
+import org.apache.synapse.axis2.Axis2SynapseMessage;
+/*
+* 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 ClassMediatorProcessorTest extends TestCase {
+    public void testClassMediatorProcessor() throws Exception {
+        SynapseMessage sm = new Axis2SynapseMessage(
+                Axis2EvnSetup.axis2Deployment("target/synapse-repository"));
+        ClassMediatorProcessor pro = new ClassMediatorProcessor();
+        pro.setClazz(Class.forName("sampleMediators.Logger"));
+        boolean result = pro.process(null,sm);
+        assertTrue(result);
+        //todo:
+    }
+}

Added: incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/FaultProcessorTest.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/FaultProcessorTest.java?rev=350001&view=auto
==============================================================================
--- incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/FaultProcessorTest.java (added)
+++ incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/FaultProcessorTest.java Wed Nov 30 09:26:22 2005
@@ -0,0 +1,26 @@
+package org.apache.synapse.spi.processors;
+
+import junit.framework.TestCase;
+/*
+* 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 FaultProcessorTest extends TestCase {
+    public void testFaultProcessor() throws Exception {
+        //todo:
+        // todo: this is a complex test case which should be delt with carefully
+    }
+}

Added: incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/InProcessorTest.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/InProcessorTest.java?rev=350001&view=auto
==============================================================================
--- incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/InProcessorTest.java (added)
+++ incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/InProcessorTest.java Wed Nov 30 09:26:22 2005
@@ -0,0 +1,35 @@
+package org.apache.synapse.spi.processors;
+
+import junit.framework.TestCase;
+import org.apache.synapse.processors.InProcessor;
+import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.util.Axis2EvnSetup;
+import org.apache.synapse.axis2.Axis2SynapseMessage;
+/*
+* 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 InProcessorTest extends TestCase {
+
+    public void testInProcessor() throws Exception {
+        SynapseMessage sm = new Axis2SynapseMessage(
+                Axis2EvnSetup.axis2Deployment("target/synapse-repository"));
+        InProcessor pro = new InProcessor();
+        boolean retrun = pro.process(null,sm);
+        assertTrue(retrun);
+    }
+
+}

Added: incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/NeverProcessorTest.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/NeverProcessorTest.java?rev=350001&view=auto
==============================================================================
--- incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/NeverProcessorTest.java (added)
+++ incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/NeverProcessorTest.java Wed Nov 30 09:26:22 2005
@@ -0,0 +1,26 @@
+package org.apache.synapse.spi.processors;
+
+import junit.framework.TestCase;
+/*
+* 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 NeverProcessorTest extends TestCase {
+    public void testNeverProcessor() throws Exception{
+        //todo: this should be filled 
+
+    }
+}

Added: incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/RegexProcessorTest.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/RegexProcessorTest.java?rev=350001&view=auto
==============================================================================
--- incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/RegexProcessorTest.java (added)
+++ incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/RegexProcessorTest.java Wed Nov 30 09:26:22 2005
@@ -0,0 +1,37 @@
+package org.apache.synapse.spi.processors;
+
+import junit.framework.TestCase;
+import org.apache.synapse.util.Axis2EvnSetup;
+import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.processors.rules.RegexProcessor;
+import org.apache.synapse.axis2.Axis2SynapseMessage;
+import org.apache.axis2.addressing.EndpointReference;
+/*
+* 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 RegexProcessorTest extends TestCase {
+    public void testRegexProcessor() throws Exception {
+        SynapseMessage sm = new Axis2SynapseMessage(Axis2EvnSetup.axis2Deployment("target/synapse-repository"));
+        sm.setTo(new EndpointReference("http://xmethods.org"));
+        RegexProcessor pro = new RegexProcessor();
+        pro.setPattern("http://xmethods..\\*");
+        boolean result = pro.process(null,sm);
+        assertTrue(result);
+        //todo:
+
+    }
+}

Added: incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/StageProcessorTest.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/StageProcessorTest.java?rev=350001&view=auto
==============================================================================
--- incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/StageProcessorTest.java (added)
+++ incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/StageProcessorTest.java Wed Nov 30 09:26:22 2005
@@ -0,0 +1,48 @@
+package org.apache.synapse.spi.processors;
+
+import junit.framework.TestCase;
+import org.apache.synapse.processors.StageProcessor;
+import org.apache.synapse.processors.rules.RegexProcessor;
+import org.apache.synapse.processors.rules.XPathProcessor;
+import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.util.Axis2EvnSetup;
+import org.apache.synapse.axis2.Axis2SynapseMessage;
+
+import java.util.List;
+import java.util.LinkedList;
+/*
+* 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 StageProcessorTest extends TestCase {
+    public void testStageProcessor() throws Exception {
+        SynapseMessage sm = new Axis2SynapseMessage(
+                Axis2EvnSetup.axis2Deployment("target/synapse-repository"));
+        StageProcessor pro = new StageProcessor();
+        boolean result = pro.process(null, sm);
+        assertTrue(result);
+
+        List list = new LinkedList();
+        list.add(new RegexProcessor());
+        list.add(new XPathProcessor());
+        pro.setList(list);
+
+        boolean ret = pro.process(null,sm);
+
+        assertTrue(ret);
+
+    }
+}

Added: incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/XSLTProcessorTest.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/XSLTProcessorTest.java?rev=350001&view=auto
==============================================================================
--- incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/XSLTProcessorTest.java (added)
+++ incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/XSLTProcessorTest.java Wed Nov 30 09:26:22 2005
@@ -0,0 +1,25 @@
+package org.apache.synapse.spi.processors;
+
+import junit.framework.TestCase;
+/*
+* 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 XSLTProcessorTest extends TestCase {
+    public void testXSLTProcessor() throws Exception {
+        //todo;
+    }
+}

Added: incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/XpathProcessorTest.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/XpathProcessorTest.java?rev=350001&view=auto
==============================================================================
--- incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/XpathProcessorTest.java (added)
+++ incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/XpathProcessorTest.java Wed Nov 30 09:26:22 2005
@@ -0,0 +1,36 @@
+package org.apache.synapse.spi.processors;
+
+import junit.framework.TestCase;
+import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.axis2.Axis2SynapseMessage;
+import org.apache.synapse.processors.rules.XPathProcessor;
+import org.apache.synapse.util.Axis2EvnSetup;
+/*
+* 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 XpathProcessorTest extends TestCase {
+    public void testXpathProcessor() throws Exception {
+        SynapseMessage sm = new Axis2SynapseMessage(
+                Axis2EvnSetup.axis2Deployment("target/synapse-repository"));
+        XPathProcessor pro = new XPathProcessor();
+        pro.setXPathExpr("//ns:text");
+        pro.addXPathNamespace("ns", "urn:text-body");
+        boolean result = pro.process(null, sm);
+        assertTrue(result);
+
+    }
+}

Added: incubator/synapse/trunk/java/test/org/apache/synapse/util/Axis2EvnSetup.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/test/org/apache/synapse/util/Axis2EvnSetup.java?rev=350001&view=auto
==============================================================================
--- incubator/synapse/trunk/java/test/org/apache/synapse/util/Axis2EvnSetup.java (added)
+++ incubator/synapse/trunk/java/test/org/apache/synapse/util/Axis2EvnSetup.java Wed Nov 30 09:26:22 2005
@@ -0,0 +1,101 @@
+package org.apache.synapse.util;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.InOutAxisOperation;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.om.*;
+import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.synapse.axis2.SynapseMessageReceiver;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import java.io.ByteArrayInputStream;
+/*
+* 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 Axis2EvnSetup {
+    public static MessageContext axis2Deployment(String testingReposity)
+            throws AxisFault {
+        ConfigurationContextFactory conFac = new ConfigurationContextFactory();
+        ConfigurationContext configCtx = conFac
+                .buildClientConfigurationContext(testingReposity);
+        MessageContext msgCtx = new MessageContext(configCtx);
+        msgCtx.setEnvelope(testEnvSetup());
+        msgCtx.setServerSide(true);
+
+        AxisConfiguration axisConfiguration = msgCtx.getSystemContext()
+                .getAxisConfiguration();
+        AxisService service = new AxisService(
+                new QName("se"));
+        msgCtx.setAxisService(service);
+        service.setClassLoader(axisConfiguration.getServiceClassLoader());
+        AxisOperation axisOp = new InOutAxisOperation(
+                new QName("op"));
+        msgCtx.setAxisOperation(axisOp);
+        axisOp.setMessageReceiver(new SynapseMessageReceiver());
+        service.addOperation(axisOp);
+        axisConfiguration.addService(service);
+        msgCtx.setTo(
+                new EndpointReference("/axis2/services/" + "se" + "/" + "op"));
+        msgCtx.setSoapAction("op");
+        return msgCtx;
+    }
+
+    private static SOAPEnvelope testEnvSetup() {
+        OMFactory fac = OMAbstractFactory.getOMFactory();
+        SOAPEnvelope env = OMAbstractFactory.getSOAP11Factory()
+                .getDefaultEnvelope();
+        OMDocument doc = fac.createOMDocument();
+        doc.addChild(env);
+        OMElement ele = fac.createOMElement("text", "urn:text-body", "ns");
+        env.getBody().addChild(ele);
+        return env;
+    }
+
+    public static OMElement getSynapseConfigElement(String synapseXml)
+            throws XMLStreamException {
+        XMLStreamReader parser = XMLInputFactory.newInstance()
+                .createXMLStreamReader(
+                        new ByteArrayInputStream(synapseXml.getBytes()));
+        OMFactory fac = OMAbstractFactory.getOMFactory();
+        StAXOMBuilder staxBuilder = new StAXOMBuilder(fac, parser);
+        OMElement config = staxBuilder.getDocumentElement();
+        return config;
+
+    }
+
+    public static OMElement payload() {
+        OMFactory fac = OMAbstractFactory.getOMFactory();
+        OMNamespace omNs = fac.createOMNamespace(
+                "urn:text-body", "ns");
+        OMElement method = fac.createOMElement("service", omNs);
+        OMElement value = fac.createOMElement("text", omNs);
+        value.addChild(
+                fac.createText(value, "Synapse Testing String by Saminda "));
+        method.addChild(value);
+        return method;
+    }
+}

Added: incubator/synapse/trunk/java/test/rules/synapse-fault-return.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/test/rules/synapse-fault-return.xml?rev=350001&view=auto
==============================================================================
--- incubator/synapse/trunk/java/test/rules/synapse-fault-return.xml (added)
+++ incubator/synapse/trunk/java/test/rules/synapse-fault-return.xml Wed Nov 30 09:26:22 2005
@@ -0,0 +1,7 @@
+<synapse xmlns="http://ws.apache.org/ns/synapse">
+    <stage name="xpath">
+        <xpath expr="//ns:text" xmlns:ns="urn:text-body">
+            <fault/>
+        </xpath>
+    </stage>
+</synapse>
\ No newline at end of file

Added: incubator/synapse/trunk/java/test/rules/synapse-send.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/test/rules/synapse-send.xml?rev=350001&view=auto
==============================================================================
--- incubator/synapse/trunk/java/test/rules/synapse-send.xml (added)
+++ incubator/synapse/trunk/java/test/rules/synapse-send.xml Wed Nov 30 09:26:22 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="sendBackHelper" class="sampleMediators.SendBack"/>
+            <send/>
+        </xpath>
+    </stage>
+</synapse>
\ No newline at end of file

Added: incubator/synapse/trunk/java/test/rules/synapse-sendon.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/test/rules/synapse-sendon.xml?rev=350001&view=auto
==============================================================================
--- incubator/synapse/trunk/java/test/rules/synapse-sendon.xml (added)
+++ incubator/synapse/trunk/java/test/rules/synapse-sendon.xml Wed Nov 30 09:26:22 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