KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > jbossnet > message > MessageTestCase


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.message;
8
9 // $Id: MessageTestCase.java,v 1.1.2.4 2005/03/02 14:51:04 tdiesler Exp $
10

11 import junit.framework.Test;
12 import org.jboss.axis.utils.DOM2Utils;
13 import org.jboss.test.JBossTestCase;
14 import org.jboss.test.jbossnet.JBossNetTestBase;
15 import org.w3c.dom.Document JavaDoc;
16
17 import javax.xml.namespace.QName JavaDoc;
18 import javax.xml.parsers.DocumentBuilder JavaDoc;
19 import javax.xml.rpc.Call JavaDoc;
20 import javax.xml.rpc.Service JavaDoc;
21 import javax.xml.rpc.ServiceFactory JavaDoc;
22 import java.io.ByteArrayInputStream JavaDoc;
23 import java.net.URL JavaDoc;
24
25 /**
26  * Endpoint test for document centric message exchange .
27  * It uses the the jva:MSG provider.
28  *
29  * @author Thomas.Diesler@jboss.org
30  */

31 public class MessageTestCase extends JBossNetTestBase
32 {
33    public static final String JavaDoc xmlstr = "<root><child>Hello</child><child>World</child></root>";
34
35    public MessageTestCase(String JavaDoc name)
36    {
37       super(name);
38    }
39
40    /** Process an Document at the endpoint
41     */

42    public void testProcessMessage() throws Exception JavaDoc
43    {
44       DocumentBuilder JavaDoc builder = DOM2Utils.getDocumentBuilder();
45       Document JavaDoc doc = builder.parse(new ByteArrayInputStream JavaDoc(xmlstr.getBytes()));
46
47       String JavaDoc namespaceURI = "http://jboss.net/message";
48       URL JavaDoc wsdlURL = new URL JavaDoc(SERVICES_LOCATION + "/MessageServer?wsdl");
49       Service JavaDoc service = createService(wsdlURL, new QName JavaDoc(namespaceURI, "MessageServerService"));
50       Call JavaDoc call = service.createCall(new QName JavaDoc(namespaceURI, "MessageServer"), "processMessage");
51
52       Object JavaDoc retObj = call.invoke(new Object JavaDoc[]{doc});
53       assertNotNull("Return obj is null", retObj);
54    }
55
56    /** Deploy the test ear */
57    public static Test suite() throws Exception JavaDoc
58    {
59       return getDeploySetup(MessageTestCase.class, "jbossnet-message.wsr");
60    }
61
62 }
63
Popular Tags