Author: asankha
Date: Wed Dec 13 23:02:24 2006
New Revision: 487029

URL: http://svn.apache.org/viewvc?view=rev&rev=487029
Log:
Commit for Indika - includes unit tests for mediator factories and serializers
http://issues.apache.org/jira/browse/SYNAPSE-40

Added:
    
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/
    
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/
    
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/AbstractTestCase.java
    
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/ClassMediatorSerializationTest.java
    
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/DropMediatorSerializationTest.java
    
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/FaultMediatorSerializationTest.java
    
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/FilterMediatorSerializationTest.java
    
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/HeaderMediatorSerializationTest.java
    
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/InMediatorSerializationTest.java
    
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/LogMediatorSerializationTest.java
    
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/OutMediatorSerializationTest.java
    
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/SequenceMediatorSerializationTest.java
    
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/TestMediator.java

Added: 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/AbstractTestCase.java
URL: 
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/AbstractTestCase.java?view=auto&rev=487029
==============================================================================
--- 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/AbstractTestCase.java
 (added)
+++ 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/AbstractTestCase.java
 Wed Dec 13 23:02:24 2006
@@ -0,0 +1,85 @@
+/*
+* 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 junit.framework.TestCase;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.impl.exception.XMLComparisonException;
+import org.apache.axiom.om.impl.llom.util.XMLComparator;
+import org.apache.synapse.Mediator;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import java.io.StringReader;
+
+/**
+ *
+ *
+ */
+
+public abstract class AbstractTestCase extends TestCase {
+
+    XMLComparator comparator = null;
+
+    public AbstractTestCase(String name) {
+        super(name);
+    }
+
+    public AbstractTestCase() {
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        comparator = new XMLComparator();
+    }
+
+    protected OMElement createOMElement(String xml) {
+        try {
+
+            XMLStreamReader reader = 
XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(xml));
+            StAXOMBuilder builder = new StAXOMBuilder(reader);
+            OMElement omElement = builder.getDocumentElement();
+            return omElement;
+
+        }
+        catch (XMLStreamException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    protected boolean serialization(String inputXml, MediatorFactory 
mediatorFactory, MediatorSerializer mediatorSerializer) throws 
XMLComparisonException {
+
+        OMElement inputOM = createOMElement(inputXml);
+        Mediator mediator = mediatorFactory.createMediator(inputOM);
+        OMElement resultOM = mediatorSerializer.serializeMediator(null, 
mediator);
+        return comparator.compare(resultOM, inputOM);
+    }
+
+    protected boolean serialization(String inputXml, MediatorSerializer 
mediatorSerializer) throws XMLComparisonException {
+        OMElement inputOM = createOMElement(inputXml);
+        Mediator mediator = 
MediatorFactoryFinder.getInstance().getMediator(inputOM);
+        OMElement resultOM = mediatorSerializer.serializeMediator(null, 
mediator);
+        return comparator.compare(resultOM, inputOM);
+    }
+
+    protected OMElement getParent() {
+        String parentXML = "<synapse 
xmlns=\"http://ws.apache.org/ns/synapse\";><definitions></definitions></synapse>";
+        return createOMElement(parentXML);
+    }
+}

Added: 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/ClassMediatorSerializationTest.java
URL: 
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/ClassMediatorSerializationTest.java?view=auto&rev=487029
==============================================================================
--- 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/ClassMediatorSerializationTest.java
 (added)
+++ 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/ClassMediatorSerializationTest.java
 Wed Dec 13 23:02:24 2006
@@ -0,0 +1,41 @@
+/*
+* 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;
+
+/**
+ * 
+ *
+ */
+
+public class ClassMediatorSerializationTest extends AbstractTestCase {
+
+    ClassMediatorFactory classMediatorFactory;
+    ClassMediatorSerializer classMediatorSerializer;
+
+    public ClassMediatorSerializationTest() {
+        super(ClassMediatorSerializationTest.class.getName());
+        classMediatorFactory = new ClassMediatorFactory();
+        classMediatorSerializer = new ClassMediatorSerializer();
+    }
+
+    public void testClassMediatorSerializationSenarioOne() throws Exception {
+        String inputXml = "<class xmlns=\"http://ws.apache.org/ns/synapse\"; 
name=\"org.apache.synapse.config.xml.TestMediator\"></class> ";
+        assertTrue(serialization(inputXml, classMediatorFactory, 
classMediatorSerializer));
+        assertTrue(serialization(inputXml, classMediatorSerializer));
+    }
+
+
+}

Added: 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/DropMediatorSerializationTest.java
URL: 
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/DropMediatorSerializationTest.java?view=auto&rev=487029
==============================================================================
--- 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/DropMediatorSerializationTest.java
 (added)
+++ 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/DropMediatorSerializationTest.java
 Wed Dec 13 23:02:24 2006
@@ -0,0 +1,41 @@
+/*
+* 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;
+
+/**
+ *
+ *
+ */
+
+public class DropMediatorSerializationTest extends AbstractTestCase {
+
+    DropMediatorFactory dropMediatorFactory;
+    DropMediatorSerializer dropMediatorSerializer;
+
+    public DropMediatorSerializationTest() {
+        super(DropMediatorSerializationTest.class.getName());
+        dropMediatorFactory = new DropMediatorFactory();
+        dropMediatorSerializer = new DropMediatorSerializer();
+    }
+
+    public void testDropMediatorSerializationSenarioOne() throws Exception {
+        String inputXml = "<drop xmlns=\"http://ws.apache.org/ns/synapse\"; />";
+        assertTrue(serialization(inputXml, dropMediatorFactory, 
dropMediatorSerializer));
+        assertTrue(serialization(inputXml, dropMediatorSerializer));
+    }
+
+
+}

Added: 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/FaultMediatorSerializationTest.java
URL: 
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/FaultMediatorSerializationTest.java?view=auto&rev=487029
==============================================================================
--- 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/FaultMediatorSerializationTest.java
 (added)
+++ 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/FaultMediatorSerializationTest.java
 Wed Dec 13 23:02:24 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.config.xml;
+
+/**
+ *
+ *
+ */
+
+public class FaultMediatorSerializationTest extends AbstractTestCase {
+
+    FaultMediatorFactory faultMediatorFactory;
+    FaultMediatorSerializer faultMediatorSerializer;
+    private static final String SOAP11 = "soap11";
+    private static final String SOAP12 = "soap12";
+    private static final String EMPTY = "";
+
+    public FaultMediatorSerializationTest() {
+        super(FaultMediatorSerializationTest.class.getName());
+        faultMediatorFactory = new FaultMediatorFactory();
+        faultMediatorSerializer = new FaultMediatorSerializer();
+    }
+
+    public void testFaultMediatorSerializationSOAP11() throws Exception {
+        String inputXml = getXmlOfMediatorForSOAP11(SOAP11, "syn:Client", 
"reason", EMPTY, EMPTY);
+        assertTrue(serialization(inputXml, faultMediatorFactory, 
faultMediatorSerializer));
+        assertTrue(serialization(inputXml, faultMediatorSerializer));
+    }
+
+    public void testFaultMediatorSerializationSOAP12() throws Exception {
+        String inputXml = getXmlOfMediatorForSOAP12(SOAP12, "soap:Sender", 
"reason", EMPTY, EMPTY, EMPTY);
+        assertTrue(serialization(inputXml, faultMediatorFactory, 
faultMediatorSerializer));
+        assertTrue(serialization(inputXml, faultMediatorSerializer));
+    }
+
+    private String getXmlOfMediatorForSOAP11(String version, String 
attrOfCode, String attrOfReasion
+            , String role, String details) throws Exception {
+        return "<makefault  version=\"" + version + "\" 
xmlns=\"http://ws.apache.org/ns/synapse\";><code value=\"" + attrOfCode + "\" 
xmlns:syn=\"http://ws.apache.org/ns/synapse\"/><reason value=\"" + 
attrOfReasion + "\"/>" +
+                "<role>" + role + "</role><detail>" + details + 
"</detail></makefault>";
+
+    }
+
+    private String getXmlOfMediatorForSOAP12(String version, String 
attrOfCode, String attrOfReasion
+            , String node, String role, String details) throws Exception {
+        return "<makefault xmlns=\"http://ws.apache.org/ns/synapse\"; 
version=\"" + version + "\"><code value=\"" + attrOfCode + "\" 
xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\"/><reason value=\"" + 
attrOfReasion + "\"/>" +
+                "<node>" + node + "</node><role>" + role + "</role><detail>" + 
details + "</detail></makefault>";
+
+    }
+
+}

Added: 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/FilterMediatorSerializationTest.java
URL: 
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/FilterMediatorSerializationTest.java?view=auto&rev=487029
==============================================================================
--- 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/FilterMediatorSerializationTest.java
 (added)
+++ 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/FilterMediatorSerializationTest.java
 Wed Dec 13 23:02:24 2006
@@ -0,0 +1,46 @@
+/*
+* 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;
+
+/**
+ *
+ *
+ */
+
+public class FilterMediatorSerializationTest extends AbstractTestCase {
+
+    FilterMediatorFactory filterMediatorFactory;
+    FilterMediatorSerializer filterMediatorSerializer;
+
+    public FilterMediatorSerializationTest() {
+        super(FilterMediatorSerializationTest.class.getName());
+        filterMediatorFactory = new FilterMediatorFactory();
+        filterMediatorSerializer = new FilterMediatorSerializer();
+    }
+
+    public void testFilterMediatorSerializationSenarioOne() throws Exception {
+        String inputXml = "<filter xmlns=\"http://ws.apache.org/ns/synapse\"; 
xpath=\"//*[wsx:symbol='MSFT']\" xmlns:wsx=\"http://services.samples/xsd\"/>";
+        assertTrue(serialization(inputXml, filterMediatorFactory, 
filterMediatorSerializer));
+        assertTrue(serialization(inputXml, filterMediatorSerializer));
+    }
+
+    public void testFilterMediatorSerializationSenarioTwo() throws Exception {
+        String inputXml = "<filter xmlns=\"http://ws.apache.org/ns/synapse\"; 
source=\"get-property('To')\" regex=\".*/StockQuote.*\"></filter>";
+        assertTrue(serialization(inputXml, filterMediatorFactory, 
filterMediatorSerializer));
+        assertTrue(serialization(inputXml, filterMediatorSerializer));
+    }
+
+}

Added: 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/HeaderMediatorSerializationTest.java
URL: 
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/HeaderMediatorSerializationTest.java?view=auto&rev=487029
==============================================================================
--- 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/HeaderMediatorSerializationTest.java
 (added)
+++ 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/HeaderMediatorSerializationTest.java
 Wed Dec 13 23:02:24 2006
@@ -0,0 +1,45 @@
+/*
+* 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;
+
+/**
+ *
+ *
+ */
+
+public class HeaderMediatorSerializationTest extends AbstractTestCase {
+
+    HeaderMediatorFactory headerMediatorFactory;
+    HeaderMediatorSerializer headerMediatorSerializer;
+
+    public HeaderMediatorSerializationTest() {
+        super(AbstractTestCase.class.getName());
+        headerMediatorFactory = new HeaderMediatorFactory();
+        headerMediatorSerializer = new HeaderMediatorSerializer();
+    }
+
+    public void testHeaderMediatorSerializationSenarioOne() throws Exception {
+        String inputXml = "<header xmlns=\"http://ws.apache.org/ns/synapse\"; 
name=\"To\" value=\"http://127.0.0.1:10001/axis2/services/Services\"/>";
+        assertTrue(serialization(inputXml, headerMediatorFactory, 
headerMediatorSerializer));
+        assertTrue(serialization(inputXml, headerMediatorSerializer));
+    }
+
+    public void testHeaderMediatorSerializationSenarioTwo() throws Exception {
+        String inputXml = "<header xmlns=\"http://ws.apache.org/ns/synapse\"; 
name=\"To\" action=\"remove\"/>";
+        assertTrue(serialization(inputXml, headerMediatorFactory, 
headerMediatorSerializer));
+        assertTrue(serialization(inputXml, headerMediatorSerializer));
+    }
+}

Added: 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/InMediatorSerializationTest.java
URL: 
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/InMediatorSerializationTest.java?view=auto&rev=487029
==============================================================================
--- 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/InMediatorSerializationTest.java
 (added)
+++ 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/InMediatorSerializationTest.java
 Wed Dec 13 23:02:24 2006
@@ -0,0 +1,39 @@
+/*
+* 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;
+
+/**
+ *
+ *
+ */
+
+public class InMediatorSerializationTest extends AbstractTestCase {
+
+    InMediatorFactory inMediatorFactory;
+    InMediatorSerializer inMediatorSerializer;
+
+    public InMediatorSerializationTest() {
+        super(InMediatorSerializationTest.class.getName());
+        inMediatorFactory = new InMediatorFactory();
+        inMediatorSerializer = new InMediatorSerializer();
+    }
+
+    public void testInMediatorSerialization() throws Exception {
+        String inptXml = " <in 
xmlns=\"http://ws.apache.org/ns/synapse\";><header name=\"To\" 
value=\"http://64.124.140.30:9090/soap\"/></in>";
+        assertTrue(serialization(inptXml, inMediatorFactory, 
inMediatorSerializer));
+        assertTrue(serialization(inptXml, inMediatorSerializer));
+    }
+}

Added: 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/LogMediatorSerializationTest.java
URL: 
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/LogMediatorSerializationTest.java?view=auto&rev=487029
==============================================================================
--- 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/LogMediatorSerializationTest.java
 (added)
+++ 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/LogMediatorSerializationTest.java
 Wed Dec 13 23:02:24 2006
@@ -0,0 +1,79 @@
+/*
+* 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;
+
+/**
+ *
+ *
+ */
+
+public class LogMediatorSerializationTest extends AbstractTestCase {
+
+    LogMediatorFactory logMediatorFactory;
+    LogMediatorSerializer logMediatorSerializer;
+
+    private static final String SIMPLE = "simple";
+    private static final String HEADERS = "headers";
+    private static final String FULL = "full";
+    private static final String CUSTOM = "custom";
+
+    public LogMediatorSerializationTest() {
+        super(LogMediatorSerializationTest.class.getName());
+        logMediatorFactory = new LogMediatorFactory();
+        logMediatorSerializer = new LogMediatorSerializer();
+    }
+
+    public void testLogMediatorSerializationSenarioOne() throws Exception {
+
+        //    assertTrue(serialization(getXmlOfMediatorSenarioOne(SIMPLE), 
logMediatorFactory, logMediatorSerializer));
+        assertTrue(serialization(getXmlOfMediatorSenarioOne(HEADERS), 
logMediatorFactory, logMediatorSerializer));
+        assertTrue(serialization(getXmlOfMediatorSenarioOne(FULL), 
logMediatorFactory, logMediatorSerializer));
+        assertTrue(serialization(getXmlOfMediatorSenarioOne(CUSTOM), 
logMediatorFactory, logMediatorSerializer));
+
+//        assertTrue(serialization(getXmlOfMediatorSenarioOne(SIMPLE), 
logMediatorSerializer));
+        assertTrue(serialization(getXmlOfMediatorSenarioOne(HEADERS), 
logMediatorSerializer));
+        assertTrue(serialization(getXmlOfMediatorSenarioOne(FULL), 
logMediatorSerializer));
+        assertTrue(serialization(getXmlOfMediatorSenarioOne(CUSTOM), 
logMediatorSerializer));
+
+
+    }
+
+    public void testLogMediatorSerializationSenarioTwo() throws Exception {
+
+//        assertTrue(serialization(getXmlOfMediatorSenarioTwo(SIMPLE, ":"), 
logMediatorFactory, logMediatorSerializer));
+        assertTrue(serialization(getXmlOfMediatorSenarioTwo(HEADERS, ":"), 
logMediatorFactory, logMediatorSerializer));
+        assertTrue(serialization(getXmlOfMediatorSenarioTwo(FULL, ";"), 
logMediatorFactory, logMediatorSerializer));
+        assertTrue(serialization(getXmlOfMediatorSenarioTwo(CUSTOM, ":"), 
logMediatorFactory, logMediatorSerializer));
+
+        //       assertTrue(serialization(getXmlOfMediatorSenarioTwo(SIMPLE, 
":"), logMediatorSerializer));
+        assertTrue(serialization(getXmlOfMediatorSenarioTwo(HEADERS, ":"), 
logMediatorSerializer));
+        assertTrue(serialization(getXmlOfMediatorSenarioTwo(FULL, ";"), 
logMediatorSerializer));
+        assertTrue(serialization(getXmlOfMediatorSenarioTwo(CUSTOM, ":"), 
logMediatorSerializer));
+
+
+    }
+
+    private String getXmlOfMediatorSenarioOne(String level) {
+        return "<log xmlns=\"http://ws.apache.org/ns/synapse\"; level=\"" + 
level + "\"><property name=\"Text\" value=\"Sending quote request\"/></log>";
+
+    }
+
+    private String getXmlOfMediatorSenarioTwo(String level, String seperator) {
+        return "<log xmlns=\"http://ws.apache.org/ns/synapse\"; level=\"" + 
level + "\" separator=\"" + seperator + "\"><property name=\"Text\" 
value=\"Sending quote request\"/></log>";
+
+    }
+
+}

