[
https://jira.jboss.org/browse/JBRULES-2436?page=com.atlassian.jira.plugin...
]
Edson Tirelli resolved JBRULES-2436.
------------------------------------
Resolution: Done
This issue was fixed as part of the linked issue. Thank you for reporting and providing
test case. Let me know if you still face any problem.
Inheritance of events does not work as one would expect when using
working memory entry-points
----------------------------------------------------------------------------------------------
Key: JBRULES-2436
URL:
https://jira.jboss.org/browse/JBRULES-2436
Project: Drools
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: drools-core (fusion)
Reporter: Jerome Bernard
Assignee: Edson Tirelli
Fix For: 5.1.0.CR1
When using working memory entry-points, I have a different behaviour than when I use the
session.
Here is a test illustrating this:
package org.drools.test;
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseConfiguration;
import org.drools.KnowledgeBaseFactory;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
import org.drools.conf.EventProcessingOption;
import org.drools.io.ResourceFactory;
import org.drools.logger.KnowledgeRuntimeLoggerFactory;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.rule.WorkingMemoryEntryPoint;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.StringReader;
public class DroolsFusionInheritanceBugsTest {
private StatefulKnowledgeSession session;
private WorkingMemoryEntryPoint stream;
private final static String drl = "package org.drools.test;\n" +
"declare A\n" +
" @role(event)\n" +
"end\n" +
"\n" +
"rule \"myrule\"\n" +
"when\n" +
" $a : A() from entry-point \"mystream\"\n" +
"then\n" +
" System.out.println(\"fired!\");\n" +
"end\n";
@Test
public void testOkWithEventsInheritance() {
session.insert(new A());
session.insert(new B());
session.fireAllRules();
}
@Test
public void testFailsWithEventsInheritanceThroughWorkingMemoryEntryPoint() {
stream.insert(new A());
stream.insert(new B());
session.fireAllRules();
}
@Before
public void setupDrools() {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
System.out.println("DRL is:\n" + drl);
kbuilder.add(ResourceFactory.newReaderResource(new StringReader(drl)),
ResourceType.DRL);
KnowledgeBaseConfiguration conf =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
conf.setOption(EventProcessingOption.STREAM);
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(conf);
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
session = kbase.newStatefulKnowledgeSession();
assert session != null;
KnowledgeRuntimeLoggerFactory.newConsoleLogger(session);
stream = session.getWorkingMemoryEntryPoint("mystream");
assert stream != null : "Could not find working memory entry-point
'mystream'";
}
@After
public void releaseDroolsSession() {
if (session != null)
session.dispose();
}
}
class A {}
class B extends A { }
When using working memory entry-points, the insert of a B instances fails with a:
java.lang.ClassCastException: org.drools.common.DefaultFactHandle cannot be cast to
org.drools.common.EventFactHandle
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira