You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by "Asankha C. Perera" <as...@wso2.com> on 2006/05/09 06:58:18 UTC

Added unit tests for more mediators.. (filter, switch, validate, transform, class..)

Saminda

Could you apply this patch as well..

thanks
asankha

Re: Added unit tests for more mediators.. (filter, switch, validate, transform, class..)

Posted by Saminda Abeyruwan <sa...@gmail.com>.
applied. Thank you

saminda

On 5/9/06, Asankha C. Perera <as...@wso2.com> wrote:
>
> Saminda
>
> Could you apply this patch as well..
>
> thanks
> asankha
>
>
> Index: modules/core/src/org/apache/synapse/api/ListMediator.java
> ===================================================================
> --- modules/core/src/org/apache/synapse/api/ListMediator.java   (revision
> 405043)
> +++ modules/core/src/org/apache/synapse/api/ListMediator.java   (working
> copy)
> @@ -30,6 +30,14 @@
>      public boolean addChild(Mediator m);
>
>      /**
> +     * Appends all of the mediators in the specified collection to the
> end of this mediator's (children)
> +     * list, in the order that they are returned by the specified
> collection's iterator
> +     * @param c the list of mediators to be added
> +     * @return true if this list changed as a result of the call
> +     */
> +    public boolean addAll(List c);
> +
> +    /**
>       * Returns the mediator at the specified position
>       * @param pos index of mediator to return
>       * @return the mediator at the specified position in this list
> Index:
> modules/core/src/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java
> ===================================================================
> ---
> modules/core/src/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java
> (revision 0)
> +++
> modules/core/src/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java
> (revision 0)
> @@ -0,0 +1,57 @@
> +/*
> + * 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.core.axis2;
> +
> +import org.apache.commons.logging.Log;
> +import org.apache.commons.logging.LogFactory;
> +import org.apache.synapse.SynapseContext;
> +import org.apache.synapse.core.SynapseEnvironment;
> +
> +/**
> + * <p> This is the Axis2 implementation of the SynapseContext
> + */
> +public class Axis2SynapseEnvironment implements SynapseEnvironment {
> +
> +    private ClassLoader cl = null;
> +    private static final Log log = LogFactory.getLog(
> Axis2SynapseEnvironment.class);
> +
> +    public Axis2SynapseEnvironment(ClassLoader cl) {
> +        super();
> +        this.cl = cl;
> +    }
> +
> +    public void injectMessage(SynapseContext synCtx) {
> +        synCtx.setSynapseEnvironment(this);
> +        synCtx.getConfiguration().getMainMediator().mediate(synCtx);
> +    }
> +
> +    public void send(SynapseContext synCtx) {
> +        if (synCtx.getSynapseMessage().isResponse())
> +            Axis2Sender.sendBack(synCtx);
> +        else
> +            Axis2Sender.sendOn(synCtx);
> +    }
> +
> +    public ClassLoader getClassLoader() {
> +        return cl;
> +    }
> +
> +    public void setClassLoader(ClassLoader cl) {
> +        this.cl = cl;
> +    }
> +
> +}
> Index:
> modules/core/src/org/apache/synapse/mediators/AbstractListMediator.java
> ===================================================================
> ---
> modules/core/src/org/apache/synapse/mediators/AbstractListMediator.java
> (revision 405043)
> +++
> modules/core/src/org/apache/synapse/mediators/AbstractListMediator.java
> (working copy)
> @@ -58,6 +58,10 @@
>          return mediators.add(m);
>      }
>
> +    public boolean addAll(List c) {
> +        return mediators.addAll(c);
> +    }
> +
>      public Mediator getChild(int pos) {
>          return (Mediator) mediators.get(pos);
>      }
> Index:
> modules/core/src/org/apache/synapse/mediators/filters/SwitchCaseMediator.java
> ===================================================================
> ---
> modules/core/src/org/apache/synapse/mediators/filters/SwitchCaseMediator.java
> (revision 405043)
> +++
> modules/core/src/org/apache/synapse/mediators/filters/SwitchCaseMediator.java
> (working copy)
> @@ -18,6 +18,7 @@
> import org.apache.synapse.mediators.AbstractListMediator;
>
> import java.util.regex.Pattern;
> +import java.util.List;
>
> /**
>   * A SwitchCaseMediator is a list mediator which has a regex that is
> matched by
> @@ -28,6 +29,14 @@
>      private Pattern regex = null;
>      private boolean defaultCase = false;
>
> +    public SwitchCaseMediator() {}
> +
> +    public SwitchCaseMediator(Pattern regex, boolean defaultCase, List
> children) {
> +        this.regex = regex;
> +        this.defaultCase = defaultCase;
> +        this.addAll(children);
> +    }
> +
>      public Pattern getRegex() {
>          return regex;
>      }
> @@ -45,6 +54,8 @@
>      }
>
>      public boolean matches(String value) {
> +        if (isDefaultCase())
> +            return true;
>          return regex.matcher(value).matches();
>      }
> }
> \ No newline at end of file
> Index:
> modules/core/src/org/apache/synapse/mediators/filters/SwitchMediator.java
> ===================================================================
> ---
> modules/core/src/org/apache/synapse/mediators/filters/SwitchMediator.java
> (revision 405043)
> +++
> modules/core/src/org/apache/synapse/mediators/filters/SwitchMediator.java
> (working copy)
> @@ -75,4 +75,20 @@
>      public void addCase(SwitchCaseMediator m) {
>          cases.add(m);
>      }
> +
> +    /**
> +     * Return the source XPath expression set
> +     * @return thje source XPath expression
> +     */
> +    public AXIOMXPath getSource() {
> +        return source;
> +    }
> +
> +    /**
> +     * Sets the source XPath expression
> +     * @param source the XPath expression to be used as the source
> +     */
> +    public void setSource(AXIOMXPath source) {
> +        this.source = source;
> +    }
> }
> Index: modules/core/test-resources/misc/transform.xslt
> ===================================================================
> --- modules/core/test-resources/misc/transform.xslt     (revision 0)
> +++ modules/core/test-resources/misc/transform.xslt     (revision 0)
> @@ -0,0 +1,20 @@
> +<?xml version="1.0" encoding="ISO-8859-1"?>
> +<xsl:stylesheet version="2.0"
> +       xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> +       xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
> +       xmlns:m0="http://www.apache-synapse.org/test"
> +       exclude-result-prefixes="m0 fn">
> +<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
> +
> +<xsl:template match="/">
> +  <xsl:apply-templates select="//m0:CheckPriceRequest" />
> +</xsl:template>
> +
> +<xsl:template match="m0:CheckPriceRequest">
> +
> +<m:GetQuote xmlns:m="http://www.webserviceX.NET/">
> +       <m:symbol><xsl:value-of select="m0:Code"/></m:symbol>
> +</m:GetQuote>
> +
> +</xsl:template>
> +</xsl:stylesheet>
> \ No newline at end of file
> Index:
> modules/core/test/org/apache/axis2/MultipleAddressingModuleEngagementTest.java
> ===================================================================
> ---
> modules/core/test/org/apache/axis2/MultipleAddressingModuleEngagementTest.java      (revision
> 405035)
> +++
> modules/core/test/org/apache/axis2/MultipleAddressingModuleEngagementTest.java      (working
> copy)
> @@ -1,61 +0,0 @@
> -package org.apache.axis2;
> -
> -import junit.framework.TestCase;
> -import org.apache.axis2.context.MessageContext;
> -import org.apache.synapse.SynapseEnvironment;
> -import org.apache.synapse.SynapseMessage;
> -
> -import org.apache.synapse.axis2.Axis2SynapseEnvironment;
> -import org.apache.synapse.axis2.Axis2SynapseMessage;
> -import org.apache.synapse.util.Axis2EnvSetup;
> -import org.apache.axiom.om.OMElement;
> -/*
> -* Copyright 2004,2005 The Apache Software Foundation.
> -*
> -* Licensed under the Apache License, Version 2.0 (the "License");
> -* you may not use this file except in compliance with the License.
> -* You may obtain a copy of the License at
> -*
> -*      http://www.apache.org/licenses/LICENSE-2.0
> -*
> -* Unless required by applicable law or agreed to in writing, software
> -* distributed under the License is distributed on an "AS IS" BASIS,
> -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> -* See the License for the specific language governing permissions and
> -* limitations under the License.
> -*
> -*/
> -
> -public class MultipleAddressingModuleEngagementTest extends TestCase {
> -    private MessageContext msgCtx;
> -    private SynapseEnvironment env;
> -    private OMElement config;
> -    private String synapsexml =
> -            "<synapse xmlns=\"http://ws.apache.org/ns/synapse\">\n" +
> -                    "<stage name=\"loger1\">\n" +
> -                    "    <engage-addressing-in/>" +
> -                    "    <classmediator name=\"mediation\" class=\"
> org.apache.synapse.mediators.LoggerTestSample\"/>\n" +
> -                    "</stage>\n" +
> -                    "<stage name=\"loger2\">\n" +
> -                    "    <engage-addressing-in/>" +
> -                    "    <classmediator name=\"mediation\" class=\"
> org.apache.synapse.mediators.LoggerTestSample\"/>\n" +
> -                    "</stage>\n" +
> -                    "</synapse>";
> -
> -    public void setUp() throws Exception {
> -        msgCtx = Axis2EnvSetup.axis2Deployment
> ("target/synapse-repository");
> -        config = Axis2EnvSetup.getSynapseConfigElement(synapsexml);
> -        env = new Axis2SynapseEnvironment(config,
> -                Thread.currentThread().getContextClassLoader());
> -    }
> -
> -    public void testMultipleAddressingModuleEngagement() throws Exception
> {
> -        /**
> -         * Test case return an excetion if Something goes wrong in
> AddressingINProcessor
> -         */
> -        SynapseMessage smc = new Axis2SynapseMessage(msgCtx,env);
> -        env.injectMessage(smc);
> -        assertNotNull(env.lookupMediator("mediation"));
> -    }
> -
> -}
> Index: modules/core/test/org/apache/axis2/ExceptionHandlingTest.java
> ===================================================================
> --- modules/core/test/org/apache/axis2/ExceptionHandlingTest.java
> (revision 405035)
> +++ modules/core/test/org/apache/axis2/ExceptionHandlingTest.java
> (working copy)
> @@ -1,71 +0,0 @@
> -package org.apache.axis2;
> -
> -import junit.framework.TestCase;
> -import org.apache.axis2.context.MessageContext;
> -import org.apache.axis2.context.ConfigurationContext;
> -import org.apache.axis2.context.ConfigurationContextFactory;
> -import org.apache.axis2.transport.http.SimpleHTTPServer;
> -import org.apache.synapse.SynapseEnvironment;
> -import org.apache.synapse.axis2.Axis2SynapseEnvironment;
> -import org.apache.synapse.axis2.Axis2SynapseMessage;
> -import org.apache.synapse.util.Axis2EnvSetup;
> -import org.apache.axiom.om.OMElement;
> -/*
> -* Copyright 2004,2005 The Apache Software Foundation.
> -*
> -* Licensed under the Apache License, Version 2.0 (the "License");
> -* you may not use this file except in compliance with the License.
> -* You may obtain a copy of the License at
> -*
> -*      http://www.apache.org/licenses/LICENSE-2.0
> -*
> -* Unless required by applicable law or agreed to in writing, software
> -* distributed under the License is distributed on an "AS IS" BASIS,
> -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> -* See the License for the specific language governing permissions and
> -* limitations under the License.
> -*
> -*/
> -
> -public class ExceptionHandlingTest extends TestCase {
> -    private MessageContext msgCtx;
> -    private SynapseEnvironment env;
> -    private OMElement config;
> -    private SimpleHTTPServer targetServer;
> -    private String synapsexml =
> -            "<synapse xmlns=\"http://ws.apache.org/ns/synapse\">\n" +
> -                    "<header type=\"to\" value=\"
> http://localhost:5043/axis2/services/npe\"/>\n" +
> -                    "<header type=\"action\"
> value=\"urn:synapse/sendon-fault\"/>\n" +
> -                    "<stage name=\"testing_stage\">\n" +
> -                    "    <engage-addressing-in/>\n" +
> -                    "    <send/>\n " +
> -                    "</stage>\n" +
> -                    "</synapse>";
> -
> -    public void setUp() throws Exception {
> -        msgCtx = Axis2EnvSetup.axis2Deployment
> ("target/synapse-repository");
> -        msgCtx.setSoapAction(null);
> -        config = Axis2EnvSetup.getSynapseConfigElement(synapsexml);
> -        env = new Axis2SynapseEnvironment(config,
> -                Thread.currentThread().getContextClassLoader());
> -        ConfigurationContext context = ConfigurationContextFactory
> -                .createConfigurationContextFromFileSystem(
> -                        "target/synapse-repository-sendonAxis2", null);
> -        targetServer = new SimpleHTTPServer(context,5043);
> -        targetServer.start();
> -    }
> -
> -    public void testFaultScenario() {
> -        try {
> -            env.injectMessage(new Axis2SynapseMessage(msgCtx, env));
> -            fail("Native End Point Throws an Exception");
> -        } catch (Exception e) {
> -        }
> -
> -    }
> -
> -    protected void tearDown() throws Exception {
> -        targetServer.stop();
> -    }
> -
> -}
> Index: modules/core/test/org/apache/axis2/ExceptionHandlingTest.java
> ===================================================================
> --- modules/core/test/org/apache/axis2/ExceptionHandlingTest.java
> (revision 405035)
> +++ modules/core/test/org/apache/axis2/ExceptionHandlingTest.java
> (working copy)
> @@ -1,71 +0,0 @@
> -package org.apache.axis2;
> -
> -import junit.framework.TestCase;
> -import org.apache.axis2.context.MessageContext;
> -import org.apache.axis2.context.ConfigurationContext;
> -import org.apache.axis2.context.ConfigurationContextFactory;
> -import org.apache.axis2.transport.http.SimpleHTTPServer;
> -import org.apache.synapse.SynapseEnvironment;
> -import org.apache.synapse.axis2.Axis2SynapseEnvironment;
> -import org.apache.synapse.axis2.Axis2SynapseMessage;
> -import org.apache.synapse.util.Axis2EnvSetup;
> -import org.apache.axiom.om.OMElement;
> -/*
> -* Copyright 2004,2005 The Apache Software Foundation.
> -*
> -* Licensed under the Apache License, Version 2.0 (the "License");
> -* you may not use this file except in compliance with the License.
> -* You may obtain a copy of the License at
> -*
> -*      http://www.apache.org/licenses/LICENSE-2.0
> -*
> -* Unless required by applicable law or agreed to in writing, software
> -* distributed under the License is distributed on an "AS IS" BASIS,
> -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> -* See the License for the specific language governing permissions and
> -* limitations under the License.
> -*
> -*/
> -
> -public class ExceptionHandlingTest extends TestCase {
> -    private MessageContext msgCtx;
> -    private SynapseEnvironment env;
> -    private OMElement config;
> -    private SimpleHTTPServer targetServer;
> -    private String synapsexml =
> -            "<synapse xmlns=\"http://ws.apache.org/ns/synapse\">\n" +
> -                    "<header type=\"to\" value=\"
> http://localhost:5043/axis2/services/npe\"/>\n" +
> -                    "<header type=\"action\"
> value=\"urn:synapse/sendon-fault\"/>\n" +
> -                    "<stage name=\"testing_stage\">\n" +
> -                    "    <engage-addressing-in/>\n" +
> -                    "    <send/>\n " +
> -                    "</stage>\n" +
> -                    "</synapse>";
> -
> -    public void setUp() throws Exception {
> -        msgCtx = Axis2EnvSetup.axis2Deployment
> ("target/synapse-repository");
> -        msgCtx.setSoapAction(null);
> -        config = Axis2EnvSetup.getSynapseConfigElement(synapsexml);
> -        env = new Axis2SynapseEnvironment(config,
> -                Thread.currentThread().getContextClassLoader());
> -        ConfigurationContext context = ConfigurationContextFactory
> -                .createConfigurationContextFromFileSystem(
> -                        "target/synapse-repository-sendonAxis2", null);
> -        targetServer = new SimpleHTTPServer(context,5043);
> -        targetServer.start();
> -    }
> -
> -    public void testFaultScenario() {
> -        try {
> -            env.injectMessage(new Axis2SynapseMessage(msgCtx, env));
> -            fail("Native End Point Throws an Exception");
> -        } catch (Exception e) {
> -        }
> -
> -    }
> -
> -    protected void tearDown() throws Exception {
> -        targetServer.stop();
> -    }
> -
> -}
> Index:
> modules/core/test/org/apache/axis2/MultipleAddressingModuleEngagementTest.java
> ===================================================================
> ---
> modules/core/test/org/apache/axis2/MultipleAddressingModuleEngagementTest.java      (revision
> 405035)
> +++
> modules/core/test/org/apache/axis2/MultipleAddressingModuleEngagementTest.java      (working
> copy)
> @@ -1,61 +0,0 @@
> -package org.apache.axis2;
> -
> -import junit.framework.TestCase;
> -import org.apache.axis2.context.MessageContext;
> -import org.apache.synapse.SynapseEnvironment;
> -import org.apache.synapse.SynapseMessage;
> -
> -import org.apache.synapse.axis2.Axis2SynapseEnvironment;
> -import org.apache.synapse.axis2.Axis2SynapseMessage;
> -import org.apache.synapse.util.Axis2EnvSetup;
> -import org.apache.axiom.om.OMElement;
> -/*
> -* Copyright 2004,2005 The Apache Software Foundation.
> -*
> -* Licensed under the Apache License, Version 2.0 (the "License");
> -* you may not use this file except in compliance with the License.
> -* You may obtain a copy of the License at
> -*
> -*      http://www.apache.org/licenses/LICENSE-2.0
> -*
> -* Unless required by applicable law or agreed to in writing, software
> -* distributed under the License is distributed on an "AS IS" BASIS,
> -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> -* See the License for the specific language governing permissions and
> -* limitations under the License.
> -*
> -*/
> -
> -public class MultipleAddressingModuleEngagementTest extends TestCase {
> -    private MessageContext msgCtx;
> -    private SynapseEnvironment env;
> -    private OMElement config;
> -    private String synapsexml =
> -            "<synapse xmlns=\"http://ws.apache.org/ns/synapse\">\n" +
> -                    "<stage name=\"loger1\">\n" +
> -                    "    <engage-addressing-in/>" +
> -                    "    <classmediator name=\"mediation\" class=\"
> org.apache.synapse.mediators.LoggerTestSample\"/>\n" +
> -                    "</stage>\n" +
> -                    "<stage name=\"loger2\">\n" +
> -                    "    <engage-addressing-in/>" +
> -                    "    <classmediator name=\"mediation\" class=\"
> org.apache.synapse.mediators.LoggerTestSample\"/>\n" +
> -                    "</stage>\n" +
> -                    "</synapse>";
> -
> -    public void setUp() throws Exception {
> -        msgCtx = Axis2EnvSetup.axis2Deployment
> ("target/synapse-repository");
> -        config = Axis2EnvSetup.getSynapseConfigElement(synapsexml);
> -        env = new Axis2SynapseEnvironment(config,
> -                Thread.currentThread().getContextClassLoader());
> -    }
> -
> -    public void testMultipleAddressingModuleEngagement() throws Exception
> {
> -        /**
> -         * Test case return an excetion if Something goes wrong in
> AddressingINProcessor
> -         */
> -        SynapseMessage smc = new Axis2SynapseMessage(msgCtx,env);
> -        env.injectMessage(smc);
> -        assertNotNull(env.lookupMediator("mediation"));
> -    }
> -
> -}
> Index: modules/core/test/org/apache/axis2/test/TestMediator.java
> ===================================================================
> --- modules/core/test/org/apache/axis2/test/TestMediator.java   (revision
> 405035)
> +++ modules/core/test/org/apache/axis2/test/TestMediator.java   (working
> copy)
> @@ -1,27 +0,0 @@
> -package org.apache.axis2.test;
> -
> -import org.apache.synapse.api.Mediator;
> -import org.apache.synapse.SynapseMessage;
> -/*
> -* 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 TestMediator implements Mediator {
> -    public boolean mediate(SynapseMessage smc) {
> -        System.out.println("Executing mediators");
> -        return true ;
> -    }
> -}
> Index: modules/core/test/org/apache/axis2/test/Echo.java
> ===================================================================
> --- modules/core/test/org/apache/axis2/test/Echo.java   (revision 405035)
> +++ modules/core/test/org/apache/axis2/test/Echo.java   (working copy)
> @@ -1,79 +0,0 @@
> -package org.apache.axis2.test;
> -
> -import org.apache.axis2.AxisFault;
> -import org.apache.axiom.om.OMElement;
> -import org.apache.axiom.om.OMAbstractFactory;
> -import org.apache.axiom.om.OMNamespace;
> -import org.apache.axiom.om.OMFactory;
> -/*
> -* Copyright 2004,2005 The Apache Software Foundation.
> -*
> -* Licensed under the Apache License, Version 2.0 (the "License");
> -* you may not use this file except in compliance with the License.
> -* You may obtain a copy of the License at
> -*
> -*      http://www.apache.org/licenses/LICENSE-2.0
> -*
> -* Unless required by applicable law or agreed to in writing, software
> -* distributed under the License is distributed on an "AS IS" BASIS,
> -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> -* See the License for the specific language governing permissions and
> -* limitations under the License.
> -*
> -*/
> -
> -public class Echo {
> -    public OMElement echo(OMElement element) {
> -        System.out.println(
> -                "This is the actual service which has been redirected");
> -        element.build();
> -        element.detach();
> -        OMFactory fac = OMAbstractFactory.getOMFactory();
> -        OMNamespace omNs = fac.createOMNamespace(
> -                "urn:text-body", "ns");
> -        OMElement responseText = fac.createOMElement("response_text",
> omNs);
> -        responseText.addChild(
> -                fac.createOMText(responseText, "Synapse Testing
> String_Response"));
> -        return responseText;
> -    }
> -    public OMElement fault(OMElement element) throws AxisFault {
> -        throw new AxisFault("Native End Point Throws an Exception");
> -    }
> -    public OMElement echo_addressing(OMElement element) {
> -        System.out.println(
> -                "This is the actual service which has been redirected
> with addressing");
> -        element.build();
> -        element.detach();
> -        OMFactory fac = OMAbstractFactory.getOMFactory();
> -        OMNamespace omNs = fac.createOMNamespace(
> -                "urn:text-body", "ns");
> -        OMElement responseText = fac.createOMElement("response_text_addressing",
> omNs);
> -        responseText.addChild(
> -                fac.createOMText(responseText, "Synapse Testing
> String_Response_With_Addressing"));
> -        return responseText;
> -    }
> -
> -    public void ping(OMElement element) {
> -        System.out.println(
> -                "This is the actual service which has been pinged");
> -    }
> -
> -
> -    public OMElement simple_resources(OMElement element){
> -        System.out.println("This is the actual resource provider");
> -        element.build();
> -        element.detach();
> -
> -        OMFactory fac = OMAbstractFactory.getOMFactory();
> -
> -        OMElement ele1 = fac.createOMElement("ele1","","");
> -        OMElement ele2 = fac.createOMElement("ele2","","");
> -        OMElement ele3 = fac.createOMElement("ele3","","");
> -        element.addChild(ele1);
> -        element.addChild(ele2);
> -        element.addChild(ele3);
> -        return element;
> -
> -    }
> -
> -}
> Index: modules/core/test/org/apache/axis2/test/Echo.java
> ===================================================================
> --- modules/core/test/org/apache/axis2/test/Echo.java   (revision 405035)
> +++ modules/core/test/org/apache/axis2/test/Echo.java   (working copy)
> @@ -1,79 +0,0 @@
> -package org.apache.axis2.test;
> -
> -import org.apache.axis2.AxisFault;
> -import org.apache.axiom.om.OMElement;
> -import org.apache.axiom.om.OMAbstractFactory;
> -import org.apache.axiom.om.OMNamespace;
> -import org.apache.axiom.om.OMFactory;
> -/*
> -* Copyright 2004,2005 The Apache Software Foundation.
> -*
> -* Licensed under the Apache License, Version 2.0 (the "License");
> -* you may not use this file except in compliance with the License.
> -* You may obtain a copy of the License at
> -*
> -*      http://www.apache.org/licenses/LICENSE-2.0
> -*
> -* Unless required by applicable law or agreed to in writing, software
> -* distributed under the License is distributed on an "AS IS" BASIS,
> -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> -* See the License for the specific language governing permissions and
> -* limitations under the License.
> -*
> -*/
> -
> -public class Echo {
> -    public OMElement echo(OMElement element) {
> -        System.out.println(
> -                "This is the actual service which has been redirected");
> -        element.build();
> -        element.detach();
> -        OMFactory fac = OMAbstractFactory.getOMFactory();
> -        OMNamespace omNs = fac.createOMNamespace(
> -                "urn:text-body", "ns");
> -        OMElement responseText = fac.createOMElement("response_text",
> omNs);
> -        responseText.addChild(
> -                fac.createOMText(responseText, "Synapse Testing
> String_Response"));
> -        return responseText;
> -    }
> -    public OMElement fault(OMElement element) throws AxisFault {
> -        throw new AxisFault("Native End Point Throws an Exception");
> -    }
> -    public OMElement echo_addressing(OMElement element) {
> -        System.out.println(
> -                "This is the actual service which has been redirected
> with addressing");
> -        element.build();
> -        element.detach();
> -        OMFactory fac = OMAbstractFactory.getOMFactory();
> -        OMNamespace omNs = fac.createOMNamespace(
> -                "urn:text-body", "ns");
> -        OMElement responseText = fac.createOMElement("response_text_addressing",
> omNs);
> -        responseText.addChild(
> -                fac.createOMText(responseText, "Synapse Testing
> String_Response_With_Addressing"));
> -        return responseText;
> -    }
> -
> -    public void ping(OMElement element) {
> -        System.out.println(
> -                "This is the actual service which has been pinged");
> -    }
> -
> -
> -    public OMElement simple_resources(OMElement element){
> -        System.out.println("This is the actual resource provider");
> -        element.build();
> -        element.detach();
> -
> -        OMFactory fac = OMAbstractFactory.getOMFactory();
> -
> -        OMElement ele1 = fac.createOMElement("ele1","","");
> -        OMElement ele2 = fac.createOMElement("ele2","","");
> -        OMElement ele3 = fac.createOMElement("ele3","","");
> -        element.addChild(ele1);
> -        element.addChild(ele2);
> -        element.addChild(ele3);
> -        return element;
> -
> -    }
> -
> -}
> Index: modules/core/test/org/apache/axis2/test/TestMediator.java
> ===================================================================
> --- modules/core/test/org/apache/axis2/test/TestMediator.java   (revision
> 405035)
> +++ modules/core/test/org/apache/axis2/test/TestMediator.java   (working
> copy)
> @@ -1,27 +0,0 @@
> -package org.apache.axis2.test;
> -
> -import org.apache.synapse.api.Mediator;
> -import org.apache.synapse.SynapseMessage;
> -/*
> -* 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 TestMediator implements Mediator {
> -    public boolean mediate(SynapseMessage smc) {
> -        System.out.println("Executing mediators");
> -        return true ;
> -    }
> -}
> Index:
> modules/core/test/org/apache/synapse/mediators/builtin/ValidateMediatorTest.java
> ===================================================================
> ---
> modules/core/test/org/apache/synapse/mediators/builtin/ValidateMediatorTest.java    (revision
> 405043)
> +++
> modules/core/test/org/apache/synapse/mediators/builtin/ValidateMediatorTest.java    (working
> copy)
> @@ -25,13 +25,14 @@
> import org.apache.synapse.TestSynapseMessageContext;
> import org.apache.synapse.mediators.TestMediateHandler;
> import org.apache.synapse.mediators.TestMediator;
> +import org.apache.synapse.mediators.TestUtils;
>
> import javax.xml.stream.XMLInputFactory;
> import javax.xml.stream.XMLStreamReader;
> import java.io.StringReader;
> import java.io.File;
>
> -public class ValidateMediatorTest extends TestCase implements
> TestMediateHandler {
> +public class ValidateMediatorTest extends TestCase {
>
>      private static final String VALID_ENVELOPE =
>              "<m0:CheckPriceRequest xmlns:m0=\"
> http://www.apache-synapse.org/test\">\n" +
> @@ -43,18 +44,29 @@
>              "\t<m0:Codes>String</m0:Codes>\n" +
>              "</m0:CheckPriceRequest>\n";
>
> +    private static final String VALID_ENVELOPE_NO_NS =
> +            "<CheckPriceRequest xmlns=\"
> http://www.apache-synapse.org/test\">\n" +
> +            "\t<Code>String</Code>\n" +
> +            "</CheckPriceRequest>\n";
> +
> +    private static final String IN_VALID_ENVELOPE_NO_NS =
> +            "<CheckPriceRequest xmlns=\"
> http://www.apache-synapse.org/test\">\n" +
> +            "\t<Code>String</Code>\n" +
> +            "</CheckPriceRequest>\n";
> +
>      private boolean onFailInvoked = false;
>      private TestMediator testMediator = null;
>
>      public void setUp() {
>          testMediator = new TestMediator();
> -        testMediator.setHandler(this);
> +        testMediator.setHandler(
> +            new TestMediateHandler() {
> +                public void handle(SynapseContext synCtx) {
> +                    setOnFailInvoked(true);
> +                }
> +            });
>      }
>
> -    public void handle(SynapseContext synCtx) {
> -        onFailInvoked = true;
> -    }
> -
>      public void setOnFailInvoked(boolean onFailInvoked) {
>          this.onFailInvoked = onFailInvoked;
>      }
> @@ -66,7 +78,6 @@
>          ValidateMediator validate = new ValidateMediator();
>
>          // set the schema url, source xpath and any name spaces
> -        System.out.println("Current Dir : " + new
> File(".").getAbsolutePath());
>          validate.setSchemaUrl("test-resources/misc/validate.xsd");
>          AXIOMXPath source = new AXIOMXPath("//m0:CheckPriceRequest");
>          source.addNamespace("m0", "http://www.apache-synapse.org/test");
> @@ -76,7 +87,7 @@
>          validate.addChild(testMediator);
>
>          // test validate mediator, with static enveope
> -        validate.mediate(getTestContext(VALID_ENVELOPE));
> +        validate.mediate(TestUtils.getTestContext(VALID_ENVELOPE));
>
>          assertTrue(!onFailInvoked);
>      }
> @@ -97,31 +108,50 @@
>          validate.addChild(testMediator);
>
>          // test validate mediator, with static enveope
> -        validate.mediate(getTestContext(IN_VALID_ENVELOPE));
> +        validate.mediate(TestUtils.getTestContext(IN_VALID_ENVELOPE));
>
>          assertTrue(onFailInvoked);
>      }
>
> -    private TestSynapseMessageContext getTestContext(String bodyText)
> throws Exception {
> +    public void testValidateMedaitorValidCaseNoNS() throws Exception {
> +        setOnFailInvoked(false);
>
> -        // create a test synapse context
> -        TestSynapseMessageContext synCtx = new
> TestSynapseMessageContext();
> -        TestSynapseMessage synMsg = new TestSynapseMessage();
> +        // create a validate mediator
> +        ValidateMediator validate = new ValidateMediator();
>
> -        SOAPEnvelope envelope = OMAbstractFactory.getSOAP11Factory
> ().getDefaultEnvelope();
> -        OMDocument omDoc = OMAbstractFactory.getSOAP11Factory
> ().createOMDocument();
> -        omDoc.addChild(envelope);
> +        // set the schema url, source xpath and any name spaces
> +        validate.setSchemaUrl("test-resources/misc/validate.xsd");
> +        AXIOMXPath source = new AXIOMXPath("//m0:CheckPriceRequest");
> +        source.addNamespace("m0", "http://www.apache-synapse.org/test");
> +        validate.setSource(source);
>
> -        XMLStreamReader parser = XMLInputFactory.newInstance().
> -            createXMLStreamReader(new StringReader(bodyText));
> -        StAXOMBuilder builder = new StAXOMBuilder(parser);
> +        // set dummy mediator to be called on fail
> +        validate.addChild(testMediator);
>
> -        // set a dummy static message
> -        envelope.getBody().addChild(builder.getDocumentElement());
> +        // test validate mediator, with static enveope
> +        validate.mediate(TestUtils.getTestContext(VALID_ENVELOPE_NO_NS));
>
> -        synMsg.setEnvelope(envelope);
> -        synCtx.setSynapseMessage(synMsg);
> -        return synCtx;
> +        assertTrue(!onFailInvoked);
>      }
>
> +    public void testValidateMedaitorInvalidCaseNoNS() throws Exception {
> +        setOnFailInvoked(false);
> +
> +        // create a validate mediator
> +        ValidateMediator validate = new ValidateMediator();
> +
> +        // set the schema url, source xpath and any name spaces
> +        validate.setSchemaUrl
> ("modules/core/test-resources/misc/validate.xsd");
> +        AXIOMXPath source = new AXIOMXPath("//m0:CheckPriceRequest");
> +        source.addNamespace("m0", "http://www.apache-synapse.org/test");
> +        validate.setSource(source);
> +
> +        // set dummy mediator to be called on fail
> +        validate.addChild(testMediator);
> +
> +        // test validate mediator, with static enveope
> +        validate.mediate(TestUtils.getTestContext
> (IN_VALID_ENVELOPE_NO_NS));
> +
> +        assertTrue(onFailInvoked);
> +    }
> }
> Index:
> modules/core/test/org/apache/synapse/mediators/filters/SwitchMediatorTest.java
> ===================================================================
> ---
> modules/core/test/org/apache/synapse/mediators/filters/SwitchMediatorTest.java      (revision
> 0)
> +++
> modules/core/test/org/apache/synapse/mediators/filters/SwitchMediatorTest.java      (revision
> 0)
> @@ -0,0 +1,131 @@
> +/*
> +* 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.SynapseContext;
> +import org.apache.synapse.api.Mediator;
> +import org.apache.axiom.om.xpath.AXIOMXPath;
> +
> +import java.util.regex.Pattern;
> +import java.util.ArrayList;
> +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(SynapseContext synCtx) {
> +                    setExecutedCase("IBM");
> +                }
> +            });
> +
> +        msftMediator = new TestMediator();
> +        msftMediator.setHandler(
> +            new TestMediateHandler() {
> +                public void handle(SynapseContext synCtx) {
> +                    setExecutedCase("MSFT");
> +                }
> +            });
> +
> +        defaultMediator = new TestMediator();
> +        defaultMediator.setHandler(
> +            new TestMediateHandler() {
> +                public void handle(SynapseContext 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;
> +    }
> +}
> Index:
> modules/core/test/org/apache/synapse/mediators/filters/FilterMediatorTest.java
> ===================================================================
> ---
> modules/core/test/org/apache/synapse/mediators/filters/FilterMediatorTest.java      (revision
> 0)
> +++
> modules/core/test/org/apache/synapse/mediators/filters/FilterMediatorTest.java      (revision
> 0)
> @@ -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.SynapseContext;
> +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(SynapseContext 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;
> +    }
> +}
> Index:
> modules/core/test/org/apache/synapse/mediators/filters/FilterMediatorTest.java
> ===================================================================
> ---
> modules/core/test/org/apache/synapse/mediators/filters/FilterMediatorTest.java      (revision
> 0)
> +++
> modules/core/test/org/apache/synapse/mediators/filters/FilterMediatorTest.java      (revision
> 0)
> @@ -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.SynapseContext;
> +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(SynapseContext 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;
> +    }
> +}
> Index:
> modules/core/test/org/apache/synapse/mediators/filters/SwitchMediatorTest.java
> ===================================================================
> ---
> modules/core/test/org/apache/synapse/mediators/filters/SwitchMediatorTest.java      (revision
> 0)
> +++
> modules/core/test/org/apache/synapse/mediators/filters/SwitchMediatorTest.java      (revision
> 0)
> @@ -0,0 +1,131 @@
> +/*
> +* 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.SynapseContext;
> +import org.apache.synapse.api.Mediator;
> +import org.apache.axiom.om.xpath.AXIOMXPath;
> +
> +import java.util.regex.Pattern;
> +import java.util.ArrayList;
> +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(SynapseContext synCtx) {
> +                    setExecutedCase("IBM");
> +                }
> +            });
> +
> +        msftMediator = new TestMediator();
> +        msftMediator.setHandler(
> +            new TestMediateHandler() {
> +                public void handle(SynapseContext synCtx) {
> +                    setExecutedCase("MSFT");
> +                }
> +            });
> +
> +        defaultMediator = new TestMediator();
> +        defaultMediator.setHandler(
> +            new TestMediateHandler() {
> +                public void handle(SynapseContext 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;
> +    }
> +}
> Index: modules/core/test/org/apache/synapse/mediators/TestUtils.java
> ===================================================================
> --- modules/core/test/org/apache/synapse/mediators/TestUtils.java
> (revision 0)
> +++ modules/core/test/org/apache/synapse/mediators/TestUtils.java
> (revision 0)
> @@ -0,0 +1,52 @@
> +/*
> +* 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.TestSynapseMessageContext;
> +import org.apache.synapse.TestSynapseMessage;
> +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 TestSynapseMessageContext getTestContext(String
> bodyText) throws Exception {
> +
> +        // create a test synapse context
> +        TestSynapseMessageContext synCtx = new
> TestSynapseMessageContext();
> +        TestSynapseMessage synMsg = new TestSynapseMessage();
> +
> +        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());
> +
> +        synMsg.setEnvelope(envelope);
> +        synCtx.setSynapseMessage(synMsg);
> +        return synCtx;
> +    }
> +}
> Index:
> modules/core/test/org/apache/synapse/mediators/transform/TransformMediatorTest.java
> ===================================================================
> ---
> modules/core/test/org/apache/synapse/mediators/transform/TransformMediatorTest.java
> (revision 0)
> +++
> modules/core/test/org/apache/synapse/mediators/transform/TransformMediatorTest.java
> (revision 0)
> @@ -0,0 +1,155 @@
> +/*
> +* 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.axiom.om.xpath.AXIOMXPath;
> +import org.apache.axiom.om.OMContainer;
> +import org.apache.axiom.om.OMElement;
> +import org.apache.synapse.mediators.TestUtils;
> +import org.apache.synapse.SynapseContext;
> +
> +import java.net.URL;
> +import java.io.File;
> +
> +public class TransformMediatorTest extends TestCase {
> +
> +    private static final String SOURCE =
> +        "<m0:CheckPriceRequest xmlns:m0=\"
> http://www.apache-synapse.org/test\">\n" +
> +        "<m0:Code>String</m0:Code>\n" +
> +        "</m0:CheckPriceRequest>";
> +
> +    private static final String ENCLOSING_SOURCE =
> +        "<m:someOtherElement xmlns:m=\"http://someother\">" +
> +        "<m0:CheckPriceRequest xmlns:m0=\"
> http://www.apache-synapse.org/test\">\n" +
> +        "<m0:Code>String</m0:Code>\n" +
> +        "</m0:CheckPriceRequest>" +
> +        "</m:someOtherElement>";
> +
> +    TransformMediator transformMediator = null;
> +
> +    public void testTransformXSLTCustomSource() throws Exception {
> +
> +        // create a new switch mediator
> +        transformMediator = new TransformMediator();
> +
> +        // set xpath condition to select source
> +        AXIOMXPath xpath = new AXIOMXPath("//m0:CheckPriceRequest");
> +        xpath.addNamespace("m0", "http://www.apache-synapse.org/test");
> +        transformMediator.setSource(xpath);
> +
> +        // set XSLT transformation URL
> +        transformMediator.setXsltUrl(
> +            new URL("file:///" + new File(".").getAbsolutePath() +
> "/test-resources/misc/transform.xslt"));
> +
> +        // invoke transformation, with static enveope
> +        SynapseContext synCtx = TestUtils.getTestContext(SOURCE);
> +        transformMediator.mediate(synCtx);
> +
> +        // validate result
> +        OMContainer body = synCtx.getSynapseMessage
> ().getEnvelope().getBody();
> +        if (body.getFirstOMChild() instanceof OMElement) {
> +
> +            OMElement getQuoteElem = (OMElement) body.getFirstOMChild();
> +            assertTrue("GetQuote".equals(getQuoteElem.getLocalName()));
> +            assertTrue("http://www.webserviceX.NET/".equals(
> getQuoteElem.getNamespace().getName()));
> +
> +            OMElement symbolElem = getQuoteElem.getFirstElement();
> +            assertTrue("symbol".equals(symbolElem.getLocalName()));
> +            assertTrue("http://www.webserviceX.NET/".equals(
> symbolElem.getNamespace().getName()));
> +
> +            assertTrue("String".equals(symbolElem.getText()));
> +        } else {
> +            fail("Unexpected element found in SOAP body");
> +        }
> +    }
> +
> +    /**
> +     * If a source element for transformation is not found, default to
> soap body
> +     * @throws Exception
> +     */
> +    public void testTransformXSLTDefaultSource() throws Exception {
> +
> +        // create a new switch mediator
> +        transformMediator = new TransformMediator();
> +
> +        // set XSLT transformation URL
> +        transformMediator.setXsltUrl(
> +            new URL("file:///" + new File(".").getAbsolutePath() +
> "/test-resources/misc/transform.xslt"));
> +
> +        // invoke transformation, with static enveope
> +        SynapseContext synCtx = TestUtils.getTestContext(SOURCE);
> +        transformMediator.mediate(synCtx);
> +
> +        // validate result
> +        OMContainer body = synCtx.getSynapseMessage
> ().getEnvelope().getBody();
> +        if (body.getFirstOMChild() instanceof OMElement) {
> +
> +            OMElement getQuoteElem = (OMElement) body.getFirstOMChild();
> +            assertTrue("GetQuote".equals(getQuoteElem.getLocalName()));
> +            assertTrue("http://www.webserviceX.NET/".equals(
> getQuoteElem.getNamespace().getName()));
> +
> +            OMElement symbolElem = getQuoteElem.getFirstElement();
> +            assertTrue("symbol".equals(symbolElem.getLocalName()));
> +            assertTrue("http://www.webserviceX.NET/".equals(
> symbolElem.getNamespace().getName()));
> +
> +            assertTrue("String".equals(symbolElem.getText()));
> +        } else {
> +            fail("Unexpected element found in SOAP body");
> +        }
> +    }
> +
> +    public void testTransformXSLTCustomSourceNonMainElement() throws
> Exception {
> +
> +        // create a new switch mediator
> +        transformMediator = new TransformMediator();
> +
> +        // set xpath condition to select source
> +        AXIOMXPath xpath = new AXIOMXPath("//m0:CheckPriceRequest");
> +        xpath.addNamespace("m0", "http://www.apache-synapse.org/test");
> +        transformMediator.setSource(xpath);
> +
> +        // set XSLT transformation URL
> +        transformMediator.setXsltUrl(
> +            new URL("file:///" + new File(".").getAbsolutePath() +
> "/test-resources/misc/transform.xslt"));
> +
> +        // invoke transformation, with static enveope
> +        SynapseContext synCtx = TestUtils.getTestContext
> (ENCLOSING_SOURCE);
> +        transformMediator.mediate(synCtx);
> +
> +        // validate result
> +        OMContainer body = synCtx.getSynapseMessage
> ().getEnvelope().getBody();
> +        if (body.getFirstOMChild() instanceof OMElement) {
> +
> +            OMElement someOtherElem = (OMElement) body.getFirstOMChild();
> +            assertTrue("someOtherElement".equals(
> someOtherElem.getLocalName()));
> +            assertTrue("http://someother".equals(
> someOtherElem.getNamespace().getName()));
> +
> +            OMElement getQuoteElem = (OMElement)
> someOtherElem.getFirstOMChild();
> +            assertTrue("GetQuote".equals(getQuoteElem.getLocalName()));
> +            assertTrue("http://www.webserviceX.NET/".equals(
> getQuoteElem.getNamespace().getName()));
> +
> +            OMElement symbolElem = getQuoteElem.getFirstElement();
> +            assertTrue("symbol".equals(symbolElem.getLocalName()));
> +            assertTrue("http://www.webserviceX.NET/".equals(
> symbolElem.getNamespace().getName()));
> +
> +            assertTrue("String".equals(symbolElem.getText()));
> +        } else {
> +            fail("Unexpected element found in SOAP body");
> +        }
> +    }
> +
> +}
> Index:
> modules/core/test/org/apache/synapse/mediators/transform/TransformMediatorTest.java
> ===================================================================
> ---
> modules/core/test/org/apache/synapse/mediators/transform/TransformMediatorTest.java
> (revision 0)
> +++
> modules/core/test/org/apache/synapse/mediators/transform/TransformMediatorTest.java
> (revision 0)
> @@ -0,0 +1,155 @@
> +/*
> +* 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.axiom.om.xpath.AXIOMXPath;
> +import org.apache.axiom.om.OMContainer;
> +import org.apache.axiom.om.OMElement;
> +import org.apache.synapse.mediators.TestUtils;
> +import org.apache.synapse.SynapseContext;
> +
> +import java.net.URL;
> +import java.io.File;
> +
> +public class TransformMediatorTest extends TestCase {
> +
> +    private static final String SOURCE =
> +        "<m0:CheckPriceRequest xmlns:m0=\"
> http://www.apache-synapse.org/test\">\n" +
> +        "<m0:Code>String</m0:Code>\n" +
> +        "</m0:CheckPriceRequest>";
> +
> +    private static final String ENCLOSING_SOURCE =
> +        "<m:someOtherElement xmlns:m=\"http://someother\">" +
> +        "<m0:CheckPriceRequest xmlns:m0=\"
> http://www.apache-synapse.org/test\">\n" +
> +        "<m0:Code>String</m0:Code>\n" +
> +        "</m0:CheckPriceRequest>" +
> +        "</m:someOtherElement>";
> +
> +    TransformMediator transformMediator = null;
> +
> +    public void testTransformXSLTCustomSource() throws Exception {
> +
> +        // create a new switch mediator
> +        transformMediator = new TransformMediator();
> +
> +        // set xpath condition to select source
> +        AXIOMXPath xpath = new AXIOMXPath("//m0:CheckPriceRequest");
> +        xpath.addNamespace("m0", "http://www.apache-synapse.org/test");
> +        transformMediator.setSource(xpath);
> +
> +        // set XSLT transformation URL
> +        transformMediator.setXsltUrl(
> +            new URL("file:///" + new File(".").getAbsolutePath() +
> "/test-resources/misc/transform.xslt"));
> +
> +        // invoke transformation, with static enveope
> +        SynapseContext synCtx = TestUtils.getTestContext(SOURCE);
> +        transformMediator.mediate(synCtx);
> +
> +        // validate result
> +        OMContainer body = synCtx.getSynapseMessage
> ().getEnvelope().getBody();
> +        if (body.getFirstOMChild() instanceof OMElement) {
> +
> +            OMElement getQuoteElem = (OMElement) body.getFirstOMChild();
> +            assertTrue("GetQuote".equals(getQuoteElem.getLocalName()));
> +            assertTrue("http://www.webserviceX.NET/".equals(
> getQuoteElem.getNamespace().getName()));
> +
> +            OMElement symbolElem = getQuoteElem.getFirstElement();
> +            assertTrue("symbol".equals(symbolElem.getLocalName()));
> +            assertTrue("http://www.webserviceX.NET/".equals(
> symbolElem.getNamespace().getName()));
> +
> +            assertTrue("String".equals(symbolElem.getText()));
> +        } else {
> +            fail("Unexpected element found in SOAP body");
> +        }
> +    }
> +
> +    /**
> +     * If a source element for transformation is not found, default to
> soap body
> +     * @throws Exception
> +     */
> +    public void testTransformXSLTDefaultSource() throws Exception {
> +
> +        // create a new switch mediator
> +        transformMediator = new TransformMediator();
> +
> +        // set XSLT transformation URL
> +        transformMediator.setXsltUrl(
> +            new URL("file:///" + new File(".").getAbsolutePath() +
> "/test-resources/misc/transform.xslt"));
> +
> +        // invoke transformation, with static enveope
> +        SynapseContext synCtx = TestUtils.getTestContext(SOURCE);
> +        transformMediator.mediate(synCtx);
> +
> +        // validate result
> +        OMContainer body = synCtx.getSynapseMessage
> ().getEnvelope().getBody();
> +        if (body.getFirstOMChild() instanceof OMElement) {
> +
> +            OMElement getQuoteElem = (OMElement) body.getFirstOMChild();
> +            assertTrue("GetQuote".equals(getQuoteElem.getLocalName()));
> +            assertTrue("http://www.webserviceX.NET/".equals(
> getQuoteElem.getNamespace().getName()));
> +
> +            OMElement symbolElem = getQuoteElem.getFirstElement();
> +            assertTrue("symbol".equals(symbolElem.getLocalName()));
> +            assertTrue("http://www.webserviceX.NET/".equals(
> symbolElem.getNamespace().getName()));
> +
> +            assertTrue("String".equals(symbolElem.getText()));
> +        } else {
> +            fail("Unexpected element found in SOAP body");
> +        }
> +    }
> +
> +    public void testTransformXSLTCustomSourceNonMainElement() throws
> Exception {
> +
> +        // create a new switch mediator
> +        transformMediator = new TransformMediator();
> +
> +        // set xpath condition to select source
> +        AXIOMXPath xpath = new AXIOMXPath("//m0:CheckPriceRequest");
> +        xpath.addNamespace("m0", "http://www.apache-synapse.org/test");
> +        transformMediator.setSource(xpath);
> +
> +        // set XSLT transformation URL
> +        transformMediator.setXsltUrl(
> +            new URL("file:///" + new File(".").getAbsolutePath() +
> "/test-resources/misc/transform.xslt"));
> +
> +        // invoke transformation, with static enveope
> +        SynapseContext synCtx = TestUtils.getTestContext
> (ENCLOSING_SOURCE);
> +        transformMediator.mediate(synCtx);
> +
> +        // validate result
> +        OMContainer body = synCtx.getSynapseMessage
> ().getEnvelope().getBody();
> +        if (body.getFirstOMChild() instanceof OMElement) {
> +
> +            OMElement someOtherElem = (OMElement) body.getFirstOMChild();
> +            assertTrue("someOtherElement".equals(
> someOtherElem.getLocalName()));
> +            assertTrue("http://someother".equals(
> someOtherElem.getNamespace().getName()));
> +
> +            OMElement getQuoteElem = (OMElement)
> someOtherElem.getFirstOMChild();
> +            assertTrue("GetQuote".equals(getQuoteElem.getLocalName()));
> +            assertTrue("http://www.webserviceX.NET/".equals(
> getQuoteElem.getNamespace().getName()));
> +
> +            OMElement symbolElem = getQuoteElem.getFirstElement();
> +            assertTrue("symbol".equals(symbolElem.getLocalName()));
> +            assertTrue("http://www.webserviceX.NET/".equals(
> symbolElem.getNamespace().getName()));
> +
> +            assertTrue("String".equals(symbolElem.getText()));
> +        } else {
> +            fail("Unexpected element found in SOAP body");
> +        }
> +    }
> +
> +}
> Index: modules/core/test/org/apache/synapse/TestSynapseMessage.java
> ===================================================================
> ---
> modules/core/test/org/apache/synapse/TestSynapseMessage.java        (revision
> 405043)
> +++
> modules/core/test/org/apache/synapse/TestSynapseMessage.java        (working
> copy)
> @@ -17,6 +17,7 @@
>
> import org.apache.axiom.soap.SOAPEnvelope;
> import org.apache.axiom.soap.SOAPFactory;
> +import org.apache.axiom.soap.SOAP11Constants;
> import org.apache.axiom.om.OMAbstractFactory;
> import org.apache.axis2.AxisFault;
> import org.apache.axis2.addressing.EndpointReference;
> @@ -115,7 +116,7 @@
>      }
>
>      public boolean isSOAP11() {
> -        return false;
> +        return envelope.getNamespace().getName().equals(
> SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
>      }
>
>      public void setResponse(boolean b) {
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: synapse-dev-help@ws.apache.org
>
>