1 22 package org.jboss.test.webservice; 23 24 import java.util.Hashtable ; 25 26 import javax.naming.InitialContext ; 27 import javax.naming.NamingException ; 28 import javax.xml.rpc.ServiceException ; 29 import javax.xml.rpc.ServiceFactory ; 30 31 import junit.framework.Test; 32 import junit.framework.TestSuite; 33 34 import org.jboss.test.JBossTestCase; 35 36 41 public class WebserviceTestBase extends JBossTestCase 42 { 43 44 public WebserviceTestBase(String name) 45 { 46 super(name); 47 } 48 49 52 protected InitialContext getClientContext(String clientName) throws NamingException 53 { 54 InitialContext initialContext = new InitialContext (); 55 Hashtable jndiEnv = initialContext.getEnvironment(); 56 jndiEnv.put("java.naming.factory.url.pkgs", "org.jboss.naming.client"); 57 jndiEnv.put("j2ee.clientName", clientName); 58 log.debug("jndiEnv: " + jndiEnv); 59 return new InitialContext (jndiEnv); 60 } 61 62 65 protected InitialContext getClientContext() throws NamingException 66 { 67 return getClientContext("ws4ee-client"); 68 } 69 70 72 public static boolean isWS4EEAvailable() 73 { 74 try 75 { 76 ServiceFactory factory = ServiceFactory.newInstance(); 77 if ("org.jboss.webservice.client.ServiceFactoryImpl".equals(factory.getClass().getName())) 78 return true; 79 } 80 catch (ServiceException e) 81 { 82 } 84 return false; 85 } 86 87 89 public static boolean isJBossWSAvailable() 90 { 91 try 92 { 93 ServiceFactory factory = ServiceFactory.newInstance(); 94 if ("org.jboss.ws.jaxrpc.ServiceFactoryImpl".equals(factory.getClass().getName())) 95 return true; 96 } 97 catch (ServiceException e) 98 { 99 } 101 return false; 102 } 103 104 public static Test getDeploySetupForWS4EE(final Class clazz, String jarName) throws Exception 105 { 106 TestSuite suite = new TestSuite(); 107 suite.addTest(new TestSuite(clazz)); 108 if (isWS4EEAvailable() == false) 109 { 110 jarName = null; 111 } 112 return getDeploySetup(suite, jarName); 113 } 114 115 public static Test getDeploySetupForJBossWS(final Class clazz, String jarName) throws Exception 116 { 117 TestSuite suite = new TestSuite(); 118 suite.addTest(new TestSuite(clazz)); 119 if (isJBossWSAvailable() == false) 120 { 121 jarName = null; 122 } 123 return getDeploySetup(suite, jarName); 124 } 125 } 126 | Popular Tags |