KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > rift > coad > daemon > messageservice > message > rpc > RPCXMLParserTest


1 /*
2  * MessageQueueClient: The message queue client library
3  * Copyright (C) 2007 Rift IT Contracting
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  * RPCXMLParserTest.java
20  */

21
22 // package path
23
package com.rift.coad.daemon.messageservice.message.rpc;
24
25 // java imports
26
import java.io.ByteArrayInputStream JavaDoc;
27 import java.util.ArrayList JavaDoc;
28 import java.util.List JavaDoc;
29 import javax.xml.parsers.SAXParserFactory JavaDoc;
30 import javax.xml.parsers.SAXParser JavaDoc;
31 import org.xml.sax.InputSource JavaDoc;
32 import org.xml.sax.helpers.DefaultHandler JavaDoc;
33 import org.xml.sax.SAXException JavaDoc;
34 import org.xml.sax.Attributes JavaDoc;
35
36
37 // junit imports
38
import junit.framework.*;
39
40 // coadunation imports
41
import com.rift.coad.daemon.messageservice.message.RPCMessageImpl;
42
43 /**
44  * This object is responsible for testing the RPC xml parser.
45  *
46  * @author Brett Chaldecott
47  */

48 public class RPCXMLParserTest extends TestCase {
49     
50     public RPCXMLParserTest(String JavaDoc testName) {
51         super(testName);
52     }
53
54     protected void setUp() throws Exception JavaDoc {
55     }
56
57     protected void tearDown() throws Exception JavaDoc {
58     }
59
60     /**
61      * Test of class com.rift.coad.daemon.messageservice.message.rpc.RPCXMLParser.
62      */

63     public void testRPCXMLParser() throws Exception JavaDoc {
64         System.out.println("testRPCXMLParser");
65         
66         // message
67
RPCMessageImpl message = new RPCMessageImpl("test", "test", "test",
68             null, 1);
69         message.defineMethod(java.lang.Long JavaDoc.class,"test",new Class JavaDoc[] {
70             java.lang.String JavaDoc.class,java.lang.Integer JavaDoc.class,int[].class,
71             int.class});
72         
73         System.out.println(message.getMethodBodyXML());
74         
75         com.rift.coad.daemon.messageservice.message.rpc.RPCXMLParser instance =
76                 new com.rift.coad.daemon.messageservice.message.rpc.RPCXMLParser
77                 (message.getMethodBodyXML());
78         
79         assertEquals(message.getMethodBodyXML(), instance.getRPCXML());
80         
81         assertEquals(java.lang.Long JavaDoc.class, instance.getReturnType());
82         assertEquals("test", instance.getMethodName());
83         
84         Object JavaDoc[] arguments = instance.getArgumentTypes();
85         assertEquals(4, arguments.length);
86         assertEquals(java.lang.String JavaDoc.class, arguments[0]);
87         assertEquals(java.lang.Integer JavaDoc.class, arguments[1]);
88         assertEquals(int[].class, arguments[2]);
89         assertEquals(int.class, arguments[3]);
90     }
91     
92     
93 }
94
Popular Tags