//package Rules.fixture;
//
//import java.io.File;
//import java.io.FileInputStream;
//import java.io.InputStream;
//import java.io.InputStreamReader;
//import java.net.URL;
//import java.util.Iterator;
//import java.util.LinkedList;
//import java.util.List;
//
//import org.drools.RuleBase;
//import org.drools.RuleBaseFactory;
//import org.drools.WorkingMemory;
//import org.drools.compiler.PackageBuilder;
//import org.drools.rule.Package;
//
//import fit.Parse;
//
///**
// * A fixture for testing Drools rule packages using the native API.
// * @author Michael Neale
// */
//public class Drools extends AbstractRulesTestingFixture {
//
//	
//	List objects;
//	RuleBase ruleBase;
//	
//	public Drools() {
//		objects = new LinkedList();
//	}
//	
//	/**
//	 * Only expectation on this usage is that "Execute" is called last, that is the instruction
//	 * for the rules engine to light the fires and kick the tyres.
//	 * (Yes I think that is backwards, but I was 30 before I got around to seeing Top Gun).
//	 */
//	void processRow(Parse cell) {
//		if (cell.text().equalsIgnoreCase("Execute")) {
//			executeRulesEngine();
//		} else if (cell.text().equalsIgnoreCase("Assert") 
//				|| cell.text().equalsIgnoreCase("Insert")) {
//			addDomainObjects(cell.more.text());			
//		} else if (cell.text().equalsIgnoreCase("Ruleset") 
//				|| cell.text().equalsIgnoreCase("Package")) {
//			try {
//				loadPackage(cell.more.text());
//			} catch (Exception e) {
//				super.exception(cell, e);
//			}
//		}
//	}
//
////	private void addDomainObjects(Parse cell) {
////		if (cell.more.text().equalsIgnoreCase("all")) {
////			for (Iterator iter = getDomainObjects().all().iterator(); iter.hasNext();) {
////				objects.add(iter.next());				
////			} 
////		} else {
////			objects.add(getDomainObjects().getObject(cell.more.text()));
////		}
////	}
//	
//	void addDomainObjects(String more) {
//	if (more.equalsIgnoreCase("all")) {
//		for (Iterator iter = getDomainObjects().all().iterator(); iter.hasNext();) {
//			objects.add(iter.next());				
//		} 
//	} else {
//		objects.add(getDomainObjects().getObject(more));
//	}
//}
//	
//	void loadPackage(String uri) throws Exception {		
//		InputStream stream = this.getClass().getResourceAsStream(uri);
//		if (stream == null) {
//			File file = new File(uri);
//			if (file.exists())
//			stream = new FileInputStream(file);
//		}
//		if (stream == null) {
//			URL url = new URL(uri);
//			stream = url.openStream();
//		}
//		
//		PackageBuilder builder = new PackageBuilder();
//		builder.addPackageFromDrl(new InputStreamReader(stream));
//		Package pkg = builder.getPackage();
//		this.ruleBase = RuleBaseFactory.newRuleBase();
//		this.ruleBase.addPackage(pkg);		
//	}
//	
//	void executeRulesEngine() {
//		WorkingMemory wm = this.ruleBase.newWorkingMemory();
//		for (Iterator iter = this.objects.iterator(); iter.hasNext();) {
//			wm.assertObject(iter.next());			
//		}
//		wm.fireAllRules();
//	}
//
//}
