KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > compliance > security > MBeanServerPermissionTestCase


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7
8 package test.compliance.security;
9
10 import java.security.PermissionCollection;
11 import javax.management.InstanceAlreadyExistsException;
12 import javax.management.InstanceNotFoundException;
13 import javax.management.MBeanServer;
14 import javax.management.MBeanServerFactory;
15 import javax.management.ObjectName;
16 import javax.management.MBeanServerPermission;
17 import javax.management.relation.RelationService;
18
19 import junit.framework.TestCase;
20 import test.compliance.server.support.Broadcaster;
21 import test.compliance.server.support.Test;
22
23 /** Tests of the javax.management.MBeanServerPermission
24  *
25  * @author Scott.Stark@jboss.org
26  * @version $Revision: 1.1 $
27  */

28 public class MBeanServerPermissionTestCase
29   extends TestCase
30 {
31    public MBeanServerPermissionTestCase(String s)
32    {
33       super(s);
34    }
35
36    public void testMBeanServerPermission()
37    {
38       MBeanServerPermission p0 = new MBeanServerPermission("newMBeanServer");
39       MBeanServerPermission p1 = new MBeanServerPermission("createMBeanServer");
40       assertTrue("createMBeanServer implies newMBeanServer", p1.implies(p0));
41       assertTrue("createMBeanServer implies newMBeanServer", p0.implies(p1));
42
43       PermissionCollection pc = p0.newPermissionCollection();
44       pc.add(p0);
45       assertTrue("PC(newMBeanServer) implies createMBeanServer", pc.implies(p1));
46    }
47 }
48
Popular Tags