Package org.drools.runtime

Examples of org.drools.runtime.StatefulKnowledgeSession.dispose()


        assertTrue(queryResults.size() == 1);
        assertTrue(queryResults.iterator().next().get("$strings").equals("Some String"));


        ksession.dispose();
    }
   
}
View Full Code Here


            fail("The agent should failed");
        } catch (IllegalStateException ex){
        }

        //We need to dispose the ksession first
        ksession.dispose();

        //Now it is safe to dispose the kagent
        kagent.dispose();

        //the dsrl file is modified
View Full Code Here

        this.fileManager.write("rules.dslr", this.createCommonDSLRRule("Rule3"));

        this.scan(kagent);
       
        //we want to use a new ksession.
        ksession.dispose();
        ksession = kbase.newStatefulKnowledgeSession();

        //insert John
        list.clear();
        ksession.setGlobal("list", list);
View Full Code Here

            fail( "Knowledge should fail to compile" );
        } catch (Exception e) {
           
        }

        ksession.dispose();
        kagent.dispose();
    }

    @Test
    public void testDSLAndNewInstance() throws Exception {
View Full Code Here

        //The rule should be fired
        assertEquals(1, list.size());
        assertTrue(list.contains("Rule1"));
        list.clear();

        ksession.dispose();

        //Let's modify the dsl file
        File expander = this.fileManager.write("myExpander.dsl", this.createCommonDSL("name == \"John\""));

        //We also need to mark the dslr file as modified, so the rules could
View Full Code Here

        ksession.fireAllRules();

        assertEquals(1, list.size());
        assertTrue(list.contains("Rule1"));

        ksession.dispose();

        //Let's add a new Rule
        this.fileManager.write("rules.dslr", this.createCommonDSLRRule(new String[]{"Rule1","Rule2"}));

        this.scan(kagent);
View Full Code Here

        assertEquals(2, list.size());
        assertTrue(list.contains("Rule1"));
        assertTrue(list.contains("Rule2"));

        ksession.dispose();

        //Let's remove both rules and add a new one: Rule3
        this.fileManager.write("rules.dslr", this.createCommonDSLRRule("Rule3"));

        this.scan(kagent);
View Full Code Here

        ksession.fireAllRules();

        assertEquals(1, list.size());
        assertTrue(list.contains("Rule3"));

        ksession.dispose();

        //let's delete the dsl file (errors are expected)
        fileManager.deleteFile(expander);

        this.fileManager.write("rules.dslr", this.createCommonDSLRRule("Rule1"));
View Full Code Here

        assertEquals( 1,
                      list.size() );

        assertTrue( list.contains( "rule3" ) );

        ksession.dispose();
        kagent.dispose();
    }

   
}
View Full Code Here

        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
        List list = new ArrayList();
        ksession.setGlobal( "list",
                            list );
        ksession.fireAllRules();
        ksession.dispose();

        assertEquals( 2,
                      list.size() );
        assertTrue( list.containsAll( Arrays.asList( new String[]{"rule1", "rule2"} ) ) );
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.