Author: jochen
Date: Sun Nov  6 18:46:21 2005
New Revision: 331181

URL: http://svn.apache.org/viewcvs?rev=331181&view=rev
Log:
Got "mvn test" working.

Added:
    
webservices/xmlrpc/branches/b20050512_streaming/src/test/org/apache/xmlrpc/test/ServletWebServerProvider.java
    
webservices/xmlrpc/branches/b20050512_streaming/src/testResources/org/apache/xmlrpc/webserver/
    
webservices/xmlrpc/branches/b20050512_streaming/src/testResources/org/apache/xmlrpc/webserver/XmlRpcServlet.properties
Modified:
    webservices/xmlrpc/branches/b20050512_streaming/pom.xml
    
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/common/XmlRpcHttpConfig.java
    
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/common/XmlRpcStreamConfig.java
    
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/serializer/BaseXmlWriterFactory.java
    
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/server/XmlRpcStreamServer.java
    
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/util/HttpUtil.java
    
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/webserver/HttpServletRequestImpl.java
    
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/webserver/ServletWebServer.java
    
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/webserver/WebServer.java
    
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/webserver/XmlRpcServlet.java
    
webservices/xmlrpc/branches/b20050512_streaming/src/test/org/apache/xmlrpc/test/BaseTest.java
    
webservices/xmlrpc/branches/b20050512_streaming/src/test/org/apache/xmlrpc/test/SerializerTest.java

Modified: webservices/xmlrpc/branches/b20050512_streaming/pom.xml
URL: 
http://svn.apache.org/viewcvs/webservices/xmlrpc/branches/b20050512_streaming/pom.xml?rev=331181&r1=331180&r2=331181&view=diff
==============================================================================
--- webservices/xmlrpc/branches/b20050512_streaming/pom.xml (original)
+++ webservices/xmlrpc/branches/b20050512_streaming/pom.xml Sun Nov  6 18:46:21 
2005
@@ -170,6 +170,28 @@
             <artifactId>jaxmeapi</artifactId>
             <version>0.5</version>
         </dependency>
+               <!-- One should think, that the Xerces dependency is not
+                    required with Java 1.4 or Java 5. However, see
+                    http://jira.codehaus.org/browse/MNG-1303
+                    for why we add it here.
+               -->
+        <dependency>
+            <groupId>xerces</groupId>
+            <artifactId>xercesImpl</artifactId>
+            <version>2.6.2</version>
+        </dependency>
     </dependencies>
+    <reporting>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-javadoc-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-pmd-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </reporting>
 </project>
 

Modified: 
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/common/XmlRpcHttpConfig.java
URL: 
http://svn.apache.org/viewcvs/webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/common/XmlRpcHttpConfig.java?rev=331181&r1=331180&r2=331181&view=diff
==============================================================================
--- 
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/common/XmlRpcHttpConfig.java
 (original)
+++ 
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/common/XmlRpcHttpConfig.java
 Sun Nov  6 18:46:21 2005
@@ -23,7 +23,7 @@
         * into bytes.
         * @return Encoding being used for basic HTTP authentication 
credentials,
         * or null, if the default encoding
