1 23 24 29 package com.sun.enterprise.management.client; 30 31 import java.io.IOException ; 32 33 import com.sun.appserv.management.client.AppserverConnectionSource; 34 35 36 import com.sun.enterprise.management.AMXTestBase; 37 import com.sun.enterprise.management.Capabilities; 38 39 46 public final class AppserverConnectionSourceTest extends AMXTestBase 47 { 48 public 49 AppserverConnectionSourceTest( ) 50 { 51 } 52 public static Capabilities 53 getCapabilities() 54 { 55 return getOfflineCapableCapabilities( false ); 56 } 57 58 private static void 59 testConnect( 60 final String host, 61 final int port, 62 final String protocol, 63 final String user, 64 final String password ) 65 throws IOException 66 { 67 final AppserverConnectionSource source = 68 new AppserverConnectionSource( protocol, host, port, user, password, null); 69 70 source.getMBeanServerConnection( true ); 71 72 } 73 74 public void 75 testConnect() 76 throws Exception 77 { 78 final String host = (String )getEnvValue( "HOST" ); 79 final String port = (String )getEnvValue( "PORT" ); 80 final String protocol = (String )getEnvValue( "PROTOCOL" ); 81 final String user = (String )getEnvValue( "USER" ); 82 final String password = (String )getEnvValue( "PASSWORD" ); 83 84 if ( host == null || port == null || protocol == null || 85 user == null || password == null || 86 ! AppserverConnectionSource.isSupportedProtocol( protocol ) ) 87 { 88 trace( "AppserverConnectionSourceTest: skipped connect test; missing config:" + 89 "host = " + host + 90 ", port = " + port + 91 ", protocol = " + protocol + 92 ", user = " + user + 93 ", password = " + password ); 94 } 95 else 96 { 97 testConnect( host, new Integer ( port ).intValue(), protocol, user, password ); 98 } 99 } 100 101 private AppserverConnectionSource 102 create( final String protocol ) 103 { 104 return( new AppserverConnectionSource( protocol, "localhost", 9999, "admin", "admin123", null) ); 105 } 106 107 public void 108 testCreateS1ASHTTP() 109 { 110 create( AppserverConnectionSource.PROTOCOL_HTTP ); 111 } 112 113 public void 114 testCreateRMI() 115 { 116 create( AppserverConnectionSource.PROTOCOL_RMI ); 117 } 118 119 public void 120 testCreateIllegal() 121 { 122 try 123 { 124 create( "jmxmp" ); 125 } 126 catch( IllegalArgumentException e ) 127 { 128 } 130 } 131 132 public void 133 testToString() 134 { 135 create( AppserverConnectionSource.PROTOCOL_RMI ).toString(); 136 create( AppserverConnectionSource.PROTOCOL_HTTP ).toString(); 137 } 138 } 139 140 141 142 143 144 145 | Popular Tags |