Author: ruwan
Date: Tue Oct 2 21:36:20 2007
New Revision: 581490
URL: http://svn.apache.org/viewvc?rev=581490&view=rev
Log:
Finalized the clone and iterate mediators (adding tests)
Added:
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/CloneMediatorSerializationTest.java
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/IterateMediatorSerializationTest.java
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/eip/AbstractSplitMediatorTestCase.java
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/eip/CloneMediatorTest.java
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/eip/IterateMediatorTest.java
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/eip/SplitTestHelperMediator.java
Modified:
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/IterateMediatorSerializer.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/SequenceMediatorFactory.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/eip/Target.java
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/TestMessageContext.java
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/TestUtils.java
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/ext/ClassMediatorTest.java
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/ext/POJOCommandMediatorTest.java
Modified:
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/IterateMediatorSerializer.java
URL:
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/IterateMediatorSerializer.java?rev=581490&r1=581489&r2=581490&view=diff
==============================================================================
---
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/IterateMediatorSerializer.java
(original)
+++
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/IterateMediatorSerializer.java
Tue Oct 2 21:36:20 2007
@@ -66,6 +66,15 @@
itrElem.addAttribute("continueParent", Boolean.toString(true),
nullNS);
}
+ if (itrMed.isPreservePayload()) {
+ itrElem.addAttribute("preservePayload", Boolean.toString(true),
nullNS);
+ }
+
+ if (itrMed.getAttachPath() != null &&
!".".equals(itrMed.getAttachPath().toString())) {
+ itrElem.addAttribute("attachPath",
itrMed.getAttachPath().toString(), nullNS);
+ serializeNamespaces(itrElem, itrMed.getAttachPath());
+ }
+
if (itrMed.getExpression() != null) {
itrElem.addAttribute("expression",
itrMed.getExpression().toString(), nullNS);
serializeNamespaces(itrElem, itrMed.getExpression());
Modified:
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/SequenceMediatorFactory.java
URL:
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/SequenceMediatorFactory.java?rev=581490&r1=581489&r2=581490&view=diff
==============================================================================
---
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/SequenceMediatorFactory.java
(original)
+++
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/SequenceMediatorFactory.java
Tue Oct 2 21:36:20 2007
@@ -30,7 +30,8 @@
import javax.xml.namespace.QName;
/**
- * Builds an instance of a Sequence mediator through the Synapse
configuration. It follows the following
+ * Builds an instance of a Sequence mediator through the Synapse configuration.
+ * It follows the following configuration;
*
* <pre>
* <sequence name="string" [onError="string"]>
@@ -46,7 +47,8 @@
*/
public class SequenceMediatorFactory extends AbstractListMediatorFactory {
- private static final QName SEQUENCE_Q = new
QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "sequence");
+ private static final QName SEQUENCE_Q
+ = new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "sequence");
public QName getTagQName() {
return SEQUENCE_Q;
@@ -65,9 +67,11 @@
String statisticsValue = statistics.getAttributeValue();
if (statisticsValue != null) {
if
(XMLConfigConstants.STATISTICS_ENABLE.equals(statisticsValue)) {
-
seqMediator.setStatisticsState(org.apache.synapse.SynapseConstants.STATISTICS_ON);
+ seqMediator.setStatisticsState(
+ org.apache.synapse.SynapseConstants.STATISTICS_ON);
} else if
(XMLConfigConstants.STATISTICS_DISABLE.equals(statisticsValue)) {
-
seqMediator.setStatisticsState(org.apache.synapse.SynapseConstants.STATISTICS_OFF);
+ seqMediator.setStatisticsState(
+ org.apache.synapse.SynapseConstants.STATISTICS_OFF);
}
}
}
@@ -93,13 +97,14 @@
if (n != null) {
seqMediator.setKey(n.getAttributeValue());
if (e != null) {
- String msg = "A sequence mediator swhich a reference to
another sequence can not have 'ErrorHandler'";
+ String msg = "A sequence mediator with a reference to
another " +
+ "sequence can not have 'ErrorHandler'";
log.error(msg);
throw new SynapseException(msg);
}
} else {
- String msg = "A sequence mediator should be a named sequence
or a reference to another sequence " +
- "(i.e. a name attribute or key attribute is required.";
+ String msg = "A sequence mediator should be a named sequence
or a reference " +
+ "to another sequence (i.e. a name attribute or key
attribute is required)";
log.error(msg);
throw new SynapseException(msg);
}
@@ -110,9 +115,11 @@
String statisticsValue = statistics.getAttributeValue();
if (statisticsValue != null) {
if
(XMLConfigConstants.STATISTICS_ENABLE.equals(statisticsValue)) {
-
seqMediator.setStatisticsState(org.apache.synapse.SynapseConstants.STATISTICS_ON);
+ seqMediator.setStatisticsState(
+ org.apache.synapse.SynapseConstants.STATISTICS_ON);
} else if
(XMLConfigConstants.STATISTICS_DISABLE.equals(statisticsValue)) {
-
seqMediator.setStatisticsState(org.apache.synapse.SynapseConstants.STATISTICS_OFF);
+ seqMediator.setStatisticsState(
+ org.apache.synapse.SynapseConstants.STATISTICS_OFF);
}
}
}
Modified:
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/eip/Target.java
URL:
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/eip/Target.java?rev=581490&r1=581489&r2=581490&view=diff
==============================================================================
---
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/eip/Target.java
(original)
+++
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/eip/Target.java
Tue Oct 2 21:36:20 2007
@@ -23,6 +23,7 @@
import org.apache.synapse.MessageContext;
import org.apache.synapse.endpoints.Endpoint;
import org.apache.synapse.mediators.base.SequenceMediator;
+import org.apache.axis2.addressing.EndpointReference;
/**
* This class will be a bean which carries the target information for most of
the EIP mediators
@@ -67,6 +68,18 @@
* @return boolean true if the sequence does not drop the message, false
if it does
*/
public boolean mediate(MessageContext synCtx) {
+
+ if (soapAction != null) {
+ synCtx.setSoapAction(soapAction);
+ }
+
+ if (to != null) {
+ if (synCtx.getTo() != null) {
+ synCtx.getTo().setAddress(to);
+ } else {
+ synCtx.setTo(new EndpointReference(to));
+ }
+ }
if (sequence != null) {
return sequence.mediate(synCtx);
Modified:
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/TestMessageContext.java
URL:
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/TestMessageContext.java?rev=581490&r1=581489&r2=581490&view=diff
==============================================================================
---
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/TestMessageContext.java
(original)
+++
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/TestMessageContext.java
Tue Oct 2 21:36:20 2007
@@ -46,9 +46,13 @@
private SynapseConfiguration synCfg = null;
+ private SynapseEnvironment synEnv = null;
+
SOAPEnvelope envelope = null;
private EndpointReference to = null;
+
+ private String soapAction = null;
public SynapseConfiguration getConfiguration() {
return synCfg;
@@ -59,10 +63,11 @@
}
public SynapseEnvironment getEnvironment() {
- return null;
+ return synEnv;
}
public void setEnvironment(SynapseEnvironment se) {
+ synEnv = se;
}
public Object getProperty(String key) {
@@ -195,10 +200,11 @@
}
public String getSoapAction() {
- return null;
+ return soapAction;
}
public void setSoapAction(String string) {
+ soapAction = string;
}
public void setWSAMessageID(String messageID) {
Added:
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/CloneMediatorSerializationTest.java
URL:
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/CloneMediatorSerializationTest.java?rev=581490&view=auto
==============================================================================
---
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/CloneMediatorSerializationTest.java
(added)
+++
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/CloneMediatorSerializationTest.java
Tue Oct 2 21:36:20 2007
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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;
+
+/**
+ * Factory and Serializer tests for the CloneMediator
+ */
+public class CloneMediatorSerializationTest extends AbstractTestCase {
+
+ CloneMediatorFactory cloneMediatorFactory;
+ CloneMediatorSerializer cloneMediatorSerializer;
+
+ public CloneMediatorSerializationTest() {
+ super(CloneMediatorSerializationTest.class.getName());
+ cloneMediatorFactory = new CloneMediatorFactory();
+ cloneMediatorSerializer = new CloneMediatorSerializer();
+ }
+
+ public void testCloneMediatorSerializationSenarioOne() throws Exception {
+ String inputXml = "<clone xmlns=\"http://ws.apache.org/ns/synapse\" " +
+ "continueParent=\"true\"><target sequence=\"sequenceRef1\" " +
+ "endpoint=\"endpointRef1\"/><target sequence=\"sequenceRef2\" " +
+ "endpoint=\"endpointRef2\"/></clone> ";
+ assertTrue(serialization(inputXml, cloneMediatorFactory,
cloneMediatorSerializer));
+ assertTrue(serialization(inputXml, cloneMediatorSerializer));
+ }
+
+ public void testCloneMediatorSerializationScenarioTwo() throws Exception {
+ String inputXml = "<clone xmlns=\"http://ws.apache.org/ns/synapse\">" +
+ "<target
endpoint=\"endpointRef1\"><sequence><log/></sequence></target>" +
+ "<target sequence=\"sequenceRef2\"><endpoint><address
uri=\"http://testURL\"/>" +
+ "</endpoint></target></clone> ";
+ assertTrue(serialization(inputXml, cloneMediatorFactory,
cloneMediatorSerializer));
+ assertTrue(serialization(inputXml, cloneMediatorSerializer));
+ }
+
+ public void testCloneMediatorSerializationScenarioThree() throws Exception
{
+ String inputXml = "<clone xmlns=\"http://ws.apache.org/ns/synapse\">" +
+ "<target><sequence><send/></sequence><endpoint><address
uri=\"http://testURL2\"/>" +
+ "</endpoint></target><target sequence=\"sequenceRef2\" " +
+ "endpoint=\"endpointRef2\"/></clone> ";
+ assertTrue(serialization(inputXml, cloneMediatorFactory,
cloneMediatorSerializer));
+ assertTrue(serialization(inputXml, cloneMediatorSerializer));
+ }
+
+ public void testCloneMediatorSerializationScenarioFour() throws Exception {
+ String inputXml = "<clone xmlns=\"http://ws.apache.org/ns/synapse\" " +
+ "continueParent=\"true\"><target
to=\"http://localhost:7777\"><sequence><send/>" +
+ "</sequence><endpoint><address
uri=\"http://testURL2\"/></endpoint></target>" +
+ "<target soapAction=\"urn:test\" sequence=\"sequenceRef2\" " +
+ "endpoint=\"endpointRef2\"/></clone> ";
+ assertTrue(serialization(inputXml, cloneMediatorFactory,
cloneMediatorSerializer));
+ assertTrue(serialization(inputXml, cloneMediatorSerializer));
+ }
+}
Added:
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/IterateMediatorSerializationTest.java
URL:
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/IterateMediatorSerializationTest.java?rev=581490&view=auto
==============================================================================
---
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/IterateMediatorSerializationTest.java
(added)
+++
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/IterateMediatorSerializationTest.java
Tue Oct 2 21:36:20 2007
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.SynapseException;
+
+/**
+ * Factory and Serializer tests for the IterateMediator
+ */
+public class IterateMediatorSerializationTest extends AbstractTestCase {
+
+ IterateMediatorFactory iterateMediatorFactory;
+ IterateMediatorSerializer iterateMediatorSerializer;
+
+ public IterateMediatorSerializationTest() {
+ super(IterateMediatorSerializationTest.class.getName());
+ iterateMediatorFactory = new IterateMediatorFactory();
+ iterateMediatorSerializer = new IterateMediatorSerializer();
+ }
+
+ public void testIterateMediatorSerializationSenarioOne() throws Exception {
+ String inputXml = "<iterate xmlns=\"http://ws.apache.org/ns/synapse\"
" +
+ "continueParent=\"true\" preservePayload=\"true\" expression=\".\"
" +
+ "attachPath=\"get-property('to')\"><target
sequence=\"sequenceRef1\" " +
+ "endpoint=\"endpointRef1\"/>" + "</iterate>";
+ assertTrue(serialization(inputXml, iterateMediatorFactory,
iterateMediatorSerializer));
+ assertTrue(serialization(inputXml, iterateMediatorSerializer));
+ }
+
+ public void testIterateMediatorSerializationScenarioTwo() throws Exception
{
+ String inputXml = "<iterate xmlns=\"http://ws.apache.org/ns/synapse\"
expression=\".\">" +
+ "<target
endpoint=\"endpointRef1\"><sequence><log/></sequence></target>" + "</iterate>";
+ assertTrue(serialization(inputXml, iterateMediatorFactory,
iterateMediatorSerializer));
+ assertTrue(serialization(inputXml, iterateMediatorSerializer));
+ }
+
+ public void testIterateMediatorSerializationScenarioThree() throws
Exception {
+ String inputXml = "<iterate xmlns=\"http://ws.apache.org/ns/synapse\"
expression=\".\">" +
+ "<target><sequence><send/></sequence><endpoint><address
uri=\"http://testURL2\"/>" +
+ "</endpoint></target></iterate>";
+ assertTrue(serialization(inputXml, iterateMediatorFactory,
iterateMediatorSerializer));
+ assertTrue(serialization(inputXml, iterateMediatorSerializer));
+ }
+
+ public void testIterateMediatorSerializationScenarioFour() throws
Exception {
+ String inputXml = "<iterate xmlns=\"http://ws.apache.org/ns/synapse\"
expression=\".\">" +
+ "<target soapAction=\"urn:test\"
to=\"http://localhost:7777\"><sequence><send/>" +
+ "</sequence><endpoint><address
uri=\"http://testURL2\"/></endpoint></target>" +
+ "</iterate>";
+ assertTrue(serialization(inputXml, iterateMediatorFactory,
iterateMediatorSerializer));
+ assertTrue(serialization(inputXml, iterateMediatorSerializer));
+ }
+
+ public void testIterateMediatorSerializationScenarioFive() throws
Exception {
+ String inputXml = "<iterate xmlns=\"http://ws.apache.org/ns/synapse\"
expression=\".\" " +
+ "attachPath=\".\" preservePayload=\"false\"><target
to=\"http://localhost:7777\">" +
+ "<sequence><send/></sequence><endpoint><address
uri=\"http://testURL2\"/></endpoint>" +
+ "</target></iterate>";
+ try {
+ serialization(inputXml, iterateMediatorFactory,
iterateMediatorSerializer);
+ serialization(inputXml, iterateMediatorSerializer);
+ } catch (SynapseException syne) {
+ assertTrue(true);
+ }
+ }
+
+ public void testIterateMediatorSerializationScenarioSix() throws Exception
{
+ String inputXml =
+ "<clone xmlns=\"http://ws.apache.org/ns/synapse\" expression=\".\"
attachPath=\".\">" +
+ "<target
to=\"http://localhost:7777\"><sequence><send/></sequence><endpoint>" +
+ "<address uri=\"http://testURL2\"/></endpoint></target><target
soapAction=" +
+ "\"urn:test\" sequence=\"sequenceRef2\"
endpoint=\"endpointRef2\"/></clone> ";
+ try {
+ serialization(inputXml, iterateMediatorFactory,
iterateMediatorSerializer);
+ serialization(inputXml, iterateMediatorSerializer);
+ } catch (SynapseException syne) {
+ assertTrue(true);
+ }
+ }
+
+}
Modified:
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/TestUtils.java
URL:
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/TestUtils.java?rev=581490&r1=581489&r2=581490&view=diff
==============================================================================
---
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/TestUtils.java
(original)
+++
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/TestUtils.java
Tue Oct 2 21:36:20 2007
@@ -40,6 +40,8 @@
import org.apache.synapse.core.axis2.Axis2MessageContext;
import org.apache.synapse.core.axis2.Axis2SynapseEnvironment;
import org.apache.synapse.registry.url.SimpleURLRegistry;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.engine.AxisConfiguration;
public class TestUtils {
@@ -58,6 +60,8 @@
}
}
synCtx.setConfiguration(testConfig);
+ synCtx.setEnvironment(new Axis2SynapseEnvironment(
+ new ConfigurationContext(new AxisConfiguration()), testConfig));
SOAPEnvelope envelope =
OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
OMDocument omDoc =
OMAbstractFactory.getSOAP11Factory().createOMDocument();
Added:
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/eip/AbstractSplitMediatorTestCase.java
URL:
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/eip/AbstractSplitMediatorTestCase.java?rev=581490&view=auto
==============================================================================
---
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/eip/AbstractSplitMediatorTestCase.java
(added)
+++
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/eip/AbstractSplitMediatorTestCase.java
Tue Oct 2 21:36:20 2007
@@ -0,0 +1,50 @@
+package org.apache.synapse.mediators.eip;
+
+import org.apache.synapse.mediators.AbstractMediatorTestCase;
+import org.apache.synapse.mediators.base.SequenceMediator;
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.core.axis2.Axis2MessageContext;
+import org.apache.synapse.core.axis2.Axis2SynapseEnvironment;
+import org.apache.synapse.config.SynapseConfiguration;
+import org.apache.synapse.config.xml.CloneMediatorFactory;
+import org.apache.synapse.config.xml.MediatorFactory;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.om.OMAbstractFactory;
+
+/**
+ * Preperation of the split mediator test cases
+ */
+public class AbstractSplitMediatorTestCase extends AbstractMediatorTestCase {
+
+ SplitTestHelperMediator helperMediator;
+ MessageContext testCtx;
+ MediatorFactory fac;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ SynapseConfiguration synCfg = new SynapseConfiguration();
+ AxisConfiguration config = new AxisConfiguration();
+ testCtx = new Axis2MessageContext(new
org.apache.axis2.context.MessageContext(),
+ synCfg, new Axis2SynapseEnvironment(new
ConfigurationContext(config), synCfg));
+ SOAPEnvelope envelope =
OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
+
envelope.getBody().addChild(createOMElement("<original>test-split-context</original>"));
+ testCtx.setEnvelope(envelope);
+ testCtx.setSoapAction("urn:test");
+ SequenceMediator seqMed = new SequenceMediator();
+ helperMediator = new SplitTestHelperMediator();
+ helperMediator.init(testCtx.getEnvironment());
+ seqMed.addChild(helperMediator);
+ testCtx.getConfiguration().addSequence("seqRef", seqMed);
+ testCtx.getConfiguration().addSequence("main", new SequenceMediator());
+ testCtx.getConfiguration().addSequence("fault", new
SequenceMediator());
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ helperMediator.destroy();
+ helperMediator = null;
+ testCtx = null;
+ }
+}
Added:
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/eip/CloneMediatorTest.java
URL:
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/eip/CloneMediatorTest.java?rev=581490&view=auto
==============================================================================
---
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/eip/CloneMediatorTest.java
(added)
+++
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/eip/CloneMediatorTest.java
Tue Oct 2 21:36:20 2007
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.eip;
+
+import org.apache.synapse.Mediator;
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.config.xml.CloneMediatorFactory;
+
+/**
+ *
+ */
+public class CloneMediatorTest extends AbstractSplitMediatorTestCase {
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ fac = new CloneMediatorFactory();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ fac = null;
+ }
+
+ public void testClonningScenarioOne() throws Exception {
+ Mediator clone = fac.createMediator(createOMElement("<clone " +
+ "xmlns=\"http://ws.apache.org/ns/synapse\"><target
soapAction=\"urn:clone\" " +
+ "sequence=\"seqRef\"/><target
to=\"http://test\"><sequence><sequence " +
+ "key=\"seqRef\"/></sequence></target></clone>"));
+ clone.mediate(testCtx);
+ MessageContext mediatedCtx = helperMediator.getMediatedContext(0);
+ assertEquals(mediatedCtx.getSoapAction(), "urn:clone");
+ mediatedCtx = helperMediator.getMediatedContext(1);
+ assertEquals(mediatedCtx.getSoapAction(), "urn:test");
+ assertEquals(mediatedCtx.getTo().getAddress(), "http://test");
+ }
+
+ public void testClonningWithContinueParent() throws Exception {
+ Mediator clone = fac.createMediator(createOMElement("<clone
continueParent=\"true\" " +
+ "xmlns=\"http://ws.apache.org/ns/synapse\"><target
soapAction=\"urn:clone\" " +
+ "sequence=\"seqRef\"/><target
to=\"http://test\"><sequence><sequence " +
+ "key=\"seqRef\"/></sequence></target></clone>"));
+ assertTrue(clone.mediate(testCtx));
+ MessageContext mediatedCtx = helperMediator.getMediatedContext(0);
+ assertTrue(mediatedCtx.getEnvelope().getBody().getFirstElement() ==
null);
+ assertEquals(mediatedCtx.getSoapAction(), "urn:clone");
+ mediatedCtx = helperMediator.getMediatedContext(1);
+ assertEquals(mediatedCtx.getSoapAction(), "urn:test");
+ assertEquals(mediatedCtx.getTo().getAddress(), "http://test");
+ assertEquals(testCtx.getSoapAction(), "urn:test");
+ assertTrue(testCtx.getEnvelope().getBody().getFirstElement() != null);
+ assertEquals(testCtx.getTo(), null);
+ }
+}
Added:
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/eip/IterateMediatorTest.java
URL:
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/eip/IterateMediatorTest.java?rev=581490&view=auto
==============================================================================
---
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/eip/IterateMediatorTest.java
(added)
+++
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/eip/IterateMediatorTest.java
Tue Oct 2 21:36:20 2007
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.eip;
+
+import org.apache.synapse.config.xml.IterateMediatorFactory;
+import org.apache.synapse.Mediator;
+import org.apache.synapse.MessageContext;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.om.OMAbstractFactory;
+
+/**
+ *
+ */
+public class IterateMediatorTest extends AbstractSplitMediatorTestCase {
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ SOAPEnvelope envelope =
OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
+ envelope.getBody().addChild(createOMElement("<original>" +
+ "<itr>test-split-context-itr1-body</itr>" +
+ "<itr>test-split-context-itr2-body</itr>" +
+ "</original>"));
+ testCtx.setEnvelope(envelope);
+ fac = new IterateMediatorFactory();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ fac = null;
+ }
+
+ public void testIterationScenarioOne() throws Exception {
+ Mediator iterate = fac.createMediator(createOMElement("<iterate " +
+ "expression=\"//original/itr\"
xmlns=\"http://ws.apache.org/ns/synapse\">" +
+ "<target soapAction=\"urn:iterate\"
sequence=\"seqRef\"/></iterate>"));
+ iterate.mediate(testCtx);
+ MessageContext mediatedCtx = helperMediator.getMediatedContext(0);
+ assertEquals(mediatedCtx.getSoapAction(), "urn:iterate");
+ mediatedCtx = helperMediator.getMediatedContext(1);
+ assertEquals(mediatedCtx.getSoapAction(), "urn:iterate");
+ assertEquals(mediatedCtx.getEnvelope()
+ .getBody().getFirstElement().getText(),
"test-split-context-itr2-body");
+ }
+
+ public void testIterationWithPreservePayload() throws Exception {
+ Mediator iterate = fac.createMediator(createOMElement("<iterate " +
+ "expression=\"//original/itr\" preservePayload=\"true\"
attachPath=\"//original\" " +
+ "xmlns=\"http://ws.apache.org/ns/synapse\"><target
soapAction=\"urn:iterate\" " +
+ "sequence=\"seqRef\"/></iterate>"));
+ iterate.mediate(testCtx);
+ MessageContext mediatedCtx = helperMediator.getMediatedContext(0);
+ assertEquals(mediatedCtx.getSoapAction(), "urn:iterate");
+ mediatedCtx = helperMediator.getMediatedContext(1);
+ assertEquals(mediatedCtx.getSoapAction(), "urn:iterate");
+ assertEquals(mediatedCtx.getEnvelope().getBody()
+ .getFirstElement().getFirstElement().getText(),
"test-split-context-itr2-body");
+ }
+}
Added:
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/eip/SplitTestHelperMediator.java
URL:
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/eip/SplitTestHelperMediator.java?rev=581490&view=auto
==============================================================================
---
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/eip/SplitTestHelperMediator.java
(added)
+++
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/eip/SplitTestHelperMediator.java
Tue Oct 2 21:36:20 2007
@@ -0,0 +1,56 @@
+package org.apache.synapse.mediators.eip;
+
+import org.apache.synapse.mediators.AbstractMediator;
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.ManagedLifecycle;
+import org.apache.synapse.core.SynapseEnvironment;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axis2.AxisFault;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * Created by IntelliJ IDEA. User: ruwan Date: Oct 3, 2007 Time: 7:26:09 AM To
change this template
+ * use File | Settings | File Templates.
+ */
+public class SplitTestHelperMediator extends AbstractMediator implements
ManagedLifecycle {
+
+ private List mediatedContext = new ArrayList();
+ int msgcount;
+
+ public boolean mediate(MessageContext synCtx) {
+ if (msgcount == 0) {
+ SOAPEnvelope envelope =
OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
+ try {
+ synCtx.setEnvelope(envelope);
+ } catch (AxisFault ignore) {
+ }
+ }
+ mediatedContext.add(synCtx);
+ msgcount++;
+ return false;
+ }
+
+ public MessageContext getMediatedContext(int position) {
+ if (mediatedContext.size() > position) {
+ return (MessageContext) mediatedContext.get(position);
+ } else {
+ return null;
+ }
+ }
+
+ public void clearMediatedContexts() {
+ mediatedContext.clear();
+ }
+
+ public void init(SynapseEnvironment se) {
+ msgcount = 0;
+ }
+
+ public void destroy() {
+ clearMediatedContexts();
+ msgcount = 0;
+ }
+}
Modified:
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/ext/ClassMediatorTest.java
URL:
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/ext/ClassMediatorTest.java?rev=581490&r1=581489&r2=581490&view=diff
==============================================================================
---
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/ext/ClassMediatorTest.java
(original)
+++
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/ext/ClassMediatorTest.java
Tue Oct 2 21:36:20 2007
@@ -22,6 +22,7 @@
import org.apache.synapse.ManagedLifecycle;
import org.apache.synapse.Mediator;
import org.apache.synapse.TestMessageContext;
+import org.apache.synapse.mediators.AbstractMediatorTestCase;
import org.apache.synapse.config.xml.AbstractTestCase;
import org.apache.synapse.config.xml.MediatorFactoryFinder;
import org.apache.synapse.core.axis2.Axis2SynapseEnvironment;
@@ -30,9 +31,9 @@
* Tests the class mediator instantiation and setting of literal and
* XPath parameters at runtime.
*/
-public class ClassMediatorTest extends AbstractTestCase {
+public class ClassMediatorTest extends AbstractMediatorTestCase {
- public void testCreationWithoutProperties() throws Exception {
+ public void testMediationWithoutProperties() throws Exception {
Mediator cm =
MediatorFactoryFinder.getInstance().getMediator(createOMElement(
"<class
name='org.apache.synapse.mediators.ext.ClassMediatorTestMediator' " +
"xmlns='http://ws.apache.org/ns/synapse'/>"));
@@ -40,7 +41,7 @@
assertTrue(ClassMediatorTestMediator.invoked);
}
- public void testCreationWithLiteralProperties() throws Exception {
+ public void testMediationWithLiteralProperties() throws Exception {
Mediator cm =
MediatorFactoryFinder.getInstance().getMediator(createOMElement(
"<class
name='org.apache.synapse.mediators.ext.ClassMediatorTestMediator' " +
"xmlns='http://ws.apache.org/ns/synapse'><property
name='testProp' value='testValue'/></class>"));
@@ -49,7 +50,7 @@
assertTrue(ClassMediatorTestMediator.testProp.equals("testValue"));
}
- public void testInitialization() throws Exception {
+ public void testInitializationAndMedition() throws Exception {
Mediator cm =
MediatorFactoryFinder.getInstance().getMediator(createOMElement(
"<class
name='org.apache.synapse.mediators.ext.ClassMediatorTestMediator' " +
"xmlns='http://ws.apache.org/ns/synapse'/>"));
Modified:
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/ext/POJOCommandMediatorTest.java
URL:
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/ext/POJOCommandMediatorTest.java?rev=581490&r1=581489&r2=581490&view=diff
==============================================================================
---
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/ext/POJOCommandMediatorTest.java
(original)
+++
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/ext/POJOCommandMediatorTest.java
Tue Oct 2 21:36:20 2007
@@ -19,16 +19,16 @@
package org.apache.synapse.mediators.ext;
-import org.apache.synapse.config.xml.AbstractTestCase;
import org.apache.synapse.config.xml.MediatorFactoryFinder;
import org.apache.synapse.Mediator;
import org.apache.synapse.TestMessageContext;
+import org.apache.synapse.mediators.AbstractMediatorTestCase;
/**
* Tests the pojo command mediator instantiation and setting of literal and
* XPath parameters at runtime.
*/
-public class POJOCommandMediatorTest extends AbstractTestCase {
+public class POJOCommandMediatorTest extends AbstractMediatorTestCase {
public void testPojoWithoutPropertiesNotCommandImpl() throws Exception {
Mediator pcm =
MediatorFactoryFinder.getInstance().getMediator(createOMElement(
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]