KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > ws > jaxws > webserviceref > WebServiceRefServletTestCase


1 /*
2  * JBoss, Home of Professional Open Source
3  * Copyright 2006, Red Hat Middleware LLC, and individual contributors
4  * by the @authors tag. See the copyright.txt in the distribution for a
5  * full listing of individual contributors.
6  *
7  * This is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation; either version 2.1 of
10  * the License, or (at your option) any later version.
11  *
12  * This software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this software; if not, write to the Free
19  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21  */

22 package org.jboss.test.ws.jaxws.webserviceref;
23
24 import java.io.BufferedReader JavaDoc;
25 import java.io.File JavaDoc;
26 import java.io.InputStreamReader JavaDoc;
27 import java.net.MalformedURLException JavaDoc;
28 import java.net.URL JavaDoc;
29
30 import javax.xml.namespace.QName JavaDoc;
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 /**
41  * Test the JAXWS annotation: javax.xml.ws.WebServiceref
42  *
43  * @author Thomas.Diesler@jboss.com
44  * @since 23-Oct-2005
45  */

46 public class WebServiceRefServletTestCase extends JBossWSTest
47 {
48    public final String JavaDoc 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 JavaDoc
56    {
57       URL JavaDoc wsdlURL = new URL JavaDoc(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 JavaDoc
64    {
65       URL JavaDoc wsdlURL = getResource("ws/jaxws/webserviceref/META-INF/wsdl/TestEndpoint.wsdl");
66       QName JavaDoc qname = new QName JavaDoc("http://org.jboss.ws/wsref", "TestEndpointService");
67       Service service = Service.create(wsdlURL, qname);
68       TestEndpoint port = (TestEndpoint)service.getPort(TestEndpoint.class);
69
70       String JavaDoc helloWorld = "Hello World!";
71       Object JavaDoc retObj = port.echo(helloWorld);
72       assertEquals(helloWorld, retObj);
73    }
74
75    public void testServletClient() throws Exception JavaDoc
76    {
77       System.out.println("FIXME: [JBAS-3824] Fix ENC for EJB2.1 and Servlets");
78       if (true) return;
79       
80       URL JavaDoc url = new URL JavaDoc(TARGET_ENDPOINT_ADDRESS + "-servlet-client?echo=HelloWorld");
81       BufferedReader JavaDoc br = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(url.openStream()));
82       String JavaDoc retStr = br.readLine();
83       assertEquals("HelloWorld", retStr);
84    }
85 }
86
Popular Tags