1 8 9 package test.javax.management.remote.rmi; 10 11 import javax.management.MBeanServerConnection ; 12 import javax.management.remote.JMXConnector ; 13 import javax.management.remote.JMXConnectorFactory ; 14 import javax.management.remote.JMXConnectorServer ; 15 import javax.management.remote.JMXConnectorServerFactory ; 16 import javax.management.remote.JMXServiceURL ; 17 import javax.management.remote.rmi.RMIConnector ; 18 import javax.management.remote.rmi.RMIServer ; 19 20 import test.javax.management.remote.JMXConnectorTestCase; 21 22 25 public abstract class RMIConnectorTestCase extends JMXConnectorTestCase implements RMITestCase 26 { 27 public RMIConnectorTestCase(String s) 28 { 29 super(s); 30 } 31 32 public void testNewRMIConnectorNullURL() throws Exception 33 { 34 try 35 { 36 new RMIConnector ((JMXServiceURL )null, null); 37 fail(); 38 } 39 catch (IllegalArgumentException x) 40 { 41 } 42 } 43 44 public void testNewRMIConnectorNullRMIServer() throws Exception 45 { 46 try 47 { 48 new RMIConnector ((RMIServer )null, null); 49 fail(); 50 } 51 catch (IllegalArgumentException x) 52 { 53 } 54 } 55 56 public void testJNDILookupWithRelativePath() throws Exception 57 { 58 JMXConnectorServer cntorServer = null; 59 JMXConnector cntor = null; 60 try 61 { 62 startNaming(); 63 64 JMXServiceURL url = createJMXConnectorServerAddress(); 65 url = new JMXServiceURL (url.getProtocol(), url.getHost(), url.getPort(), "/jndi/jmx"); 66 cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, getEnvironment(), newMBeanServer()); 67 cntorServer.start(); 68 69 cntor = JMXConnectorFactory.connect(cntorServer.getAddress(), getEnvironment()); 70 MBeanServerConnection mbsc = cntor.getMBeanServerConnection(); 71 mbsc.getDefaultDomain(); 72 } 73 finally 74 { 75 if (cntor != null) cntor.close(); 76 if (cntorServer != null) cntorServer.stop(); 77 stopNaming(); 78 } 79 } 80 81 public void testJNDILookupWithAbsolutePath() throws Exception 82 { 83 JMXConnectorServer cntorServer = null; 84 JMXConnector cntor = null; 85 try 86 { 87 startNaming(); 88 89 JMXServiceURL url = createJMXConnectorServerAddress(); 90 url = new JMXServiceURL (url.getProtocol(), url.getHost(), url.getPort(), "/jndi/" + url.getProtocol() + "://localhost:" + getNamingPort() + "/jmx"); 91 cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, getEnvironment(), newMBeanServer()); 92 cntorServer.start(); 93 94 cntor = JMXConnectorFactory.connect(cntorServer.getAddress(), getEnvironment()); 95 MBeanServerConnection mbsc = cntor.getMBeanServerConnection(); 96 mbsc.getDefaultDomain(); 97 } 98 finally 99 { 100 if (cntor != null) cntor.close(); 101 if (cntorServer != null) cntorServer.stop(); 102 stopNaming(); 103 } 104 } 105 } 106 | Popular Tags |