1 // Tags: JDK1.4 |
|
2 // Uses: TestHandler TestSecurityManager |
|
3 |
|
4 // Copyright (C) 2004 Sascha Brawer <brawer@dandelis.ch> |
|
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.util.logging.Handler; |
|
24 |
|
25 import gnu.testlet.Testlet; |
|
26 import gnu.testlet.TestHarness; |
|
27 |
|
28 import java.util.logging.Level; |
|
29 |
|
30 |
|
31 /** |
|
32 * @author <a href="mailto:brawer@dandelis.ch">Sascha Brawer</a> |
|
33 */ |
|
34 public class setLevel |
|
35 implements Testlet |
|
36 { |
|
37 TestSecurityManager sec = new TestSecurityManager(); |
|
38 TestHandler handler = new TestHandler(); |
|
39 |
|
40 public void test(TestHarness th) |
|
41 { |
|
42 Throwable caught; |
|
43 |
|
44 sec.install(); |
|
45 try |
|
46 { |
|
47 // Check #1. |
|
48 sec.setGrantLoggingControl(false); |
|
49 th.check(handler.getLevel(), Level.ALL); |
|
50 |
|
51 // Check #2. |
|
52 sec.setGrantLoggingControl(false); |
|
53 caught = null; |
|
54 try |
|
55 { |
|
56 handler.setLevel(Level.INFO); |
|
57 } |
|
58 catch (Exception ex) |
|
59 { |
|
60 caught = ex; |
|
61 } |
|
62 th.check(caught instanceof SecurityException); |
|
63 |
|
64 // Check #3. |
|
65 sec.setGrantLoggingControl(true); |
|
66 handler.setLevel(Level.FINEST); |
|
67 th.check(handler.getLevel(), Level.FINEST); |
|
68 |
|
69 // Check #4: setLevel(null). |
|
70 sec.setGrantLoggingControl(true); |
|
71 caught = null; |
|
72 try |
|
73 { |
|
74 handler.setLevel(null); |
|
75 } |
|
76 catch (Exception ex) |
|
77 { |
|
78 caught = ex; |
|
79 } |
|
80 th.check(caught instanceof NullPointerException); |
|
81 } |
|
82 finally |
|
83 { |
|
84 sec.uninstall(); |
|
85 } |
|
86 } |
|
87 } |
|