KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > webservice > jbws413 > JBWS413TestCase


1 /*
2  * JBoss, Home of Professional Open Source
3  * Copyright 2005, JBoss Inc., and individual contributors as indicated
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.webservice.jbws413;
23
24 import java.net.URL JavaDoc;
25
26 import javax.naming.InitialContext JavaDoc;
27 import javax.xml.namespace.QName JavaDoc;
28 import javax.xml.rpc.Call JavaDoc;
29 import javax.xml.rpc.Service JavaDoc;
30 import javax.xml.rpc.ServiceFactory JavaDoc;
31
32 import junit.framework.Test;
33
34 import org.jboss.test.webservice.WebserviceTestBase;
35
36 /**
37  * JBoss ignores metadata supplied in a JAX-RPC Mapping DD
38  *
39  * http://jira.jboss.com/jira/browse/JBWS-413
40  *
41  * @author Thomas.Diesler@jboss.org
42  * @since 21-Oct-2005
43  */

44 public class JBWS413TestCase extends WebserviceTestBase
45 {
46    /** Construct the test case with a given name
47     */

48    public JBWS413TestCase(String JavaDoc name)
49    {
50       super(name);
51    }
52
53    /** Deploy the test */
54    public static Test suite() throws Exception JavaDoc
55    {
56       return getDeploySetup(JBWS413TestCase.class, "ws4ee-jbws413.war, ws4ee-jbws413-client.jar");
57    }
58
59    public void testClientAccess() throws Exception JavaDoc
60    {
61       InitialContext JavaDoc iniCtx = getClientContext();
62       Service JavaDoc service = (Service JavaDoc)iniCtx.lookup("java:comp/env/service/TestService");
63       TestSEI port = (TestSEI)service.getPort(TestSEI.class);
64
65       JavaType in = new JavaType(new Double JavaDoc[] { new Double JavaDoc(1), new Double JavaDoc(2), new Double JavaDoc(3) });
66       JavaType retObj = port.doStuff(in);
67       assertEquals(in, retObj);
68    }
69
70    /**
71     * Auto discover jaxrpc-mapping.xml and other client artifacts
72     *
73     * http://jira.jboss.com/jira/browse/JBWS-314
74     */

75    public void testDIIAccess() throws Exception JavaDoc
76    {
77       String JavaDoc targetEndpoint = "http://" + getServerHost() + ":8080/ws4ee-jbws413";
78       String JavaDoc nsURI = "http://org.jboss.test.webservice/jbws413";
79       QName JavaDoc serviceName = new QName JavaDoc(nsURI, "TestService");
80
81       ServiceFactory JavaDoc factory = ServiceFactory.newInstance();
82       
83       // Note, this is a standard call to createService without mappingURL
84
Service JavaDoc service = factory.createService(new URL JavaDoc(targetEndpoint + "?wsdl"), serviceName);
85       Call JavaDoc call = service.createCall();
86       
87       call.setOperationName(new QName JavaDoc(nsURI, "doStuff"));
88       call.setTargetEndpointAddress(targetEndpoint);
89
90       JavaType in = new JavaType(new Double JavaDoc[] { new Double JavaDoc(1), new Double JavaDoc(2), new Double JavaDoc(3) });
91       Object JavaDoc retObj = call.invoke(new Object JavaDoc[] { in });
92       assertEquals(in, retObj);
93    }
94 }
95
Popular Tags