Added: 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/OutMediatorSerializationTest.java
URL: 
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/OutMediatorSerializationTest.java?view=auto&rev=487029
==============================================================================
--- 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/OutMediatorSerializationTest.java
 (added)
+++ 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/OutMediatorSerializationTest.java
 Wed Dec 13 23:02:24 2006
@@ -0,0 +1,39 @@
+/*
+* 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;
+
+/**
+ *
+ *
+ */
+
+public class OutMediatorSerializationTest extends AbstractTestCase {
+
+    OutMediatorFactory outMediatorFactory;
+    OutMediatorSerializer outMediatorSerializer;
+
+    public OutMediatorSerializationTest() {
+        super(OutMediatorSerializationTest.class.getName());
+        outMediatorFactory = new OutMediatorFactory();
+        outMediatorSerializer = new OutMediatorSerializer();
+    }
+
+    public void testOutMediatorSerialization() throws Exception {
+        String inptXml = " <out 
xmlns=\"http://ws.apache.org/ns/synapse\";><header name=\"To\" 
value=\"http://64.124.140.30:9090/soap\"/></out>";
+        assertTrue(serialization(inptXml, outMediatorFactory, 
outMediatorSerializer));
+        assertTrue(serialization(inptXml, outMediatorSerializer));
+    }
+}

