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/30 16:33:52 UTC

svn commit: r349965 - /incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/injection/

Author: saminda
Date: Wed Nov 30 07:33:43 2005
New Revision: 349965

URL: http://svn.apache.org/viewcvs?rev=349965&view=rev
Log:
Updated the following test cases to be more robust 

Added:
    incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/injection/InProcessorWithRuleTest.java
      - copied, changed from r349952, incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/injection/InWithRuleTest.java
Removed:
    incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/injection/InWithRuleTest.java
Modified:
    incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/injection/AddressingProcessorWithRuleTest.java
    incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/injection/ClassMediatorProcessorWithRuleTest.java
    incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/injection/RegexProcessorWithRuleTest.java
    incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/injection/XpathProcessorWithRuleTest.java

Modified: incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/injection/AddressingProcessorWithRuleTest.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/injection/AddressingProcessorWithRuleTest.java?rev=349965&r1=349964&r2=349965&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/injection/AddressingProcessorWithRuleTest.java (original)
+++ incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/injection/AddressingProcessorWithRuleTest.java Wed Nov 30 07:33:43 2005
@@ -2,9 +2,13 @@
 
 import junit.framework.TestCase;
 import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.om.OMElement;
 import org.apache.synapse.Constants;
 import org.apache.synapse.SynapseEnvironment;
 import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.Processor;
+import org.apache.synapse.processors.builtin.axis2.AddressingProcessor;
+import org.apache.synapse.xml.AddressingProcessorConfigurator;
 import org.apache.synapse.axis2.Axis2SynapseMessage;
 import org.apache.synapse.axis2.Axis2SynapseEnvironment;
 import org.apache.synapse.util.Axis2EvnSetup;
@@ -27,6 +31,8 @@
 
 public class AddressingProcessorWithRuleTest 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=\"logall\">\n" +
@@ -36,15 +42,24 @@
 
     public void setUp() throws Exception {
         msgCtx = Axis2EvnSetup.axis2Deployment("target/synapse-repository");
+        config =Axis2EvnSetup.getSynapseConfigElement(synapsexml);
+        env = new Axis2SynapseEnvironment(config,
+                Thread.currentThread().getContextClassLoader());
     }
 
     public void testAddressingProcessor() throws Exception {
-        SynapseEnvironment env = new Axis2SynapseEnvironment(
-                Axis2EvnSetup.getSynapseConfigElement(synapsexml),
-                Thread.currentThread().getContextClassLoader());
+
         SynapseMessage smc = new Axis2SynapseMessage(msgCtx);
         env.injectMessage(smc);
         assertTrue(((Boolean) smc.getProperty(
                 Constants.MEDIATOR_RESPONSE_PROPERTY)).booleanValue());
+    }
+
+    public void testAddressingConfigurator() throws Exception {
+        AddressingProcessorConfigurator conf = new AddressingProcessorConfigurator();
+
+        Processor pro = conf.createProcessor(env,config.getFirstElement().getFirstElement());
+        assertTrue(pro instanceof AddressingProcessor);
+        assertNull(pro.getName());
     }
 }

Modified: incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/injection/ClassMediatorProcessorWithRuleTest.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/injection/ClassMediatorProcessorWithRuleTest.java?rev=349965&r1=349964&r2=349965&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/injection/ClassMediatorProcessorWithRuleTest.java (original)
+++ incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/injection/ClassMediatorProcessorWithRuleTest.java Wed Nov 30 07:33:43 2005
@@ -2,8 +2,12 @@
 
 import junit.framework.TestCase;
 import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.om.OMElement;
 import org.apache.synapse.SynapseEnvironment;
 import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.Processor;
+import org.apache.synapse.processors.mediatortypes.ClassMediatorProcessor;
+import org.apache.synapse.xml.ClassMediatorProcessorConfigurator;
 import org.apache.synapse.axis2.Axis2SynapseMessage;
 import org.apache.synapse.axis2.Axis2SynapseEnvironment;
 import org.apache.synapse.util.Axis2EvnSetup;
