synapse-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject svn commit: r562331 - in /webservices/synapse/trunk/java/modules/core/src: main/java/org/apache/synapse/config/xml/ test/java/org/apache/synapse/mediators/ext/
Date Fri, 03 Aug 2007 05:04:58 GMT
Author: ruwan
Date: Thu Aug  2 22:04:58 2007
New Revision: 562331

URL: http://svn.apache.org/viewvc?view=rev&rev=562331
Log:
Adding ClassMediator initialization and destroying test methods (managed lifecycle tests)

Modified:
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ClassMediatorFactory.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/ClassMediatorTestMediator.java

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ClassMediatorFactory.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ClassMediatorFactory.java?view=diff&rev=562331&r1=562330&r2=562331
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ClassMediatorFactory.java
(original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ClassMediatorFactory.java
Thu Aug  2 22:04:58 2007
@@ -104,6 +104,9 @@
                         throw new SynapseException(msg, e);
 
                     }
+                } else if (child.getAttributeValue(new QName("expression")) != null) {
+                    // check whether there is an XPATH exp for the property value
+                    // todo:
                 } else {
                     // now try XML child
                     OMElement value = child.getFirstElement();

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?view=diff&rev=562331&r1=562330&r2=562331
==============================================================================
--- 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
Thu Aug  2 22:04:58 2007
@@ -19,14 +19,12 @@
 
 package org.apache.synapse.mediators.ext;
 
-import junit.framework.TestCase;
-import org.apache.axiom.om.xpath.AXIOMXPath;
-import org.apache.synapse.TestMessageContext;
+import org.apache.synapse.ManagedLifecycle;
 import org.apache.synapse.Mediator;
-import org.apache.synapse.config.xml.ClassMediatorFactory;
-import org.apache.synapse.config.xml.MediatorFactoryFinder;
+import org.apache.synapse.TestMessageContext;
 import org.apache.synapse.config.xml.AbstractTestCase;
-import org.apache.synapse.mediators.MediatorProperty;
+import org.apache.synapse.config.xml.MediatorFactoryFinder;
+import org.apache.synapse.core.axis2.Axis2SynapseEnvironment;
 
 /**
  * Tests the class mediator instantiation and setting of literal and
@@ -49,6 +47,26 @@
         cm.mediate(new TestMessageContext());
         assertTrue(ClassMediatorTestMediator.invoked);
         assertTrue(ClassMediatorTestMediator.testProp.equals("testValue"));
+    }
+
+    public void testInitialization() throws Exception {
+        Mediator cm = MediatorFactoryFinder.getInstance().getMediator(createOMElement(
+                "<class name='org.apache.synapse.mediators.ext.ClassMediatorTestMediator'
" +
+                        "xmlns='http://ws.apache.org/ns/synapse'/>"));
+        ((ManagedLifecycle) cm).init(new Axis2SynapseEnvironment());
+        assertTrue(ClassMediatorTestMediator.initialized);
+        cm.mediate(new TestMessageContext());
+        assertTrue(ClassMediatorTestMediator.invoked);
+    }
+
+    public void testDestroy() throws Exception {
+        Mediator cm = MediatorFactoryFinder.getInstance().getMediator(createOMElement(
+                "<class name='org.apache.synapse.mediators.ext.ClassMediatorTestMediator'
" +
+                        "xmlns='http://ws.apache.org/ns/synapse'/>"));
+        cm.mediate(new TestMessageContext());
+        assertTrue(ClassMediatorTestMediator.invoked);
+        ((ManagedLifecycle) cm).destroy();
+        assertTrue(ClassMediatorTestMediator.destroyed);
     }
 
 //    public void testCreationWithXPathProperties() throws Exception {

Modified: webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/ext/ClassMediatorTestMediator.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/ext/ClassMediatorTestMediator.java?view=diff&rev=562331&r1=562330&r2=562331
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/ext/ClassMediatorTestMediator.java
(original)
+++ webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/ext/ClassMediatorTestMediator.java
Thu Aug  2 22:04:58 2007
@@ -33,6 +33,8 @@
 public class ClassMediatorTestMediator extends AbstractMediator implements ManagedLifecycle
{
 
     public static boolean invoked = false;
+    public static boolean initialized = false;
+    public static boolean destroyed = false;
 
     public static String testProp = null;
 
@@ -54,10 +56,10 @@
     }
 
     public void init(SynapseEnvironment se) {
-//To change body of implemented methods use File | Settings | File Templates.
+        initialized = true;
     }
 
     public void destroy() {
-//To change body of implemented methods use File | Settings | File Templates.
+        destroyed = 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