刘光辉
15 小时以前 34981c30a78e8bbd7791131059a9210f9928b62c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package jnpf.audit.sdk;
 
/** Source-scope acceptance matrix; runnable without a test framework. */
public final class AuditRequestScopeFilterChecks {
 
    private AuditRequestScopeFilterChecks() {
    }
 
    public static void main(String[] args) {
        AuditRequestScopeFilter limsFrontend = new AuditRequestScopeFilter(true, "LIMS");
        check("FRONTEND + LIMS", limsFrontend.accepts("FRONTEND", "LIMS"));
        check("case-insensitive app code", limsFrontend.accepts("frontend", "lims"));
        check("BACKEND rejected", !limsFrontend.accepts("BACKEND", "LIMS"));
        check("CONSOLE rejected", !limsFrontend.accepts("CONSOLE", "LIMS"));
        check("missing scope rejected", !limsFrontend.accepts(null, "LIMS"));
        check("other app rejected", !limsFrontend.accepts("FRONTEND", "ELN"));
 
        AuditRequestScopeFilter unrestricted = new AuditRequestScopeFilter(false, "");
        check("disabled filter remains backward compatible", unrestricted.accepts(null, null));
        System.out.println("AuditRequestScopeFilterChecks: all checks passed");
    }
 
    private static void check(String name, boolean condition) {
        if (!condition) {
            throw new AssertionError(name);
        }
    }
}