[jboss-svn-commits] JBL Code SVN: r30571 - in labs/jbossrules/trunk: drools-compiler/src/test/resources/org/drools/integrationtests and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Dec 9 18:46:59 EST 2009
Author: tirelli
Date: 2009-12-09 18:46:58 -0500 (Wed, 09 Dec 2009)
New Revision: 30571
Added:
labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_JBRules2369.drl
Modified:
labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/RuleTerminalNode.java
Log:
JBRULES-2369: fixing interaction between no-loop and modify
Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java 2009-12-09 23:38:51 UTC (rev 30570)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java 2009-12-09 23:46:58 UTC (rev 30571)
@@ -6787,6 +6787,44 @@
}
+ public void testJBRules2369() {
+ KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
+ kbuilder.add( ResourceFactory.newClassPathResource( "test_JBRules2369.drl",
+ getClass() ),
+ ResourceType.DRL );
+ KnowledgeBuilderErrors errors = kbuilder.getErrors();
+ if ( errors.size() > 0 ) {
+ for ( KnowledgeBuilderError error : errors ) {
+ System.err.println( error );
+ }
+ fail( "Error loading test_JBRules2369" );
+ }
+ KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
+ kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
+ StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
+ List<String> results = new ArrayList<String>();
+ ksession.setGlobal( "results",
+ results );
+
+ FactA a = new FactA();
+ FactB b = new FactB( Integer.valueOf( 0 ) );
+
+ org.drools.runtime.rule.FactHandle aHandle = ksession.insert( a );
+ org.drools.runtime.rule.FactHandle bHandle = ksession.insert( b );
+
+ ksession.fireAllRules();
+
+ assertEquals( 1,
+ results.size() );
+
+ ksession.update( aHandle,
+ a );
+
+ ksession.fireAllRules();
+ assertEquals( 2,
+ results.size() );
+ }
+
public void testInsertionOrder() {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( ResourceFactory.newClassPathResource( "test_InsertionOrder.drl",
@@ -6882,7 +6920,7 @@
assertFalse( "T1 should have finished",
aliveT1 );
}
-
+
public void testFireUntilHaltFailingAcrossEntryPoints() throws Exception {
String rule1 = "package org.drools\n";
rule1 += "global java.util.List list\n";
Copied: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_JBRules2369.drl (from rev 30568, labs/jbossrules/soa_branches/BRMS-5.0.1/drools-compiler/src/test/resources/org/drools/integrationtests/test_JBRules2369.drl)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_JBRules2369.drl (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_JBRules2369.drl 2009-12-09 23:46:58 UTC (rev 30571)
@@ -0,0 +1,15 @@
+package org.drools
+
+global java.util.List results
+
+rule "test jira jbrules 2369"
+ no-loop
+ when
+ $a : FactA( )
+ $b : FactB( )
+ then
+ results.add( "FIRED" );
+ modify( $b ) {
+ setF2( $b.getF2().intValue() + 1 )
+ }
+end
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/RuleTerminalNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/RuleTerminalNode.java 2009-12-09 23:38:51 UTC (rev 30570)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/RuleTerminalNode.java 2009-12-09 23:46:58 UTC (rev 30571)
@@ -191,17 +191,19 @@
return;
}
+ final InternalAgenda agenda = (InternalAgenda) workingMemory.getAgenda();
+
// if the current Rule is no-loop and the origin rule is the same and its the same set of facts (tuple) then return
if ( context.getType() == PropagationContext.MODIFICATION ) {
if ( this.rule.isNoLoop() && this.rule.equals( context.getRuleOrigin() ) && context.getLeftTupleOrigin().equals( tuple ) ) {
+ agenda.increaseDormantActivations();
return;
}
} else if ( this.rule.isNoLoop() && this.rule.equals( context.getRuleOrigin() ) ) {
+ agenda.increaseDormantActivations();
return;
}
- final InternalAgenda agenda = (InternalAgenda) workingMemory.getAgenda();
-
final Timer timer = this.rule.getTimer();
if ( timer != null ) {
More information about the jboss-svn-commits
mailing list