import java.io.*; import java.util.*; import net.deterlab.abac.*; import net.deterlab.abac.regression.*; /** * Simple test of the native Java implementation of ABAC. Loads credentials * from an rt0 file and runs a query against them. */ public class Regression { static RegressionTest[] tests = new RegressionTest[] { new WriteCreds("net.deterlab.abac.GENICredential"), new WriteCreds("net.deterlab.abac.X509Credential"), }; public static void fatal(String s) { if (s != null ) System.err.println(s); System.exit(20); } public static boolean clearDir(File d) { for (String fn: d.list() ) { File f = new File(d, fn); if ( f.isDirectory() ) if ( !clearDir(f) ) return false; if ( !f.delete() ) return false; } return true; } public static void main(String[] args) throws IOException { if (args.length < 2 ) fatal("Usage Regression regression_data_dir scratch"); File data = new File(args[0]); File scratch = new File(args[1]); if ( !data.isDirectory() ) fatal(data + " is not a directory"); if ( !scratch.isDirectory() ) fatal(scratch + " is not a directory"); for (RegressionTest test: tests) { if (!clearDir(scratch) ) fatal("Could not clear " + scratch); if ( test.runTest(data, scratch)) System.out.println(test.getName() + " Passed."); else fatal(test.getName() + " Failed: " + test.getReason()); } System.exit(0); } }