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 2006/06/01 11:28:27 UTC
svn commit: r410809 [6/10] - in /incubator/synapse/tags/M2: ./ bin/ etc/
modules/ modules/core/ modules/core/conf/ modules/core/src/
modules/core/src/org/ modules/core/src/org/apache/
modules/core/src/org/apache/synapse/ modules/core/src/org/apache/syn...
Added: incubator/synapse/tags/M2/modules/core/test-resources/org/apache/axis2/META-INF/environmentaware-service.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test-resources/org/apache/axis2/META-INF/environmentaware-service.xml?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test-resources/org/apache/axis2/META-INF/environmentaware-service.xml (added)
+++ incubator/synapse/tags/M2/modules/core/test-resources/org/apache/axis2/META-INF/environmentaware-service.xml Thu Jun 1 02:28:13 2006
@@ -0,0 +1,11 @@
+<service name="environmentaware-mediator">
+ <description>
+ EnvironmentAware-Mediator
+ </description>
+ <parameter name="ServiceClass" locked="false">
+ org.apache.axis2.test.EnvironmentAwareMediator</parameter>
+ <operation name="mediate">
+ <messageReceiver
+ class="org.apache.synapse.core.axis2.axis2.ServiceMediatorMessageReceiver"/>
+ </operation>
+</service>
\ No newline at end of file
Added: incubator/synapse/tags/M2/modules/core/test-resources/org/apache/axis2/META-INF/service-mediator.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test-resources/org/apache/axis2/META-INF/service-mediator.xml?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test-resources/org/apache/axis2/META-INF/service-mediator.xml (added)
+++ incubator/synapse/tags/M2/modules/core/test-resources/org/apache/axis2/META-INF/service-mediator.xml Thu Jun 1 02:28:13 2006
@@ -0,0 +1,11 @@
+<service name="test-mediator">
+ <description>
+ Test-Mediator
+ </description>
+ <parameter name="ServiceClass" locked="false">
+ org.apache.axis2.test.TestMediator</parameter>
+ <operation name="mediate">
+ <messageReceiver
+ class="org.apache.synapse.core.axis2.axis2.ServiceMediatorMessageReceiver"/>
+ </operation>
+</service>
\ No newline at end of file
Added: incubator/synapse/tags/M2/modules/core/test-resources/org/apache/axis2/META-INF/services.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test-resources/org/apache/axis2/META-INF/services.xml?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test-resources/org/apache/axis2/META-INF/services.xml (added)
+++ incubator/synapse/tags/M2/modules/core/test-resources/org/apache/axis2/META-INF/services.xml Thu Jun 1 02:28:13 2006
@@ -0,0 +1,23 @@
+<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"/>
+ <actionMapping>urn:synapse/sendon</actionMapping>
+ </operation>
+ <operation name="fault" locked="false">
+ <actionMapping>urn:synapse/sendon-fault</actionMapping>
+ </operation>
+ <operation name="echo_addressing" locked="false">
+ <actionMapping>urn:synapse/sendon-addressing-engage</actionMapping>
+ </operation>
+ <operation name="ping">
+ <messageReceiver class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
+ <actionMapping>urn:synapse/ping</actionMapping>
+ </operation>
+ <operation name="simple_resources"/>
+</service>
Added: incubator/synapse/tags/M2/modules/core/test-resources/rest/conf/axis2-rest.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test-resources/rest/conf/axis2-rest.xml?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test-resources/rest/conf/axis2-rest.xml (added)
+++ incubator/synapse/tags/M2/modules/core/test-resources/rest/conf/axis2-rest.xml Thu Jun 1 02:28:13 2006
@@ -0,0 +1,150 @@
+<axisconfig name="AxisJava2.0">
+ <!-- ================================================= -->
+ <!-- Parameters -->
+ <!-- ================================================= -->
+ <parameter name="hotdeployment" locked="false">true</parameter>
+ <parameter name="hotupdate" locked="false">false</parameter>
+ <parameter name="enableMTOM" locked="false">true</parameter>
+ <parameter name="sendStacktraceDetailsWithFaults" locked="false">true</parameter>
+
+ <!-- Uncomment this to enable REST support -->
+ <parameter name="enableREST" locked="false">true</parameter>
+
+
+ <parameter name="userName" locked="false">admin</parameter>
+ <parameter name="password" locked="false">axis2</parameter>
+
+ <!-- ================================================= -->
+ <!-- Message Receivers -->
+ <!-- ================================================= -->
+ <!--This is the Deafult Message Receiver for the system , if you want to have MessageReceivers for -->
+ <!--all the other MEP implement it and add the correct entry to here , so that you can refer from-->
+ <!--any operation -->
+ <!--Note : You can ovride this for particular service by adding the same element with your requirement-->
+ <messageReceivers>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
+ class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
+ class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
+ </messageReceivers>
+ <!-- ================================================= -->
+ <!-- Transport Ins -->
+ <!-- ================================================= -->
+ <transportReceiver name="http"
+ class="org.apache.axis2.transport.http.SimpleHTTPServer">
+ <parameter name="port" locked="false">6060</parameter>
+ <!--If you want to give your own host address for EPR generation-->
+ <!--uncommet following paramter , and set as you required.-->
+ <!--<parameter name="hostname" locked="false">http://myApp.com/ws</parameter>-->
+ </transportReceiver>
+
+ <transportReceiver name="tcp"
+ class="org.apache.axis2.transport.tcp.TCPServer">
+ <parameter name="port" locked="false">6061</parameter>
+ <!--If you want to give your own host address for EPR generation-->
+ <!--uncommet following paramter , and set as you required.-->
+ <!--<parameter name="hostname" locked="false">tcp://myApp.com/ws</parameter>-->
+ </transportReceiver>
+
+ <!-- ================================================= -->
+ <!-- Transport Outs -->
+ <!-- ================================================= -->
+
+ <transportSender name="tcp"
+ class="org.apache.axis2.transport.tcp.TCPTransportSender"/>
+ <transportSender name="local"
+ class="org.apache.axis2.transport.local.LocalTransportSender"/>
+ <transportSender name="jms"
+ class="org.apache.axis2.transport.jms.JMSSender"/>
+ <transportSender name="http"
+ class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+ <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
+ <parameter name="Transfer-Encoding" locked="false">chunked</parameter>
+ </transportSender>
+ <transportSender name="https"
+ class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+ <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
+ <parameter name="Transfer-Encoding" locked="false">chunked</parameter>
+ </transportSender>
+
+ <!-- ================================================= -->
+ <!-- Phases -->
+ <!-- ================================================= -->
+ <phaseOrder type="inflow">
+ <!-- System pre defined phases -->
+ <phase name="Transport">
+ <handler name="RequestURIBasedDispatcher"
+ class="org.apache.axis2.engine.RequestURIBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+ <handler name="SOAPActionBasedDispatcher"
+ class="org.apache.axis2.engine.SOAPActionBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+ </phase>
+ <phase name="Security"/>
+ <phase name="PreDispatch"/>
+ <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
+ <handler name="AddressingBasedDispatcher"
+ class="org.apache.axis2.engine.AddressingBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+
+ <handler name="SOAPMessageBodyBasedDispatcher"
+ class="org.apache.axis2.engine.SOAPMessageBodyBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+ <handler name="InstanceDispatcher"
+ class="org.apache.axis2.engine.InstanceDispatcher">
+ <order phase="PostDispatch"/>
+ </handler>
+ </phase>
+ <!-- System pre defined phases -->
+ <!-- After Postdispatch phase module author or or service author can add any phase he want -->
+ <phase name="OperationInPhase"/>
+ </phaseOrder>
+ <phaseOrder type="outflow">
+ <!-- user can add his own phases to this area -->
+ <phase name="OperationOutPhase"/>
+ <!--system predefined phase-->
+ <!--these phase will run irrespective of the service-->
+ <phase name="PolicyDetermination"/>
+ <phase name="MessageOut"/>
+ </phaseOrder>
+ <phaseOrder type="INfaultflow">
+ <phase name="PreDispatch"/>
+ <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
+ <handler name="RequestURIBasedDispatcher"
+ class="org.apache.axis2.engine.RequestURIBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+
+ <handler name="SOAPActionBasedDispatcher"
+ class="org.apache.axis2.engine.SOAPActionBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+
+ <handler name="AddressingBasedDispatcher"
+ class="org.apache.axis2.engine.AddressingBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+
+ <handler name="SOAPMessageBodyBasedDispatcher"
+ class="org.apache.axis2.engine.SOAPMessageBodyBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+ <handler name="InstanceDispatcher"
+ class="org.apache.axis2.engine.InstanceDispatcher">
+ <order phase="PostDispatch"/>
+ </handler>
+ </phase>
+ <!-- user can add his own phases to this area -->
+ <phase name="OperationInFaultPhase"/>
+ </phaseOrder>
+ <phaseOrder type="Outfaultflow">
+ <!-- user can add his own phases to this area -->
+ <phase name="OperationOutFaultPhase"/>
+ <phase name="PolicyDetermination"/>
+ <phase name="MessageOut"/>
+ </phaseOrder>
+</axisconfig>
\ No newline at end of file
Added: incubator/synapse/tags/M2/modules/core/test-resources/tcp/axis2-tcp.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test-resources/tcp/axis2-tcp.xml?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test-resources/tcp/axis2-tcp.xml (added)
+++ incubator/synapse/tags/M2/modules/core/test-resources/tcp/axis2-tcp.xml Thu Jun 1 02:28:13 2006
@@ -0,0 +1,152 @@
+<axisconfig name="AxisJava2.0">
+ <!-- ================================================= -->
+ <!-- Parameters -->
+ <!-- ================================================= -->
+ <parameter name="hotdeployment" locked="false">true</parameter>
+ <parameter name="hotupdate" locked="false">false</parameter>
+ <parameter name="enableMTOM" locked="false">true</parameter>
+ <parameter name="sendStacktraceDetailsWithFaults" locked="false">true</parameter>
+
+ <!-- Uncomment this to enable REST support -->
+ <!-- <parameter name="enableREST" locked="false">true</parameter>-->
+
+
+ <module ref="addressing"/>
+
+ <parameter name="userName" locked="false">admin</parameter>
+ <parameter name="password" locked="false">axis2</parameter>
+
+ <!-- ================================================= -->
+ <!-- Message Receivers -->
+ <!-- ================================================= -->
+ <!--This is the Deafult Message Receiver for the system , if you want to have MessageReceivers for -->
+ <!--all the other MEP implement it and add the correct entry to here , so that you can refer from-->
+ <!--any operation -->
+ <!--Note : You can ovride this for particular service by adding the same element with your requirement-->
+ <messageReceivers>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
+ class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
+ class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
+ </messageReceivers>
+ <!-- ================================================= -->
+ <!-- Transport Ins -->
+ <!-- ================================================= -->
+ <transportReceiver name="http"
+ class="org.apache.axis2.transport.http.SimpleHTTPServer">
+ <parameter name="port" locked="false">6060</parameter>
+ <!--If you want to give your own host address for EPR generation-->
+ <!--uncommet following paramter , and set as you required.-->
+ <!--<parameter name="hostname" locked="false">http://myApp.com/ws</parameter>-->
+ </transportReceiver>
+
+ <transportReceiver name="tcp"
+ class="org.apache.axis2.transport.tcp.TCPServer">
+ <parameter name="port" locked="false">6061</parameter>
+ <!--If you want to give your own host address for EPR generation-->
+ <!--uncommet following paramter , and set as you required.-->
+ <!--<parameter name="hostname" locked="false">tcp://myApp.com/ws</parameter>-->
+ </transportReceiver>
+
+ <!-- ================================================= -->
+ <!-- Transport Outs -->
+ <!-- ================================================= -->
+
+ <transportSender name="tcp"
+ class="org.apache.axis2.transport.tcp.TCPTransportSender"/>
+ <transportSender name="local"
+ class="org.apache.axis2.transport.local.LocalTransportSender"/>
+ <transportSender name="jms"
+ class="org.apache.axis2.transport.jms.JMSSender"/>
+ <transportSender name="http"
+ class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+ <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
+ <parameter name="Transfer-Encoding" locked="false">chunked</parameter>
+ </transportSender>
+ <transportSender name="https"
+ class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+ <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
+ <parameter name="Transfer-Encoding" locked="false">chunked</parameter>
+ </transportSender>
+
+ <!-- ================================================= -->
+ <!-- Phases -->
+ <!-- ================================================= -->
+ <phaseOrder type="inflow">
+ <!-- System pre defined phases -->
+ <phase name="Transport">
+ <handler name="RequestURIBasedDispatcher"
+ class="org.apache.axis2.engine.RequestURIBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+ <handler name="SOAPActionBasedDispatcher"
+ class="org.apache.axis2.engine.SOAPActionBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+ </phase>
+ <phase name="Security"/>
+ <phase name="PreDispatch"/>
+ <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
+ <handler name="AddressingBasedDispatcher"
+ class="org.apache.axis2.engine.AddressingBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+
+ <handler name="SOAPMessageBodyBasedDispatcher"
+ class="org.apache.axis2.engine.SOAPMessageBodyBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+ <handler name="InstanceDispatcher"
+ class="org.apache.axis2.engine.InstanceDispatcher">
+ <order phase="PostDispatch"/>
+ </handler>
+ </phase>
+ <!-- System pre defined phases -->
+ <!-- After Postdispatch phase module author or or service author can add any phase he want -->
+ <phase name="OperationInPhase"/>
+ </phaseOrder>
+ <phaseOrder type="outflow">
+ <!-- user can add his own phases to this area -->
+ <phase name="OperationOutPhase"/>
+ <!--system predefined phase-->
+ <!--these phase will run irrespective of the service-->
+ <phase name="PolicyDetermination"/>
+ <phase name="MessageOut"/>
+ </phaseOrder>
+ <phaseOrder type="INfaultflow">
+ <phase name="PreDispatch"/>
+ <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
+ <handler name="RequestURIBasedDispatcher"
+ class="org.apache.axis2.engine.RequestURIBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+
+ <handler name="SOAPActionBasedDispatcher"
+ class="org.apache.axis2.engine.SOAPActionBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+
+ <handler name="AddressingBasedDispatcher"
+ class="org.apache.axis2.engine.AddressingBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+
+ <handler name="SOAPMessageBodyBasedDispatcher"
+ class="org.apache.axis2.engine.SOAPMessageBodyBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+ <handler name="InstanceDispatcher"
+ class="org.apache.axis2.engine.InstanceDispatcher">
+ <order phase="PostDispatch"/>
+ </handler>
+ </phase>
+ <!-- user can add his own phases to this area -->
+ <phase name="OperationInFaultPhase"/>
+ </phaseOrder>
+ <phaseOrder type="Outfaultflow">
+ <!-- user can add his own phases to this area -->
+ <phase name="OperationOutFaultPhase"/>
+ <phase name="PolicyDetermination"/>
+ <phase name="MessageOut"/>
+ </phaseOrder>
+</axisconfig>
\ No newline at end of file
Added: incubator/synapse/tags/M2/modules/core/test-resources/transformation/simple_transformation.xsl
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test-resources/transformation/simple_transformation.xsl?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test-resources/transformation/simple_transformation.xsl (added)
+++ incubator/synapse/tags/M2/modules/core/test-resources/transformation/simple_transformation.xsl Thu Jun 1 02:28:13 2006
@@ -0,0 +1,9 @@
+<xsl:stylesheet version='1.0'
+ xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
+ <xsl:template match="/">
+ <transformedText>
+ <xsl:value-of select="//text"/>
+ <xsl:text>Test Being Transformed</xsl:text>
+ </transformedText>
+ </xsl:template>
+</xsl:stylesheet>
Added: incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/TestMessageContext.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/TestMessageContext.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/TestMessageContext.java (added)
+++ incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/TestMessageContext.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,190 @@
+/*
+* 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;
+
+import org.apache.synapse.config.SynapseConfiguration;
+import org.apache.synapse.core.SynapseEnvironment;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAP11Constants;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.addressing.RelatesTo;
+import org.apache.axis2.AxisFault;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Set;
+
+public class TestMessageContext implements MessageContext {
+
+ private Map properties = new HashMap();
+
+ private SynapseConfiguration synCfg = null;
+
+ SOAPEnvelope envelope = null;
+
+ private EndpointReference to = null;
+
+ public SynapseConfiguration getConfiguration() {
+ return synCfg;
+ }
+
+ public void setConfiguration(SynapseConfiguration cfg) {
+ this.synCfg = cfg;
+ }
+
+ public SynapseEnvironment getEnvironment() {
+ return null;
+ }
+
+ public void setEnvironment(SynapseEnvironment se) {
+ }
+
+ public Object getProperty(String key) {
+ Object ret = properties.get(key);
+ if (ret != null) {
+ return ret;
+ } else if (getConfiguration() != null) {
+ return getConfiguration().getProperty(key);
+ } else {
+ return null;
+ }
+ }
+
+ public void setProperty(String key, Object value) {
+ properties.put(key, value);
+ }
+
+ public Set getPropertyKeySet() {
+ return properties.keySet();
+ }
+
+ //---------
+ public SOAPEnvelope getEnvelope() {
+ if (envelope == null)
+ return OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
+ else
+ return envelope;
+ }
+
+ public void setEnvelope(SOAPEnvelope envelope) throws AxisFault {
+ this.envelope = envelope;
+ }
+
+ public EndpointReference getFaultTo() {
+ return null;
+ }
+
+ public void setFaultTo(EndpointReference reference) {
+ }
+
+ public EndpointReference getFrom() {
+ return null;
+ }
+
+ public void setFrom(EndpointReference reference) {
+ }
+
+ public String getMessageID() {
+ return null;
+ }
+
+ public void setMessageID(String string) {
+ }
+
+ public RelatesTo getRelatesTo() {
+ return null;
+ }
+
+ public void setRelatesTo(RelatesTo[] reference) {
+ }
+
+ public EndpointReference getReplyTo() {
+ return null;
+ }
+
+ public void setReplyTo(EndpointReference reference) {
+ }
+
+ public EndpointReference getTo() {
+ return to;
+ }
+
+ public void setTo(EndpointReference reference) {
+ to = reference;
+ }
+
+ public void setWSAAction(String actionURI) {
+ }
+
+ public String getWSAAction() {
+ return null;
+ }
+
+ public String getSoapAction() {
+ return null;
+ }
+
+ public void setSoapAction(String string) {
+ }
+
+ public void setMessageId(String messageID) {
+ }
+
+ public String getMessageId() {
+ return null;
+ }
+
+ public boolean isDoingMTOM() {
+ return false;
+ }
+
+ public void setDoingMTOM(boolean b) {
+ }
+
+ public boolean isDoingREST() {
+ return false;
+ }
+
+ public void setDoingREST(boolean b) {
+ }
+
+ public boolean isSOAP11() {
+ return envelope.getNamespace().getName().equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+ }
+
+ public void setResponse(boolean b) {
+ }
+
+ public boolean isResponse() {
+ return false;
+ }
+
+ public void setFaultResponse(boolean b) {
+ }
+
+ public boolean isFaultResponse() {
+ return false;
+ }
+
+ public MessageContext getSynapseContext() {
+ return null;
+ }
+
+ public void setSynapseContext(MessageContext env) {
+ }
+}
Added: incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/TestMediateHandler.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/TestMediateHandler.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/TestMediateHandler.java (added)
+++ incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/TestMediateHandler.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,23 @@
+/*
+* 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.mediators;
+
+import org.apache.synapse.MessageContext;
+
+public interface TestMediateHandler {
+
+ public void handle(MessageContext synCtx);
+}
Added: incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/TestMediator.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/TestMediator.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/TestMediator.java (added)
+++ incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/TestMediator.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,49 @@
+/*
+* 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.mediators;
+
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.MessageContext;
+
+/**
+ * Test mediator class.
+ */
+public class TestMediator implements Mediator {
+
+ private TestMediateHandler handlerTest = null;
+
+ public TestMediator() {
+ }
+
+ public boolean mediate(MessageContext synCtx) {
+ if (handlerTest != null) {
+ handlerTest.handle(synCtx);
+ }
+ return true;
+ }
+
+ public String getType() {
+ return null;
+ }
+
+ public TestMediateHandler getHandler() {
+ return handlerTest;
+ }
+
+ public void setHandler(TestMediateHandler handlerTest) {
+ this.handlerTest = handlerTest;
+ }
+}
\ No newline at end of file
Added: incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/TestUtils.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/TestUtils.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/TestUtils.java (added)
+++ incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/TestUtils.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,49 @@
+/*
+* 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.mediators;
+
+import org.apache.synapse.TestMessageContext;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMDocument;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLInputFactory;
+import java.io.StringReader;
+
+public class TestUtils {
+
+ public static TestMessageContext getTestContext(String bodyText) throws Exception {
+
+ // create a test synapse context
+ TestMessageContext synCtx = new TestMessageContext();
+
+ SOAPEnvelope envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
+ OMDocument omDoc = OMAbstractFactory.getSOAP11Factory().createOMDocument();
+ omDoc.addChild(envelope);
+
+ XMLStreamReader parser = XMLInputFactory.newInstance().
+ createXMLStreamReader(new StringReader(bodyText));
+ StAXOMBuilder builder = new StAXOMBuilder(parser);
+
+ // set a dummy static message
+ envelope.getBody().addChild(builder.getDocumentElement());
+
+ synCtx.setEnvelope(envelope);
+ return synCtx;
+ }
+}
Added: incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/base/SequenceMediatorTest.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/base/SequenceMediatorTest.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/base/SequenceMediatorTest.java (added)
+++ incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/base/SequenceMediatorTest.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,63 @@
+/*
+* 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.mediators.base;
+
+import junit.framework.TestCase;
+import org.apache.synapse.mediators.TestMediator;
+import org.apache.synapse.mediators.TestMediateHandler;
+import org.apache.synapse.mediators.TestUtils;
+import org.apache.synapse.MessageContext;
+
+public class SequenceMediatorTest extends TestCase {
+
+ private StringBuffer result = new StringBuffer();
+
+ public void testSequenceMediator() throws Exception {
+
+ TestMediator t1 = new TestMediator();
+ t1.setHandler(
+ new TestMediateHandler() {
+ public void handle(MessageContext synCtx) {
+ result.append("T1.");
+ }
+ });
+ TestMediator t2 = new TestMediator();
+ t2.setHandler(
+ new TestMediateHandler() {
+ public void handle(MessageContext synCtx) {
+ result.append("T2.");
+ }
+ });
+ TestMediator t3 = new TestMediator();
+ t3.setHandler(
+ new TestMediateHandler() {
+ public void handle(MessageContext synCtx) {
+ result.append("T3");
+ }
+ });
+
+ SequenceMediator seq = new SequenceMediator();
+ seq.addChild(t1);
+ seq.addChild(t2);
+ seq.addChild(t3);
+
+ // invoke transformation, with static enveope
+ MessageContext synCtx = TestUtils.getTestContext("<empty/>");
+ seq.mediate(synCtx);
+
+ assertTrue("T1.T2.T3".equals(result.toString()));
+ }
+}
Added: incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/builtin/DropMediatorTest.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/builtin/DropMediatorTest.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/builtin/DropMediatorTest.java (added)
+++ incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/builtin/DropMediatorTest.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,35 @@
+/*
+* 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.mediators.builtin;
+
+import junit.framework.TestCase;
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.mediators.TestUtils;
+
+public class DropMediatorTest extends TestCase {
+
+ public void testDropMediator() throws Exception {
+
+ DropMediator drop = new DropMediator();
+
+ // invoke transformation, with static enveope
+ MessageContext synCtx = TestUtils.getTestContext("<empty/>");
+ boolean returnValue = drop.mediate(synCtx);
+
+ assertTrue(!returnValue);
+ assertTrue(synCtx.getTo() == null);
+ }
+}
Added: incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/builtin/PropertyMediatorTest.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/builtin/PropertyMediatorTest.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/builtin/PropertyMediatorTest.java (added)
+++ incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/builtin/PropertyMediatorTest.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,87 @@
+/*
+* 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.mediators.builtin;
+
+import junit.framework.TestCase;
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.Util;
+import org.apache.synapse.config.SynapseConfiguration;
+import org.apache.synapse.mediators.TestUtils;
+import org.apache.synapse.mediators.MediatorProperty;
+import org.apache.axiom.om.xpath.AXIOMXPath;
+
+public class PropertyMediatorTest extends TestCase {
+
+ public void testSetAndReadContextProperty() throws Exception {
+
+ PropertyMediator propMediator = new PropertyMediator();
+ propMediator.setName("name");
+ propMediator.setValue("value");
+
+ MessageContext synCtx = TestUtils.getTestContext("<empty/>");
+ propMediator.mediate(synCtx);
+
+ assertTrue(
+ "value".equals(Util.getStringValue(
+ new AXIOMXPath("synapse:get-property('name')"), synCtx)));
+ }
+
+ /**
+ * property being searched does not exist in context, and lookup should go up into the config
+ * @throws Exception
+ */
+ public void testSetAndReadGlobalProperty() throws Exception {
+
+ MessageContext synCtx = TestUtils.getTestContext("<empty/>");
+
+ SynapseConfiguration synCfg = new SynapseConfiguration();
+ synCfg.addProperty("name", "value");
+ synCtx.setConfiguration(synCfg);
+
+ assertTrue(
+ "value".equals(Util.getStringValue(
+ new AXIOMXPath("synapse:get-property('name')"), synCtx)));
+ }
+
+ public void testMediatorPropertiesLiteral() throws Exception {
+
+ MediatorProperty medProp = new MediatorProperty();
+ medProp.setName("name");
+ medProp.setValue("value");
+ assertTrue("value".equals(medProp.getValue()));
+ }
+
+ public void testMediatorPropertiesExpression() throws Exception {
+
+ // set a local property to the synapse context
+ PropertyMediator propMediator = new PropertyMediator();
+ propMediator.setName("name");
+ propMediator.setValue("value");
+
+ MessageContext synCtx = TestUtils.getTestContext("<empty/>");
+ propMediator.mediate(synCtx);
+
+ // read property through a mediator property
+ MediatorProperty medProp = new MediatorProperty();
+ medProp.setExpression(new AXIOMXPath("synapse:get-property('name')"));
+
+ assertTrue(
+ "value".equals(medProp.getEvaluatedExpression(synCtx)));
+ }
+
+}
+
+
Added: incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/ext/ClassMediatorTest.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/ext/ClassMediatorTest.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/ext/ClassMediatorTest.java (added)
+++ incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/ext/ClassMediatorTest.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,58 @@
+/*
+* 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.mediators.ext;
+
+import junit.framework.TestCase;
+import org.apache.synapse.TestMessageContext;
+import org.apache.synapse.mediators.MediatorProperty;
+import org.apache.axiom.om.xpath.AXIOMXPath;
+
+/**
+ * Tests the class mediator instantiation and setting of literal and
+ * XPath parameters at runtime.
+ */
+public class ClassMediatorTest extends TestCase {
+
+ public void testCreationWithoutProperties() throws Exception {
+ ClassMediator cm = new ClassMediator();
+ cm.setClazz(ClassMediatorTestMediator.class);
+ cm.mediate(new TestMessageContext());
+ assertTrue(ClassMediatorTestMediator.invoked);
+ }
+
+ public void testCreationWithLiteralProperties() throws Exception {
+ ClassMediator cm = new ClassMediator();
+ MediatorProperty mp = new MediatorProperty();
+ mp.setName("testProp");
+ mp.setValue("testValue");
+ cm.addProperty(mp);
+ cm.setClazz(ClassMediatorTestMediator.class);
+ cm.mediate(new TestMessageContext());
+ assertTrue(ClassMediatorTestMediator.testProp.equals("testValue"));
+ }
+
+ public void testCreationWithXPathProperties() throws Exception {
+ ClassMediator cm = new ClassMediator();
+ MediatorProperty mp = new MediatorProperty();
+ mp.setName("testProp");
+ mp.setExpression(new AXIOMXPath("concat('XPath ','is ','FUN!')"));
+ cm.addProperty(mp);
+ cm.setClazz(ClassMediatorTestMediator.class);
+ cm.mediate(new TestMessageContext());
+ assertTrue(ClassMediatorTestMediator.testProp.equals("XPath is FUN!"));
+ }
+
+}
Added: incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/ext/ClassMediatorTestMediator.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/ext/ClassMediatorTestMediator.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/ext/ClassMediatorTestMediator.java (added)
+++ incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/ext/ClassMediatorTestMediator.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,48 @@
+/*
+* 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.mediators.ext;
+
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.MessageContext;
+
+/**
+ * Since the class mediator always "instantiates" a new instance of a class
+ * use a static member variable just to test this.. This class is not nice.. :-)
+ * but does what is expected... :-(
+ */
+public class ClassMediatorTestMediator implements Mediator {
+
+ public static boolean invoked = false;
+
+ public static String testProp = null;
+
+ public boolean mediate(MessageContext synCtx) {
+ invoked = true;
+ return false;
+ }
+
+ public String getType() {
+ return null;
+ }
+
+ public void setTestProp(String s) {
+ testProp = s;
+ }
+
+ public String getTestProp() {
+ return testProp;
+ }
+}
Added: incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/filters/FilterMediatorTest.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/filters/FilterMediatorTest.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/filters/FilterMediatorTest.java (added)
+++ incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/filters/FilterMediatorTest.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,142 @@
+/*
+* 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.mediators.filters;
+
+import junit.framework.TestCase;
+import org.apache.synapse.mediators.TestMediateHandler;
+import org.apache.synapse.mediators.TestMediator;
+import org.apache.synapse.mediators.TestUtils;
+import org.apache.synapse.MessageContext;
+import org.apache.axiom.om.xpath.AXIOMXPath;
+
+import java.util.regex.Pattern;
+
+public class FilterMediatorTest extends TestCase {
+
+ private static final String REQ =
+ "<m:GetQuote xmlns:m=\"http://www.webserviceX.NET/\">\n" +
+ "\t<m:symbol>IBM</m:symbol>\n" +
+ "</m:GetQuote>";
+
+ private boolean filterConditionPassed = false;
+ TestMediator testMediator = new TestMediator();
+
+ public void setUp() {
+ testMediator = new TestMediator();
+ testMediator.setHandler(
+ new TestMediateHandler() {
+ public void handle(MessageContext synCtx) {
+ setFilterConditionPassed(true);
+ }
+ });
+ }
+
+ public void testFilterConditionTrueXPath() throws Exception {
+ setFilterConditionPassed(false);
+
+ // create a new filter mediator
+ FilterMediator filter = new FilterMediator();
+
+ // set xpath condition to IBM
+ AXIOMXPath xpath = new AXIOMXPath("//*[wsx:symbol='IBM']");
+ xpath.addNamespace("wsx", "http://www.webserviceX.NET/");
+ filter.setXpath(xpath);
+
+ // set dummy mediator to be called on success
+ filter.addChild(testMediator);
+
+ // test validate mediator, with static enveope
+ filter.mediate(TestUtils.getTestContext(REQ));
+
+ assertTrue(filterConditionPassed);
+ }
+
+ public void testFilterConditionFalseXPath() throws Exception {
+ setFilterConditionPassed(false);
+
+ // create a new filter mediator
+ FilterMediator filter = new FilterMediator();
+
+ // set xpath condition to MSFT
+ AXIOMXPath xpath = new AXIOMXPath("//*[wsx:symbol='MSFT']");
+ xpath.addNamespace("wsx", "http://www.webserviceX.NET/");
+ filter.setXpath(xpath);
+
+ // set dummy mediator to be called on success
+ filter.addChild(testMediator);
+
+ // test validate mediator, with static enveope
+ filter.mediate(TestUtils.getTestContext(REQ));
+
+ assertTrue(!filterConditionPassed);
+ }
+
+ public void testFilterConditionTrueRegex() throws Exception {
+ setFilterConditionPassed(false);
+
+ // create a new filter mediator
+ FilterMediator filter = new FilterMediator();
+
+ // set source xpath condition to //symbol
+ AXIOMXPath source = new AXIOMXPath("//wsx:symbol");
+ source.addNamespace("wsx", "http://www.webserviceX.NET/");
+ filter.setSource(source);
+
+ // set regex to IBM
+ Pattern regex = Pattern.compile("IBM");
+ filter.setRegex(regex);
+
+ // set dummy mediator to be called on success
+ filter.addChild(testMediator);
+
+ // test validate mediator, with static enveope
+ filter.mediate(TestUtils.getTestContext(REQ));
+
+ assertTrue(filterConditionPassed);
+ }
+
+ public void testFilterConditionFalseRegex() throws Exception {
+ setFilterConditionPassed(false);
+
+ // create a new filter mediator
+ FilterMediator filter = new FilterMediator();
+
+ // set source xpath condition to //symbol
+ AXIOMXPath source = new AXIOMXPath("//wsx:symbol");
+ source.addNamespace("wsx", "http://www.webserviceX.NET/");
+ filter.setSource(source);
+
+ // set regex to MSFT
+ Pattern regex = Pattern.compile("MSFT");
+ filter.setRegex(regex);
+
+ // set dummy mediator to be called on success
+ filter.addChild(testMediator);
+
+ // test validate mediator, with static enveope
+ filter.mediate(TestUtils.getTestContext(REQ));
+
+ assertTrue(!filterConditionPassed);
+ }
+
+ public boolean isFilterConditionPassed() {
+ return filterConditionPassed;
+ }
+
+ public void setFilterConditionPassed(boolean filterConditionPassed) {
+ this.filterConditionPassed = filterConditionPassed;
+ }
+}
Added: incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/filters/SwitchMediatorTest.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/filters/SwitchMediatorTest.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/filters/SwitchMediatorTest.java (added)
+++ incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/filters/SwitchMediatorTest.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,130 @@
+/*
+* 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.mediators.filters;
+
+import junit.framework.TestCase;
+import org.apache.synapse.mediators.TestMediateHandler;
+import org.apache.synapse.mediators.TestMediator;
+import org.apache.synapse.mediators.TestUtils;
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.api.Mediator;
+import org.apache.axiom.om.xpath.AXIOMXPath;
+
+import java.util.regex.Pattern;
+import java.util.Arrays;
+
+public class SwitchMediatorTest extends TestCase {
+
+ private static final String IBM_REQ =
+ "<m:GetQuote xmlns:m=\"http://www.webserviceX.NET/\">\n" +
+ "\t<m:symbol>IBM</m:symbol>\n" +
+ "</m:GetQuote>";
+
+ private static final String MSFT_REQ =
+ "<m:GetQuote xmlns:m=\"http://www.webserviceX.NET/\">\n" +
+ "\t<m:symbol>MSFT</m:symbol>\n" +
+ "</m:GetQuote>";
+
+ private static final String DEFAULT_REQ =
+ "<m:GetQuote xmlns:m=\"http://www.webserviceX.NET/\">\n" +
+ "\t<m:symbol>SUN</m:symbol>\n" +
+ "</m:GetQuote>";
+
+ private String executedCase = null;
+ TestMediator ibmMediator, msftMediator, defaultMediator;
+ SwitchMediator switchMediator = null;
+
+ public void setUp() throws Exception {
+
+ ibmMediator = new TestMediator();
+ ibmMediator.setHandler(
+ new TestMediateHandler() {
+ public void handle(MessageContext synCtx) {
+ setExecutedCase("IBM");
+ }
+ });
+
+ msftMediator = new TestMediator();
+ msftMediator.setHandler(
+ new TestMediateHandler() {
+ public void handle(MessageContext synCtx) {
+ setExecutedCase("MSFT");
+ }
+ });
+
+ defaultMediator = new TestMediator();
+ defaultMediator.setHandler(
+ new TestMediateHandler() {
+ public void handle(MessageContext synCtx) {
+ setExecutedCase("DEFAULT");
+ }
+ });
+
+ // create a new switch mediator
+ switchMediator = new SwitchMediator();
+
+ // set xpath condition to select symbol
+ AXIOMXPath xpath = new AXIOMXPath("//wsx:symbol");
+ xpath.addNamespace("wsx", "http://www.webserviceX.NET/");
+ switchMediator.setSource(xpath);
+
+ // set ibm mediator to be called for IBM, msft for MSFT and default for others..
+ switchMediator.addCase(new SwitchCaseMediator(Pattern.compile("IBM"), false,
+ Arrays.asList(new Mediator[] {ibmMediator})));
+ switchMediator.addCase(new SwitchCaseMediator(Pattern.compile("MSFT"), false,
+ Arrays.asList(new Mediator[] {msftMediator})));
+ switchMediator.addCase(new SwitchCaseMediator(null, true,
+ Arrays.asList(new Mediator[] {defaultMediator})));
+ }
+
+ public void testSwitchConditionCaseOne() throws Exception {
+ setExecutedCase(null);
+
+ // test switch mediator, with static enveope
+ switchMediator.mediate(TestUtils.getTestContext(IBM_REQ));
+
+ assertTrue("IBM".equals(getExecutedCase()));
+ }
+
+ public void testSwitchConditionCaseTwo() throws Exception {
+ setExecutedCase(null);
+
+ // test switch mediator, with static enveope
+ switchMediator.mediate(TestUtils.getTestContext(MSFT_REQ));
+
+ assertTrue("MSFT".equals(getExecutedCase()));
+ }
+
+ public void testSwitchConditionCaseDefault() throws Exception {
+ setExecutedCase(null);
+
+ // test switch mediator, with static enveope
+ switchMediator.mediate(TestUtils.getTestContext(DEFAULT_REQ));
+
+ assertTrue("DEFAULT".equals(getExecutedCase()));
+ }
+
+ public String getExecutedCase() {
+ return executedCase;
+ }
+
+ public void setExecutedCase(String executedCase) {
+ if (this.executedCase != null) {
+ throw new RuntimeException("Case already executed");
+ }
+ this.executedCase = executedCase;
+ }
+}
Added: incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/transform/FaultMediatorTest.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/transform/FaultMediatorTest.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/transform/FaultMediatorTest.java (added)
+++ incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/transform/FaultMediatorTest.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,56 @@
+/*
+* 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.mediators.transform;
+
+import junit.framework.TestCase;
+
+import javax.xml.namespace.QName;
+
+import org.apache.synapse.mediators.TestUtils;
+import org.apache.synapse.MessageContext;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFault;
+
+import java.net.URI;
+
+public class FaultMediatorTest extends TestCase {
+
+ private static final QName F_CODE = new QName("http://namespace", "somefaultcode");
+ private static final String F_STRING = "Some fault string";
+ private static final String F_ACTOR_URI = "http://actor";
+ private static final String F_DETAIL = "Some detail text";
+
+ public void testSOAP11Fault() throws Exception {
+
+ FaultMediator faultMediator = new FaultMediator();
+ faultMediator.setSoapVersion(FaultMediator.SOAP11);
+ faultMediator.setFaultCodeValue(F_CODE);
+ faultMediator.setFaultReasonValue(F_STRING);
+ faultMediator.setFaultRole(new URI(F_ACTOR_URI));
+ faultMediator.setFaultDetail(F_DETAIL);
+
+ // invoke transformation, with static enveope
+ MessageContext synCtx = TestUtils.getTestContext("<empty/>");
+ faultMediator.mediate(synCtx);
+
+ SOAPEnvelope envelope = synCtx.getEnvelope();
+ SOAPFault fault = envelope.getBody().getFault();
+ assertTrue(F_CODE.equals(fault.getCode().getValue().getTextAsQName()));
+ assertTrue(F_STRING.equals(fault.getReason().getFirstSOAPText().getText()));
+ assertTrue(F_ACTOR_URI.equals(fault.getRole().getRoleValue()));
+ assertTrue(F_DETAIL.equals(fault.getDetail().getText()));
+ }
+}
Added: incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/transform/HeaderMediatorTest.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/transform/HeaderMediatorTest.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/transform/HeaderMediatorTest.java (added)
+++ incubator/synapse/tags/M2/modules/core/test/org/apache/synapse/mediators/transform/HeaderMediatorTest.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,67 @@
+/*
+* 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.mediators.transform;
+
+import junit.framework.TestCase;
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.HeaderType;
+import org.apache.synapse.mediators.TestUtils;
+import org.apache.axiom.om.xpath.AXIOMXPath;
+
+public class HeaderMediatorTest extends TestCase {
+
+ private static final String TEST_HEADER = "http://server/path";
+
+ public void testSimpleHeaderSetAndRemove() throws Exception {
+
+ HeaderMediator headerMediator = new HeaderMediator();
+ headerMediator.setName(HeaderType.STR_TO);
+ headerMediator.setValue(TEST_HEADER);
+
+ // invoke transformation, with static enveope
+ MessageContext synCtx = TestUtils.getTestContext("<empty/>");
+ headerMediator.mediate(synCtx);
+
+ assertTrue(TEST_HEADER.equals(synCtx.getTo().getAddress()));
+
+ // set the header mediator as a remove-header
+ headerMediator.setAction(HeaderMediator.ACTION_REMOVE);
+ headerMediator.mediate(synCtx);
+
+ assertTrue(synCtx.getTo() == null);
+ }
+
+ public void testSimpleHeaderXPathSetAndRemove() throws Exception {
+
+ HeaderMediator headerMediator = new HeaderMediator();
+ headerMediator.setName(HeaderType.STR_TO);
+ headerMediator.setExpression(new AXIOMXPath("concat('http://','server','/path')"));
+
+ // invoke transformation, with static enveope
+ MessageContext synCtx = TestUtils.getTestContext("<empty/>");
+ headerMediator.mediate(synCtx);
+
+ assertTrue(TEST_HEADER.equals(synCtx.getTo().getAddress()));
+
+ // set the header mediator as a remove-header
+ headerMediator.setAction(HeaderMediator.ACTION_REMOVE);
+ headerMediator.mediate(synCtx);
+
+ assertTrue(synCtx.getTo() == null);
+ }
+
+
+}
Added: incubator/synapse/tags/M2/modules/core/test/rules/synapse-environmentaware.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test/rules/synapse-environmentaware.xml?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test/rules/synapse-environmentaware.xml (added)
+++ incubator/synapse/tags/M2/modules/core/test/rules/synapse-environmentaware.xml Thu Jun 1 02:28:13 2006
@@ -0,0 +1,7 @@
+<synapse xmlns="http://ws.apache.org/ns/synapse">
+ <stage name="test-environmentaware">
+ <engage-addressing-in/>
+ <servicemediator name="environmentaware-mediator"
+ service="environmentaware-mediator"/>
+ </stage>
+</synapse>
\ No newline at end of file
Added: incubator/synapse/tags/M2/modules/core/test/rules/synapse-fault-return.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test/rules/synapse-fault-return.xml?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test/rules/synapse-fault-return.xml (added)
+++ incubator/synapse/tags/M2/modules/core/test/rules/synapse-fault-return.xml Thu Jun 1 02:28:13 2006
@@ -0,0 +1,10 @@
+<synapse xmlns="http://ws.apache.org/ns/synapse">
+ <stage name="xpath">
+ <xpath expr="//ns:text" xmlns:ns="urn:text-body">
+ <fault/>
+ </xpath>
+ </stage>
+ <stage name="fault_return">
+ <send/>
+ </stage>
+</synapse>
\ No newline at end of file
Added: incubator/synapse/tags/M2/modules/core/test/rules/synapse-httptcp.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test/rules/synapse-httptcp.xml?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test/rules/synapse-httptcp.xml (added)
+++ incubator/synapse/tags/M2/modules/core/test/rules/synapse-httptcp.xml Thu Jun 1 02:28:13 2006
@@ -0,0 +1,13 @@
+<synapse xmlns="http://ws.apache.org/ns/synapse">
+ <stage name="xpath">
+ <xpath expr="//ns:response_text" xmlns:ns="urn:text-body">
+ <send/>
+ </xpath>
+ <xpath expr="//ns:text" xmlns:ns="urn:text-body">
+ <engage-addressing-in/>
+ <header type="to" value="tcp://localhost:8090/axis2/services/npe"/>
+ <header type="action" value="urn:synapse/sendon"/>
+ <send/>
+ </xpath>
+ </stage>
+</synapse>
\ No newline at end of file
Added: incubator/synapse/tags/M2/modules/core/test/rules/synapse-send.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test/rules/synapse-send.xml?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test/rules/synapse-send.xml (added)
+++ incubator/synapse/tags/M2/modules/core/test/rules/synapse-send.xml Thu Jun 1 02:28:13 2006
@@ -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="org.apache.synapse.mediators.SendBack"/>
+ <send/>
+ </xpath>
+ </stage>
+</synapse>
\ No newline at end of file
Added: incubator/synapse/tags/M2/modules/core/test/rules/synapse-sendnow.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test/rules/synapse-sendnow.xml?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test/rules/synapse-sendnow.xml (added)
+++ incubator/synapse/tags/M2/modules/core/test/rules/synapse-sendnow.xml Thu Jun 1 02:28:13 2006
@@ -0,0 +1,22 @@
+<synapse xmlns="http://ws.apache.org/ns/synapse">
+ <engage-addressing-in/>
+
+ <refdefine ref="ping"/>
+ <refdefine ref="addressing"/>
+
+ <define name="addressing">
+ <xpath expr="//ns:text_addressing" xmlns:ns="urn:text-body">
+ <header type="to" value="http://localhost:8090/axis2/services/npe"/>
+ <header type="action" value="urn:synapse/sendon-addressing-engage"/>
+ <sendnow/>
+ </xpath>
+ </define>
+
+ <define name="ping">
+ <xpath expr="//ns:text_ping" xmlns:ns="urn:text-body">
+ <header type="to" value="http://localhost:8090/axis2/services/npe"/>
+ <header type="action" value="urn:synapse/ping"/>
+ <sendnow/>
+ </xpath>
+ </define>
+ </synapse>
\ No newline at end of file
Added: incubator/synapse/tags/M2/modules/core/test/rules/synapse-sendon.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/core/test/rules/synapse-sendon.xml?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/core/test/rules/synapse-sendon.xml (added)
+++ incubator/synapse/tags/M2/modules/core/test/rules/synapse-sendon.xml Thu Jun 1 02:28:13 2006
@@ -0,0 +1,22 @@
+<synapse xmlns="http://ws.apache.org/ns/synapse">
+ <stage name="xpath">
+ <xpath expr="//ns:text" xmlns:ns="urn:text-body">
+ <engage-addressing-out/>
+ <classmediator name="simpleRouting" class="org.apache.synapse.mediators.SampleRouter"/>
+ <send/>
+ </xpath>
+ <xpath expr="//ns:response_text" xmlns:ns="urn:text-body">
+ <send/>
+ </xpath>
+ <xpath expr="//ns:text_addressing" xmlns:ns="urn:text-body">
+ <engage-addressing-in/>
+ <header type="to" value="http://localhost:8090/axis2/services/npe"/>
+ <header type="action" value="urn:synapse/sendon-addressing-engage"/>
+ <send/>
+ </xpath>
+ <xpath expr="//ns:response_text_addressing" xmlns:ns="urn:text-body">
+ <send/>
+ </xpath>
+
+ </stage>
+</synapse>
\ No newline at end of file
Added: incubator/synapse/tags/M2/modules/extensions/maven.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/extensions/maven.xml?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/extensions/maven.xml (added)
+++ incubator/synapse/tags/M2/modules/extensions/maven.xml Thu Jun 1 02:28:13 2006
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project default="jar"
+ xmlns:j="jelly:core"
+ xmlns:u="jelly:util"
+ xmlns:deploy="deploy"
+ xmlns:ant="jelly:ant"
+ xmlns:maven="jelly:maven"
+ xmlns:define="jelly:define">
+
+ <j:set var="dist.name" value="${pom.artifactId}-${pom.currentVersion}"/>
+ <!--<j:set var="dist.dir" value="target/dist"/>-->
+ <j:set var="extensions.dir" value="target/extensions"/>
+
+ <postGoal name="test:compile">
+ <mkdir dir="${extensions.dir}"/>
+ <attainGoal name="synapse_extensions"/>
+ <attainGoal name="extensions"/>
+ </postGoal>
+ <goal name="synapse_extensions">
+ <j:set var="class_test.dir" value="target/test-classes"/>
+
+ <mkdir dir="target/synapse-repository"/>
+ <ant:copy todir="target/synapse-repository">
+ <ant:fileset dir="../core/target/synapse-repository">
+ <ant:include name="**/**"/>
+ </ant:fileset>
+ </ant:copy>
+ <ant:path id="classes_test.dir" location="${class_test.dir}"/>
+ <maven:addPath id="maven.dependency.classpath" refid="classes_test.dir"/>
+ </goal>
+
+
+ <goal name="extensions">
+ <mkdir dir="${extensions.dir}"/>
+ <mkdir dir="target/dist"/>
+ <mkdir dir="${extensions.dir}/META-INF"/>
+ <ant:copy todir="${extensions.dir}">
+ <ant:fileset dir="target/classes">
+ <ant:include name="**/**"/>
+ </ant:fileset>
+ </ant:copy>
+ <ant:copy todir="${extensions.dir}/META-INF">
+ <ant:fileset dir="src/META-INF">
+ <ant:include name="**/**"/>
+ </ant:fileset>
+ </ant:copy>
+
+ <jar jarfile="target/dist/extension_mediators.jar"
+ basedir="${extensions.dir}">
+ <include name="**/**"/>
+ </jar>
+ <ant:delete dir="${extensions.dir}"/>
+ </goal>
+</project>
Added: incubator/synapse/tags/M2/modules/extensions/project.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/extensions/project.xml?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/extensions/project.xml (added)
+++ incubator/synapse/tags/M2/modules/extensions/project.xml Thu Jun 1 02:28:13 2006
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+
+ <pomVersion>3</pomVersion>
+ <extend>../../etc/project.xml</extend>
+
+ <!-- ============ -->
+ <!-- Dependencies -->
+ <!-- ============ -->
+ <name>Apache Synapse - Extensions</name>
+ <id>synapse-extensions</id>
+ <groupId>synapse</groupId>
+
+ <dependencies>
+ <dependency>
+ <groupId>synapse</groupId>
+ <artifactId>synapse-core</artifactId>
+ <version>${synapse.version}</version>
+ </dependency>
+
+ <!-- external JARs -->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring</artifactId>
+ <version>${spring.version}</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ </dependency>
+
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <version>${xerces.version}</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ </dependency>
+
+ <dependency>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ <version>${xml_apis.version}</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ </dependency>
+
+ <dependency>
+ <groupId>xalan</groupId>
+ <artifactId>xalan</artifactId>
+ <version>${xalan.version}</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <nagEmailAddress>synapse-dev@ws.apache.org</nagEmailAddress>
+ <sourceDirectory>src</sourceDirectory>
+ <unitTestSourceDirectory>test</unitTestSourceDirectory>
+ <unitTest>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+
+ <resources>
+ <resource>
+ <directory>src</directory>
+ <includes>
+ <include>**/org.apache.synapse.config.xml.MediatorFactory</include>
+ <include>**/org.apache.synapse.config.xml.ExtensionFactory</include>
+ </includes>
+ </resource>
+ </resources>
+ </unitTest>
+
+ </build>
+</project>
+
Added: incubator/synapse/tags/M2/modules/extensions/src/META-INF/services/org.apache.synapse.config.xml.ExtensionFactory
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/extensions/src/META-INF/services/org.apache.synapse.config.xml.ExtensionFactory?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/extensions/src/META-INF/services/org.apache.synapse.config.xml.ExtensionFactory (added)
+++ incubator/synapse/tags/M2/modules/extensions/src/META-INF/services/org.apache.synapse.config.xml.ExtensionFactory Thu Jun 1 02:28:13 2006
@@ -0,0 +1 @@
+org.apache.synapse.config.xml.SpringConfigExtensionFactory
\ No newline at end of file
Added: incubator/synapse/tags/M2/modules/extensions/src/META-INF/services/org.apache.synapse.config.xml.MediatorFactory
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/extensions/src/META-INF/services/org.apache.synapse.config.xml.MediatorFactory?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/extensions/src/META-INF/services/org.apache.synapse.config.xml.MediatorFactory (added)
+++ incubator/synapse/tags/M2/modules/extensions/src/META-INF/services/org.apache.synapse.config.xml.MediatorFactory Thu Jun 1 02:28:13 2006
@@ -0,0 +1,3 @@
+org.apache.synapse.config.xml.SpringMediatorFactory
+org.apache.synapse.config.xml.ValidateMediatorFactory
+org.apache.synapse.config.xml.TransformMediatorFactory
\ No newline at end of file
Added: incubator/synapse/tags/M2/modules/extensions/src/org/apache/synapse/config/SpringConfigExtension.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/extensions/src/org/apache/synapse/config/SpringConfigExtension.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/extensions/src/org/apache/synapse/config/SpringConfigExtension.java (added)
+++ incubator/synapse/tags/M2/modules/extensions/src/org/apache/synapse/config/SpringConfigExtension.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,68 @@
+/*
+* 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.config;
+
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.core.io.FileSystemResource;
+
+/**
+ * This defines an extension to Synapse to process a Spring Configuration.
+ * This keeps the Spring dependency out from the Synapse core, and the
+ * dependent Jars from the core distribution.
+ *
+ * A Spring configuration is usually named, but this class allows an
+ * inlined configuration to be built up as well, where the Spring mediator
+ * defines an inline Spring configuration
+ */
+public class SpringConfigExtension implements Extension {
+
+ /**
+ * The name of this Spring configuration
+ */
+ private String name = null;
+
+ /**
+ * This is the Spring ApplicationContext/BeanFactory
+ */
+ private GenericApplicationContext appContext = null;
+
+ /**
+ * Create a Spring configuration from the given configuration
+ *
+ * @param configFile the configuration file to be used
+ */
+ public SpringConfigExtension(String name, String configFile) {
+ setName(name);
+ appContext = new GenericApplicationContext();
+ XmlBeanDefinitionReader xbdr = new XmlBeanDefinitionReader(appContext);
+ xbdr.setValidating(false);
+ xbdr.loadBeanDefinitions(new FileSystemResource(configFile));
+ appContext.refresh();
+ }
+
+ public GenericApplicationContext getAppContext() {
+ return appContext;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Added: incubator/synapse/tags/M2/modules/extensions/src/org/apache/synapse/config/xml/SpringConfigExtensionFactory.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/extensions/src/org/apache/synapse/config/xml/SpringConfigExtensionFactory.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/extensions/src/org/apache/synapse/config/xml/SpringConfigExtensionFactory.java (added)
+++ incubator/synapse/tags/M2/modules/extensions/src/org/apache/synapse/config/xml/SpringConfigExtensionFactory.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,70 @@
+/*
+* 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.config.xml;
+
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.config.Extension;
+import org.apache.synapse.config.SpringConfigExtension;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Creates a Spring configuration extension from XML configuration. A Spring
+ * configuration extension keeps Spring away from the core of synapse
+ *
+ * <spring:config name="string" src="file"/>
+ */
+public class SpringConfigExtensionFactory implements ExtensionFactory {
+
+ private static final Log log = LogFactory.getLog(SpringConfigExtensionFactory.class);
+
+ private static final QName SPRING_CFG_Q = new QName(Constants.SYNAPSE_NAMESPACE + "/spring", "config");
+
+ /**
+ * <spring:config name="string" src="file"/>
+ *
+ * @param elem the XML configuration element
+ * @return A named Spring Configuration
+ */
+ public Extension createExtension(OMElement elem) {
+
+ SpringConfigExtension springCfgExt = null;
+ OMAttribute name = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "name"));
+ OMAttribute src = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "src"));
+
+ if (name == null) {
+ handleException("The 'name' attribute is required for a Spring configuration definition");
+ } else if (src == null) {
+ handleException("The 'src' attribute is required for a Spring configuration definition");
+ } else {
+ springCfgExt = new SpringConfigExtension(name.getAttributeValue(), src.getAttributeValue());
+ }
+ return springCfgExt;
+ }
+
+ private void handleException(String msg) {
+ log.error(msg);
+ throw new SynapseException(msg);
+ }
+
+ public QName getTagQName() {
+ return SPRING_CFG_Q;
+ }
+}
Added: incubator/synapse/tags/M2/modules/extensions/src/org/apache/synapse/config/xml/SpringMediatorFactory.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/extensions/src/org/apache/synapse/config/xml/SpringMediatorFactory.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/extensions/src/org/apache/synapse/config/xml/SpringMediatorFactory.java (added)
+++ incubator/synapse/tags/M2/modules/extensions/src/org/apache/synapse/config/xml/SpringMediatorFactory.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,71 @@
+package org.apache.synapse.config.xml;
+
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.config.SpringConfigExtension;
+import org.apache.synapse.mediators.ext.spring.SpringMediator;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Creates an instance of a Spring mediator that refers to the given Spring
+ * configuration and bean. Optionally, one could specify an inlined Spring
+ * configuration as opposed to a globally defined Spring configuration
+ * <p/>
+ * <spring bean="exampleBean1" (config="spring1" | src="spring.xml)"/>
+ */
+public class SpringMediatorFactory implements MediatorFactory {
+
+ private static final Log log = LogFactory.getLog(SpringMediatorFactory.class);
+
+ private static final QName tagName = new QName(Constants.SYNAPSE_NAMESPACE, "spring");
+
+ /**
+ * Create a Spring mediator instance referring to the bean and configuration given
+ * by the OMElement declaration
+ *
+ * @param elem the OMElement that specifies the Spring mediator configuration
+ * @return the Spring mediator instance created
+ */
+ public Mediator createMediator(OMElement elem) {
+
+ SpringMediator sm = new SpringMediator();
+ OMAttribute bean = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "bean"));
+ OMAttribute cfg = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "config"));
+ OMAttribute src = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "src"));
+
+ if (bean == null) {
+ handleException("The 'bean' attribute is required for a Spring mediator definition");
+ } else if (cfg == null && src == null) {
+ handleException("A 'config' or 'src' attribute is required for a Spring mediator definition");
+
+ } else {
+ sm.setBeanName(bean.getAttributeValue());
+ if (cfg != null) {
+ log.debug("Creating a Spring mediator using configuration named : " + cfg.getAttributeValue());
+ sm.setConfigName(cfg.getAttributeValue());
+
+ } else {
+ log.debug("Creating an inline Spring configuration using source : " + src.getAttributeValue());
+ SpringConfigExtension sce = new SpringConfigExtension("inline", src.getAttributeValue());
+ sm.setAppContext(sce.getAppContext());
+ }
+ return sm;
+ }
+ return null;
+ }
+
+ private void handleException(String msg) {
+ log.error(msg);
+ throw new SynapseException(msg);
+ }
+
+ public QName getTagQName() {
+ return tagName;
+ }
+
+}
Added: incubator/synapse/tags/M2/modules/extensions/src/org/apache/synapse/config/xml/TransformMediatorFactory.java
URL: http://svn.apache.org/viewvc/incubator/synapse/tags/M2/modules/extensions/src/org/apache/synapse/config/xml/TransformMediatorFactory.java?rev=410809&view=auto
==============================================================================
--- incubator/synapse/tags/M2/modules/extensions/src/org/apache/synapse/config/xml/TransformMediatorFactory.java (added)
+++ incubator/synapse/tags/M2/modules/extensions/src/org/apache/synapse/config/xml/TransformMediatorFactory.java Thu Jun 1 02:28:13 2006
@@ -0,0 +1,101 @@
+/*
+* 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.config.xml;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.xpath.AXIOMXPath;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.Util;
+import org.apache.synapse.mediators.transform.TransformMediator;
+import org.apache.synapse.api.Mediator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jaxen.JaxenException;
+
+import javax.xml.namespace.QName;
+import java.net.URL;
+import java.net.MalformedURLException;
+
+/**
+ * Creates a transform mediator from the given XML
+ *
+ * <pre>
+ * <transform xslt|xquery="url" [source="xpath"]>
+ * <property name="string" (value="literal" | expression="xpath")/>*
+ * </transform>
+ * </pre>
+ */
+public class TransformMediatorFactory extends AbstractMediatorFactory {
+
+ private static final Log log = LogFactory.getLog(TransformMediatorFactory.class);
+ private static final QName LOG_Q = new QName(Constants.SYNAPSE_NAMESPACE, "transform");
+
+ public QName getTagQName() {
+ return LOG_Q;
+ }
+
+ public Mediator createMediator(OMElement elem) {
+
+ TransformMediator transformMediator = new TransformMediator();
+
+ OMAttribute attXslt = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "xslt"));
+ OMAttribute attXQuery = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "xquery"));
+ OMAttribute attSource = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "source"));
+
+ if (attXslt != null) {
+ try {
+ transformMediator.setXsltUrl(new URL(attXslt.getAttributeValue()));
+ } catch (MalformedURLException e) {
+ String msg = "Invalid URL specified for the xslt attribute : " + attXslt.getAttributeValue();
+ log.error(msg);
+ throw new SynapseException(msg);
+ }
+
+ } else if (attXQuery != null) {
+ try {
+ transformMediator.setXQueryUrl(new URL(attXQuery.getAttributeValue()));
+ } catch (MalformedURLException e) {
+ String msg = "Invalid URL specified for the xquery attribute : " + attXQuery.getAttributeValue();
+ log.error(msg);
+ throw new SynapseException(msg);
+ }
+
+ } else {
+ String msg = "The 'xslt' or 'xquery' attributes are required for the Transform mediator";
+ log.error(msg);
+ throw new SynapseException(msg);
+ }
+
+ if (attSource != null) {
+ try {
+ AXIOMXPath xp = new AXIOMXPath(attSource.getAttributeValue());
+ Util.addNameSpaces(xp, elem, log);
+ transformMediator.setSource(xp);
+
+ } catch (JaxenException e) {
+ String msg = "Invalid XPath specified for the source attribute : " + attSource.getAttributeValue();
+ log.error(msg);
+ throw new SynapseException(msg);
+ }
+ }
+
+ transformMediator.addAllProperties(MediatorPropertyFactory.getMediatorProperties(elem));
+
+ return transformMediator;
+ }
+
+}
\ 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