Added: 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/SequenceMediatorSerializationTest.java
URL: 
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/SequenceMediatorSerializationTest.java?view=auto&rev=487029
==============================================================================
--- 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/SequenceMediatorSerializationTest.java
 (added)
+++ 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/SequenceMediatorSerializationTest.java
 Wed Dec 13 23:02:24 2006
@@ -0,0 +1,64 @@
+/*
+* 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;
+
+/**
+ *
+ *
+ */
+
+public class SequenceMediatorSerializationTest extends AbstractTestCase {
+
+    SequenceMediatorFactory sequenceMediatorFactory;
+    SequenceMediatorSerializer sequenceMediatorSerializer;
+
+    public SequenceMediatorSerializationTest() {
+        super(SequenceMediatorSerializationTest.class.getName());
+        sequenceMediatorFactory = new SequenceMediatorFactory();
+        sequenceMediatorSerializer = new SequenceMediatorSerializer();
+    }
+
+    public void testSequenceMediatorSerializationSenarioOne() throws Exception 
{
+        String xml = "<sequence xmlns=\"http://ws.apache.org/ns/synapse\"; 
name=\"namedsequence\"><header name=\"To\" 
value=\"http://localhost:9000/axis2/services/TestService\"/><send/></sequence>";
+        assertTrue(serialization(xml, sequenceMediatorFactory, 
sequenceMediatorSerializer));
+        assertTrue(serialization(xml, sequenceMediatorSerializer));
+    }
+
+    public void testSequenceMediatorSerializationSenarioTwo() throws Exception 
{
+        String xml = "<sequence xmlns=\"http://ws.apache.org/ns/synapse\"; 
name=\"namedsequence\"  onError=\"ErrorHandler\"><header name=\"To\" 
value=\"http://localhost:9000/axis2/services/TestService\"/><send/></sequence>";
+        assertTrue(serialization(xml, sequenceMediatorFactory, 
sequenceMediatorSerializer));
+        assertTrue(serialization(xml, sequenceMediatorSerializer));
+    }
+
+    public void testSequenceMediatorSerializationSenarioThree() throws 
Exception {
+        String xml = "<sequence xmlns=\"http://ws.apache.org/ns/synapse\"; 
ref=\"sequenceone\"></sequence>";
+        assertTrue(serialization(xml, sequenceMediatorFactory, 
sequenceMediatorSerializer));
+        assertTrue(serialization(xml, sequenceMediatorSerializer));
+    }
+
+    public void testSequenceMediatorSerializationSenarioFour() throws 
Exception {
+        String xml = "<sequence xmlns=\"http://ws.apache.org/ns/synapse\"; 
name=\"sequenceone\" onError=\"ErrorHandler\"></sequence>";
+        assertTrue(serialization(xml, sequenceMediatorFactory, 
sequenceMediatorSerializer));
+        assertTrue(serialization(xml, sequenceMediatorSerializer));
+    }
+
+    public void testSequenceMediatorSerializationSenarioFive() throws 
Exception {
+        String xml = "<sequence xmlns=\"http://ws.apache.org/ns/synapse\"; 
ref=\"sequenceone\" ></sequence>";
+        assertTrue(serialization(xml, sequenceMediatorFactory, 
sequenceMediatorSerializer));
+        assertTrue(serialization(xml, sequenceMediatorSerializer));
+    }
+}

Added: 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/TestMediator.java
URL: 
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/TestMediator.java?view=auto&rev=487029
==============================================================================
--- 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/TestMediator.java
 (added)
+++ 
incubator/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/TestMediator.java
 Wed Dec 13 23:02:24 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.config.xml;
+
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.mediators.AbstractMediator;
+
+/**
+ *
+ *
+ */
+
+public class TestMediator extends AbstractMediator {
+
+    public boolean mediate(MessageContext synCtx) {
+        return false;
+    }
+
+    public String getType() {
+        return TestMediator.class.getName();
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to