KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2 * JBoss, the OpenSource J2EE webOS
3 *
4 * Distributable under LGPL license.
5 * See terms of license at gnu.org.
6 */

7 package org.jboss.test.jbossnet.admindevel;
8
9 import junit.framework.Test;
10 import org.jboss.test.JBossTestCase;
11
12 /** A test for the examples from the JBoss Admin Devel book.
13  *
14  * @author Thomas.Diesler@jboss.org
15  * @version $Revision: 1.1.2.2 $
16  */

17 public class ExampleTestCase extends JBossTestCase
18 {
19    private Hello helloPort;
20
21    public ExampleTestCase(String JavaDoc name)
22    {
23       super(name);
24    }
25
26    protected void setUp() throws Exception JavaDoc
27    {
28       super.setUp();
29       HelloServiceLocator locator = new HelloServiceLocator();
30       helloPort = locator.getHello();
31    }
32
33    public void testHelloString() throws Exception JavaDoc
34    {
35       String JavaDoc retStr = helloPort.helloString("Kermit");
36       assertEquals("Hello Kermit!", retStr);
37    }
38
39    public void testHelloBean() throws Exception JavaDoc
40    {
41       HelloObj ho = new HelloObj("Kermit");
42       HelloReplyObj hro = helloPort.helloBean(ho);
43       assertEquals("Hello Kermit!", hro.getMsg());
44    }
45
46    public void testHelloArray() throws Exception JavaDoc
47    {
48       HelloObj[] query = new HelloObj[3];
49       HelloObj ho = new HelloObj();
50       ho.setMsg("Kermit");
51       query[0] = ho;
52       ho = new HelloObj();
53       ho.setMsg("Piggy");
54       query[1] = ho;
55       ho = new HelloObj();
56       ho.setMsg("Fozzy");
57       query[2] = ho;
58
59       Object JavaDoc[] reply = helloPort.helloArray(query);
60       for (int i = 0; i < reply.length; i++)
61       {
62          HelloReplyObj replyObj = (HelloReplyObj)reply[i];
63          assertEquals("Hello " + query[i].getMsg() + "!", replyObj.getMsg());
64       }
65    }
66
67    /** Deploy the test ear */
68    public static Test suite() throws Exception JavaDoc
69    {
70       return getDeploySetup(ExampleTestCase.class, "jbossnet-admindevel.ear");
71    }
72
73 }
74
Popular Tags