jdk/test/javax/smartcardio/TestCardPermission.java
changeset 40266 d198987d85e1
parent 40261 86a49ba76f52
child 44108 8de4ce18c36f
equal deleted inserted replaced
40265:e73a9c4ada83 40266:d198987d85e1
     1 /*
     1 /*
     2  * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 /**
    24 /**
    25  * @test
    25  * @test
    26  * @bug 6293767
    26  * @bug 6293767 6469513
    27  * @summary Test for the CardPermission class
    27  * @summary Test for the CardPermission class
    28  * @author Andreas Sterbenz
    28  * @author Andreas Sterbenz
    29  * @compile --add-modules=java.smartcardio TestCardPermission.java
    29  * @compile --add-modules=java.smartcardio TestCardPermission.java
    30  * @run main/othervm --add-modules=java.smartcardio TestCardPermission
    30  * @run main/othervm --add-modules=java.smartcardio TestCardPermission
    31  */
    31  */
    47 
    47 
    48         test("connect,reset");
    48         test("connect,reset");
    49         test("Reset,coNnect", "connect,reset");
    49         test("Reset,coNnect", "connect,reset");
    50         test("exclusive,*,connect", "*");
    50         test("exclusive,*,connect", "*");
    51         test("connect,reset,exclusive,transmitControl,getBasicChannel,openLogicalChannel", "*");
    51         test("connect,reset,exclusive,transmitControl,getBasicChannel,openLogicalChannel", "*");
       
    52         test(null, null);
    52 
    53 
    53         invalid(null);
       
    54         invalid("");
    54         invalid("");
    55         invalid("foo");
    55         invalid("foo");
    56         invalid("connect, reset");
    56         invalid("connect, reset");
    57         invalid("connect,,reset");
    57         invalid("connect,,reset");
    58         invalid("connect,");
    58         invalid("connect,");
    59         invalid(",connect");
    59         invalid(",connect");
    60         invalid("");
       
    61     }
    60     }
    62 
    61 
    63     private static void invalid(String s) throws Exception {
    62     private static void invalid(String s) throws Exception {
    64         try {
    63         try {
    65             CardPermission c = new CardPermission("*", s);
    64             CardPermission c = new CardPermission("*", s);
    75 
    74 
    76     private static void test(String actions, String canon) throws Exception {
    75     private static void test(String actions, String canon) throws Exception {
    77         CardPermission p = new CardPermission("*", actions);
    76         CardPermission p = new CardPermission("*", actions);
    78         System.out.println(p);
    77         System.out.println(p);
    79         String a = p.getActions();
    78         String a = p.getActions();
    80         if (canon.equals(a) == false) {
    79         if (canon != null && canon.equals(a) == false) {
    81             throw new Exception("Canonical actions mismatch: " + canon + " != " + a);
    80             throw new Exception("Canonical actions mismatch: " + canon + " != " + a);
    82         }
    81         }
    83     }
    82     }
    84 
    83 
    85 }
    84 }