@@ -26,6 +30,8 @@
 
 public class ClassMediatorProcessorWithRuleTest 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=\"loger\">\n" +
@@ -35,14 +41,21 @@
 
     public void setUp() throws Exception {
         msgCtx = Axis2EvnSetup.axis2Deployment("target/synapse-repository");
+        config = Axis2EvnSetup.getSynapseConfigElement(synapsexml);
+        env = new Axis2SynapseEnvironment(config,
+                Thread.currentThread().getContextClassLoader());
     }
 
     public void testClassMediatorProcessor() throws Exception {
-        SynapseEnvironment env = new Axis2SynapseEnvironment(
-                Axis2EvnSetup.getSynapseConfigElement(synapsexml),
-                Thread.currentThread().getContextClassLoader());
+
         SynapseMessage smc = new Axis2SynapseMessage(msgCtx);
         env.injectMessage(smc);
         assertNotNull(env.lookupProcessor("mediation"));
+    }
+    public void testClassMediatorConfigurator() throws Exception {
+        ClassMediatorProcessorConfigurator conf = new ClassMediatorProcessorConfigurator();
+        Processor pro = conf.createProcessor(env, config.getFirstElement().getFirstElement());
+        assertTrue(pro instanceof ClassMediatorProcessor);
+        assertEquals("mediation",pro.getName());
     }
 }

Copied: incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/injection/InProcessorWithRuleTest.java (from r349952, incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/injection/InWithRuleTest.java)
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/injection/InProcessorWithRuleTest.java?p2=incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/injection/InProcessorWithRuleTest.java&p1=incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/injection/InWithRuleTest.java&r1=349952&r2=349965&rev=349965&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/injection/InWithRuleTest.java (original)
+++ incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/injection/InProcessorWithRuleTest.java Wed Nov 30 07:33:43 2005
@@ -25,7 +25,7 @@
 *
 */
 
