001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)TestJMXConnectionProperties.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.ui.client;
030:
031: import java.util.ArrayList;
032: import java.util.Iterator;
033: import java.util.List;
034: import junit.framework.TestCase;
035:
036: /**
037: * test class
038: * @author Sun Microsystems, Inc.
039: */
040: public class TestJMXConnectionProperties extends TestCase {
041:
042: /**
043: * Creates a new instance of TestMgmtMessage
044: * @param aTestName name
045: */
046: public TestJMXConnectionProperties(String aTestName) {
047: super (aTestName);
048: }
049:
050: /**
051: * test sucess msg
052: * @throws Exception on error
053: */
054: public void testConnectionURL() throws Exception {
055: String defURL = JMXConnectionProperties.getInstance()
056: .getConnectionURL();
057:
058: /*
059: if ( "service:jmx:jmxmp://localhost:5555".equals(defURL) ) {
060: System.out.println("Default URL: " + defURL);
061: } else {
062: throw new Exception ("In correct Default URL " + defURL );
063: }
064: */
065: if ("service:jmx:rmi:///jndi/rmi://localhost:8686/management/rmi-jmx-connector"
066: .equals(defURL)) {
067: System.out.println("Default URL: " + defURL);
068: } else {
069: throw new Exception("In correct Default URL " + defURL);
070: }
071:
072: String customURL = JMXConnectionProperties.getInstance()
073: .getConnectionURL("myhost", "7777");
074:
075: if ("service:jmx:rmi:///jndi/rmi://myhost:7777/management/rmi-jmx-connector"
076: .equals(customURL)) {
077: System.out.println("Custom URL: " + customURL);
078: } else {
079: throw new Exception("In Correct Custom URL " + customURL);
080: }
081:
082: /*
083: String customURL =
084: JMXConnectionProperties.getInstance().getConnectionURL("myhost", "7777");
085:
086: if ( "service:jmx:jmxmp://myhost:7777".equals(customURL) ) {
087: System.out.println("Custom URL: " + customURL);
088: } else {
089: throw new Exception ("In Correct Custom URL " + customURL );
090: }
091: */
092:
093: /*
094: System.setProperty("com.sun.jbi.tools.remote.jmx.host","syshost");
095: System.setProperty("com.sun.jbi.tools.remote.jmx.port","8888");
096: System.setProperty("com.sun.jbi.tools.remote.jmx.url.property",
097: "com.sun.jbi.tools.remote.jmx.url.jmxrmi");
098:
099: String sysHost = JMXConnectionProperties.getInstance().getHost();
100: String sysPort = JMXConnectionProperties.getInstance().getPort();
101: String sysURL =
102: JMXConnectionProperties.getInstance().getConnectionURL(sysHost, sysPort);
103:
104: if ( "service:jmx:rmi:///jndi/rmi://syshost:8888/management/rmi-jmx-connector"
105: .equals(sysURL) ) {
106: System.out.println("System URL: " + sysURL);
107: } else {
108: throw new Exception ("In Correct System URL " + sysURL );
109: }
110: */
111:
112: }
113:
114: /**
115: * main
116: * @param args the command line arguments
117: */
118: public static void main(String[] args) {
119: // TODO code application logic here
120: try {
121: new TestJMXConnectionProperties("test").testConnectionURL();
122: } catch (Exception ex) {
123: ex.printStackTrace();
124: }
125: }
126: }
|