[jboss-jira] [JBoss JIRA] Updated: (JBRULES-2108) A rule does not fire for all objects satisfying the rule code.
Mark Proctor (JIRA)
jira-events at lists.jboss.org
Sun Apr 4 01:27:38 EDT 2010
[ https://jira.jboss.org/jira/browse/JBRULES-2108?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mark Proctor updated JBRULES-2108:
----------------------------------
Fix Version/s: 5.1.0.M2
This is still a problem in trunk, fixing now.
Mark
> A rule does not fire for all objects satisfying the rule code.
> --------------------------------------------------------------
>
> Key: JBRULES-2108
> URL: https://jira.jboss.org/jira/browse/JBRULES-2108
> Project: Drools
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: drools-core
> Affects Versions: 4.0.7
> Reporter: Andrey Nechaev
> Assignee: Mark Proctor
> Fix For: 5.1.0.M2
>
> Attachments: patch
>
>
> The following code shows the problem:
> public class DroolsTest {
> private final static int NUM_FACTS = 20;
> private final static String rule = "" +
> "package test\n" +
> "import com.test.DroolsTest;\n" +
> "import com.test.DroolsTest.Foo;\n" +
> "import com.test.DroolsTest.Bar;\n" +
> "rule test\n" +
> "\twhen\n" +
> "\t\tFoo($p : id < " + Integer.toString(NUM_FACTS) + ") && Bar(id == $p)\n" +
> "\tthen\n" +
> "\t\tDroolsTest.incCounter();\n" +
> "end";
>
> private static int counter;
>
> public static class Foo {
> private final int id;
>
> Foo(int id) {
> this.id = id;
> }
>
> public int getId() {
> return id;
> }
> }
>
> public static class Bar {
> private final int id;
>
> Bar(int id) {
> this.id = id;
> }
>
> public int getId() {
> return id;
> }
> }
>
> public static void main(String[] args) throws Exception {
> RuleBase rb;
> WorkingMemory wm;
> counter = 0;
>
> rb = RuleBaseFactory.newRuleBase();
> wm = rb.newStatefulSession();
>
> for(int i = 0; i < NUM_FACTS; i++) {
> wm.insert(new Foo(i));
> wm.insert(new Bar(i));
> }
> PackageBuilder bld = new PackageBuilder();
> bld.addPackageFromDrl(new StringReader(rule));
>
> rb.addPackage(bld.getPackage());
> System.out.println(counter == NUM_FACTS ? "passed" : "failed");
> }
>
> public static void incCounter() {
> ++counter;
> }
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list