KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > webservice > admindevel > ExampleTestCase


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.admindevel;
23
24 import junit.framework.Test;
25 import org.jboss.test.webservice.WebserviceTestBase;
26
27 import javax.naming.InitialContext JavaDoc;
28 import javax.xml.rpc.Service JavaDoc;
29
30 /** A test for the examples from the JBoss Admin Devel book.
31  *
32  * @author Thomas.Diesler@jboss.org
33  * @version $Revision: 37406 $
34  */

35 public class ExampleTestCase extends WebserviceTestBase
36 {
37    private static Hello helloPort;
38
39    public ExampleTestCase(String JavaDoc name)
40    {
41       super(name);
42    }
43
44    /** Deploy the test ear */
45    public static Test suite() throws Exception JavaDoc
46    {
47       return getDeploySetup(ExampleTestCase.class, "ws4ee-admindevel.jar, ws4ee-admindevel-client.jar");
48    }
49
50    protected void setUp() throws Exception JavaDoc
51    {
52       super.setUp();
53       if (helloPort == null)
54       {
55          InitialContext JavaDoc iniCtx = getClientContext();
56          Service JavaDoc service = (Service JavaDoc)iniCtx.lookup("java:comp/env/service/HelloService");
57          helloPort = (Hello)service.getPort(Hello.class);
58       }
59    }
60
61    public void testHelloString() throws Exception JavaDoc
62    {
63
64       String JavaDoc retStr = helloPort.helloString("Kermit");
65       assertEquals("Hello Kermit!", retStr);
66    }
67
68    public void testHelloBean() throws Exception JavaDoc
69    {
70       HelloObj ho = new HelloObj("Kermit");
71       HelloObj hro = helloPort.helloBean(ho);
72       assertEquals("Hello Kermit!", hro.getMsg());
73    }
74
75    public void testHelloArray() throws Exception JavaDoc
76    {
77       HelloObj[] query = new HelloObj[3];
78       HelloObj ho = new HelloObj();
79       ho.setMsg("Kermit");
80       query[0] = ho;
81       ho = new HelloObj();
82       ho.setMsg("Piggy");
83       query[1] = ho;
84       ho = new HelloObj();
85       ho.setMsg("Fozzy");
86       query[2] = ho;
87
88       HelloObj[] reply = helloPort.helloArray(query);
89       for (int i = 0; i < reply.length; i++)
90       {
91          HelloObj replyObj = reply[i];
92          assertEquals("Hello " + query[i].getMsg() + "!", replyObj.getMsg());
93       }
94    }
95 }
96
Popular Tags