01: /*
02: * MessageQueueClient: The message queue client library
03: * Copyright (C) 2007 Rift IT Contracting
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
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;
27: import java.util.ArrayList;
28: import java.util.List;
29: import javax.xml.parsers.SAXParserFactory;
30: import javax.xml.parsers.SAXParser;
31: import org.xml.sax.InputSource;
32: import org.xml.sax.helpers.DefaultHandler;
33: import org.xml.sax.SAXException;
34: import org.xml.sax.Attributes;
35:
36: // junit imports
37: import junit.framework.*;
38:
39: // coadunation imports
40: import com.rift.coad.daemon.messageservice.message.RPCMessageImpl;
41:
42: /**
43: * This object is responsible for testing the RPC xml parser.
44: *
45: * @author Brett Chaldecott
46: */
47: public class RPCXMLParserTest extends TestCase {
48:
49: public RPCXMLParserTest(String testName) {
50: super (testName);
51: }
52:
53: protected void setUp() throws Exception {
54: }
55:
56: protected void tearDown() throws Exception {
57: }
58:
59: /**
60: * Test of class com.rift.coad.daemon.messageservice.message.rpc.RPCXMLParser.
61: */
62: public void testRPCXMLParser() throws Exception {
63: System.out.println("testRPCXMLParser");
64:
65: // message
66: RPCMessageImpl message = new RPCMessageImpl("test", "test",
67: "test", null, 1);
68: message.defineMethod(java.lang.Long.class, "test", new Class[] {
69: java.lang.String.class, java.lang.Integer.class,
70: int[].class, int.class });
71:
72: System.out.println(message.getMethodBodyXML());
73:
74: com.rift.coad.daemon.messageservice.message.rpc.RPCXMLParser instance = new com.rift.coad.daemon.messageservice.message.rpc.RPCXMLParser(
75: message.getMethodBodyXML());
76:
77: assertEquals(message.getMethodBodyXML(), instance.getRPCXML());
78:
79: assertEquals(java.lang.Long.class, instance.getReturnType());
80: assertEquals("test", instance.getMethodName());
81:
82: Object[] arguments = instance.getArgumentTypes();
83: assertEquals(4, arguments.length);
84: assertEquals(java.lang.String.class, arguments[0]);
85: assertEquals(java.lang.Integer.class, arguments[1]);
86: assertEquals(int[].class, arguments[2]);
87: assertEquals(int.class, arguments[3]);
88: }
89:
90: }
|