You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xmlrpc-dev@ws.apache.org by jo...@apache.org on 2005/05/23 08:11:15 UTC
cvs commit: ws-xmlrpc/src/test/org/apache/xmlrpc/test BaseTest.java
jochen 2005/05/22 23:11:15
Modified: src/test/org/apache/xmlrpc/test Tag: b20050512_streaming
BaseTest.java
Log:
Added unit test for serializable objects.
Revision Changes Path
No revision
No revision
1.1.2.4 +44 -0 ws-xmlrpc/src/test/org/apache/xmlrpc/test/Attic/BaseTest.java
Index: BaseTest.java
===================================================================
RCS file: /home/cvs/ws-xmlrpc/src/test/org/apache/xmlrpc/test/Attic/BaseTest.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- BaseTest.java 21 May 2005 21:23:51 -0000 1.1.2.3
+++ BaseTest.java 23 May 2005 06:11:14 -0000 1.1.2.4
@@ -17,12 +17,15 @@
import java.io.IOException;
import java.io.StringReader;
+import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Arrays;
+import java.util.Calendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import java.util.TimeZone;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -257,6 +260,14 @@
return result;
}
}
+
+ /** Returns the calendar value in milliseconds.
+ * @param pCal Calendar object
+ * @return <code>pCal.getTime().getTime()</code>.
+ */
+ public long serializableParam(Calendar pCal) {
+ return pCal.getTime().getTime();
+ }
}
protected XmlRpcHandlerMapping getHandlerMapping() throws IOException, XmlRpcException {
@@ -787,4 +798,37 @@
}
assertTrue(ok);
}
+
+ /** Test, whether we can invoke a method, passing an instance of
+ * {@link java.io.Serializable} as an instance.
+ * @throws Exception The test failed.
+ */
+ public void testSerializableParam() throws Exception {
+ for (int i = 0; i < providers.length; i++) {
+ testSerializableParam(providers[i]);
+ }
+ }
+
+ private void testSerializableParam(ClientProvider pProvider) throws Exception {
+ final String methodName = "Remote.serializableParam";
+ Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+ cal.set(Calendar.YEAR, 2005);
+ cal.set(Calendar.MONTH, 5);
+ cal.set(Calendar.DAY_OF_MONTH, 23);
+ cal.set(Calendar.HOUR_OF_DAY, 8);
+ cal.set(Calendar.MINUTE, 4);
+ cal.set(Calendar.SECOND, 0);
+ cal.set(Calendar.MILLISECOND, 5);
+ final Object[] params = new Object[]{cal};
+ final XmlRpcClient client = pProvider.getClient();
+ Object result = client.execute(getExConfig(pProvider), methodName, params);
+ assertEquals(new Long(cal.getTime().getTime()), result);
+ boolean ok = false;
+ try {
+ client.execute(getConfig(pProvider), methodName, params);
+ } catch (XmlRpcExtensionException e) {
+ ok = true;
+ }
+ assertTrue(ok);
+ }
}