Bug 1034250 - KIE FileSystem resource type overriding does not work as reported by documentation
Summary: KIE FileSystem resource type overriding does not work as reported by document...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss BRMS Platform 6
Classification: Retired
Component: BRE
Version: 6.0.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ER6
: 6.0.0
Assignee: Mario Fusco
QA Contact: Tomas Schlosser
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-11-25 13:38 UTC by Mario Fusco
Modified: 2014-08-06 20:18 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-08-06 20:18:46 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker DROOLS-351 0 Major Resolved KIE FileSystem resource type overriding does not work as reported by documentation 2014-01-02 13:09:54 UTC

Description Mario Fusco 2013-11-25 13:38:50 UTC
When a resource is written into the KieFileSystem using the method write( path, Resource ), the resource type is ignored and it will be resolved from the file extension instead. For instance the following test should work regardless of the file extension.

    @Test
    public void testHelloWorldWithResource() throws Exception {
        String drl = "package org.drools.compiler.integrationtests\n" +
                "import " + Message.class.getCanonicalName() + "\n" +
                "rule R1 when\n" +
                "   $m : Message( message == \"Hello World\" )\n" +
                "then\n" +
                "end\n";

        KieServices ks = KieServices.Factory.get();

        KieFileSystem kfs = ks.newKieFileSystem().write(
                ks.getResources()
                  .newReaderResource( new StringReader(drl) )
                  .setResourceType(ResourceType.DRL)
                  .setSourcePath("src/main/resources/r1.txt") );
        ks.newKieBuilder( kfs ).buildAll();

        KieSession ksession = ks.newKieContainer(ks.getRepository().getDefaultReleaseId()).newKieSession();
        ksession.insert(new Message("Hello World"));

        int count = ksession.fireAllRules();

        assertEquals( 1, count );
    }

Comment 1 Mario Fusco 2013-11-25 13:39:41 UTC
Fixed by https://github.com/droolsjbpm/drools/commit/de4d4a6c9

Comment 3 Tomas Schlosser 2014-01-02 13:09:48 UTC
Verified in brms 6.0.1-redhat-1


Note You need to log in before you can comment on or make changes to this bug.