synapse-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r356301 - in /incubator/synapse/trunk/java/test/org/apache/synapse: ./ mediators/ mediators/builtin/ mediators/builtin/axis2/ spi/processors/ util/
Date Mon, 12 Dec 2005 17:49:51 GMT
Author: pzf
Date: Mon Dec 12 09:48:40 2005
New Revision: 356301

URL: http://svn.apache.org/viewcvs?rev=356301&view=rev
Log:
new test cases for addressing... trying to refactor test approach

Added:
    incubator/synapse/trunk/java/test/org/apache/synapse/SynapseEnvironmentTest.java
    incubator/synapse/trunk/java/test/org/apache/synapse/SynapseMessageTest.java
    incubator/synapse/trunk/java/test/org/apache/synapse/mediators/
    incubator/synapse/trunk/java/test/org/apache/synapse/mediators/builtin/
    incubator/synapse/trunk/java/test/org/apache/synapse/mediators/builtin/axis2/
    incubator/synapse/trunk/java/test/org/apache/synapse/mediators/builtin/axis2/AddressingInProcessorTest.java
Modified:
    incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/AddressingProcessorTest.java
    incubator/synapse/trunk/java/test/org/apache/synapse/util/Axis2EvnSetup.java

Added: incubator/synapse/trunk/java/test/org/apache/synapse/SynapseEnvironmentTest.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/test/org/apache/synapse/SynapseEnvironmentTest.java?rev=356301&view=auto
==============================================================================
--- incubator/synapse/trunk/java/test/org/apache/synapse/SynapseEnvironmentTest.java (added)
+++ incubator/synapse/trunk/java/test/org/apache/synapse/SynapseEnvironmentTest.java Mon Dec
12 09:48:40 2005
@@ -0,0 +1,12 @@
+package org.apache.synapse;
+
+import org.apache.synapse.axis2.Axis2SynapseEnvironment;
+
+public class SynapseEnvironmentTest {
+
+	public static SynapseEnvironment createAxis2SynapseEnvironment() {
+		Axis2SynapseEnvironment se = new Axis2SynapseEnvironment(null, null);
+		return se;
+	}
+
+}

Added: incubator/synapse/trunk/java/test/org/apache/synapse/SynapseMessageTest.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/test/org/apache/synapse/SynapseMessageTest.java?rev=356301&view=auto
==============================================================================
--- incubator/synapse/trunk/java/test/org/apache/synapse/SynapseMessageTest.java (added)
+++ incubator/synapse/trunk/java/test/org/apache/synapse/SynapseMessageTest.java Mon Dec 12
09:48:40 2005
@@ -0,0 +1,62 @@
+package org.apache.synapse;
+
+import org.apache.axis2.AxisFault;
+
+import org.apache.axis2.addressing.AddressingConstants.Submission;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.OMElement;
+
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.synapse.axis2.Axis2SynapseMessage;
+
+public class SynapseMessageTest {
+	public static final String URN_SAMPLE_TO_ADDRESS = "urn:sample-toAddress";
+
+	public static void main(String[] args) {
+		SynapseMessage sm = createSampleSOAP11MessageWithoutAddressing();
+		System.out.println(sm.getEnvelope());
+		SynapseMessage sm2 = createSampleSOAP11MessageWithAddressing();
+		System.out.println(sm2.getEnvelope());
+	}
+
+	public static Axis2SynapseMessage createSampleSOAP11MessageWithoutAddressing() {
+		// create a lightweight Axis Config with no addressing to demonstrate
+		// "dumb" SOAP
+		AxisConfiguration ac = new AxisConfiguration();
+		ConfigurationContext cc = new ConfigurationContext(ac);
+		MessageContext msgCtx;
+		try {
+			msgCtx = new MessageContext(cc);
+
+			SOAPEnvelope env = OMAbstractFactory.getSOAP11Factory()
+					.getDefaultEnvelope();
+
+			OMElement body = OMAbstractFactory.getOMFactory().createOMElement(
+					"test-body", "urn:test", "test");
+			OMAbstractFactory.getOMFactory().createText(body,
+					"Do not be alarmed, this is just a test");
+
+			env.getBody().addChild(body);
+			msgCtx.setEnvelope(env);
+		} catch (AxisFault e) {
+			throw new SynapseException(e);
+		}
+
+		return new Axis2SynapseMessage(msgCtx);
+	}
+
+	public static Axis2SynapseMessage createSampleSOAP11MessageWithAddressing() {
+		Axis2SynapseMessage sm = createSampleSOAP11MessageWithoutAddressing();
+
+		OMElement addressingTo = OMAbstractFactory.getOMFactory()
+				.createOMElement("To", Submission.WSA_NAMESPACE, "wsa");
+		OMAbstractFactory.getOMFactory().createText(addressingTo,
+				URN_SAMPLE_TO_ADDRESS);
+		sm.getEnvelope().getHeader().addChild(addressingTo);
+		return sm;
+
+	}
+}

