rwaldhoff 01/08/16 18:42:04 Modified: httpclient/src/test-webapp/src/org/apache/commons/httpclient Tag: rlwrefactoring BasicAuthServlet.java HeaderServlet.java ParamServlet.java RedirectServlet.java RequestBodyServlet.java httpclient/src/test/org/apache/commons/httpclient Tag: rlwrefactoring TestWebapp.java TestWebappBasicAuth.java TestWebappHeaders.java TestWebappMethods.java TestWebappParameters.java TestWebappRedirect.java Added: httpclient/src/test-webapp/src/org/apache/commons/httpclient Tag: rlwrefactoring MultiMethodServlet.java httpclient/src/test/org/apache/commons/httpclient Tag: rlwrefactoring TestWebappBase.java Log: factoring out common code in test servlets and test cases Revision Changes Path No revision No revision 1.1.2.2 +1 -17 jakarta-commons/httpclient/src/test-webapp/src/org/apache/commons/httpclient/Attic/BasicAuthServlet.java Index: BasicAuthServlet.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/test-webapp/src/org/apache/commons/httpclient/Attic/BasicAuthServlet.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- BasicAuthServlet.java 2001/08/16 23:58:12 1.1.2.1 +++ BasicAuthServlet.java 2001/08/17 01:42:03 1.1.2.2 @@ -5,7 +5,7 @@ import javax.servlet.http.*; import java.util.*; -public class BasicAuthServlet extends HttpServlet { +public class BasicAuthServlet extends MultiMethodServlet { // rather then make this servlet depend upon a base64 impl, // we'll just hard code some base65 encodings private static final HashMap creds = new HashMap(); @@ -56,22 +56,6 @@ } } - } - - public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - genericService(request,response); - } - - public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - genericService(request,response); - } - - public void doDelete(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - genericService(request,response); - } - - public void doPut(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - genericService(request,response); } } 1.1.2.2 +1 -17 jakarta-commons/httpclient/src/test-webapp/src/org/apache/commons/httpclient/Attic/HeaderServlet.java Index: HeaderServlet.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/test-webapp/src/org/apache/commons/httpclient/Attic/HeaderServlet.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- HeaderServlet.java 2001/08/13 15:56:31 1.1.2.1 +++ HeaderServlet.java 2001/08/17 01:42:03 1.1.2.2 @@ -5,7 +5,7 @@ import javax.servlet.http.*; import java.util.*; -public class HeaderServlet extends HttpServlet { +public class HeaderServlet extends MultiMethodServlet { protected void genericService(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setHeader("HeaderSetByServlet","Yes"); @@ -28,22 +28,6 @@ } out.println("</body>"); out.println("</html>"); - } - - public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - genericService(request,response); - } - - public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - genericService(request,response); - } - - public void doDelete(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - genericService(request,response); - } - - public void doPut(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - genericService(request,response); } } 1.1.2.2 +1 -17 jakarta-commons/httpclient/src/test-webapp/src/org/apache/commons/httpclient/Attic/ParamServlet.java Index: ParamServlet.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/test-webapp/src/org/apache/commons/httpclient/Attic/ParamServlet.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- ParamServlet.java 2001/08/13 15:56:31 1.1.2.1 +++ ParamServlet.java 2001/08/17 01:42:03 1.1.2.2 @@ -5,7 +5,7 @@ import javax.servlet.http.*; import java.util.*; -public class ParamServlet extends HttpServlet { +public class ParamServlet extends MultiMethodServlet { protected void genericService(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); @@ -44,22 +44,6 @@ out.println("</body>"); out.println("</html>"); - } - - public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - genericService(request,response); - } - - public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - genericService(request,response); - } - - public void doDelete(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - genericService(request,response); - } - - public void doPut(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - genericService(request,response); } } 1.1.2.2 +1 -17 jakarta-commons/httpclient/src/test-webapp/src/org/apache/commons/httpclient/Attic/RedirectServlet.java Index: RedirectServlet.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/test-webapp/src/org/apache/commons/httpclient/Attic/RedirectServlet.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- RedirectServlet.java 2001/08/15 23:00:06 1.1.2.1 +++ RedirectServlet.java 2001/08/17 01:42:03 1.1.2.2 @@ -5,29 +5,13 @@ import javax.servlet.http.*; import java.util.*; -public class RedirectServlet extends HttpServlet { +public class RedirectServlet extends MultiMethodServlet { protected void genericService(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { String to = request.getParameter("to"); if(null == to) { to = "/"; } response.sendRedirect(to); - } - - public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - genericService(request,response); - } - - public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - genericService(request,response); - } - - public void doDelete(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - genericService(request,response); - } - - public void doPut(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - genericService(request,response); } } 1.1.2.4 +1 -17 jakarta-commons/httpclient/src/test-webapp/src/org/apache/commons/httpclient/Attic/RequestBodyServlet.java Index: RequestBodyServlet.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/test-webapp/src/org/apache/commons/httpclient/Attic/RequestBodyServlet.java,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -r1.1.2.3 -r1.1.2.4 --- RequestBodyServlet.java 2001/08/16 23:58:12 1.1.2.3 +++ RequestBodyServlet.java 2001/08/17 01:42:03 1.1.2.4 @@ -5,7 +5,7 @@ import javax.servlet.http.*; import java.util.*; -public class RequestBodyServlet extends HttpServlet { +public class RequestBodyServlet extends MultiMethodServlet { protected void genericService(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); @@ -47,22 +47,6 @@ } out.println("</body>"); out.println("</html>"); - } - - public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - genericService(request,response); - } - - public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - genericService(request,response); - } - - public void doDelete(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - genericService(request,response); - } - - public void doPut(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - genericService(request,response); } } No revision No revision 1.1.2.1 +27 -0 jakarta-commons/httpclient/src/test-webapp/src/org/apache/commons/httpclient/Attic/MultiMethodServlet.java No revision No revision 1.1.2.4 +4 -22 jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/Attic/TestWebapp.java Index: TestWebapp.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/Attic/TestWebapp.java,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -r1.1.2.3 -r1.1.2.4 --- TestWebapp.java 2001/08/16 23:59:14 1.1.2.3 +++ TestWebapp.java 2001/08/17 01:42:03 1.1.2.4 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/Attic/TestWebapp.java,v 1.1.2.3 2001/08/16 23:59:14 rwaldhoff Exp $ - * $Revision: 1.1.2.3 $ - * $Date: 2001/08/16 23:59:14 $ + * $Header: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/Attic/TestWebapp.java,v 1.1.2.4 2001/08/17 01:42:03 rwaldhoff Exp $ + * $Revision: 1.1.2.4 $ + * $Date: 2001/08/17 01:42:03 $ * ==================================================================== * Copyright (C) The Apache Software Foundation. All rights reserved. * @@ -32,7 +32,7 @@ * "httpclient.test.webappContext" property. * * @author Rodney Waldhoff - * @version $Id: TestWebapp.java,v 1.1.2.3 2001/08/16 23:59:14 rwaldhoff Exp $ + * @version $Id: TestWebapp.java,v 1.1.2.4 2001/08/17 01:42:03 rwaldhoff Exp $ */ public class TestWebapp extends TestCase { @@ -54,24 +54,6 @@ String[] testCaseName = { TestWebapp.class.getName() }; junit.textui.TestRunner.main(testCaseName); } - - // -------------------------------------------------------------- Constants - - private static final String context = System.getProperty("httpclient.test.webappContext","httpclienttest"); - private static final String host = System.getProperty("httpclient.test.localHost","127.0.0.1"); - private static final int port; - static { - String portString = System.getProperty("httpclient.test.localPort","8080"); - int tempPort = 8080; - try { - tempPort = Integer.parseInt(portString); - } catch(Exception e) { - tempPort = 8080; - } - port = tempPort; - } - - // ------------------------------------------------------------------ Tests } 1.1.2.2 +5 -22 jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/Attic/TestWebappBasicAuth.java Index: TestWebappBasicAuth.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/Attic/TestWebappBasicAuth.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- TestWebappBasicAuth.java 2001/08/16 23:59:14 1.1.2.1 +++ TestWebappBasicAuth.java 2001/08/17 01:42:03 1.1.2.2 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/Attic/TestWebappBasicAuth.java,v 1.1.2.1 2001/08/16 23:59:14 rwaldhoff Exp $ - * $Revision: 1.1.2.1 $ - * $Date: 2001/08/16 23:59:14 $ + * $Header: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/Attic/TestWebappBasicAuth.java,v 1.1.2.2 2001/08/17 01:42:03 rwaldhoff Exp $ + * $Revision: 1.1.2.2 $ + * $Date: 2001/08/17 01:42:03 $ * ==================================================================== * Copyright (C) The Apache Software Foundation. All rights reserved. * @@ -33,9 +33,9 @@ * "httpclient.test.webappContext" property. * * @author Rodney Waldhoff - * @version $Id: TestWebappBasicAuth.java,v 1.1.2.1 2001/08/16 23:59:14 rwaldhoff Exp $ + * @version $Id: TestWebappBasicAuth.java,v 1.1.2.2 2001/08/17 01:42:03 rwaldhoff Exp $ */ -public class TestWebappBasicAuth extends TestCase { +public class TestWebappBasicAuth extends TestWebappBase { public TestWebappBasicAuth(String testName) { super(testName); @@ -50,23 +50,6 @@ String[] testCaseName = { TestWebappBasicAuth.class.getName() }; junit.textui.TestRunner.main(testCaseName); } - - // -------------------------------------------------------------- Constants - - private static final String context = System.getProperty("httpclient.test.webappContext","httpclienttest"); - private static final String host = System.getProperty("httpclient.test.localHost","127.0.0.1"); - private static final int port; - static { - String portString = System.getProperty("httpclient.test.localPort","8080"); - int tempPort = 8080; - try { - tempPort = Integer.parseInt(portString); - } catch(Exception e) { - tempPort = 8080; - } - port = tempPort; - } - // ------------------------------------------------------------------ Tests 1.1.2.3 +5 -21 jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/Attic/TestWebappHeaders.java Index: TestWebappHeaders.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/Attic/TestWebappHeaders.java,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- TestWebappHeaders.java 2001/08/15 23:19:34 1.1.2.2 +++ TestWebappHeaders.java 2001/08/17 01:42:03 1.1.2.3 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/Attic/TestWebappHeaders.java,v 1.1.2.2 2001/08/15 23:19:34 rwaldhoff Exp $ - * $Revision: 1.1.2.2 $ - * $Date: 2001/08/15 23:19:34 $ + * $Header: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/Attic/TestWebappHeaders.java,v 1.1.2.3 2001/08/17 01:42:03 rwaldhoff Exp $ + * $Revision: 1.1.2.3 $ + * $Date: 2001/08/17 01:42:03 $ * ==================================================================== * Copyright (C) The Apache Software Foundation. All rights reserved. * @@ -32,9 +32,9 @@ * "httpclient.test.webappContext" property. * * @author Rodney Waldhoff - * @version $Id: TestWebappHeaders.java,v 1.1.2.2 2001/08/15 23:19:34 rwaldhoff Exp $ + * @version $Id: TestWebappHeaders.java,v 1.1.2.3 2001/08/17 01:42:03 rwaldhoff Exp $ */ -public class TestWebappHeaders extends TestCase { +public class TestWebappHeaders extends TestWebappBase { public TestWebappHeaders(String testName) { super(testName); @@ -48,22 +48,6 @@ public static void main(String args[]) { String[] testCaseName = { TestWebappHeaders.class.getName() }; junit.textui.TestRunner.main(testCaseName); - } - - // -------------------------------------------------------------- Constants - - private static final String context = System.getProperty("httpclient.test.webappContext","httpclienttest"); - private static final String host = System.getProperty("httpclient.test.localHost","127.0.0.1"); - private static final int port; - static { - String portString = System.getProperty("httpclient.test.localPort","8080"); - int tempPort = 8080; - try { - tempPort = Integer.parseInt(portString); - } catch(Exception e) { - tempPort = 8080; - } - port = tempPort; } // ------------------------------------------------------------------ Tests 1.1.2.5 +5 -24 jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/Attic/TestWebappMethods.java Index: TestWebappMethods.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/Attic/TestWebappMethods.java,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -r1.1.2.4 -r1.1.2.5 --- TestWebappMethods.java 2001/08/16 23:59:14 1.1.2.4 +++ TestWebappMethods.java 2001/08/17 01:42:03 1.1.2.5 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/Attic/TestWebappMethods.java,v 1.1.2.4 2001/08/16 23:59:14 rwaldhoff Exp $ - * $Revision: 1.1.2.4 $ - * $Date: 2001/08/16 23:59:14 $ + * $Header: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/Attic/TestWebappMethods.java,v 1.1.2.5 2001/08/17 01:42:03 rwaldhoff Exp $ + * $Revision: 1.1.2.5 $ + * $Date: 2001/08/17 01:42:03 $ * ==================================================================== * Copyright (C) The Apache Software Foundation. All rights reserved. * @@ -32,9 +32,9 @@ * "httpclient.test.webappContext" property. * * @author Rodney Waldhoff - * @version $Id: TestWebappMethods.java,v 1.1.2.4 2001/08/16 23:59:14 rwaldhoff Exp $ + * @version $Id: TestWebappMethods.java,v 1.1.2.5 2001/08/17 01:42:03 rwaldhoff Exp $ */ -public class TestWebappMethods extends TestCase { +public class TestWebappMethods extends TestWebappBase { public TestWebappMethods(String testName) { super(testName); @@ -50,23 +50,6 @@ junit.textui.TestRunner.main(testCaseName); } - // -------------------------------------------------------------- Constants - - private static final String context = System.getProperty("httpclient.test.webappContext","httpclienttest"); - private static final String host = System.getProperty("httpclient.test.localHost","127.0.0.1"); - private static final int port; - static { - String portString = System.getProperty("httpclient.test.localPort","8080"); - int tempPort = 8080; - try { - tempPort = Integer.parseInt(portString); - } catch(Exception e) { - tempPort = 8080; - } - port = tempPort; - } - - // ------------------------------------------------------------------ Tests /** @@ -257,8 +240,6 @@ assertEquals(200,method.getStatusCode()); assert(method.getResponseBodyAsString(),method.getResponseBodyAsString().indexOf("<title>Param Servlet: PUT</title>") >= 0); } - -//// public void testPostBody() throws Exception { HttpClient client = new HttpClient(); 1.1.2.4 +5 -21 jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/Attic/TestWebappParameters.java Index: TestWebappParameters.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/Attic/TestWebappParameters.java,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -r1.1.2.3 -r1.1.2.4 --- TestWebappParameters.java 2001/08/15 23:19:34 1.1.2.3 +++ TestWebappParameters.java 2001/08/17 01:42:03 1.1.2.4 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/Attic/TestWebappParameters.java,v 1.1.2.3 2001/08/15 23:19:34 rwaldhoff Exp $ - * $Revision: 1.1.2.3 $ - * $Date: 2001/08/15 23:19:34 $ + * $Header: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/Attic/TestWebappParameters.java,v 1.1.2.4 2001/08/17 01:42:03 rwaldhoff Exp $ + * $Revision: 1.1.2.4 $ + * $Date: 2001/08/17 01:42:03 $ * ==================================================================== * Copyright (C) The Apache Software Foundation. All rights reserved. * @@ -32,9 +32,9 @@ * "httpclient.test.webappContext" property. * * @author Rodney Waldhoff - * @version $Id: TestWebappParameters.java,v 1.1.2.3 2001/08/15 23:19:34 rwaldhoff Exp $ + * @version $Id: TestWebappParameters.java,v 1.1.2.4 2001/08/17 01:42:03 rwaldhoff Exp $ */ -public class TestWebappParameters extends TestCase { +public class TestWebappParameters extends TestWebappBase { public TestWebappParameters(String testName) { super(testName); @@ -48,22 +48,6 @@ public static void main(String args[]) { String[] testCaseName = { TestWebappParameters.class.getName() }; junit.textui.TestRunner.main(testCaseName); - } - - // -------------------------------------------------------------- Constants - - private static final String context = System.getProperty("httpclient.test.webappContext","httpclienttest"); - private static final String host = System.getProperty("httpclient.test.localHost","127.0.0.1"); - private static final int port; - static { - String portString = System.getProperty("httpclient.test.localPort","8080"); - int tempPort = 8080; - try { - tempPort = Integer.parseInt(portString); - } catch(Exception e) { - tempPort = 8080; - } - port = tempPort; } // ------------------------------------------------------------------ Tests 1.1.2.5 +5 -22 jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/Attic/TestWebappRedirect.java Index: TestWebappRedirect.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/Attic/TestWebappRedirect.java,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -r1.1.2.4 -r1.1.2.5 --- TestWebappRedirect.java 2001/08/16 23:59:14 1.1.2.4 +++ TestWebappRedirect.java 2001/08/17 01:42:03 1.1.2.5 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/Attic/TestWebappRedirect.java,v 1.1.2.4 2001/08/16 23:59:14 rwaldhoff Exp $ - * $Revision: 1.1.2.4 $ - * $Date: 2001/08/16 23:59:14 $ + * $Header: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/Attic/TestWebappRedirect.java,v 1.1.2.5 2001/08/17 01:42:03 rwaldhoff Exp $ + * $Revision: 1.1.2.5 $ + * $Date: 2001/08/17 01:42:03 $ * ==================================================================== * Copyright (C) The Apache Software Foundation. All rights reserved. * @@ -33,9 +33,9 @@ * "httpclient.test.webappContext" property. * * @author Rodney Waldhoff - * @version $Id: TestWebappRedirect.java,v 1.1.2.4 2001/08/16 23:59:14 rwaldhoff Exp $ + * @version $Id: TestWebappRedirect.java,v 1.1.2.5 2001/08/17 01:42:03 rwaldhoff Exp $ */ -public class TestWebappRedirect extends TestCase { +public class TestWebappRedirect extends TestWebappBase { public TestWebappRedirect(String testName) { super(testName); @@ -50,23 +50,6 @@ String[] testCaseName = { TestWebappRedirect.class.getName() }; junit.textui.TestRunner.main(testCaseName); } - - // -------------------------------------------------------------- Constants - - private static final String context = System.getProperty("httpclient.test.webappContext","httpclienttest"); - private static final String host = System.getProperty("httpclient.test.localHost","127.0.0.1"); - private static final int port; - static { - String portString = System.getProperty("httpclient.test.localPort","8080"); - int tempPort = 8080; - try { - tempPort = Integer.parseInt(portString); - } catch(Exception e) { - tempPort = 8080; - } - port = tempPort; - } - // ------------------------------------------------------------------ Tests No revision No revision 1.1.2.1 +60 -0 jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/Attic/TestWebappBase.java