1 22 package org.jboss.test.ws.jaxws.webserviceref; 23 24 import java.io.BufferedReader ; 25 import java.io.File ; 26 import java.io.InputStreamReader ; 27 import java.net.MalformedURLException ; 28 import java.net.URL ; 29 30 import javax.xml.namespace.QName ; 31 import javax.xml.ws.Service; 32 33 import junit.framework.Test; 34 35 import org.jboss.test.ws.JBossWSTest; 36 import org.jboss.test.ws.JBossWSTestSetup; 37 import org.jboss.ws.metadata.wsdl.WSDLDefinitions; 38 import org.jboss.ws.metadata.wsdl.WSDLDefinitionsFactory; 39 40 46 public class WebServiceRefServletTestCase extends JBossWSTest 47 { 48 public final String TARGET_ENDPOINT_ADDRESS = "http://" + getServerHost() + ":8080/jaxws-webserviceref"; 49 50 public static Test suite() 51 { 52 return JBossWSTestSetup.newTestSetup(WebServiceRefServletTestCase.class, "jaxws-webserviceref.war, jaxws-webserviceref-servlet-client.war"); 53 } 54 55 public void testWSDLAccess() throws MalformedURLException 56 { 57 URL wsdlURL = new URL (TARGET_ENDPOINT_ADDRESS + "?wsdl"); 58 WSDLDefinitionsFactory factory = WSDLDefinitionsFactory.newInstance(); 59 WSDLDefinitions wsdlDefinitions = factory.parse(wsdlURL); 60 assertNotNull(wsdlDefinitions); 61 } 62 63 public void testDynamicProxy() throws Exception 64 { 65 URL wsdlURL = getResource("ws/jaxws/webserviceref/META-INF/wsdl/TestEndpoint.wsdl"); 66 QName qname = new QName ("http://org.jboss.ws/wsref", "TestEndpointService"); 67 Service service = Service.create(wsdlURL, qname); 68 TestEndpoint port = (TestEndpoint)service.getPort(TestEndpoint.class); 69 70 String helloWorld = "Hello World!"; 71 Object retObj = port.echo(helloWorld); 72 assertEquals(helloWorld, retObj); 73 } 74 75 public void testServletClient() throws Exception 76 { 77 System.out.println("FIXME: [JBAS-3824] Fix ENC for EJB2.1 and Servlets"); 78 if (true) return; 79 80 URL url = new URL (TARGET_ENDPOINT_ADDRESS + "-servlet-client?echo=HelloWorld"); 81 BufferedReader br = new BufferedReader (new InputStreamReader (url.openStream())); 82 String retStr = br.readLine(); 83 assertEquals("HelloWorld", retStr); 84 } 85 } 86 | Popular Tags |