001: /*
002: * Copyright (C) The MX4J Contributors.
003: * All rights reserved.
004: *
005: * This software is distributed under the terms of the MX4J License version 1.0.
006: * See the terms of the MX4J License in the documentation provided with this software.
007: */
008:
009: package test.javax.management.remote.rmi;
010:
011: import java.net.MalformedURLException;
012: import java.util.Map;
013: import javax.management.remote.JMXConnectorServer;
014: import javax.management.remote.JMXConnectorServerFactory;
015: import javax.management.remote.JMXServiceURL;
016: import javax.management.remote.rmi.RMIConnectorServer;
017:
018: import test.javax.management.remote.JMXConnectorServerTestCase;
019:
020: /**
021: * @version $Revision: 1.8 $
022: */
023: public abstract class RMIConnectorServerTestCase extends
024: JMXConnectorServerTestCase implements RMITestCase {
025: public RMIConnectorServerTestCase(String s) {
026: super (s);
027: }
028:
029: public void testNewRMIConnectorServerNullURL() throws Exception {
030: try {
031: new RMIConnectorServer(null, null);
032: fail();
033: } catch (IllegalArgumentException x) {
034: }
035: }
036:
037: public void testNewRMIConnectorServerNullEnvironment()
038: throws Exception {
039: JMXServiceURL url = createJMXConnectorServerAddress();
040: JMXConnectorServer server = new RMIConnectorServer(url, null,
041: newMBeanServer());
042: try {
043: server.start();
044: } finally {
045: server.stop();
046: }
047: }
048:
049: public void testNewRMIConnectorServerWithFactoryWrongClassLoader()
050: throws Exception {
051: JMXServiceURL url = createJMXConnectorServerAddress();
052: Map env = getEnvironment();
053: env.put(JMXConnectorServerFactory.DEFAULT_CLASS_LOADER,
054: new Object());
055: try {
056: JMXConnectorServerFactory.newJMXConnectorServer(url, env,
057: null);
058: fail();
059: } catch (IllegalArgumentException x) {
060: }
061: }
062:
063: public void testNewRMIConnectorServerWithFactoryWrongClassLoaderName()
064: throws Exception {
065: JMXServiceURL url = createJMXConnectorServerAddress();
066: Map env = getEnvironment();
067: env.put(JMXConnectorServerFactory.DEFAULT_CLASS_LOADER_NAME,
068: new Object());
069: try {
070: JMXConnectorServerFactory.newJMXConnectorServer(url, env,
071: null);
072: fail();
073: } catch (IllegalArgumentException x) {
074: }
075: }
076:
077: public void testJNDIBindWithWrongPath1() throws Exception {
078: JMXServiceURL temp = createJMXConnectorServerAddress();
079: JMXServiceURL url = new JMXServiceURL(temp.getProtocol(), temp
080: .getHost(), temp.getPort(), "/jndi");
081: JMXConnectorServer cntorServer = JMXConnectorServerFactory
082: .newJMXConnectorServer(url, getEnvironment(),
083: newMBeanServer());
084: try {
085: cntorServer.start();
086: fail();
087: } catch (MalformedURLException x) {
088: }
089: }
090:
091: public void testJNDIBindWithWrongPath2() throws Exception {
092: JMXServiceURL temp = createJMXConnectorServerAddress();
093: JMXServiceURL url = new JMXServiceURL(temp.getProtocol(), temp
094: .getHost(), temp.getPort(), "/jndi");
095: JMXConnectorServer cntorServer = JMXConnectorServerFactory
096: .newJMXConnectorServer(url, getEnvironment(),
097: newMBeanServer());
098: try {
099: cntorServer.start();
100: fail();
101: } catch (MalformedURLException x) {
102: }
103: }
104:
105: public void testJNDIBindWithRelativePath() throws Exception {
106: JMXConnectorServer cntorServer = null;
107: try {
108: startNaming();
109:
110: JMXServiceURL temp = createJMXConnectorServerAddress();
111: JMXServiceURL url = new JMXServiceURL(temp.getProtocol(),
112: temp.getHost(), temp.getPort(), "/jndi/jmx");
113: cntorServer = JMXConnectorServerFactory
114: .newJMXConnectorServer(url, getEnvironment(),
115: newMBeanServer());
116: cntorServer.start();
117: } finally {
118: if (cntorServer != null)
119: cntorServer.stop();
120: stopNaming();
121: }
122: }
123:
124: public void testJNDIBindWithAbsolutePath() throws Exception {
125: JMXConnectorServer cntorServer = null;
126: try {
127: startNaming();
128:
129: JMXServiceURL temp = createJMXConnectorServerAddress();
130: JMXServiceURL url = new JMXServiceURL(temp.getProtocol(),
131: temp.getHost(), temp.getPort(), "/jndi/"
132: + temp.getProtocol() + "://localhost:"
133: + getNamingPort() + "/jmx");
134: cntorServer = JMXConnectorServerFactory
135: .newJMXConnectorServer(url, getEnvironment(),
136: newMBeanServer());
137: cntorServer.start();
138: } finally {
139: if (cntorServer != null)
140: cntorServer.stop();
141: stopNaming();
142: }
143: }
144: }
|