01: package org.drools.agent;
02:
03: import java.io.File;
04: import java.util.Properties;
05:
06: import org.drools.RuleBase;
07: import org.drools.RuleBaseFactory;
08: import org.drools.rule.Package;
09:
10: import junit.framework.TestCase;
11:
12: public class DirectoryScannerTest extends TestCase {
13:
14: public void testScan() throws Exception {
15: File dir = RuleBaseAssemblerTest.getTempDirectory();
16:
17: Package p1 = new Package("p1");
18: Package p2 = new Package("p2");
19: File p1f = new File(dir, "p1.pkg");
20: File p2f = new File(dir, "p2.pkg");
21:
22: RuleBaseAssemblerTest.writePackage(p1, p1f);
23: RuleBaseAssemblerTest.writePackage(p2, p2f);
24:
25: DirectoryScanner scan = new DirectoryScanner();
26: scan.listener = new MockListener();
27: Properties props = new Properties();
28: props.setProperty(RuleAgent.DIRECTORY, dir.getPath());
29:
30: scan.configure(props);
31:
32: RuleBase rb = RuleBaseFactory.newRuleBase();
33: PackageProvider.applyChanges(rb, true, scan
34: .loadPackageChanges(), new MockListener());
35:
36: assertEquals(2, rb.getPackages().length);
37:
38: Package p3 = new Package("p3");
39: File p3f = new File(dir, "p3.pkg");
40:
41: RuleBaseAssemblerTest.writePackage(p3, p3f);
42:
43: PackageProvider.applyChanges(rb, true, scan
44: .loadPackageChanges(), new MockListener());
45:
46: assertEquals(3, rb.getPackages().length);
47: }
48:
49: }
|