1 22 package org.jboss.test.ws; 23 24 import java.io.File ; 25 import java.net.MalformedURLException ; 26 import java.net.URL ; 27 28 import javax.management.MBeanServerConnection ; 29 import javax.naming.InitialContext ; 30 import javax.naming.NamingException ; 31 32 38 public class JBossWSTestHelper 39 { 40 42 public void deploy(String archive) throws Exception 43 { 44 URL url = getArchiveURL(archive); 45 getDeployer().deploy(url); 46 } 47 48 50 public void undeploy(String archive) throws Exception 51 { 52 URL url = getArchiveURL(archive); 53 getDeployer().undeploy(url); 54 } 55 56 57 public boolean isTargetServerJBoss() 58 { 59 String targetServer = System.getProperty("jbossws.target.server"); 60 if( targetServer == null ) 61 return ! isTargetServerTomcat(); 62 return "jboss".equals(targetServer); 63 } 64 65 66 public boolean isTargetServerTomcat() 67 { 68 String targetServer = System.getProperty("jbossws.target.server"); 69 return "tomcat".equals(targetServer); 70 } 71 72 public MBeanServerConnection getServer() throws NamingException 73 { 74 InitialContext iniCtx = new InitialContext (); 75 MBeanServerConnection server = (MBeanServerConnection )iniCtx.lookup("jmx/invoker/RMIAdaptor"); 76 return server; 77 } 78 79 private JBossWSTestDeployer getDeployer() 80 { 81 return new JBossTestDeployer(); 82 } 83 84 85 public URL getArchiveURL(String archive) throws MalformedURLException 86 { 87 URL url = null; 88 try 89 { 90 url = new URL (archive); 91 } 92 catch (MalformedURLException ignore) 93 { 94 } 96 97 if (url == null) 98 { 99 File file = new File (archive); 100 if (file.exists()) 101 url = file.toURL(); 102 } 103 104 if (url == null) 105 { 106 File file = new File ("output/lib/" + archive); 107 if (file.exists()) 108 url = file.toURL(); 109 } 110 111 if (url == null) 112 throw new IllegalArgumentException ("Cannot obtain URL for: " + archive+", cwd="+new File (".").getAbsolutePath()); 113 114 return url; 115 } 116 } 117 | Popular Tags |