KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > jbossnet > wsr > WSRUnitTestCase


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

7
8 // $Id: WSRUnitTestCase.java,v 1.1.1.1.6.3 2004/11/05 12:55:52 tdiesler Exp $
9

10 package org.jboss.test.jbossnet.wsr;
11
12 import com.ibm.wsdl.factory.WSDLFactoryImpl;
13 import junit.framework.Test;
14 import org.jboss.test.jbossnet.JBossNetTestBase;
15 import org.xml.sax.InputSource JavaDoc;
16
17 import javax.wsdl.Definition;
18 import javax.wsdl.factory.WSDLFactory;
19 import javax.wsdl.xml.WSDLReader;
20 import javax.xml.namespace.QName JavaDoc;
21 import javax.xml.rpc.Service JavaDoc;
22 import java.io.InputStream JavaDoc;
23 import java.net.URL JavaDoc;
24
25 /**
26  * Tests remote accessibility of "ordinary" (wsr-) deployed Axis services
27  * @since 11. Oktober 2001
28  * @author <a HREF="mailto:Christoph.Jung@infor.de">Christoph G. Jung</a>
29  * @version $Revision: 1.1.1.1.6.3 $
30  */

31 public class WSRUnitTestCase extends JBossNetTestBase
32 {
33    private QName JavaDoc ADDRESS_SERVICE = new QName JavaDoc("http://test.jboss.org/samples/AddressBook", "AddressBookService");
34
35    // Constructors --------------------------------------------------
36
public WSRUnitTestCase(String JavaDoc name)
37    {
38       super(name);
39    }
40
41    /** prepared data */
42    Address address;
43    AddressBook book;
44
45    /** sets up the test */
46    public void setUp() throws Exception JavaDoc
47    {
48       super.setUp();
49
50       Phone phone = new Phone();
51       phone.setExchange("(0)6897");
52       phone.setNumber("6666");
53       phone.setAreaCode(49);
54       StateType state = StateType.fromString("TX");
55       address = new Address();
56       address.setStreetNum(42);
57       address.setStreetName("Milky Way");
58       address.setCity("Galactic City");
59       address.setZip(2121);
60       address.setState(state);
61       address.setPhoneNumber(phone);
62
63       URL JavaDoc wsdlURI = new URL JavaDoc(SERVICES_LOCATION + "/AddressBook?wsdl");
64       Service JavaDoc service = createService(wsdlURI, ADDRESS_SERVICE, true);
65
66       book = (AddressBook)service.getPort(AddressBook.class);
67    }
68
69    /** this is where the axis config is stored */
70    protected String JavaDoc getAxisConfiguration()
71    {
72       return "jbossnet/wsr/client/client-config.wsdd";
73    }
74
75    /** routes an address to the server and tests the result */
76    public void testAddress() throws Exception JavaDoc
77    {
78       book.addEntry("George", address);
79       Address retAddress = book.getAddressFromName("George");
80       assertEquals("Comparing addresses", address, retAddress);
81    }
82
83    /** suite method */
84    public static Test suite() throws Exception JavaDoc
85    {
86       return getDeploySetup(WSRUnitTestCase.class, "jbossnet-wsr.wsr");
87    }
88 }
Popular Tags