1 22 package org.jboss.test.ws.jaxws.webserviceref; 23 24 import java.net.MalformedURLException ; 25 import java.net.URL ; 26 27 import javax.naming.InitialContext ; 28 import javax.xml.namespace.QName ; 29 import javax.xml.ws.Service; 30 31 import junit.framework.Test; 32 33 import org.jboss.test.ws.JBossWSTest; 34 import org.jboss.test.ws.JBossWSTestSetup; 35 import org.jboss.ws.metadata.wsdl.WSDLDefinitions; 36 import org.jboss.ws.metadata.wsdl.WSDLDefinitionsFactory; 37 38 44 public class WebServiceRefEJB3TestCase extends JBossWSTest 45 { 46 public final String TARGET_ENDPOINT_ADDRESS = "http://" + getServerHost() + ":8080/jaxws-webserviceref"; 47 48 public static Test suite() 49 { 50 return JBossWSTestSetup.newTestSetup(WebServiceRefEJB3TestCase.class, "jaxws-webserviceref.war, jaxws-webserviceref-ejb3-client.jar"); 51 } 52 53 public void testWSDLAccess() throws MalformedURLException 54 { 55 URL wsdlURL = new URL (TARGET_ENDPOINT_ADDRESS + "?wsdl"); 56 WSDLDefinitionsFactory factory = WSDLDefinitionsFactory.newInstance(); 57 WSDLDefinitions wsdlDefinitions = factory.parse(wsdlURL); 58 assertNotNull(wsdlDefinitions); 59 } 60 61 public void testDynamicProxy() throws Exception 62 { 63 URL wsdlURL = super.getResource("ws/jaxws/webserviceref/META-INF/wsdl/TestEndpoint.wsdl"); 64 QName qname = new QName ("http://org.jboss.ws/wsref", "TestEndpointService"); 65 Service service = Service.create(wsdlURL, qname); 66 TestEndpoint port = (TestEndpoint)service.getPort(TestEndpoint.class); 67 68 String helloWorld = "Hello World!"; 69 Object retObj = port.echo(helloWorld); 70 assertEquals(helloWorld, retObj); 71 } 72 73 public void testEJB3Client() throws Exception 74 { 75 InitialContext iniCtx = getInitialContext(); 76 EJB3Remote ejb3Remote = (EJB3Remote)iniCtx.lookup("/ejb3/EJB3Client"); 77 78 String helloWorld = "Hello World!"; 79 Object retObj = ejb3Remote.echo(helloWorld); 80 assertEquals(helloWorld, retObj); 81 82 } 83 } 84 | Popular Tags |