1 19 25 26 package org.netbeans.modules.j2ee.sun.share; 27 28 import javax.enterprise.deploy.spi.DeploymentManager ; 29 import javax.enterprise.deploy.spi.factories.DeploymentFactory ; 30 import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException ; 31 import java.io.*; 32 import javax.enterprise.deploy.spi.Target ; 33 import javax.enterprise.deploy.spi.status.ProgressObject ; 35 import javax.enterprise.deploy.spi.TargetModuleID ; 36 import junit.framework.*; 37 38 42 public class SunONEDeploymentFactoryTest extends TestCase implements Constants { 43 44 public void testGetPortFromURI() { 45 assertEquals(-1,DF.getPortFromURI("anyother thing without a colon in it")); 46 assertEquals(12345, DF.getPortFromURI("deployer:Sun:S1AS::host:12345")); 47 assertEquals(-1,DF.getPortFromURI("anyother thing with a : in it")); 48 assertEquals(-1,DF.getPortFromURI("deployer:Sun:S1AS::host:12345:")); 49 } 50 51 public void testGetHost() { 52 assertEquals("host", DF.getHostFromURI("deployer:Sun:S1AS::host:12345")); 53 assertEquals("host", DF.getHostFromURI("host:12345")); 54 assertEquals(null, DF.getHostFromURI("host12345")); 55 } 56 57 public void testTomcatUriIssues() { 58 if (DF.handlesURI("tomcat:home=jakarta-tomcat-5.0.5:base=jakarta-tomcat-5.0.5_base:http://localhost:8080/manager/")) 59 fail("tomcat uri accepted"); 60 } 61 62 public SunONEDeploymentFactoryTest(java.lang.String testName) { 63 super(testName); 64 } 65 66 public static SunDeploymentFactory DF = 67 new SunDeploymentFactory(); 68 69 70 71 public void testGetDeploymentManager() { 72 DeploymentManager c; 74 jsr88Logger.config("level is "+jsr88Logger.getLevel()); 75 jsr88Logger.entering("","level is "+jsr88Logger.getLevel()); 76 jsr88Logger.exiting("","level is "+jsr88Logger.getLevel()); 77 jsr88Logger.fine("level is "+jsr88Logger.getLevel()); 78 jsr88Logger.finer("level is "+jsr88Logger.getLevel()); 79 jsr88Logger.finest("level is "+jsr88Logger.getLevel()); 80 jsr88Logger.info("level is "+jsr88Logger.getLevel()); 81 jsr88Logger.severe("level is "+jsr88Logger.getLevel()); 82 jsr88Logger.throwing("","level is "+jsr88Logger.getLevel(),new RuntimeException ("ABC")); 83 jsr88Logger.warning("level is "+jsr88Logger.getLevel()); 84 try { 85 String bogusuri = "a:foo:bar::plink:fudge"; 86 String validuri = "deployer:Sun:S1AS::localhost:4848"; 87 String adminName = "admin"; 88 String adminPassword = "admin321"; 89 c = DF.getDeploymentManager(validuri, adminName, adminPassword); 90 assertNotNull("valid case failed",c); 92 try { 93 c = DF.getDeploymentManager(bogusuri, "a", "a"); 94 fail("negative case failed"); 95 } 96 catch (DeploymentManagerCreationException dmce) { 97 assertEquals("invalid URI", 98 dmce.getMessage()); 99 } 100 } 101 catch (junit.framework.AssertionFailedError afe) { 102 throw afe; 103 } 104 catch (Throwable t) { 105 t.printStackTrace(); 106 fail("unexpected exception"); 107 } 108 } 109 110 111 public void testGetDisconnectedDeploymentManager() { 112 System.out.println("testGetDisconnectedDeploymentManager"); 113 114 DeploymentManager c; 115 try { 116 String bogusuri = "a:foo:bar::plink:fudge"; 117 String validuri = "deployer:Sun:S1AS::localhost:4848"; 118 String adminName = "admin"; 119 String adminPassword = "admin321"; 120 c = DF.getDisconnectedDeploymentManager(validuri); 121 assertNotNull("valid case failed",c); 122 try { 123 c = DF.getDisconnectedDeploymentManager(bogusuri); 124 fail("negative case failed"); 125 } 126 catch (DeploymentManagerCreationException dmce) { 127 assertEquals("invalid URI", 128 dmce.getMessage()); 129 } 130 } 131 catch (junit.framework.AssertionFailedError afe) { 132 throw afe; 133 } 134 catch (Throwable t) { 135 t.printStackTrace(); 136 fail("unexpected exception"); 137 } 138 } 139 140 141 public void testHandlesDisconnectedURI() { 142 144 if (!DF.handlesURI("deployer:Sun:S1AS")) 148 fail("disconnected URI is not accepted"); 149 } 150 public void testHandlesCompleteURI() { 151 if (!DF.handlesURI("deployer:Sun:S1AS::localhost:4848")) 152 fail("complete URI is not accpeted"); 153 } 154 public void testHandlesIPURI() { 155 if (!DF.handlesURI("deployer:Sun:S1AS::127.0.0.1:4848")) 156 fail("IP address not accepted"); 157 } 158 159 public void testHandleMisspelledURI() { 160 if (DF.handlesURI("deployerr:Sun:S1AS")) 161 fail("misspelled URI accepted"); 162 } 163 164 public void testHandleIllegalThirdSepURI() { 165 if (!DF.handlesURI("deployer:Sun:S1AS:localhost:4848")) 166 fail("illegal host sep ':' not accepted"); 167 } 168 public void testHandleIllegalFirstSepURI() { 169 if (DF.handlesURI("deployer@Sun:S1AS::localhost:4848")) 170 fail("illegal first sep '@' accepted"); 171 } 172 public void testHandleIllegalSecondSepURI() { 173 if (DF.handlesURI("deployer:Sun@S1AS::localhost:4848")) 174 fail("illegal second sep '@' accepted"); 175 } 176 177 181 197 205 207 208 public void testGetDisplayName() { 209 System.out.println("testGetDisplayName"); 210 String dn = DF.getDisplayName(); 211 System.out.println("dn = "+dn); 212 assertNotNull("the dn is null",dn); 213 assertEquals("empty dn", dn.length() > 0, true); 214 } 215 216 217 public void testGetProductVersion() { 218 System.out.println("testGetProductVersion"); 219 String pv = DF.getProductVersion(); 220 System.out.println("pv = "+pv); 221 assertNotNull("the pv is null",pv); 222 assertEquals("empty pv", pv.length() > 0, true); 223 } 224 225 } 226 | Popular Tags |