1 // Tags: JDK1.5 |
|
2 // Uses: BadGuy |
|
3 |
|
4 // Copyright (C) 2006 Andrew John Hughes <gnu_andrew@member.fsf.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.lang.management; |
|
24 |
|
25 import gnu.testlet.TestHarness; |
|
26 import gnu.testlet.Testlet; |
|
27 |
|
28 import java.lang.management.ClassLoadingMXBean; |
|
29 import java.lang.management.ManagementFactory; |
|
30 |
|
31 /** |
|
32 * Gets hold of a class loading management bean from the |
|
33 * @link{java.lang.management.ManagementFactory} and |
|
34 * test its security. |
|
35 * |
|
36 * @author <a href="mailto:gnu_andrew@member.fsf.org">Andrew John Hughes</a> |
|
37 */ |
|
38 public class ClassLoadingMXBeanTest |
|
39 implements Testlet |
|
40 { |
|
41 |
|
42 private BadGuy bg = new BadGuy(); |
|
43 |
|
44 public void test(TestHarness h) |
|
45 { |
|
46 try |
|
47 { |
|
48 Exception caught = null; |
|
49 ClassLoadingMXBean bean = ManagementFactory.getClassLoadingMXBean(); |
|
50 |
|
51 bg.install(); |
|
52 |
|
53 // Check getName |
|
54 caught = null; |
|
55 try |
|
56 { |
|
57 bean.setVerbose(true); |
|
58 } |
|
59 catch (Exception ex) |
|
60 { |
|
61 caught = ex; |
|
62 } |
|
63 h.check(caught instanceof SecurityException, "verbose"); |
|
64 |
|
65 } |
|
66 finally |
|
67 { |
|
68 bg.uninstall(); |
|
69 } |
|
70 } |
|
71 |
|
72 } |
|
73 |
|