Added: incubator/synapse/trunk/java/test/org/apache/synapse/mediators/builtin/axis2/AddressingInProcessorTest.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/test/org/apache/synapse/mediators/builtin/axis2/AddressingInProcessorTest.java?rev=356301&view=auto
==============================================================================
--- incubator/synapse/trunk/java/test/org/apache/synapse/mediators/builtin/axis2/AddressingInProcessorTest.java
(added)
+++ incubator/synapse/trunk/java/test/org/apache/synapse/mediators/builtin/axis2/AddressingInProcessorTest.java
Mon Dec 12 09:48:40 2005
@@ -0,0 +1,26 @@
+package org.apache.synapse.mediators.builtin.axis2;
+
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseEnvironmentTest;
+import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.SynapseMessageTest;
+import org.apache.synapse.processors.builtin.axis2.AddressingInProcessor;
+
+import junit.framework.TestCase;
+
+public class AddressingInProcessorTest extends TestCase {
+
+    public void testAddressingInProcessor() throws Exception {
+    	
+    	SynapseEnvironment se = SynapseEnvironmentTest.createAxis2SynapseEnvironment();
+    	SynapseMessage smNoAdd = SynapseMessageTest.createSampleSOAP11MessageWithoutAddressing();
+    	AddressingInProcessor aip = new AddressingInProcessor();
+    	
+    	aip.process(se,smNoAdd);
+    	assertTrue("to should be null if there is no addressing header", smNoAdd.getTo()==null);
+    	
+    	SynapseMessage smAdd = SynapseMessageTest.createSampleSOAP11MessageWithAddressing();
+    	assertTrue("to should be the incoming addressing header", smAdd.getTo().getAddress().equals(SynapseMessageTest.URN_SAMPLE_TO_ADDRESS));
+    	
+    }
+}
\ No newline at end of file

Modified: incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/AddressingProcessorTest.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/AddressingProcessorTest.java?rev=356301&r1=356300&r2=356301&view=diff
==============================================================================
--- incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/AddressingProcessorTest.java
(original)
+++ incubator/synapse/trunk/java/test/org/apache/synapse/spi/processors/AddressingProcessorTest.java
Mon Dec 12 09:48:40 2005
@@ -28,7 +28,7 @@
 *
 */
 
-public class AddressingProcessorTest extends TestCase{
+public class AddressingProcessorTest extends TestCase {
 
     public void testAddressingProcessor() throws Exception {
         SynapseMessage sm = new Axis2SynapseMessage(

Modified: incubator/synapse/trunk/java/test/org/apache/synapse/util/Axis2EvnSetup.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/test/org/apache/synapse/util/Axis2EvnSetup.java?rev=356301&r1=356300&r2=356301&view=diff
==============================================================================
--- incubator/synapse/trunk/java/test/org/apache/synapse/util/Axis2EvnSetup.java (original)
+++ incubator/synapse/trunk/java/test/org/apache/synapse/util/Axis2EvnSetup.java Mon Dec 12
09:48:40 2005
@@ -37,11 +37,11 @@
 */
 
 public class Axis2EvnSetup {
-    public static MessageContext axis2Deployment(String testingReposity)
+    public static MessageContext axis2Deployment(String testingRepository)
             throws AxisFault {
         ConfigurationContextFactory conFac = new ConfigurationContextFactory();
         ConfigurationContext configCtx = conFac
-                .buildConfigurationContext(testingReposity);
+                .buildConfigurationContext(testingRepository);
         MessageContext msgCtx = new MessageContext(configCtx);
         msgCtx.setEnvelope(testEnvSetup());
         msgCtx.setServerSide(true);



---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org


Mime
View raw message