1 22 package org.jboss.test.jbossmx.compliance.server; 23 24 import org.jboss.test.jbossmx.compliance.TestCase; 25 26 import javax.management.MBeanServer ; 27 import javax.management.MBeanServerFactory ; 28 import java.util.List ; 29 30 public class MBeanServerFactoryTestCase 31 extends TestCase 32 { 33 public MBeanServerFactoryTestCase(String s) 34 { 35 super(s); 36 } 37 38 public void testFindNonCreated() 39 { 40 MBeanServer server = MBeanServerFactory.newMBeanServer(); 41 List mbsList = MBeanServerFactory.findMBeanServer(null); 42 assertEquals(0, mbsList.size()); 43 } 44 45 public void testCreateFindAndRelease() 46 { 47 MBeanServer server = null; 48 List mbsList = null; 49 50 try 51 { 52 server = MBeanServerFactory.createMBeanServer(); 53 mbsList = MBeanServerFactory.findMBeanServer(null); 54 assertEquals(1, mbsList.size()); 55 } 56 finally 57 { 58 if (null != server) 59 { 60 MBeanServerFactory.releaseMBeanServer(server); 61 } 62 } 63 64 mbsList = MBeanServerFactory.findMBeanServer(null); 65 assertEquals(0, mbsList.size()); 66 } 67 68 public void testRemoveNonCreated() 69 { 70 try 71 { 72 MBeanServer server = MBeanServerFactory.newMBeanServer(); 73 MBeanServerFactory.releaseMBeanServer(server); 74 fail("expected an IllegalArgumentException"); 75 } 76 catch (IllegalArgumentException e) 77 { 78 } 79 catch (Exception e) 80 { 81 fail("expected an IllegalArgumentException but got: " + e.getMessage()); 82 } 83 } 84 85 public void testDomainCreated() 86 { 87 String domain = "dOmAiN"; 88 MBeanServer server = null; 89 try 90 { 91 server = MBeanServerFactory.createMBeanServer(domain); 92 assertEquals(domain, server.getDefaultDomain()); 93 List mbsList = MBeanServerFactory.findMBeanServer(null); 94 assertEquals(server, mbsList.get(0)); 95 assertTrue("expected server reference equality", mbsList.get(0) == server); 96 } 97 finally 98 { 99 if (null != server) 100 { 101 MBeanServerFactory.releaseMBeanServer(server); 102 } 103 } 104 } 105 106 public void testDomainNonCreated() 107 { 108 String domain = "dOmAiN"; 109 MBeanServer server = MBeanServerFactory.newMBeanServer(domain); 110 assertEquals(domain, server.getDefaultDomain()); 111 } 112 113 public void testFindByAgentID() 114 { 115 } 117 118 } 119 | Popular Tags |