Author: jochen
Date: Tue Aug 22 18:06:11 2006
New Revision: 433819
URL:
http://svn.apache.org/viewvc?rev=433819&view=rev
Log:
Added documentation on custom data types.
Added:
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/CustomTypesTest.java
Modified:
webservices/xmlrpc/trunk/common/src/main/java/org/apache/xml
rpc/common/XmlRpcWorkerFactory.java
webservices/xmlrpc/trunk/common/src/main/java/org/apache/xml
rpc/parser/DateParser.java
webservices/xmlrpc/trunk/common/src/main/java/org/apache/xml
rpc/serializer/DateSerializer.java
webservices/xmlrpc/trunk/src/changes/changes.xml
webservices/xmlrpc/trunk/src/site/apt/advanced.apt
webservices/xmlrpc/trunk/src/site/fml/faq.fml
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/ClientProvider.java
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/LocalStreamTransportProvider.java
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/LocalTransportProvider.java
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/SerializerTest.java
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/ServletWebServerProvider.java
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/WebServerProvider.java
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/XmlRpcTestCase.java
Modified:
webservices/xmlrpc/trunk/common/src/main/java/org/apache/xml
rpc/common/XmlRpcWorkerFactory.java
URL: http://svn.apache.org/viewvc/webservices/xmlrpc/trunk/c
ommon/src/main/java/org/apache/xmlrpc/common/XmlRpcWorkerFac
tory.java?rev=433819&r1=433818&r2=433819&view=di
ff
============================================================
==================
---
webservices/xmlrpc/trunk/common/src/main/java/org/apache/xml
rpc/common/XmlRpcWorkerFactory.java (original)
+++
webservices/xmlrpc/trunk/common/src/main/java/org/apache/xml
rpc/common/XmlRpcWorkerFactory.java Tue Aug 22 18:06:11 2006
 -59,10
