KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > webservice > jbas897 > JBAS897TestCase


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.jbas897;
23
24 import java.io.IOException JavaDoc;
25 import java.net.URL JavaDoc;
26
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 org.jboss.deployment.DeploymentException;
33 import org.jboss.test.webservice.WebserviceTestBase;
34
35 /**
36  * I made a typo in my ejb-jar.xml file so it didn't match the
37  * <ejb-link> within my webservices.xml file. No complaint
38  * from JBoss on deployment on this.
39
40  * http://jira.jboss.com/jira/browse/JBAS-897
41  *
42  * @author Thomas.Diesler@jboss.org
43  * @since 04-Feb-2005
44  */

45 public class JBAS897TestCase extends WebserviceTestBase
46 {
47    private String JavaDoc NAMESPACE = "http://org.jboss.test.webservice/jbas897";
48
49    private QName JavaDoc SERVICE_NAME = new QName JavaDoc(NAMESPACE, "HelloService");
50
51    /**
52     * Construct the test case with a given name
53     */

54    public JBAS897TestCase(String JavaDoc name)
55    {
56       super(name);
57    }
58
59    /**
60     * Test JSE endpoint
61     */

62    public void testJSEEndpoint() throws Exception JavaDoc
63    {
64       deploy("ws4ee-jbas897.war");
65       try
66       {
67          ServiceFactory JavaDoc serviceFactory = ServiceFactory.newInstance();
68          Service JavaDoc service = serviceFactory.createService(new URL JavaDoc("http://" + getServerHost() + ":8080/ws4ee-jbas897/HelloJSE?wsdl"), SERVICE_NAME);
69          Call JavaDoc call = (Call JavaDoc)service.createCall(new QName JavaDoc(NAMESPACE, "HelloPort"), "sayHello");
70          String JavaDoc retstr = (String JavaDoc)call.invoke(new Object JavaDoc[] { "Hello" });
71          assertEquals("'Hello' to you too!", retstr);
72       }
73       finally
74       {
75          undeploy("ws4ee-jbas897.war");
76       }
77    }
78
79    /**
80     * Test JSE endpoint with invalid deployment
81     */

82    public void testJSEEndpointFail() throws Exception JavaDoc
83    {
84       try
85       {
86          try
87          {
88             deploy("ws4ee-jbas897-fail.war");
89          }
90          catch (DeploymentException e)
91          {
92             // expected
93
}
94
95          try
96          {
97             URL JavaDoc url = new URL JavaDoc("http://" + getServerHost() + ":8080/ws4ee-jbas897-fail/HelloJSE");
98             url.openStream();
99             fail("Deployment was expected to fail");
100          }
101          catch (IOException JavaDoc e)
102          {
103             // expected
104
}
105       }
106       finally
107       {
108          undeploy("ws4ee-jbas897-fail.war");
109       }
110    }
111
112    /**
113     * Test EJB endpoint
114     */

115    public void testEJBEndpoint() throws Exception JavaDoc
116    {
117       deploy("ws4ee-jbas897.jar");
118       try
119       {
120          ServiceFactory JavaDoc serviceFactory = ServiceFactory.newInstance();
121          Service JavaDoc service = serviceFactory.createService(new URL JavaDoc("http://" + getServerHost() + ":8080/ws4ee-jbas897/HelloEJB?wsdl"), SERVICE_NAME);
122          Call JavaDoc call = (Call JavaDoc)service.createCall(new QName JavaDoc(NAMESPACE, "HelloPort"), "sayHello");
123          String JavaDoc retstr = (String JavaDoc)call.invoke(new Object JavaDoc[] { "Hello" });
124          assertEquals("'Hello' to you too!", retstr);
125       }
126       finally
127       {
128          undeploy("ws4ee-jbas897.jar");
129       }
130    }
131
132    /**
133     * Test EJB endpoint
134     */

135    public void testEJBEndpointFail() throws Exception JavaDoc
136    {
137       try
138       {
139          try
140          {
141             deploy("ws4ee-jbas897-fail.jar");
142          }
143          catch (DeploymentException e)
144          {
145             // expected
146
}
147
148          try
149          {
150             URL JavaDoc url = new URL JavaDoc("http://" + getServerHost() + ":8080/ws4ee-jbas897-fail/HelloEJB");
151             url.openStream();
152             fail("Deployment was expected to fail");
153          }
154          catch (IOException JavaDoc e)
155          {
156             // expected
157
}
158       }
159       finally
160       {
161          undeploy("ws4ee-jbas897-fail.jar");
162       }
163    }
164 }
165
Popular Tags