-        * ([EMAIL PROTECTED] 
org.apache.xmlrpc.common.XmlRpcStreamRequestConfig#DEFAULT_ENCODING})
+        * ([EMAIL PROTECTED] 
org.apache.xmlrpc.common.XmlRpcStreamRequestConfig#UTF8_ENCODING})
         * is being used.
         */
        String getBasicEncoding();

Modified: 
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/common/XmlRpcStreamConfig.java
URL: 
http://svn.apache.org/viewcvs/webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/common/XmlRpcStreamConfig.java?rev=331181&r1=331180&r2=331181&view=diff
==============================================================================
--- 
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/common/XmlRpcStreamConfig.java
 (original)
+++ 
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/common/XmlRpcStreamConfig.java
 Sun Nov  6 18:46:21 2005
@@ -23,11 +23,11 @@
 public interface XmlRpcStreamConfig extends XmlRpcConfig {
        /** Default encoding (UTF-8).
         */
-       public static final String DEFAULT_ENCODING = "UTF8";
+       public static final String UTF8_ENCODING = "UTF-8";
 
        /** Returns the encoding being used for data encoding, when writing
         * to a stream.
-        * @return Suggested encoding, or null, if the [EMAIL PROTECTED] 
#DEFAULT_ENCODING}
+        * @return Suggested encoding, or null, if the [EMAIL PROTECTED] 
#UTF8_ENCODING}
         * is being used.
         */
        String getEncoding();

Modified: 
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/serializer/BaseXmlWriterFactory.java
URL: 
http://svn.apache.org/viewcvs/webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/serializer/BaseXmlWriterFactory.java?rev=331181&r1=331180&r2=331181&view=diff
==============================================================================
--- 
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/serializer/BaseXmlWriterFactory.java
 (original)
+++ 
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/serializer/BaseXmlWriterFactory.java
 Sun Nov  6 18:46:21 2005
@@ -42,7 +42,7 @@
                xw.setDeclarating(true);
                String enc = pConfig.getEncoding();
                if (enc == null) {
-                       enc = XmlRpcStreamConfig.DEFAULT_ENCODING;
+                       enc = XmlRpcStreamConfig.UTF8_ENCODING;
                }
                xw.setEncoding(enc);
                xw.setIndenting(false);

Modified: 
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/server/XmlRpcStreamServer.java
URL: 
http://svn.apache.org/viewcvs/webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/server/XmlRpcStreamServer.java?rev=331181&r1=331180&r2=331181&view=diff
==============================================================================
--- 
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/server/XmlRpcStreamServer.java
 (original)
+++ 
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/server/XmlRpcStreamServer.java
 Sun Nov  6 18:46:21 2005
@@ -26,6 +26,8 @@
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.parsers.SAXParserFactory;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.xmlrpc.XmlRpcException;
 import org.apache.xmlrpc.XmlRpcRequest;
 import org.apache.xmlrpc.XmlRpcRequestConfig;
@@ -45,6 +47,7 @@
  * stream.
  */
 public abstract class XmlRpcStreamServer extends XmlRpcServer {
+       private static final Log log = 
LogFactory.getLog(XmlRpcStreamServer.class);
        private static final SAXParserFactory spf;
        private XmlWriterFactory writerFactory = new DefaultXMLWriterFactory();
        static {
@@ -195,6 +198,7 @@
        public void execute(XmlRpcStreamRequestConfig pConfig,
                                                Object pConnection)
                        throws IOException, XmlRpcException {
+               log.debug("execute: ->");
                try {
                        Object result;
                        Throwable error;
@@ -206,7 +210,9 @@
                                istream.close();
                                istream = null;
                                error = null;
+                               log.debug("execute: Request performed 
successfully");
                        } catch (Throwable t) {
+                               log.error("execute: Error while performing 
request", t);
                                result = null;
                                error = t;
                        } finally {
@@ -249,5 +255,6 @@
                } finally {
                        if (pConnection != null) { try { 
closeConnection(pConnection); } catch (Throwable ignore) {} }
                }
+               log.debug("execute: <-");
        }
 }

Modified: 
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/util/HttpUtil.java
URL: 
http://svn.apache.org/viewcvs/webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/util/HttpUtil.java?rev=331181&r1=331180&r2=331181&view=diff
==============================================================================
--- 
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/util/HttpUtil.java
 (original)
+++ 
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/util/HttpUtil.java
 Sun Nov  6 18:46:21 2005
@@ -42,7 +42,7 @@
         }
                String s = pUser + ':' + pPassword;
                if (pEncoding == null) {
-                       pEncoding = XmlRpcStreamConfig.DEFAULT_ENCODING;
+                       pEncoding = XmlRpcStreamConfig.UTF8_ENCODING;
                }
                return new String(Base64.encode(s.getBytes(pEncoding)));
     }

Modified: 
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/webserver/HttpServletRequestImpl.java
URL: 
http://svn.apache.org/viewcvs/webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/webserver/HttpServletRequestImpl.java?rev=331181&r1=331180&r2=331181&view=diff
==============================================================================
--- 
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/webserver/HttpServletRequestImpl.java
 (original)
+++ 
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/webserver/HttpServletRequestImpl.java
 Sun Nov  6 18:46:21 2005
@@ -42,6 +42,7 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
 
+import org.apache.xmlrpc.common.XmlRpcStreamConfig;
 import org.apache.xmlrpc.util.HttpUtil;
 
 
@@ -65,6 +66,7 @@
        private final Map attributes = new HashMap();
        private Map parameters;
        private String characterEncoding;
+       private int contentBytesRemaining = -1;
 
        /** Creates a new instance, which reads input from the given
         * socket.
@@ -83,7 +85,14 @@
         };
                istream = new ServletInputStream(){
                        public int read() throws IOException {
-                               return bis.read();
+                               if (contentBytesRemaining == 0) {
+                                       return -1;
+                               }
+                               int c = bis.read();
+                               if (c != -1  &&  contentBytesRemaining > 0) {
+                                       --contentBytesRemaining;
+                               }
+                               return c;
                        }
                };
 
@@ -139,7 +148,11 @@
                        protocol = "HTTP";
                }
 
-               for (line = HttpUtil.readLine(istream, buffer);  line != null  
&&  line.length() > 0;  ) {
+               for (;;) {
+                       line = HttpUtil.readLine(istream, buffer);
+                       if (line == null  ||  line.length() == 0) {
+                               break;
+                       }
                        int off = line.indexOf(':');
                        if (off > 0) {
                                addHeader(line.substring(0, off), 
line.substring(off+1).trim());
@@ -147,6 +160,7 @@
                                throw new ServletWebServer.Exception(400, "Bad 
Request", "Unable to parse header line: " + line);
                        }
                }
+               contentBytesRemaining = getIntHeader("content-length");
        }
 
        protected String readLine(byte[] pBuffer) throws IOException {
@@ -398,7 +412,7 @@
                }
                String encoding = getCharacterEncoding();
                if (encoding == null) {
-                       encoding = "UTF8";
+                       encoding = XmlRpcStreamConfig.UTF8_ENCODING;
                }
                Map params = new HashMap();
                String s = getQueryString();

Modified: 
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/webserver/ServletWebServer.java
URL: 
http://svn.apache.org/viewcvs/webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/webserver/ServletWebServer.java?rev=331181&r1=331180&r2=331181&view=diff
==============================================================================
--- 
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/webserver/ServletWebServer.java
 (original)
+++ 
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/webserver/ServletWebServer.java
 Sun Nov  6 18:46:21 2005
@@ -18,7 +18,12 @@
 import java.io.IOException;
 import java.net.InetAddress;
 import java.net.Socket;
+import java.util.Enumeration;
+import java.util.NoSuchElementException;
 
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
 
 import org.apache.xmlrpc.server.XmlRpcStreamServer;
@@ -70,10 +75,10 @@
         * @param pServlet The servlet, which is handling requests.
         * @param pPort The servers port number; 0 for a random
         * port being choosen.
+        * @throws ServletException Initializing the servlet failed.
         */
-       public ServletWebServer(HttpServlet pServlet, int pPort) {
-               super(pPort);
-               servlet = pServlet;
+       public ServletWebServer(HttpServlet pServlet, int pPort) throws 
ServletException {
+               this(pServlet, pPort, null);
        }
 
        /** Creates a new instance, which is listening on the
@@ -82,10 +87,31 @@
         * @param pPort The servers port number; 0 for a random
         * port being choosen.
         * @param pAddr The servers IP address.
+        * @throws ServletException Initializing the servlet failed.
         */
-       public ServletWebServer(HttpServlet pServlet, int pPort, InetAddress 
pAddr) {
+       public ServletWebServer(HttpServlet pServlet, int pPort, InetAddress 
pAddr)
+                       throws ServletException {
                super(pPort, pAddr);
                servlet = pServlet;
+               servlet.init(new ServletConfig(){
+                       public String getServletName() { return 
servlet.getClass().getName(); }
+                       public ServletContext getServletContext() {
+                               throw new IllegalStateException("Context not 
available");
+                       }
+                       public String getInitParameter(String pArg0) {
+                               return null;
+                       }
+               
+                       public Enumeration getInitParameterNames() {
+                               return new Enumeration(){
+                                       public boolean hasMoreElements() { 
return false; }
+                                       public Object nextElement() {
+                                               throw new 
NoSuchElementException();
+                                       }
+                               };
+                       }
+                       
+               });
        }
 
        protected ThreadPool.Task newTask(WebServer pWebServer,

Modified: 
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/webserver/WebServer.java
URL: 
http://svn.apache.org/viewcvs/webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/webserver/WebServer.java?rev=331181&r1=331180&r2=331181&view=diff
==============================================================================
--- 
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/webserver/WebServer.java
 (original)
+++ 
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/webserver/WebServer.java
 Sun Nov  6 18:46:21 2005
@@ -17,19 +17,17 @@
 
 import java.io.IOException;
 import java.io.InterruptedIOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
 import java.net.BindException;
 import java.net.InetAddress;
 import java.net.ServerSocket;
 import java.net.Socket;
 import java.net.SocketException;
-import java.text.DateFormat;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.List;
 import java.util.StringTokenizer;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.xmlrpc.server.XmlRpcStreamServer;
 import org.apache.xmlrpc.util.ThreadPool;
 
@@ -37,6 +35,8 @@
 /** A minimal web server that exclusively handles XML-RPC requests.
  */
 public class WebServer implements Runnable {
+       private static final Log log = LogFactory.getLog(WebServer.class);
+
        private class AddressMatcher {
                private final int pattern[];
                
@@ -79,7 +79,11 @@
        private ThreadPool pool;
        protected final List accept = new ArrayList();
        protected final List deny = new ArrayList();
-       protected final XmlRpcStreamServer server = new ConnectionServer();
+       protected final XmlRpcStreamServer server = newXmlRpcStreamServer();
+
+       protected XmlRpcStreamServer newXmlRpcStreamServer(){
+               return new ConnectionServer();
+       }
 
        // Inputs to setupServerSocket()
        private InetAddress address;
@@ -339,26 +343,14 @@
         * @param pError The error being logged.
         */
        public void log(Throwable pError) {
-               /* We could do a simple pError.printStackTrace() here,
-                * but at the risk, that the stack trace could be
-                * interrupted by other threads logging messages.
-                * So we log to a StringWriter and do the actual
-                * logging with a single println().
-                */
-               StringWriter sw = new StringWriter();
-               PrintWriter pw = new PrintWriter(sw);
-               pError.printStackTrace(pw);
-               pw.close();
-               log(sw.toString());
+               log.error(pError.getMessage(), pError);
        }
 
-       private final DateFormat df = DateFormat.getDateTimeInstance();
-
        /** Logs a message.
         * @param pMessage The being logged.
         */
        public synchronized void log(String pMessage) {
-               System.err.println(df.format(new Date()) + ", " + 
Thread.currentThread().getName() + ": " + pMessage);
+               log.error(pMessage);
        }
 
        /** Returns the [EMAIL PROTECTED] 
org.apache.xmlrpc.server.XmlRpcServer}.

Modified: 
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/webserver/XmlRpcServlet.java
URL: 
http://svn.apache.org/viewcvs/webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/webserver/XmlRpcServlet.java?rev=331181&r1=331180&r2=331181&view=diff
==============================================================================
--- 
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/webserver/XmlRpcServlet.java
 (original)
+++ 
webservices/xmlrpc/branches/b20050512_streaming/src/java/org/apache/xmlrpc/webserver/XmlRpcServlet.java
 Sun Nov  6 18:46:21 2005
@@ -35,17 +35,27 @@
  * method [EMAIL PROTECTED] #newXmlRpcHandlerMapping()}.
  */
 public class XmlRpcServlet extends HttpServlet {
-
        private static final long serialVersionUID = 2348768267234L;
        private XmlRpcServletServer server;
 
+       /** Returns the servlets instance of [EMAIL PROTECTED] 
XmlRpcServletServer}. 
+        * @return The configurable instance of [EMAIL PROTECTED] 
XmlRpcServletServer}.
+        */
+       public XmlRpcServletServer getXmlRpcServletServer() {
+               return server;
+       }
+
        public void init(ServletConfig pConfig) throws ServletException {
                super.init(pConfig);
                try {
-                       server = newXmlRpcServer();
+                       server = newXmlRpcServer(pConfig);
                        server.setHandlerMapping(newXmlRpcHandlerMapping());
                } catch (XmlRpcException e) {
-                       log("Failed to create XmlRpcServer: " + e.getMessage(), 
e);
+                       try {
+                               log("Failed to create XmlRpcServer: " + 
e.getMessage(), e);
+                       } catch (Throwable ignore) {
+                       }
+                       throw new ServletException(e);
                }
        }
 
@@ -53,7 +63,8 @@
         * which is being used to process the requests. The default 
implementation
         * will simply invoke <code>new [EMAIL PROTECTED] XmlRpcServer}.
         */
-       protected XmlRpcServletServer newXmlRpcServer() throws XmlRpcException {
+       protected XmlRpcServletServer newXmlRpcServer(ServletConfig pConfig)
+                       throws XmlRpcException {
                return new XmlRpcServletServer();
        }
 

Modified: 
webservices/xmlrpc/branches/b20050512_streaming/src/test/org/apache/xmlrpc/test/BaseTest.java
URL: 
http://svn.apache.org/viewcvs/webservices/xmlrpc/branches/b20050512_streaming/src/test/org/apache/xmlrpc/test/BaseTest.java?rev=331181&r1=331180&r2=331181&view=diff
==============================================================================
--- 
webservices/xmlrpc/branches/b20050512_streaming/src/test/org/apache/xmlrpc/test/BaseTest.java
 (original)
+++ 
webservices/xmlrpc/branches/b20050512_streaming/src/test/org/apache/xmlrpc/test/BaseTest.java
 Sun Nov  6 18:46:21 2005
@@ -60,7 +60,9 @@
                                new LiteTransportProvider(mapping, false),
                                new SunHttpTransportProvider(mapping, true),
                                new SunHttpTransportProvider(mapping, false),
-                               new CommonsProvider(mapping)
+                               new CommonsProvider(mapping),
+                               new ServletWebServerProvider(mapping, true),
+                               new ServletWebServerProvider(mapping, false)
                        };
                }
        }

Modified: 
webservices/xmlrpc/branches/b20050512_streaming/src/test/org/apache/xmlrpc/test/SerializerTest.java
URL: 
http://svn.apache.org/viewcvs/webservices/xmlrpc/branches/b20050512_streaming/src/test/org/apache/xmlrpc/test/SerializerTest.java?rev=331181&r1=331180&r2=331181&view=diff
==============================================================================
--- 
webservices/xmlrpc/branches/b20050512_streaming/src/test/org/apache/xmlrpc/test/SerializerTest.java
 (original)
+++ 
webservices/xmlrpc/branches/b20050512_streaming/src/test/org/apache/xmlrpc/test/SerializerTest.java
 Sun Nov  6 18:46:21 2005
@@ -94,7 +94,7 @@
                String expect =
                        "<?xml version=\"1.0\" encoding=\"US-ASCII\"?>"
                        + "<methodCall>"
-                       + 
"<methodName>intParam</methodName><params><param><value><int>3</int></value></param></params></methodCall>";
+                       + 
"<methodName>intParam</methodName><params><param><value><i4>3</i4></value></param></params></methodCall>";
                assertEquals(expect, got);
        }
 
@@ -128,8 +128,8 @@
                        "<?xml version=\"1.0\" encoding=\"US-ASCII\"?>"
                        + "<methodCall><methodName>mapParam</methodName>"
                        + "<params><param><value><struct>"
-                       + 
"<member><name>3</name><value><int>5</int></value></member>"
-                       + 
"<member><name>2</name><value><int>3</int></value></member>"
+                       + 
"<member><name>3</name><value><i4>5</i4></value></member>"
+                       + 
"<member><name>2</name><value><i4>3</i4></value></member>"
                        + "</struct></value></param></params></methodCall>";
                assertEquals(expect, got);
        }

Added: 
webservices/xmlrpc/branches/b20050512_streaming/src/test/org/apache/xmlrpc/test/ServletWebServerProvider.java
URL: 
http://svn.apache.org/viewcvs/webservices/xmlrpc/branches/b20050512_streaming/src/test/org/apache/xmlrpc/test/ServletWebServerProvider.java?rev=331181&view=auto
==============================================================================
--- 
webservices/xmlrpc/branches/b20050512_streaming/src/test/org/apache/xmlrpc/test/ServletWebServerProvider.java
 (added)
+++ 
webservices/xmlrpc/branches/b20050512_streaming/src/test/org/apache/xmlrpc/test/ServletWebServerProvider.java
 Sun Nov  6 18:46:21 2005
@@ -0,0 +1,74 @@
+/*
+ * 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.net.URL;
+
+import javax.servlet.ServletException;
+
+import org.apache.xmlrpc.client.XmlRpcClient;
+import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
+import org.apache.xmlrpc.client.XmlRpcSunHttpTransportFactory;
+import org.apache.xmlrpc.client.XmlRpcTransportFactory;
+import org.apache.xmlrpc.server.XmlRpcHandlerMapping;
+import org.apache.xmlrpc.server.XmlRpcServer;
+import org.apache.xmlrpc.server.XmlRpcServerConfigImpl;
+import org.apache.xmlrpc.webserver.ServletWebServer;
+import org.apache.xmlrpc.webserver.XmlRpcServlet;
+
+
+/** A provider class for testing the [EMAIL PROTECTED] ServletWebServer}.
+ */
+public class ServletWebServerProvider extends ClientProviderImpl {
+       protected final ServletWebServer webServer;
+       private final boolean contentLength;
+       private final int port;
+
+       /** Creates a new instance.
+        * @param pMapping The test servers handler mapping.
+        * @throws ServletException 
+        * @throws IOException 
+        */
+       protected ServletWebServerProvider(XmlRpcHandlerMapping pMapping, 
boolean pContentLength) throws ServletException, IOException {
+               super(pMapping);
+               contentLength = pContentLength;
+               XmlRpcServlet servlet = new XmlRpcServlet();
+               webServer = new ServletWebServer(servlet, 0);
+               XmlRpcServer server = servlet.getXmlRpcServletServer();
+               server.setHandlerMapping(mapping);
+               XmlRpcServerConfigImpl serverConfig = (XmlRpcServerConfigImpl) 
server.getConfig();
+               serverConfig.setEnabledForExtensions(true);
+               serverConfig.setContentLengthOptional(!contentLength);
+               webServer.start();
+               port = webServer.getPort();
+        }
+
+       public final XmlRpcClientConfigImpl getConfig() throws Exception {
+               return getConfig(new URL("http://127.0.0.1:"; + port + "/"));
+       }
+
+       protected XmlRpcClientConfigImpl getConfig(URL pServerURL) throws 
Exception {
+               XmlRpcClientConfigImpl config = super.getConfig();
+               config.setServerURL(pServerURL);
+               config.setContentLengthOptional(!contentLength);
+               return config;
+       }
+
+       protected XmlRpcTransportFactory getTransportFactory(XmlRpcClient 
pClient) {
+               return new XmlRpcSunHttpTransportFactory(pClient);
+       }
+}

Added: 
webservices/xmlrpc/branches/b20050512_streaming/src/testResources/org/apache/xmlrpc/webserver/XmlRpcServlet.properties
URL: 
http://svn.apache.org/viewcvs/webservices/xmlrpc/branches/b20050512_streaming/src/testResources/org/apache/xmlrpc/webserver/XmlRpcServlet.properties?rev=331181&view=auto
==============================================================================
--- 
webservices/xmlrpc/branches/b20050512_streaming/src/testResources/org/apache/xmlrpc/webserver/XmlRpcServlet.properties
 (added)
+++ 
webservices/xmlrpc/branches/b20050512_streaming/src/testResources/org/apache/xmlrpc/webserver/XmlRpcServlet.properties
 Sun Nov  6 18:46:21 2005
@@ -0,0 +1 @@
+Remote=org.apache.xmlrpc.test.BaseTest$Remote


Reply via email to