1 22 package org.jboss.test.jmx.compliance.security; 23 24 import javax.management.MBeanPermission ; 25 26 import junit.framework.TestCase; 27 28 33 public class MBeanPermissionTestCase 34 extends TestCase 35 { 36 public MBeanPermissionTestCase(String s) 37 { 38 super(s); 39 } 40 41 public void testCtor() 42 { 43 MBeanPermission p = new MBeanPermission ("*", "*"); 44 } 45 46 public void testImpiles() 47 { 48 MBeanPermission p0 = new MBeanPermission ("*", "*"); 49 MBeanPermission p1 = new MBeanPermission ("*", "*"); 50 assertTrue("* implies *", p1.implies(p0)); 51 52 p0 = new MBeanPermission ("[*:*]", "*"); 53 p1 = new MBeanPermission ("[*:*]", "*"); 54 assertTrue("[*:*] * implies [*:*] *", p1.implies(p0)); 55 56 p0 = new MBeanPermission ("*", "*"); 57 p1 = new MBeanPermission ("#", "*"); 58 assertTrue("# implies *", p1.implies(p0)); 59 60 p0 = new MBeanPermission ("*#", "*"); 61 p1 = new MBeanPermission ("*", "*"); 62 assertTrue("*# implies *", p1.implies(p0)); 63 64 p0 = new MBeanPermission ("*", "addNotificationListener"); 65 p1 = new MBeanPermission ("*", "*"); 66 assertTrue("* * implies * addNotificationListener", p1.implies(p0)); 67 68 p0 = new MBeanPermission ("*", "queryMBeans"); 69 p1 = new MBeanPermission ("*", "queryNames"); 70 assertTrue("* queryMBeans implies * queryNames", p0.implies(p1)); 71 72 p0 = new MBeanPermission ("[MyDomain:type=Product]", "getAttribute"); 73 p1 = new MBeanPermission ("test.Product#Price[MyDomain:type=Product]", "getAttribute"); 74 assertTrue(p0+" implies "+p1, p0.implies(p1)); 75 76 p0 = new MBeanPermission ("a.b.c#d[e:f=g]", "*"); 77 p1 = new MBeanPermission ("a.b.c#d[e:f=g]", "getAttribute"); 78 assertTrue(p0+" implies "+p1, p0.implies(p1)); 79 80 p0 = new MBeanPermission ("a.b.c#*[e:f=g]", "*"); 81 p1 = new MBeanPermission ("a.b.c#d[e:f=g]", "getAttribute"); 82 assertTrue(p0+" implies "+p1, p0.implies(p1)); 83 } 84 85 public void testNotImpiled() throws Exception 86 { 87 MBeanPermission p0 = new MBeanPermission ("test.Product#Price[MyDomain:type=Product]", "getAttribute"); 88 MBeanPermission p1 = new MBeanPermission ("test.Product#Cost[MyDomain:type=Product]", "getAttribute"); 89 assertTrue("!p0 implies p1", p0.implies(p1) == false); 90 91 p0 = new MBeanPermission ("a.b.c#d[e:f=g]", "*"); 92 p1 = new MBeanPermission ("a.b.c#d[e:f=g]", "getAttribute"); 93 assertTrue(p1+" ! implies "+p0, p1.implies(p0) == false); 94 } 95 } 96 | Popular Tags |