1 19 package org.netbeans.modules.j2ee.sun.util; 20 21 import java.io.IOException ; 22 import junit.framework.*; 23 import com.sun.appserv.management.client.ConnectionSource; 24 import com.sun.appserv.management.client.AppserverConnectionSource; 25 import com.sun.appserv.management.DomainRoot; 26 import org.netbeans.modules.j2ee.sun.util.AppserverConnectionFactory; 27 28 32 public class AppserverConnectionFactoryTest extends TestCase { 33 34 private static final String HOST = "localhost"; 35 private static final int PORT = 4848; 36 private static final String USER_NAME = "admin"; 37 private static final String PASSWORD = "adminadmin"; 38 39 40 public AppserverConnectionFactoryTest(java.lang.String testName) { 41 super(testName); 42 } 43 44 public void testGetHTTPAppserverConnection() { 45 AppserverConnectionSource conn = 46 AppserverConnectionFactory.getHTTPAppserverConnectionSource(HOST, 47 PORT, USER_NAME, PASSWORD, null); 48 assertNotNull(conn); 49 try { 50 conn.getDomainRoot(); 51 } catch(IOException e) { 52 fail("Error connecting to the DAS!!!"); 53 e.printStackTrace(); 54 } 55 } 56 57 public void testIsAppserverConnectionSecurityEnabled() { 58 try { 59 System.out.println("Is Security Enabled? " + 60 AppserverConnectionFactory.isAppserverConnectionSecurityEnabled( 61 AppserverConnectionFactory.getHTTPAppserverConnectionSource( 62 HOST, PORT, USER_NAME, PASSWORD, null))); 63 } catch(IOException e) { 64 e.printStackTrace(); 65 } 66 } 67 68 69 public void testGetAppserverConnection() { 70 try { 71 AppserverConnectionSource conn = 72 AppserverConnectionFactory.getAppserverConnection(HOST, PORT, 73 USER_NAME, PASSWORD, null, false); 74 System.out.println(conn.getDomainRoot().getAppserverDomainName()); 75 System.out.println(conn.getJMXConnector(false).getConnectionId()); 76 AppserverConnectionSource conn2 = 77 AppserverConnectionFactory.getAppserverConnection(HOST, PORT, 78 USER_NAME, PASSWORD, null, true); 79 AppserverConnectionSource conn3 = 80 AppserverConnectionFactory.getAppserverConnection(HOST, PORT, 81 USER_NAME, PASSWORD, null, false); 82 } catch(Exception e) { 83 e.printStackTrace(); 84 } 85 } 86 87 88 public static Test suite() { 89 TestSuite suite = new TestSuite(AppserverConnectionFactoryTest.class); 90 return suite; 91 } 92 93 public static void main(java.lang.String [] args) { 94 junit.textui.TestRunner.run(suite()); 95 } 96 97 } | Popular Tags |