You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by sa...@apache.org on 2005/11/25 07:45:10 UTC
svn commit: r348895 - in /incubator/synapse/trunk/scratch/prototype3:
src/org/apache/synapse/axis2/ test/org/apache/synapse/spi/
test/org/apache/synapse/util/
Author: saminda
Date: Thu Nov 24 22:44:54 2005
New Revision: 348895
URL: http://svn.apache.org/viewcvs?rev=348895&view=rev
Log:
1. tested AddressingProcessor.
2. Since Axis2SOAPMessageContext has its own map to store properties,
the searching hierarchy update to search the MessageContext if prior
doesn't contain the Object
Added:
incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/AddressingProcessorTest.java
incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/util/
incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/util/Axis2EvnSetup.java
Modified:
incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/axis2/Axis2SOAPMessageContext.java
incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/BuiltInProcessorTest.java
Modified: incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/axis2/Axis2SOAPMessageContext.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/axis2/Axis2SOAPMessageContext.java?rev=348895&r1=348894&r2=348895&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/axis2/Axis2SOAPMessageContext.java (original)
+++ incubator/synapse/trunk/scratch/prototype3/src/org/apache/synapse/axis2/Axis2SOAPMessageContext.java Thu Nov 24 22:44:54 2005
@@ -113,7 +113,11 @@
}
public Object getProperty(String key) {
- return props.get(key);
+ Object obj = props.get(key);
+ if ( obj == null) {
+ obj = mc.getProperty(key);
+ }
+ return obj;
}
Added: incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/AddressingProcessorTest.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/AddressingProcessorTest.java?rev=348895&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/AddressingProcessorTest.java (added)
+++ incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/AddressingProcessorTest.java Thu Nov 24 22:44:54 2005
@@ -0,0 +1,50 @@
+package org.apache.synapse.spi;
+
+import junit.framework.TestCase;
+import org.apache.axis2.context.MessageContext;
+import org.apache.synapse.Constants;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.axis2.Axis2SOAPMessageContext;
+import org.apache.synapse.axis2.Axis2SynapseEnvironment;
+import org.apache.synapse.util.Axis2EvnSetup;
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*/
+
+public class AddressingProcessorTest extends TestCase {
+ private MessageContext msgCtx;
+ private String synapsexml =
+ "<synapse xmlns=\"http://ws.apache.org/ns/synapse\">\n" +
+ "<stage name=\"logall\">\n" +
+ " <addressing/>\n" +
+ "</stage>\n" +
+ "</synapse>";
+
+ public void setUp() throws Exception {
+ msgCtx = Axis2EvnSetup.axis2Deployment();
+ }
+
+ public void testAddressingProcessor() throws Exception {
+ SynapseEnvironment env = new Axis2SynapseEnvironment(
+ Axis2EvnSetup.getSynapseConfigElement(synapsexml),
+ Thread.currentThread().getContextClassLoader());
+ SynapseMessage smc = new Axis2SOAPMessageContext(msgCtx);
+ env.injectMessage(smc);
+ assertTrue(((Boolean) smc.getProperty(
+ Constants.MEDIATOR_RESPONSE_PROPERTY)).booleanValue());
+ }
+}
Modified: incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/BuiltInProcessorTest.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/BuiltInProcessorTest.java?rev=348895&r1=348894&r2=348895&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/BuiltInProcessorTest.java (original)
+++ incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/BuiltInProcessorTest.java Thu Nov 24 22:44:54 2005
@@ -6,6 +6,7 @@
import org.apache.axis2.om.OMFactory;
import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.util.Axis2EvnSetup;
import org.apache.synapse.axis2.Axis2SynapseEnvironment;
import javax.xml.stream.XMLInputFactory;
@@ -40,23 +41,9 @@
private SynapseEnvironment env;
public void testSynapseEnvironment() throws Exception {
-
env = new Axis2SynapseEnvironment(
- getSynapseConfigElement(),
+ Axis2EvnSetup.getSynapseConfigElement(synapsexml),
Thread.currentThread().getContextClassLoader());
-
}
-
-
- public OMElement getSynapseConfigElement() throws XMLStreamException {
- XMLStreamReader parser = XMLInputFactory.newInstance()
- .createXMLStreamReader(
- new ByteArrayInputStream(synapsexml.getBytes()));
- OMFactory fac = OMAbstractFactory.getOMFactory();
- StAXOMBuilder staxBuilder = new StAXOMBuilder(fac, parser);
- OMElement config = staxBuilder.getDocumentElement();
- return config;
-
- }
}
Added: incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/util/Axis2EvnSetup.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/util/Axis2EvnSetup.java?rev=348895&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/util/Axis2EvnSetup.java (added)
+++ incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/util/Axis2EvnSetup.java Thu Nov 24 22:44:54 2005
@@ -0,0 +1,92 @@
+package org.apache.synapse.util;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.InOutAxisOperation;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.axis2.om.OMFactory;
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.OMDocument;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.synapse.axis2.SynapseMessageReceiver;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLInputFactory;
+import java.io.File;
+import java.io.ByteArrayInputStream;
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*/
+
+public class Axis2EvnSetup {
+ public static MessageContext axis2Deployment() throws AxisFault {
+ ConfigurationContextFactory conFac = new ConfigurationContextFactory();
+ File path = new File("./test-resources/axis2");
+ ConfigurationContext configCtx = conFac
+ .buildClientConfigurationContext(path.getAbsolutePath());
+ MessageContext msgCtx = new MessageContext(configCtx);
+ msgCtx.setEnvelope(testEnvSetup());
+ msgCtx.setServerSide(true);
+
+ AxisConfiguration axisConfiguration = msgCtx.getSystemContext()
+ .getAxisConfiguration();
+ AxisService service = new AxisService(
+ new QName("se"));
+ msgCtx.setAxisService(service);
+ service.setClassLoader(axisConfiguration.getServiceClassLoader());
+ AxisOperation axisOp = new InOutAxisOperation(
+ new QName("op"));
+ msgCtx.setAxisOperation(axisOp);
+ axisOp.setMessageReceiver(new SynapseMessageReceiver());
+ service.addOperation(axisOp);
+ axisConfiguration.addService(service);
+ msgCtx.setTo(
+ new EndpointReference("/axis2/services/" + "se" + "/" + "op"));
+ msgCtx.setSoapAction("op");
+ return msgCtx;
+ }
+
+ private static SOAPEnvelope testEnvSetup() {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ SOAPEnvelope env = OMAbstractFactory.getSOAP11Factory()
+ .getDefaultEnvelope();
+ OMDocument doc = fac.createOMDocument();
+ doc.addChild(env);
+ OMElement ele = fac.createOMElement("text", "urn:text-body","t");
+ env.getBody().addChild(ele);
+ return env;
+ }
+
+ public static OMElement getSynapseConfigElement(String synapseXml) throws XMLStreamException {
+ XMLStreamReader parser = XMLInputFactory.newInstance()
+ .createXMLStreamReader(
+ new ByteArrayInputStream(synapseXml.getBytes()));
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ StAXOMBuilder staxBuilder = new StAXOMBuilder(fac, parser);
+ OMElement config = staxBuilder.getDocumentElement();
+ return config;
+
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org