source: java/Regression.java @ bd24a1a

abac0-leakabac0-meimei-idmei-rt0-nmei_rt0tvf-new-xml
Last change on this file since bd24a1a was 8375d4f, checked in by Ted Faber <faber@…>, 11 years ago

Regression test framework

  • Property mode set to 100644
File size: 1.3 KB
Line 
1import java.io.*;
2import java.util.*;
3
4import net.deterlab.abac.*;
5import net.deterlab.abac.regression.*;
6
7
8/**
9 * Simple test of the native Java implementation of ABAC. Loads credentials
10 * from an rt0 file and runs a query against them.
11 */
12public class Regression {
13
14    static RegressionTest[] tests = new RegressionTest[] {
15        new GENIWriteCreds(),
16    };
17
18    public static void fatal(String s) {
19        if (s != null ) 
20            System.err.println(s);
21        System.exit(20);
22    }
23
24    public static boolean clearDir(File d) {
25        for (String fn: d.list() ) {
26            File f = new File(d, fn);
27
28            if ( f.isDirectory() ) 
29                if ( !clearDir(f) ) return false;
30            if ( !f.delete() ) return false;
31        }
32        return true;
33    }
34
35
36    public static void main(String[] args) throws IOException {
37        if (args.length < 2 ) 
38            fatal("Usage Regression regression_data_dir scratch");
39
40        File data = new File(args[0]);
41        File scratch = new File(args[1]);
42
43        if ( !data.isDirectory() ) 
44            fatal(data + " is not a directory");
45        if ( !scratch.isDirectory() ) 
46            fatal(scratch + " is not a directory");
47
48        for (RegressionTest test: tests) {
49            if (!clearDir(scratch) ) 
50                fatal("Could not clear " + scratch);
51
52            if ( test.runTest(data, scratch)) 
53                System.out.println(test.getName() + " Passed.");
54            else 
55                fatal(test.getName() + " Failed: " + test.getReason());
56        }
57        System.exit(0);
58    }
59}
Note: See TracBrowser for help on using the repository browser.