1 8 9 package test.javax.management.remote.rmi; 10 11 import java.net.MalformedURLException ; 12 import java.util.Map ; 13 import javax.management.remote.JMXConnectorServer ; 14 import javax.management.remote.JMXConnectorServerFactory ; 15 import javax.management.remote.JMXServiceURL ; 16 import javax.management.remote.rmi.RMIConnectorServer ; 17 18 import test.javax.management.remote.JMXConnectorServerTestCase; 19 20 23 public abstract class RMIConnectorServerTestCase extends JMXConnectorServerTestCase implements RMITestCase 24 { 25 public RMIConnectorServerTestCase(String s) 26 { 27 super(s); 28 } 29 30 public void testNewRMIConnectorServerNullURL() throws Exception 31 { 32 try 33 { 34 new RMIConnectorServer (null, null); 35 fail(); 36 } 37 catch (IllegalArgumentException x) 38 { 39 } 40 } 41 42 public void testNewRMIConnectorServerNullEnvironment() throws Exception 43 { 44 JMXServiceURL url = createJMXConnectorServerAddress(); 45 JMXConnectorServer server = new RMIConnectorServer (url, null, newMBeanServer()); 46 try 47 { 48 server.start(); 49 } 50 finally 51 { 52 server.stop(); 53 } 54 } 55 56 public void testNewRMIConnectorServerWithFactoryWrongClassLoader() throws Exception 57 { 58 JMXServiceURL url = createJMXConnectorServerAddress(); 59 Map env = getEnvironment(); 60 env.put(JMXConnectorServerFactory.DEFAULT_CLASS_LOADER, new Object ()); 61 try 62 { 63 JMXConnectorServerFactory.newJMXConnectorServer(url, env, null); 64 fail(); 65 } 66 catch (IllegalArgumentException x) 67 { 68 } 69 } 70 71 public void testNewRMIConnectorServerWithFactoryWrongClassLoaderName() throws Exception 72 { 73 JMXServiceURL url = createJMXConnectorServerAddress(); 74 Map env = getEnvironment(); 75 env.put(JMXConnectorServerFactory.DEFAULT_CLASS_LOADER_NAME, new Object ()); 76 try 77 { 78 JMXConnectorServerFactory.newJMXConnectorServer(url, env, null); 79 fail(); 80 } 81 catch (IllegalArgumentException x) 82 { 83 } 84 } 85 86 public void testJNDIBindWithWrongPath1() throws Exception 87 { 88 JMXServiceURL temp = createJMXConnectorServerAddress(); 89 JMXServiceURL url = new JMXServiceURL (temp.getProtocol(), temp.getHost(), temp.getPort(), "/jndi"); 90 JMXConnectorServer cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, getEnvironment(), newMBeanServer()); 91 try 92 { 93 cntorServer.start(); 94 fail(); 95 } 96 catch (MalformedURLException x) 97 { 98 } 99 } 100 101 public void testJNDIBindWithWrongPath2() throws Exception 102 { 103 JMXServiceURL temp = createJMXConnectorServerAddress(); 104 JMXServiceURL url = new JMXServiceURL (temp.getProtocol(), temp.getHost(), temp.getPort(), "/jndi"); 105 JMXConnectorServer cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, getEnvironment(), newMBeanServer()); 106 try 107 { 108 cntorServer.start(); 109 fail(); 110 } 111 catch (MalformedURLException x) 112 { 113 } 114 } 115 116 public void testJNDIBindWithRelativePath() throws Exception 117 { 118 JMXConnectorServer cntorServer = null; 119 try 120 { 121 startNaming(); 122 123 JMXServiceURL temp = createJMXConnectorServerAddress(); 124 JMXServiceURL url = new JMXServiceURL (temp.getProtocol(), temp.getHost(), temp.getPort(), "/jndi/jmx"); 125 cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, getEnvironment(), newMBeanServer()); 126 cntorServer.start(); 127 } 128 finally 129 { 130 if (cntorServer != null) cntorServer.stop(); 131 stopNaming(); 132 } 133 } 134 135 public void testJNDIBindWithAbsolutePath() throws Exception 136 { 137 JMXConnectorServer cntorServer = null; 138 try 139 { 140 startNaming(); 141 142 JMXServiceURL temp = createJMXConnectorServerAddress(); 143 JMXServiceURL url = new JMXServiceURL (temp.getProtocol(), temp.getHost(), temp.getPort(), "/jndi/" + temp.getProtocol() + "://localhost:" + getNamingPort() + "/jmx"); 144 cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, getEnvironment(), newMBeanServer()); 145 cntorServer.start(); 146 } 147 finally 148 { 149 if (cntorServer != null) cntorServer.stop(); 150 stopNaming(); 151 } 152 } 153 } 154 | Popular Tags |