Hello,

I'm just beginning with drools.
I have a main method which starts a junit testsuite containing multiple calls 
of TestCase through loadTest Junitperf method:

BeneficiaryDroolsLayer.loadRules();
TestSuite suite = new TestSuite();
suite.addTest(BeneficiaryListTest.suite());
Test loadTest = new LoadTest(suite, 50);
Test timedTest = new TimedTest(loadTest, 100000);

Rules are loaded one time with loadRules method described in:

public class BeneficiaryDroolsLayer {

private static RuleBase businessRules;
public static void loadRules() throws Exception{
if (businessRules==null){
        businessRules = RuleBaseLoader.loadFromUrl
(BeneficiaryDroolsLayer.class.getResource(RULE_FILE));


public static WorkingMemory getWorkingMemory(int mode) throws Exception{

        try{
                loadRules();
                WorkingMemory workingMemory=businessRules.newWorkingMemory();
                if(mode==WMDEBUG)
                        workingMemory.addEventListener(new 
DebugWorkingMemoryEventListener());
                else
                        workingMemory.addEventListener(new 
DefaultWorkingMemoryEventListener());
                return workingMemory;
        }
        catch(Exception e){
                return null;
        }
}                       
        

}

BeneficiaryListTest class contains only one test method. Each call of this test 
method instanciates its working Memory in setup method:

wm=BeneficiaryDroolsLayer.getWorkingMemory(BeneficiaryDroolsLayer.WMDEFAULT);


To obtain correct results, i have to prefix my setup method and my test method 
from with synchronized.
Is-it the correct way to implement this stuff ???
Or do i use other object like SynchonizedWorkingMemory for instance ...

Thanks in adance !
Fanory.

Reply via email to