source: java/Regression.java @ 343b9e3

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

Read check

  • Property mode set to 100644
File size: 1.6 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 WriteCreds("net.deterlab.abac.GENICredential"),
16        new WriteCreds("net.deterlab.abac.X509Credential"),
17        new ReadCreds("e0-check-geni.xml", "Acme-check-geni.pem", 1),
18        new ReadCreds("e0-check-x509.der", "Acme-check-x509.pem", 1),
19        new ReadCreds("priv.xml", "issuer.pem", 6),
20    };
21
22    public static void fatal(String s) {
23        if (s != null ) 
24            System.out.println(s);
25        System.exit(20);
26    }
27
28    public static boolean clearDir(File d) {
29        for (String fn: d.list() ) {
30            File f = new File(d, fn);
31
32            if ( f.isDirectory() ) 
33                if ( !clearDir(f) ) return false;
34            if ( !f.delete() ) return false;
35        }
36        return true;
37    }
38
39
40    public static void main(String[] args) throws IOException {
41        if (args.length < 2 ) 
42            fatal("Usage Regression regression_data_dir scratch");
43
44        File data = new File(args[0]);
45        File scratch = new File(args[1]);
46
47        if ( !data.isDirectory() ) 
48            fatal(data + " is not a directory");
49        if ( !scratch.isDirectory() ) 
50            fatal(scratch + " is not a directory");
51
52        for (RegressionTest test: tests) {
53            if (!clearDir(scratch) ) 
54                fatal("Could not clear " + scratch);
55
56            if ( test.runTest(data, scratch)) 
57                System.out.println(test.getName() + " Passed.");
58            else 
59                fatal(test.getName() + " Failed: " + test.getReason());
60        }
61        System.exit(0);
62    }
63}
Note: See TracBrowser for help on using the repository browser.