servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lh...@apache.org
Subject svn commit: r683577 - in /servicemix/components/engines/servicemix-drools/trunk/src/test: java/org/apache/servicemix/drools/DroolsComponentTest.java resources/chained.drl
Date Thu, 07 Aug 2008 10:30:41 GMT
Author: lhein
Date: Thu Aug  7 03:30:40 2008
New Revision: 683577

URL: http://svn.apache.org/viewvc?rev=683577&view=rev
Log:
- added test case for chained routing

Added:
    servicemix/components/engines/servicemix-drools/trunk/src/test/resources/chained.drl
Modified:
    servicemix/components/engines/servicemix-drools/trunk/src/test/java/org/apache/servicemix/drools/DroolsComponentTest.java

Modified: servicemix/components/engines/servicemix-drools/trunk/src/test/java/org/apache/servicemix/drools/DroolsComponentTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-drools/trunk/src/test/java/org/apache/servicemix/drools/DroolsComponentTest.java?rev=683577&r1=683576&r2=683577&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-drools/trunk/src/test/java/org/apache/servicemix/drools/DroolsComponentTest.java
(original)
+++ servicemix/components/engines/servicemix-drools/trunk/src/test/java/org/apache/servicemix/drools/DroolsComponentTest.java
Thu Aug  7 03:30:40 2008
@@ -23,12 +23,9 @@
 import javax.jbi.messaging.InOut;
 import javax.xml.namespace.QName;
 
-import org.w3c.dom.Element;
-
-import junit.framework.TestCase;
-
 import org.apache.servicemix.client.DefaultServiceMixClient;
 import org.apache.servicemix.client.ServiceMixClient;
+import org.apache.servicemix.common.JbiConstants;
 import org.apache.servicemix.components.util.MockServiceComponent;
 import org.apache.servicemix.jbi.container.JBIContainer;
 import org.apache.servicemix.jbi.jaxp.SourceTransformer;
@@ -36,6 +33,10 @@
 import org.apache.servicemix.tck.ReceiverComponent;
 import org.springframework.core.io.ClassPathResource;
 
+import org.w3c.dom.Element;
+
+import junit.framework.TestCase;
+
 public class DroolsComponentTest extends TestCase {
 
     private JBIContainer jbi;
@@ -54,6 +55,38 @@
         jbi.shutDown();
     }
     
+    public void testChainedRoutingInOnly() throws Exception {
+        drools = new DroolsComponent();
+        
+        DroolsEndpoint endpoint = new DroolsEndpoint(drools.getServiceUnit(),
+                                                     new QName("smx", "drools"), "endpoint");
+        endpoint.setRuleBaseResource(new ClassPathResource("chained.drl"));
+        
+        drools.setEndpoints(new DroolsEndpoint[] {endpoint});
+        jbi.activateComponent(drools, "servicemix-drools");
+
+        ReceiverComponent target = new ReceiverComponent();
+        target.setService(new QName("smx", "target"));
+        target.setEndpoint("endpoint");
+        
+        jbi.activateComponent(target, "target");
+        
+        jbi.start();
+        
+        InOnly me = client.createInOnlyExchange();
+        me.setService(new QName("smx", "drools"));
+        me.setOperation(new QName("smx", "process"));
+        me.getInMessage().setContent(new StringSource("<payload />"));
+        me.setProperty(JbiConstants.CORRELATION_ID, "TEST");
+        if (client.sendSync(me, 10000)) {
+            assertEquals(ExchangeStatus.DONE, me.getStatus());
+        } else {
+            fail ("No response from drools in time...");
+        }
+        
+        Thread.sleep(50);
+    }
+    
     public void testRouteInOnly() throws Exception {
         drools = new DroolsComponent();
         DroolsEndpoint endpoint = new DroolsEndpoint(drools.getServiceUnit(),

Added: servicemix/components/engines/servicemix-drools/trunk/src/test/resources/chained.drl
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-drools/trunk/src/test/resources/chained.drl?rev=683577&view=auto
==============================================================================
--- servicemix/components/engines/servicemix-drools/trunk/src/test/resources/chained.drl (added)
+++ servicemix/components/engines/servicemix-drools/trunk/src/test/resources/chained.drl Thu
Aug  7 03:30:40 2008
@@ -0,0 +1,30 @@
+package org.apache.servicemix.drools
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.servicemix.drools.model.Exchange;
+
+global org.apache.servicemix.drools.model.JbiHelper jbi;
+
+rule UnknownOperation
+    agenda-group "init"
+    auto-focus true    
+    when
+        $me : Exchange( status == Exchange.ACTIVE, $in : in != null,
+                       operation != "{smx}process")
+    then
+        jbi.route("service:smx/target");
+end
+
+rule Input
+    agenda-group "input"
+    auto-focus true    
+    when
+        $me : Exchange( status == Exchange.ACTIVE, $in : in != null,
+                       operation == "{smx}process" )
+        eval ( true )
+    then
+        jbi.getLogger().debug("[Rule: Input]: Message routed to drools2...");
+        jbi.route("service:smx/drools");
+end



Mime
View raw message