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 ); }
Fixed by https://github.com/droolsjbpm/drools/commit/de4d4a6c9
Verified in brms 6.0.1-redhat-1