+59,10 
if (max > 0 && numThreads == max) {
throw new XmlRpcLoadException("Maximum number of
concurrent requests exceeded: " + max);
}
- ++numThreads;
if (max == 0) {
return singleton;
}
+ ++numThreads;
if (pool.size() == 0) {
return newWorker();
} else {
Modified:
webservices/xmlrpc/trunk/common/src/main/java/org/apache/xml
rpc/parser/DateParser.java
URL: http
://svn.apache.org/viewvc/webservices/xmlrpc/trunk/common/src
/main/java/org/apache/xmlrpc/parser/DateParser.java?rev=4338
19&r1=433818&r2=433819&view=diff
============================================================
==================
---
webservices/xmlrpc/trunk/common/src/main/java/org/apache/xml
rpc/parser/DateParser.java (original)
+++
webservices/xmlrpc/trunk/common/src/main/java/org/apache/xml
rpc/parser/DateParser.java Tue Aug 22 18:06:11 2006
 -15,9
+15,9 
*/
package org.apache.xmlrpc.parser;
+import java.text.Format;
import java.text.ParseException;
-import org.apache.xmlrpc.util.XmlRpcDateTimeDateFormat;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
 -25,11
+25,11 
/** Parser for integer values.
*/
public class DateParser extends AtomicParser {
- private final XmlRpcDateTimeDateFormat f;
+ private final Format f;
/** Creates a new instance with the given format.
*/
- public DateParser(XmlRpcDateTimeDateFormat pFormat) {
+ public DateParser(Format pFormat) {
f = pFormat;
}
Modified:
webservices/xmlrpc/trunk/common/src/main/java/org/apache/xml
rpc/serializer/DateSerializer.java
URL: http://svn.apache.org/viewvc/webservices/xmlrpc/trunk/co
mmon/src/main/java/org/apache/xmlrpc/serializer/DateSerializ
er.java?rev=433819&r1=433818&r2=433819&view=diff
============================================================
==================
---
webservices/xmlrpc/trunk/common/src/main/java/org/apache/xml
rpc/serializer/DateSerializer.java (original)
+++
webservices/xmlrpc/trunk/common/src/main/java/org/apache/xml
rpc/serializer/DateSerializer.java Tue Aug 22 18:06:11 2006
 -15,7
+15,8 
*/
package org.apache.xmlrpc.serializer;
-import org.apache.xmlrpc.util.XmlRpcDateTimeDateFormat;
+import java.text.Format;
+
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
 -27,11
+28,11 
*/
public static final String DATE_TAG =
"dateTime.iso8601";
- private final XmlRpcDateTimeDateFormat format;
+ private final Format format;
/** Creates a new instance with the given formatter.
*/
- public DateSerializer(XmlRpcDateTimeDateFormat pFormat)
{
+ public DateSerializer(Format pFormat) {
format = pFormat;
}
Modified: webservices/xmlrpc/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/webservices/x
mlrpc/trunk/src/changes/changes.xml?rev=433819&r1=433818
&r2=433819&view=diff
============================================================
==================
--- webservices/xmlrpc/trunk/src/changes/changes.xml
(original)
+++ webservices/xmlrpc/trunk/src/changes/changes.xml Tue Aug
22 18:06:11 2006
 -48,6
+48,9 
due-to-email="jmclaurin petronworld.com">
Documentation improvements
</action>
+ <action dev="jochen"
type="add">
+ Added documentation on custom data types.
+ </action>
</release>
<release version="3.0rc1"
date="27-Jul-2006">
<action dev="jochen"
type="fix" due-to="Alan Burlison"
Modified: webservices/xmlrpc/trunk/src/site/apt/advanced.apt
URL: http://svn.apache.org/viewvc/webservices
/xmlrpc/trunk/src/site/apt/advanced.apt?rev=433819&r1=43
3818&r2=433819&view=diff
============================================================
==================
--- webservices/xmlrpc/trunk/src/site/apt/advanced.apt
(original)
+++ webservices/xmlrpc/trunk/src/site/apt/advanced.apt Tue
Aug 22 18:06:11 2006
 -81,3
+81,111 
to consider, which exception is being trapped: If the
method exposes
XmlRpcException, then you'll need to catch the
XmlRpcException.
Otherwise, it's UndeclaredThrowableException.
+
+* Custom data types
+
+ Apache XML-RPC was built with extensibility in mind. In
particular, it was
+ written to support custom data types.
+
+ The data type handling is completely left to the
+
{{{apidocs/org/apache/xmlrpc/common/TypeFactory.html}TypeFac
tory}}. In
+ other words, adding support for custom data types is as
simple as
+ providing your own type factory. This is typically done
by subclassing
+
{{{apidocs/org/apache/xmlrpc/common/TypeFactoryImpl.html}Typ
eFactoryImpl}}.
+
+ We'll illustrate the concept by creating a type factory,
which uses a
+ non-standard date format for transmitting date values.
First of all,
+ we've got to implement the subclass:
+
+-----------------------------------------------------------
------------------------
+ import java.text.DateFormat;
+ import java.text.SimpleDateFormat;
+ import org.apache.xmlrpc.common.TypeFactoryImpl;
+ import org.apache.xmlrpc.common.XmlRpcController;
+ import org.apache.xmlrpc.parser.DateParser;
+ import org.apache.xmlrpc.parser.TypeParser;
+ import org.apache.xmlrpc.serializer.DateSerializer;
+ import org.apache.xmlrpc.serializer.TypeSerializer;
+ import org.apache.ws.commons.util.NamespaceContextImpl;
+
+ public class MyTypeFactory extends TypeFactoryImpl {
+ public MyTypeFactory(XmlRpcController pController)
{
+ super(pController);
+ }
+
+ private DateFormat newFormat() {
+ return new SimpleDateFormat("yyyy-MM-dd
HH:mm:ss.SSS");
+ }
+
+ public TypeParser getParser(XmlRpcStreamConfig
pConfig, NamespaceContextImpl pContext, String pURI, String
pLocalName) {
+ if (DateSerializer.DATE_TAG.equals(pLocalName))
{
+ return new DateParser(pFormat);
+ } else {
+ return super.getParser(pConfig, pContext,
pURI, pLocalName);
+ }
+ }
+
+ public TypeSerializer
getSerializer(XmlRpcStreamConfig pConfig, Object pObject)
throws SAXException {
+ if (pObject instanceof Date) {
+ return new DateSerializer(newFormat());
+ } else {
+ return super.getSerializer(pConfig,
pObject);
+ }
+ }
+ }
+-----------------------------------------------------------
------------------------
+
+ On the client side, we've got to tell the
+
{{{apidocs/org/apache/xmlrpc/client/XmlRpcClient.html}XmlRpc
Client}} to use the
+ new factory. That's as simple as typing
+
+-----------------------------------------------------------
------------------------
+ XmlRpcClient client = new XmlRpcClient();
+ client.setTypeFactory(new MyTypeFactory());
+-----------------------------------------------------------
------------------------
+
+ Things are a little bit more difficult on the server
side. Basically all we need
+ to do is setting the type factory on the
+
{{{apidocs/org/apache/xmlrpc/server/XmlRpcServer.html}XmlRpc
Server}}. The question
+ is, how to obtain the server object. That depends on the
environment. If you
+ are using the XmlRpcServlet, then you've got to derive a
subclass:
+
+-----------------------------------------------------------
------------------------
+ import org.apache.xmlrpc.webserver.XmlRpcServletServer;
+ import org.apache.xmlrpc.webserver.XmlRpcServlet;
+
+ public class MyXmlRpcServlet extends XmlRpcServlet {
+ protected XmlRpcServletServer
newXmlRpcServer(ServletConfig pConfig) {
+ XmlRpcServletServer server =
super.newXmlRpcServer(pConfig);
+ server.setTypeFactory(new
MyTypeFactory(server));
+ return server;
+ }
+ }
+-----------------------------------------------------------
------------------------
+
+ And, if you are using the
+
{{{apidocs/org/apache/xmlrpc/webserver/WebServer.html}WebSer
ver}}, you've got
+ to override a similar method:
+
+-----------------------------------------------------------
------------------------
+ import java.net.InetAddress;
+ import org.apache.xmlrpc.server.XmlRpcStreamServer;
+ import org.apache.xmlrpc.webserver.WebServer;
+
+ public class MyWebServer extends WebServer {
+ public MyWebServer(int pPort) {
+ super(pPort);
+ }
+
+ public MyWebServer(int pPort, InetAddress pAddr) {
+ super(pPort, pAddr);
+ }
+
+ protected XmlRpcStreamServer newXmlRpcStreamServer()
{
+ XmlRpcStreamServer server = new
ConnectionServer();
+ server.setTypeFactory(new MyTypeFactory());
+ return server;
+ }
+ }
+-----------------------------------------------------------
------------------------
+
\ No newline at end of file
Modified: webservices/xmlrpc/trunk/src/site/fml/faq.fml
URL: http://svn.apache.org/viewvc/webservices/xmlr
pc/trunk/src/site/fml/faq.fml?rev=433819&r1=433818&r
2=433819&view=diff
============================================================
==================
--- webservices/xmlrpc/trunk/src/site/fml/faq.fml (original)
+++ webservices/xmlrpc/trunk/src/site/fml/faq.fml Tue Aug 22
18:06:11 2006
 -66,6
+66,17 
]]></source>
</answer>
</faq>
+
+ <faq id="nonstandard_date_format">
+ <question>I've got a server, which is
expecting a non-standard
+ date format. How can I ensure, that my date values
have the
+ right format?</question>
+ <answer>
+ <p>You've got to use a special type factory.
An example is
+ contained in the documentation on
+ {{{advanced.html}advanced topics}}.</p>
+ </answer>
+ </faq>
</part>
<part id="server">
Modified:
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/ClientProvider.java
URL: htt
p://svn.apache.org/viewvc/webservices/xmlrpc/trunk/tests/src
/test/java/org/apache/xmlrpc/test/ClientProvider.java?rev=43
3819&r1=433818&r2=433819&view=diff
============================================================
==================
---
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/ClientProvider.java (original)
+++
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/ClientProvider.java Tue Aug 22 18:06:11 2006
 -17,6
+17,7 
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
+import org.apache.xmlrpc.server.XmlRpcServer;
/** This interface allows to perform a unit test with
various
* transports. Basically, the implementation creates the
client,
 -33,4
+34,9 
* return A client being used for performing the test.
*/
XmlRpcClient getClient();
+
+ /** Returns the providers server instance.
+ * return A server instance, which is being used for
performing the test.
+ */
+ XmlRpcServer getServer();
}
Added:
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/CustomTypesTest.java
URL: http://svn.apache.org/viewvc/w
ebservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlrp
c/test/CustomTypesTest.java?rev=433819&view=auto
============================================================
==================
---
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/CustomTypesTest.java (added)
+++
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/CustomTypesTest.java Tue Aug 22 18:06:11 2006
 -0,0
+1,125 
+/*
+ * Copyright 1999,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the
"License");
+ * you may not use this file except in compliance with the
License.
+ * You may obtain a copy of the License at
+ *
+ * http://www
.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in
writing, software
+ * distributed under the License is distributed on an
"AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied.
+ * See the License for the specific language governing
permissions and
+ * limitations under the License.
+ */
+package org.apache.xmlrpc.test;
+
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.Format;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+
+import org.apache.ws.commons.util.NamespaceContextImpl;
+import org.apache.xmlrpc.XmlRpcException;
+import org.apache.xmlrpc.XmlRpcRequest;
+import org.apache.xmlrpc.client.XmlRpcClient;
+import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
+import org.apache.xmlrpc.client.XmlRpcClientRequestImpl;
+import org.apache.xmlrpc.common.TypeFactory;
+import org.apache.xmlrpc.common.TypeFactoryImpl;
+import org.apache.xmlrpc.common.XmlRpcController;
+import org.apache.xmlrpc.common.XmlRpcStreamConfig;
+import org.apache.xmlrpc.parser.DateParser;
+import org.apache.xmlrpc.parser.TypeParser;
+import org.apache.xmlrpc.serializer.DateSerializer;
+import org.apache.xmlrpc.serializer.TypeSerializer;
+import org.apache.xmlrpc.server.PropertyHandlerMapping;
+import org.apache.xmlrpc.server.XmlRpcHandlerMapping;
+import org.apache.xmlrpc.server.XmlRpcServer;
+import org.xml.sax.SAXException;
+
+
+/**
+ * Test suite for working with custom types.
+ */
+public class CustomTypesTest extends XmlRpcTestCase {
+ /**
+ * Sample date converter
+ */
+ public static class DateConverter {
+ /**
+ * Adds one day to the given date.
+ */
+ public Date tomorrow(Date pDate) {
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(pDate);
+ cal.add(Calendar.DAY_OF_MONTH, 1);
+ return cal.getTime();
+ }
+ }
+
+ protected XmlRpcHandlerMapping getHandlerMapping()
throws IOException, XmlRpcException {
+ PropertyHandlerMapping mapping = new
PropertyHandlerMapping();
+ mapping.addHandler("DateConverter",
DateConverter.class);
+ return mapping;
+ }
+
+ /** Tests using a custom date format.
+ */
+ public void testCustomDateFormat() throws Exception {
+ for (int i = 0; i < providers.length; i++) {
+ testCustomDateFormat(providers[i]);
+ }
+ }
+
+ private TypeFactory
getCustomDateTypeFactory(XmlRpcController pController, final
Format pFormat) {
+ return new TypeFactoryImpl(pController){
+ private TypeSerializer dateSerializer = new
DateSerializer(pFormat);
+
+ public TypeParser getParser(XmlRpcStreamConfig
pConfig, NamespaceContextImpl pContext, String pURI, String
pLocalName) {
+ if
(DateSerializer.DATE_TAG.equals(pLocalName)) {
+ return new DateParser(pFormat);
+ } else {
+ return super.getParser(pConfig,
pContext, pURI, pLocalName);
+ }
+ }
+
+ public TypeSerializer
getSerializer(XmlRpcStreamConfig pConfig, Object pObject)
throws SAXException {
+ if (pObject instanceof Date) {
+ return dateSerializer;
+ } else {
+ return super.getSerializer(pConfig,
pObject);
+ }
+ }
+
+ };
+ }
+
+ private void testCustomDateFormat(ClientProvider
pProvider) throws Exception {
+ final DateFormat format = new
SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
+ XmlRpcClient client = pProvider.getClient();
+ XmlRpcClientConfigImpl config =
getConfig(pProvider);
+ client.setConfig(config);
+ TypeFactory typeFactory =
getCustomDateTypeFactory(client, format);
+ client.setTypeFactory(typeFactory);
+ Calendar cal1 = Calendar.getInstance();
+ XmlRpcRequest request = new
XmlRpcClientRequestImpl(config,
"DateConverter.tomorrow", new
Object[]{cal1.getTime()});
+ final String got =
XmlRpcTestCase.writeRequest(client, request);
+ final String expect = "<?xml
version=\"1.0\"
encoding=\"US-ASCII\"?>"
+ +
"<methodCall><methodName>DateConverter.tom
orrow</methodName>"
+ +
"<params><param><value><dateTime.
iso8601>" + format.format(cal1.getTime())
+ +
"</dateTime.iso8601></value></param>
</params></methodCall>";
+ assertEquals(expect, got);
+
+ XmlRpcServer server = pProvider.getServer();
+
server.setTypeFactory(getCustomDateTypeFactory(server,
format));
+ Date date = (Date) client.execute(request);
+ Calendar cal2 = Calendar.getInstance();
+ cal2.setTime(date);
+ cal1.add(Calendar.DAY_OF_MONTH, 1);
+ assertEquals(cal1, cal2);
+ }
+}
Modified:
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/LocalStreamTransportProvider.java
URL: http://svn.apache.org/viewvc/webservices/xmlrpc/t
runk/tests/src/test/java/org/apache/xmlrpc/test/LocalStreamT
ransportProvider.java?rev=433819&r1=433818&r2=433819
&view=diff
============================================================
==================
---
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/LocalStreamTransportProvider.java (original)
+++
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/LocalStreamTransportProvider.java Tue Aug 22
18:06:11 2006
 -20,13
+20,16 
import org.apache.xmlrpc.client.XmlRpcTransportFactory;
import org.apache.xmlrpc.server.XmlRpcHandlerMapping;
import org.apache.xmlrpc.server.XmlRpcLocalStreamServer;
+import org.apache.xmlrpc.server.XmlRpcServer;
/** Implementation of { link
org.apache.xmlrpc.test.BaseTest}
* for testing the { link
org.apache.xmlrpc.client.XmlRpcLocalStreamTransport}.
*/
public class LocalStreamTransportProvider extends
LocalTransportProvider {
- /** Creates a new instance.
+ private XmlRpcLocalStreamServer server;
+
+ /** Creates a new instance.
* param pMapping The test servers handler mapping.
*/
public LocalStreamTransportProvider(XmlRpcHandlerMapping
pMapping) {
 -34,8
+37,13 
}
protected XmlRpcTransportFactory
getTransportFactory(XmlRpcClient pClient) {
- XmlRpcLocalStreamTransportFactory factory
- = new XmlRpcLocalStreamTransportFactory(pClient, new
XmlRpcLocalStreamServer());
+ server = new XmlRpcLocalStreamServer();
+ XmlRpcLocalStreamTransportFactory factory
+ = new XmlRpcLocalStreamTransportFactory(pClient,
server);
return factory;
}
+
+ public XmlRpcServer getServer() {
+ return server;
+ }
}
Modified:
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/LocalTransportProvider.java
URL: http://svn.apache.org/viewvc/webservices/xmlrpc/trunk/t
ests/src/test/java/org/apache/xmlrpc/test/LocalTransportProv
ider.java?rev=433819&r1=433818&r2=433819&view=di
ff
============================================================
==================
---
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/LocalTransportProvider.java (original)
+++
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/LocalTransportProvider.java Tue Aug 22 18:06:11 2006
 -20,13
+20,16 
import
org.apache.xmlrpc.client.XmlRpcLocalTransportFactory;
import org.apache.xmlrpc.client.XmlRpcTransportFactory;
import org.apache.xmlrpc.server.XmlRpcHandlerMapping;
+import org.apache.xmlrpc.server.XmlRpcServer;
/** Implementation of { link
org.apache.xmlrpc.test.BaseTest}
* for testing the { link
org.apache.xmlrpc.client.XmlRpcLocalTransport}.
*/
public class LocalTransportProvider extends
ClientProviderImpl {
- /** Creates a new instance.
+ private XmlRpcServer server;
+
+ /** Creates a new instance.
* param pMapping The test servers handler mapping.
*/
public LocalTransportProvider(XmlRpcHandlerMapping
pMapping) {
 -40,7
+43,12 
public XmlRpcClientConfigImpl getConfig() throws Exception
{
XmlRpcClientConfigImpl config = super.getConfig();
- config.setXmlRpcServer(getXmlRpcServer());
+ server = getXmlRpcServer();
+ config.setXmlRpcServer(server);
return config;
}
+
+ public XmlRpcServer getServer() {
+ return server;
+ }
}
Modified:
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/SerializerTest.java
URL: htt
p://svn.apache.org/viewvc/webservices/xmlrpc/trunk/tests/src
/test/java/org/apache/xmlrpc/test/SerializerTest.java?rev=43
3819&r1=433818&r2=433819&view=diff
============================================================
==================
---
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/SerializerTest.java (original)
+++
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/SerializerTest.java Tue Aug 22 18:06:11 2006
 -15,7
+15,6 
*/
package org.apache.xmlrpc.test;
-import java.io.StringWriter;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
 -23,15
+22,13 
import junit.framework.TestCase;
-import org.apache.ws.commons.serialize.XMLWriter;
-import org.apache.ws.commons.serialize.XMLWriterImpl;
import org.apache.xmlrpc.XmlRpcRequest;
import org.apache.xmlrpc.client.XmlRpcClient;
+import org.apache.xmlrpc.client.XmlRpcClientConfig;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
import org.apache.xmlrpc.client.XmlRpcClientRequestImpl;
import
org.apache.xmlrpc.client.XmlRpcSunHttpTransportFactory;
import org.apache.xmlrpc.common.XmlRpcStreamRequestConfig;
-import org.apache.xmlrpc.serializer.XmlRpcWriter;
import org.xml.sax.SAXException;
 -60,15
+57,8 
protected String writeRequest(XmlRpcStreamRequestConfig
pConfig, XmlRpcRequest pRequest)
throws SAXException {
- StringWriter sw = new StringWriter();
- XMLWriter xw = new XMLWriterImpl();
- xw.setEncoding("US-ASCII");
- xw.setDeclarating(true);
- xw.setIndenting(false);
- xw.setWriter(sw);
- XmlRpcWriter xrw = new XmlRpcWriter(pConfig, xw,
client.getTypeFactory());
- xrw.write(pRequest);
- return sw.toString();
+ client.setConfig((XmlRpcClientConfig) pConfig);
+ return XmlRpcTestCase.writeRequest(client,
pRequest);
}
/** Test serialization of a byte parameter.
Modified:
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/ServletWebServerProvider.java
URL: http://svn.apache.org/viewvc/webservices/xmlrpc/trunk
/tests/src/test/java/org/apache/xmlrpc/test/ServletWebServer
Provider.java?rev=433819&r1=433818&r2=433819&vie
w=diff
============================================================
==================
---
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/ServletWebServerProvider.java (original)
+++
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/ServletWebServerProvider.java Tue Aug 22 18:06:11
2006
 -35,6
+35,7 
*/
public class ServletWebServerProvider extends
ClientProviderImpl {
protected final ServletWebServer webServer;
+ protected final XmlRpcServlet servlet;
private final boolean contentLength;
private final int port;
 -46,7
+47,7 
protected ServletWebServerProvider(XmlRpcHandlerMapping
pMapping, boolean pContentLength) throws ServletException,
IOException {
super(pMapping);
contentLength = pContentLength;
- XmlRpcServlet servlet = new XmlRpcServlet();
+ servlet = new XmlRpcServlet();
webServer = new ServletWebServer(servlet, 0);
XmlRpcServer server = servlet.getXmlRpcServletServer();
server.setHandlerMapping(mapping);
 -71,4
+72,8 
protected XmlRpcTransportFactory
getTransportFactory(XmlRpcClient pClient) {
return new XmlRpcSunHttpTransportFactory(pClient);
}
+
+ public XmlRpcServer getServer() {
+ return servlet.getXmlRpcServletServer();
+ }
}
Modified:
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/WebServerProvider.java
URL:
http://svn.apache.org/viewvc/webservices/xmlrpc/trunk/tests/
src/test/java/org/apache/xmlrpc/test/WebServerProvider.java?
rev=433819&r1=433818&r2=433819&view=diff
============================================================
==================
---
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/WebServerProvider.java (original)
+++
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/WebServerProvider.java Tue Aug 22 18:06:11 2006
 -62,4
+62,8 
isActive = true;
}
}
+
+ public XmlRpcServer getServer() {
+ return webServer.getXmlRpcServer();
+ }
}
Modified:
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/XmlRpcTestCase.java
URL: htt
p://svn.apache.org/viewvc/webservices/xmlrpc/trunk/tests/src
/test/java/org/apache/xmlrpc/test/XmlRpcTestCase.java?rev=43
3819&r1=433818&r2=433819&view=diff
============================================================
==================
---
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/XmlRpcTestCase.java (original)
+++
webservices/xmlrpc/trunk/tests/src/test/java/org/apache/xmlr
pc/test/XmlRpcTestCase.java Tue Aug 22 18:06:11 2006
 -16,18
+16,26 
package org.apache.xmlrpc.test;
import java.io.IOException;
+import java.io.StringWriter;
import javax.servlet.ServletException;
+import junit.framework.TestCase;
+
+import org.apache.ws.commons.serialize.XMLWriter;
+import org.apache.ws.commons.serialize.XMLWriterImpl;
import org.apache.xmlrpc.XmlRpcException;
+import org.apache.xmlrpc.XmlRpcRequest;
+import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfig;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
import org.apache.xmlrpc.common.TypeConverterFactory;
import org.apache.xmlrpc.common.TypeConverterFactoryImpl;
+import org.apache.xmlrpc.common.XmlRpcStreamConfig;
+import org.apache.xmlrpc.serializer.XmlRpcWriter;
import org.apache.xmlrpc.server.PropertyHandlerMapping;
import org.apache.xmlrpc.server.XmlRpcHandlerMapping;
-
-import junit.framework.TestCase;
+import org.xml.sax.SAXException;
/** Abstract base class for deriving test cases.
 -76,5
+84,18 
protected TypeConverterFactory
getTypeConverterFactory() {
return new TypeConverterFactoryImpl();
+ }
+
+ static String writeRequest(XmlRpcClient pClient,
XmlRpcRequest pRequest)
+ throws SAXException {
+ StringWriter sw = new StringWriter();
+ XMLWriter xw = new XMLWriterImpl();
+ xw.setEncoding("US-ASCII");
+ xw.setDeclarating(true);
+ xw.setIndenting(false);
+ xw.setWriter(sw);
+ XmlRpcWriter xrw = new
XmlRpcWriter((XmlRpcStreamConfig) pClient.getConfig(), xw,
pClient.getTypeFactory());
+ xrw.write(pRequest);
+ return sw.toString();
}
}
|