-public class InWithRuleTest extends TestCase {
+public class InProcessorWithRuleTest extends TestCase {
     private MessageContext msgCtx;
     private String synapsexml =
             "<synapse xmlns=\"http://ws.apache.org/ns/synapse\">\n" +

Modified: incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/injection/RegexProcessorWithRuleTest.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/injection/RegexProcessorWithRuleTest.java?rev=349965&r1=349964&r2=349965&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/injection/RegexProcessorWithRuleTest.java (original)
+++ incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/injection/RegexProcessorWithRuleTest.java Wed Nov 30 07:33:43 2005
@@ -3,8 +3,12 @@
 import junit.framework.TestCase;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.om.OMElement;
 import org.apache.synapse.SynapseEnvironment;
 import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.Processor;
+import org.apache.synapse.processors.rules.RegexProcessor;
+import org.apache.synapse.xml.RegexProcessorConfigurator;
 import org.apache.synapse.axis2.Axis2SynapseMessage;
 import org.apache.synapse.axis2.Axis2SynapseEnvironment;
 import org.apache.synapse.util.Axis2EvnSetup;
@@ -26,23 +30,35 @@
 */
 
 public class RegexProcessorWithRuleTest extends TestCase {
-
+    private SynapseEnvironment env;
+    private OMElement config;
+    private MessageContext mc;
     private String synapsexml =
             "<synapse xmlns=\"http://ws.apache.org/ns/synapse\">\n" +
                     "<stage name=\"regex\">\n" +
                     "    <regex message-address=\"to\" pattern=\"http://xmethods..\\*\"/>\n" +
                     "</stage>\n" +
             "</synapse>";
+    public void setUp() throws Exception{
+        mc = Axis2EvnSetup.axis2Deployment("target/synapse-repository");
+        mc.setTo(new EndpointReference("http://xmethods.org"));
+        config = Axis2EvnSetup.getSynapseConfigElement(synapsexml);
+        env = new Axis2SynapseEnvironment(config,
+                Thread.currentThread().getContextClassLoader());
+    }
 
     public void testRegexProcessor() throws Exception {
-        MessageContext mc = Axis2EvnSetup.axis2Deployment("target/synapse-repository");
-        mc.setTo(new EndpointReference("http://xmethods.org"));
         SynapseMessage smc = new Axis2SynapseMessage(mc);
-        SynapseEnvironment env = new Axis2SynapseEnvironment(
-                Axis2EvnSetup.getSynapseConfigElement(synapsexml),
-                Thread.currentThread().getContextClassLoader());
         env.injectMessage(smc);
         assertEquals("regex", env.lookupProcessor("regex").getName());
+
+    }
+
+    public void testRegexProcessorConfigurator() throws Exception {
+        RegexProcessorConfigurator conf = new RegexProcessorConfigurator();
+        Processor pro = conf.createProcessor(env,config.getFirstElement().getFirstElement());
+        assertTrue(pro instanceof RegexProcessor);
+        assertEquals("to",((RegexProcessor)pro).getHeaderType());
 
     }
 }

Modified: incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/injection/XpathProcessorWithRuleTest.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/injection/XpathProcessorWithRuleTest.java?rev=349965&r1=349964&r2=349965&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/injection/XpathProcessorWithRuleTest.java (original)
+++ incubator/synapse/trunk/scratch/prototype3/test/org/apache/synapse/spi/injection/XpathProcessorWithRuleTest.java Wed Nov 30 07:33:43 2005
@@ -2,12 +2,15 @@
 
 import junit.framework.TestCase;
 import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.synapse.util.Axis2EvnSetup;
-import org.apache.synapse.SynapseMessage;
+import org.apache.axis2.om.OMElement;
 import org.apache.synapse.SynapseEnvironment;
-import org.apache.synapse.axis2.Axis2SynapseMessage;
+import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.Processor;
+import org.apache.synapse.processors.rules.XPathProcessor;
+import org.apache.synapse.xml.XPathProcessorConfigurator;
 import org.apache.synapse.axis2.Axis2SynapseEnvironment;
+import org.apache.synapse.axis2.Axis2SynapseMessage;
+import org.apache.synapse.util.Axis2EvnSetup;
 /*
 * Copyright 2004,2005 The Apache Software Foundation.
 *
@@ -26,20 +29,34 @@
 */
 
 public class XpathProcessorWithRuleTest extends TestCase {
-     private String synapsexml =
+    private MessageContext mc;
+    private OMElement config;
+    private SynapseEnvironment env;
+    private String synapsexml =
             "<synapse xmlns=\"http://ws.apache.org/ns/synapse\">\n" +
                     "<stage name=\"xpath\">\n" +
                     "    <xpath expr=\"//ns:text\" xmlns:ns=\"urn:text-body\"/>\n" +
                     "</stage>\n" +
-            "</synapse>";
+                    "</synapse>";
+
+    public void setUp() throws Exception {
+        mc = Axis2EvnSetup
+                .axis2Deployment("target/synapse-repository");
+        config = Axis2EvnSetup.getSynapseConfigElement(synapsexml);
+        env = new Axis2SynapseEnvironment(config,
+                Thread.currentThread().getContextClassLoader());
+    }
+
     public void testXpathProcessor() throws Exception {
-        MessageContext mc = Axis2EvnSetup.axis2Deployment("target/synapse-repository");
         SynapseMessage smc = new Axis2SynapseMessage(mc);
-        SynapseEnvironment env = new Axis2SynapseEnvironment(
-                Axis2EvnSetup.getSynapseConfigElement(synapsexml),
-                Thread.currentThread().getContextClassLoader());
         env.injectMessage(smc);
-        assertEquals("xpath",env.lookupProcessor("xpath").getName());
+        assertEquals("xpath", env.lookupProcessor("xpath").getName());
+    }
+    public void testXpathProcessorConfigurator() throws Exception {
+        XPathProcessorConfigurator conf = new XPathProcessorConfigurator();
+        Processor pro = conf.createProcessor(env,config.getFirstElement().getFirstElement());
+        assertTrue(pro instanceof XPathProcessor);
+        assertEquals("//ns:text",((XPathProcessor)pro).getXPathExpr());
     }
 }
 



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