[jboss-svn-commits] JBL Code SVN: r24751 - in labs/jbossrules/trunk/drools-compiler/src/test: resources/org/drools/integrationtests and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Jan 16 01:53:31 EST 2009


Author: mark.proctor at jboss.com
Date: 2009-01-16 01:53:31 -0500 (Fri, 16 Jan 2009)
New Revision: 24751

Added:
   labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/no-loop_with_modify.drl
Modified:
   labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/ExecutionFlowControlTest.java
Log:
JBRULES-1881 no-loop attribute not working with modify 
-Added test, but could not re-create error.

Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/ExecutionFlowControlTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/ExecutionFlowControlTest.java	2009-01-16 06:44:01 UTC (rev 24750)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/ExecutionFlowControlTest.java	2009-01-16 06:53:31 UTC (rev 24751)
@@ -240,7 +240,34 @@
                              list.size() );
 
     }
+    
+    public void testNoLoopWithModify() throws Exception {
+        final PackageBuilder builder = new PackageBuilder();
+        builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "no-loop_with_modify.drl" ) ) );
+        final Package pkg = builder.getPackage();
 
+        RuleBase ruleBase = getRuleBase();
+        ruleBase.addPackage( pkg );
+        ruleBase = SerializationHelper.serializeObject( ruleBase );
+        final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+
+        final List list = new ArrayList();
+        workingMemory.setGlobal( "list",
+                                 list );
+
+        final Cheese brie = new Cheese( "brie",
+                                        12 );
+        workingMemory.insert( brie );
+
+        workingMemory.fireAllRules();
+
+        Assert.assertEquals( "Should not loop  and thus size should be 1",
+                             1,
+                             list.size() );
+        assertEquals( 50, brie.getPrice() );
+
+    }    
+
     public void testLockOnActive() throws Exception {
         final PackageBuilder builder = new PackageBuilder();
         builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_LockOnActive.drl" ) ) );

Added: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/no-loop_with_modify.drl
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/no-loop_with_modify.drl	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/no-loop_with_modify.drl	2009-01-16 06:53:31 UTC (rev 24751)
@@ -0,0 +1,17 @@
+package org.drools.test;
+
+import org.drools.Cheese;
+
+global java.util.List list
+
+rule "Do  not loop  forever"
+	no-loop true
+    when
+    	cheese : Cheese( )
+    then     
+    	list.add( cheese );
+    	if ( list.size() > 2 ) {
+    	    throw new Exception( "this should not loop" );
+    	}
+		modify( cheese ) { setPrice( 50 ) };
+end  
\ No newline at end of file




More information about the jboss-svn-commits mailing list