tests/libjava-mauve/src/gnu/testlet/java/security/BasicPermission/newPermission.java
branchjk_new_structure
changeset 1541 75c2e24dea9a
parent 1540 92ac284961c1
child 1542 be11db817bcf
equal deleted inserted replaced
1540:92ac284961c1 1541:75c2e24dea9a
     1 // Tags: JDK1.2
       
     2 
       
     3 // Copyright (C) 2006 Free Software Foundation
       
     4 // Contributed by Mark Wielaard (mark@klomp.org)
       
     5 
       
     6 // This file is part of Mauve.
       
     7 
       
     8 // Mauve is free software; you can redistribute it and/or modify
       
     9 // it under the terms of the GNU General Public License as published by
       
    10 // the Free Software Foundation; either version 2, or (at your option)
       
    11 // any later version.
       
    12 
       
    13 // Mauve is distributed in the hope that it will be useful,
       
    14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    16 // GNU General Public License for more details.
       
    17 
       
    18 // You should have received a copy of the GNU General Public License
       
    19 // along with Mauve; see the file COPYING.  If not, write to
       
    20 // the Free Software Foundation, 59 Temple Place - Suite 330,
       
    21 // Boston, MA 02111-1307, USA.  */
       
    22 
       
    23 package gnu.testlet.java.security.BasicPermission;
       
    24 
       
    25 import gnu.testlet.Testlet;
       
    26 import gnu.testlet.TestHarness;
       
    27 
       
    28 import java.security.*;
       
    29 
       
    30 public class newPermission extends BasicPermission implements Testlet
       
    31 {
       
    32   public void test (TestHarness harness)
       
    33   {
       
    34     Permission p;
       
    35     p = new newPermission("a");
       
    36     harness.check("a", p.getName());
       
    37     p = new newPermission("a", "b");
       
    38     harness.check("a", p.getName());
       
    39     harness.check("b", p.getActions());
       
    40 
       
    41     boolean exception_thrown;
       
    42     try
       
    43       {
       
    44 	p = new newPermission("");
       
    45 	exception_thrown = false;
       
    46       }
       
    47     catch (IllegalArgumentException iae)
       
    48       {
       
    49 	exception_thrown = true;
       
    50       }
       
    51     harness.check(exception_thrown);
       
    52 
       
    53     try
       
    54       {
       
    55 	p = new newPermission(null);
       
    56 	exception_thrown = false;
       
    57       }
       
    58     catch (NullPointerException npe)
       
    59       {
       
    60 	exception_thrown = true;
       
    61       }
       
    62     harness.check(exception_thrown);
       
    63 
       
    64     try
       
    65       {
       
    66 	p = new newPermission("", "");
       
    67 	exception_thrown = false;
       
    68       }
       
    69     catch (IllegalArgumentException iae)
       
    70       {
       
    71 	exception_thrown = true;
       
    72       }
       
    73     harness.check(exception_thrown);
       
    74 
       
    75     try
       
    76       {
       
    77 	p = new newPermission(null, "");
       
    78 	exception_thrown = false;
       
    79       }
       
    80     catch (NullPointerException npe)
       
    81       {
       
    82 	exception_thrown = true;
       
    83       }
       
    84     harness.check(exception_thrown);
       
    85 
       
    86     try
       
    87       {
       
    88 	p = new newPermission(null, null);
       
    89 	exception_thrown = false;
       
    90       }
       
    91     catch (NullPointerException npe)
       
    92       {
       
    93 	exception_thrown = true;
       
    94       }
       
    95     harness.check(exception_thrown);
       
    96   }
       
    97 
       
    98   private String actions;
       
    99   public newPermission() { super("newPermission"); }
       
   100   public newPermission(String n) { super(n); }
       
   101   public newPermission(String n, String a) { super(n, a); this.actions = a; }
       
   102 
       
   103   public String getActions()
       
   104   {
       
   105     // BasicPermission.getActions() should return the empty string.
       
   106     return super.getActions() + actions;
       
   107   }
       
   108 }