1 22 package org.jboss.test.jbossmx.compliance.objectname; 23 24 import org.jboss.test.jbossmx.compliance.TestCase; 25 26 import javax.management.MalformedObjectNameException ; 27 import javax.management.ObjectName ; 28 import java.util.Hashtable ; 29 30 public class CanonicalTestCase 31 extends TestCase 32 { 33 public static final String EXPECTED_NAME = "domain:a=a,b=b,c=c,d=d,e=e"; 34 public static final String [] KVP = {"a", "b", "c", "d", "e"}; 35 36 public CanonicalTestCase(String s) 37 { 38 super(s); 39 } 40 41 public void testBasicCanonical() 42 { 43 try 44 { 45 ObjectName name = new ObjectName ("domain:e=e,b=b,d=d,c=c,a=a"); 46 assertEquals(EXPECTED_NAME, name.getCanonicalName()); 47 } 48 catch (MalformedObjectNameException e) 49 { 50 fail("spurious MalformedObjectNameException"); 51 } 52 } 53 54 public void testHashtableCanonical() 55 { 56 try 57 { 58 Hashtable h = new Hashtable (); 59 for (int i = 0; i < KVP.length; i++) 60 { 61 h.put(KVP[i], KVP[i]); 62 } 63 ObjectName name = new ObjectName ("domain", h); 64 assertEquals(EXPECTED_NAME, name.getCanonicalName()); 65 } 66 catch (MalformedObjectNameException e) 67 { 68 fail("spurious MalformedObjectNameException"); 69 } 70 } 71 72 public void testSingleKVP() 73 { 74 try 75 { 76 ObjectName name = new ObjectName ("domain", "a", "a"); 77 assertEquals("domain:a=a", name.getCanonicalName()); 78 } 79 catch (MalformedObjectNameException e) 80 { 81 fail("spurious MalformedObjectNameException"); 82 } 83 } 84 } 85 | Popular Tags |