httpunit-commit Mailing List for httpunit (Page 20)
Brought to you by:
russgold
You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(5) |
Sep
(31) |
Oct
(39) |
Nov
(18) |
Dec
(6) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(8) |
Feb
(5) |
Mar
(8) |
Apr
(25) |
May
(20) |
Jun
(23) |
Jul
(28) |
Aug
(10) |
Sep
(3) |
Oct
(32) |
Nov
(61) |
Dec
(24) |
2002 |
Jan
(50) |
Feb
(34) |
Mar
(35) |
Apr
(3) |
May
(25) |
Jun
(25) |
Jul
(30) |
Aug
(146) |
Sep
(49) |
Oct
(156) |
Nov
(121) |
Dec
(54) |
2003 |
Jan
(12) |
Feb
(79) |
Mar
(88) |
Apr
(26) |
May
(67) |
Jun
(29) |
Jul
(8) |
Aug
(16) |
Sep
(20) |
Oct
(17) |
Nov
|
Dec
(5) |
2004 |
Jan
|
Feb
(40) |
Mar
(30) |
Apr
(5) |
May
|
Jun
(83) |
Jul
(34) |
Aug
(20) |
Sep
(44) |
Oct
(46) |
Nov
|
Dec
(14) |
2005 |
Jan
(4) |
Feb
|
Mar
(5) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(4) |
Oct
|
Nov
|
Dec
(1) |
2006 |
Jan
|
Feb
|
Mar
(26) |
Apr
(8) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(5) |
Nov
|
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
(36) |
May
(38) |
Jun
(1) |
Jul
(1) |
Aug
|
Sep
(4) |
Oct
|
Nov
(18) |
Dec
(4) |
2009 |
Jan
|
Feb
(2) |
Mar
(3) |
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
(35) |
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
(9) |
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(21) |
Oct
(18) |
Nov
(1) |
Dec
|
From: Russell G. <rus...@us...> - 2004-06-18 21:05:47
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21544/src/com/meterware/httpunit Modified Files: HttpWebResponse.java WebConversation.java Log Message: enhance http header logging Index: HttpWebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpWebResponse.java,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- HttpWebResponse.java 13 Jun 2004 20:57:25 -0000 1.30 +++ HttpWebResponse.java 18 Jun 2004 21:05:37 -0000 1.31 @@ -50,6 +50,7 @@ **/ HttpWebResponse( WebConversation client, FrameSelector frame, URL url, URLConnection connection, boolean throwExceptionOnError ) throws IOException { super( client, frame, url ); + if (HttpUnitOptions.isLoggingHttpHeaders()) System.out.println( "\nReceived from " + url ); readHeaders( connection ); /** make sure that any IO exception for HTML received page happens here, not later. **/ Index: WebConversation.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebConversation.java,v retrieving revision 1.33 retrieving revision 1.34 diff -u -r1.33 -r1.34 --- WebConversation.java 13 Jun 2004 20:57:25 -0000 1.33 +++ WebConversation.java 18 Jun 2004 21:05:38 -0000 1.34 @@ -55,6 +55,13 @@ **/ protected WebResponse newResponse( WebRequest request, FrameSelector targetFrame ) throws MalformedURLException, IOException { URLConnection connection = openConnection( getRequestURL( request ) ); + if (HttpUnitOptions.isLoggingHttpHeaders()) { + String urlString = request.getURLString(); + String rawUrl = request.getURL().toExternalForm(); + String target = rawUrl.substring( 0, rawUrl.indexOf( urlString ) ); + System.out.println( "\nConnecting to " + target ); + System.out.println( "Sending:: " + request.getMethod() + " " + urlString ); + } sendHeaders( connection, getHeaderFields( request.getURL() ) ); sendHeaders( connection, request.getHeaderDictionary() ); request.completeRequest( connection ); |
From: Russell G. <rus...@us...> - 2004-06-18 21:05:47
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21544/doc Modified Files: release_notes.txt Log Message: enhance http header logging Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.334 retrieving revision 1.335 diff -u -r1.334 -r1.335 --- release_notes.txt 16 Jun 2004 00:10:53 -0000 1.334 +++ release_notes.txt 18 Jun 2004 21:05:36 -0000 1.335 @@ -13,6 +13,10 @@ Revision History: +18-Jun-2004 + Additions: + 1. Enhanced http logging to show target server, request header line, and received URL + 15-Jun-2004 Thanks to Phil Zampino for finding a fixing a problem in PseudoServer's handling of very long requests. |
From: Russell G. <rus...@us...> - 2004-06-16 01:11:04
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13381/test/com/meterware/httpunit Modified Files: WebWindowTest.java Log Message: Recognize window name as a target Index: WebWindowTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebWindowTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- WebWindowTest.java 13 Jun 2004 20:57:28 -0000 1.5 +++ WebWindowTest.java 16 Jun 2004 01:10:56 -0000 1.6 @@ -71,8 +71,10 @@ public void testUnknownTarget() throws Exception { + defineResource( "goThere", "You came back!" ); defineResource( "goHere", "You made it!" ); - defineWebPage( "start", "<a href='goHere' id='go' target='somewhere'>here</a>" ); + defineWebPage( "start", "<a href='goHere' id='go' target='somewhere'>here</a>" + + "<a href='goThere' id='return' target='somewhere'>there</a>"); WebClient wc = new WebConversation(); WebResponse initialPage = wc.getResponse( getHostPath() + "/start.html" ); @@ -80,6 +82,9 @@ assertEquals( "Number of windows after following link", 2, wc.getOpenWindows().length ); WebWindow other = wc.getOpenWindows()[1]; assertEquals( "New window contents", "You made it!", other.getCurrentPage().getText() ); + initialPage.getLinkWithID( "return" ).click(); + assertEquals( "Number of windows after following link", 2, wc.getOpenWindows().length ); + assertEquals( "Updated window contents", "You came back!", other.getCurrentPage().getText() ); } |
From: Russell G. <rus...@us...> - 2004-06-16 01:11:04
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13381/src/com/meterware/httpunit Modified Files: FrameHolder.java WebClient.java Log Message: Recognize window name as a target Index: FrameHolder.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/FrameHolder.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- FrameHolder.java 13 Jun 2004 20:57:25 -0000 1.10 +++ FrameHolder.java 16 Jun 2004 01:10:55 -0000 1.11 @@ -96,7 +96,7 @@ FrameSelector getFrame( String target ) { - return getFrame( _topFrame, target ); + return target.equals( _window.getName() ) ? _topFrame : getFrame( _topFrame, target ); } Index: WebClient.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebClient.java,v retrieving revision 1.55 retrieving revision 1.56 diff -u -r1.55 -r1.56 --- WebClient.java 13 Jun 2004 20:57:25 -0000 1.55 +++ WebClient.java 16 Jun 2004 01:10:55 -0000 1.56 @@ -461,6 +461,7 @@ void updateFrameContents( WebWindow requestWindow, String requestTarget, WebResponse response, RequestContext requestContext ) throws IOException, SAXException { if (response.getFrame() == FrameSelector.NEW_FRAME) { WebWindow window = new WebWindow( this ); + if (!WebRequest.NEW_WINDOW.equalsIgnoreCase( requestTarget )) window.setName( requestTarget ); response.setFrame( window.getTopFrame() ); window.updateFrameContents( response, requestContext ); _openWindows.add( window ); |
From: Russell G. <rus...@us...> - 2004-06-16 00:11:01
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/pseudoserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23288/src/com/meterware/pseudoserver Modified Files: ReceivedHttpMessage.java Log Message: from Phil Zampino: Fix long request handling in PseudoServer Index: ReceivedHttpMessage.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/pseudoserver/ReceivedHttpMessage.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ReceivedHttpMessage.java 30 Sep 2003 00:15:05 -0000 1.2 +++ ReceivedHttpMessage.java 16 Jun 2004 00:10:53 -0000 1.3 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * - * Copyright (c) 2003, Russell Gold + * Copyright (c) 2003-2004, Russell Gold * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -103,14 +103,25 @@ private void readMessageBody( InputStream inputStream ) throws IOException { - if ("chunked".equalsIgnoreCase( getHeader( "Transfer-Encoding") )) { + if ("chunked".equalsIgnoreCase( getHeader( "Transfer-Encoding" ) )) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); - while (getNextChunkLength( inputStream ) > 0) { baos.write( readDelimitedChunk( inputStream ) ); } + while (getNextChunkLength( inputStream ) > 0) { + baos.write( readDelimitedChunk( inputStream ) ); + } flushChunkTrailer( inputStream ); _requestBody = baos.toByteArray(); } else { - _requestBody = new byte[ getContentLength() ]; - inputStream.read( _requestBody ); + int totalExpected = getContentLength(); + ByteArrayOutputStream baos = new ByteArrayOutputStream( totalExpected ); + byte[] buffer = new byte[1024]; + int total = 0; + int count = -1; + while ((total < totalExpected) && ((count = inputStream.read( buffer )) != -1)) { + baos.write( buffer, 0, count ); + total += count; + } + baos.flush(); + _requestBody = baos.toByteArray(); } _reader = new InputStreamReader( new ByteArrayInputStream( _requestBody ) ); } @@ -169,3 +180,4 @@ } + |
From: Russell G. <rus...@us...> - 2004-06-16 00:11:01
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23288/doc Modified Files: release_notes.txt Log Message: from Phil Zampino: Fix long request handling in PseudoServer Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.333 retrieving revision 1.334 diff -u -r1.333 -r1.334 --- release_notes.txt 13 Jun 2004 20:57:24 -0000 1.333 +++ release_notes.txt 16 Jun 2004 00:10:53 -0000 1.334 @@ -13,6 +13,12 @@ Revision History: +15-Jun-2004 + Thanks to Phil Zampino for finding a fixing a problem in PseudoServer's handling of very long requests. + + Problems fixed: + 1. PseudoServer would hang when sent a very long request. + 13-Jun-2004 Problems fixed: 1. bug #737167: Nested frame names are now as specified, previous included names of parent frames. |
From: Russell G. <rus...@us...> - 2004-06-13 21:52:12
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17254 Added Files: FrameSelector.java Log Message: ***** Error reading new file[Errno 2] No such file or directory: 'FrameSelector.java' |
From: Russell G. <rus...@us...> - 2004-06-13 21:01:25
|
Update of /cvsroot/httpunit/httpunit/sitedocs/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9144/sitedocs/doc Modified Files: citations.xml Log Message: added morebot to citations Index: citations.xml =================================================================== RCS file: /cvsroot/httpunit/httpunit/sitedocs/doc/citations.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- citations.xml 2 Mar 2004 10:51:39 -0000 1.3 +++ citations.xml 13 Jun 2004 21:01:17 -0000 1.4 @@ -1,6 +1,6 @@ <?xml version='1.0' ?> <citations> - <section title='HttpUnit Extensions'> + <section title='HttpUnit Extensions and Wrappers'> <citation name='Canoo WebTest' url='http://webtest.canoo.com/webtest/manual/WebTestHome.html'> Provides an XML wrapper to simplify web testing for non-Java programmers </citation> @@ -10,6 +10,9 @@ <citation name="jWebUnit" url="http://jwebunit.sourceforge.net"> A Java wrapper for HttpUnit which simplifies common, repetitive test steps </citation> + <citation name="morebot" url="http://morebot.sourceforge.net"> + A Java spider for smoke-testing web sites easily + </citation> </section> <section title="Articles"> |
From: Russell G. <rus...@us...> - 2004-06-13 20:58:03
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6276/doc Modified Files: release_notes.txt Log Message: Major rework of target functionality Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.332 retrieving revision 1.333 diff -u -r1.332 -r1.333 --- release_notes.txt 4 Jun 2004 01:20:02 -0000 1.332 +++ release_notes.txt 13 Jun 2004 20:57:24 -0000 1.333 @@ -13,6 +13,13 @@ Revision History: +13-Jun-2004 + Problems fixed: + 1. bug #737167: Nested frame names are now as specified, previous included names of parent frames. + 2. Return from a request that wrote to a new frame is now the result of that request, was the original page. + 3. Return from a request specifying an unknown frame now opens a new window; previously created a subframe + in the requesting window. + 3-Jun-2004 Additions: 1. WebForm now supports the newUnvalidatedRequest method, which should be used in preference to |
From: Russell G. <rus...@us...> - 2004-06-13 20:57:49
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6276/src/com/meterware/servletunit Modified Files: InvocationContext.java InvocationContextFactory.java InvocationContextImpl.java ServletRunner.java ServletUnitClient.java ServletUnitWebResponse.java Log Message: Major rework of target functionality Index: InvocationContext.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/InvocationContext.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- InvocationContext.java 26 Feb 2004 17:36:47 -0000 1.8 +++ InvocationContext.java 13 Jun 2004 20:57:27 -0000 1.9 @@ -20,6 +20,7 @@ * *******************************************************************************************************************/ import com.meterware.httpunit.WebResponse; +import com.meterware.httpunit.FrameSelector; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -69,9 +70,9 @@ /** - * Returns the target for the original request. + * Returns the target frame for the original request. */ - String getTarget(); + FrameSelector getFrame(); /** Index: InvocationContextFactory.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/InvocationContextFactory.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- InvocationContextFactory.java 27 Feb 2003 23:36:02 -0000 1.5 +++ InvocationContextFactory.java 13 Jun 2004 20:57:28 -0000 1.6 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * - * Copyright (c) 2001-2002, Russell Gold + * Copyright (c) 2001-2004, Russell Gold * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -20,6 +20,7 @@ * *******************************************************************************************************************/ import com.meterware.httpunit.WebRequest; +import com.meterware.httpunit.FrameSelector; import java.io.IOException; import java.net.MalformedURLException; @@ -36,6 +37,6 @@ /** * Creates and returns a new invocation context to test calling of servlet methods. **/ - public InvocationContext newInvocation( ServletUnitClient client, String targetFrame, WebRequest request, Dictionary clientHeaders, byte[] messageBody ) throws IOException, MalformedURLException; + public InvocationContext newInvocation( ServletUnitClient client, FrameSelector targetFrame, WebRequest request, Dictionary clientHeaders, byte[] messageBody ) throws IOException, MalformedURLException; } Index: InvocationContextImpl.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/InvocationContextImpl.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- InvocationContextImpl.java 15 Mar 2004 02:42:16 -0000 1.16 +++ InvocationContextImpl.java 13 Jun 2004 20:57:28 -0000 1.17 @@ -22,6 +22,7 @@ import com.meterware.httpunit.HttpException; import com.meterware.httpunit.WebRequest; import com.meterware.httpunit.WebResponse; +import com.meterware.httpunit.FrameSelector; import java.io.IOException; import java.net.MalformedURLException; @@ -42,8 +43,14 @@ **/ class InvocationContextImpl implements InvocationContext { - private Stack _contextStack = new Stack(); - private URL _effectiveURL; + private Stack _contextStack = new Stack(); + private URL _effectiveURL; + + private ServletUnitClient _client; + private WebApplication _application; + private FrameSelector _frame; + + private WebResponse _webResponse; /** @@ -96,17 +103,14 @@ cookie.setPath( _application.getContextPath() ); getResponse().addCookie( cookie ); } - _webResponse = new ServletUnitWebResponse( _client, _target, _effectiveURL, getResponse(), _client.getExceptionsThrownOnErrorStatus() ); + _webResponse = new ServletUnitWebResponse( _client, _frame, _effectiveURL, getResponse(), _client.getExceptionsThrownOnErrorStatus() ); } return _webResponse; } - /** - * Returns the target for the original request. - */ - public String getTarget() { - return _target; + public FrameSelector getFrame() { + return _frame; } @@ -175,10 +179,10 @@ * Constructs a servlet invocation context for a specified servlet container, * request, and cookie headers. **/ - InvocationContextImpl( ServletUnitClient client, ServletRunner runner, String target, WebRequest request, Dictionary clientHeaders, byte[] messageBody ) throws IOException, MalformedURLException { + InvocationContextImpl( ServletUnitClient client, ServletRunner runner, FrameSelector frame, WebRequest request, Dictionary clientHeaders, byte[] messageBody ) throws IOException, MalformedURLException { _client = client; _application = runner.getApplication(); - _target = target; + _frame = frame; URL requestURL = request.getURL(); final ServletUnitHttpRequest suhr = new ServletUnitHttpRequest( _application.getServletRequest( requestURL ), request, @@ -310,17 +314,6 @@ } } - -//------------------------------ private members --------------------------------------- - - - private ServletUnitClient _client; - private WebApplication _application; - private String _target; - - private WebResponse _webResponse; - - private ExecutionContext getContext() { return (ExecutionContext) _contextStack.lastElement(); } Index: ServletRunner.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletRunner.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- ServletRunner.java 13 Feb 2004 05:45:19 -0000 1.24 +++ ServletRunner.java 13 Jun 2004 20:57:28 -0000 1.25 @@ -29,6 +29,7 @@ import com.meterware.httpunit.HttpUnitUtils; import com.meterware.httpunit.WebRequest; import com.meterware.httpunit.WebResponse; +import com.meterware.httpunit.FrameSelector; import org.xml.sax.InputSource; import org.xml.sax.SAXException; @@ -201,7 +202,7 @@ private ServletUnitContext _context; private InvocationContextFactory _factory = new InvocationContextFactory() { - public InvocationContext newInvocation( ServletUnitClient client, String targetFrame, WebRequest request, Dictionary clientHeaders, byte[] messageBody ) throws IOException, MalformedURLException { + public InvocationContext newInvocation( ServletUnitClient client, FrameSelector targetFrame, WebRequest request, Dictionary clientHeaders, byte[] messageBody ) throws IOException, MalformedURLException { return new InvocationContextImpl( client, ServletRunner.this, targetFrame, request, clientHeaders, messageBody ); } }; Index: ServletUnitClient.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitClient.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- ServletUnitClient.java 26 Feb 2004 17:36:47 -0000 1.12 +++ ServletUnitClient.java 13 Jun 2004 20:57:28 -0000 1.13 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * -* Copyright (c) 2000-2003, Russell Gold +* Copyright (c) 2000-2004, Russell Gold * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -64,9 +64,14 @@ * Creates and returns a new invocation context to test calling of servlet methods. **/ public InvocationContext newInvocation( WebRequest request ) throws IOException, MalformedURLException { + return newInvocation( request, FrameSelector.TOP_FRAME ); + } + + + InvocationContext newInvocation( WebRequest request, FrameSelector frame ) throws IOException, MalformedURLException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); writeMessageBody( request, baos ); - return _invocationContextFactory.newInvocation( this, getTargetFrame( request ), request, getHeaderFields( request.getURL() ), baos.toByteArray() ); + return _invocationContextFactory.newInvocation( this, frame, request, getHeaderFields( request.getURL() ), baos.toByteArray() ); } @@ -76,8 +81,8 @@ * servlet invocation unless that invocation results in a redirect request. **/ public WebResponse getResponse( InvocationContext invocation ) throws MalformedURLException,IOException,SAXException { - updateMainWindow( invocation.getTarget(), invocation.getServletResponse() ); - return getFrameContents( invocation.getTarget() ); + updateMainWindow( invocation.getFrame(), invocation.getServletResponse() ); + return getFrameContents( invocation.getFrame() ); } @@ -87,10 +92,10 @@ /** * Creates a web response object which represents the response to the specified web request. **/ - protected WebResponse newResponse( WebRequest request, String frameName ) throws MalformedURLException,IOException { + protected WebResponse newResponse( WebRequest request, FrameSelector targetFrame ) throws MalformedURLException,IOException { try { - InvocationContext invocation = newInvocation( request ); + InvocationContext invocation = newInvocation( request, targetFrame ); invocation.service(); return invocation.getServletResponse(); } catch (ServletException e) { Index: ServletUnitWebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitWebResponse.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- ServletUnitWebResponse.java 17 Jun 2003 23:23:02 -0000 1.12 +++ ServletUnitWebResponse.java 13 Jun 2004 20:57:28 -0000 1.13 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * - * Copyright (c) 2000-2002, Russell Gold + * Copyright (c) 2000-2004, Russell Gold * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -20,6 +20,7 @@ * *******************************************************************************************************************/ import com.meterware.httpunit.WebResponse; +import com.meterware.httpunit.FrameSelector; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -36,12 +37,12 @@ /** * Constructs a response object from a servlet response. - * @param target the target frame on which the response will be displayed + * @param frame the target frame on which the response will be displayed * @param url the url from which the response was received * @param response the response populated by the servlet **/ - ServletUnitWebResponse( ServletUnitClient client, String target, URL url, HttpServletResponse response, boolean throwExceptionOnError ) throws IOException { - super( client, target, url ); + ServletUnitWebResponse( ServletUnitClient client, FrameSelector frame, URL url, HttpServletResponse response, boolean throwExceptionOnError ) throws IOException { + super( client, frame, url ); _response = (ServletUnitHttpResponse) response; /** make sure that any IO exception for HTML received page happens here, not later. **/ if (getResponseCode() < HttpURLConnection.HTTP_BAD_REQUEST || !throwExceptionOnError) { @@ -53,12 +54,12 @@ /** * Constructs a response object from a servlet response. - * @param target the target frame on which the response will be displayed + * @param frame the target frame on which the response will be displayed * @param url the url from which the response was received * @param response the response populated by the servlet **/ - ServletUnitWebResponse( ServletUnitClient client, String target, URL url, HttpServletResponse response ) throws IOException { - this( client, target, url, response, true ); + ServletUnitWebResponse( ServletUnitClient client, FrameSelector frame, URL url, HttpServletResponse response ) throws IOException { + this( client, frame, url, response, true ); } |
From: Russell G. <rus...@us...> - 2004-06-13 20:57:46
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6276/test/com/meterware/httpunit Modified Files: RequestTargetTest.java WebFrameTest.java WebWindowTest.java Log Message: Major rework of target functionality Index: RequestTargetTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/RequestTargetTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- RequestTargetTest.java 27 Feb 2003 23:36:04 -0000 1.3 +++ RequestTargetTest.java 13 Jun 2004 20:57:28 -0000 1.4 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * -* Copyright (c) 2000-2003, Russell Gold +* Copyright (c) 2000-2004, Russell Gold * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -72,25 +72,38 @@ public void testInheritedLinkTarget() throws Exception { - defineWebPage( "Initial", "Here is a <a href=\"SimpleLink.html\" target=\"subframe\">simple link</a>." ); + defineResource( "Start.html", + "<HTML><HEAD><TITLE>Initial</TITLE></HEAD>" + + "<FRAMESET cols=\"50%,50%\">" + + " <FRAME src=\"Initial.html\" name=\"red\">" + + " <FRAME name=\"blue\">" + + "</FRAMESET></HTML>" ); + defineWebPage( "Initial", "Here is a <a href=\"SimpleLink.html\" target=\"blue\">simple link</a>." ); defineWebPage( "SimpleLink", "Here is <a href=\"Initial.html\">another simple link</a>." ); - WebLink link = _wc.getResponse( getHostPath() + "/Initial.html" ).getLinks()[0]; - assertEquals( "explicit link target", "subframe", link.getTarget() ); - assertEquals( "request target", "subframe", link.getRequest().getTarget() ); + _wc.getResponse( getHostPath() + "/Start.html" ); + WebLink link = _wc.getFrameContents( "red" ).getLinks()[0]; + assertEquals( "explicit link target", "blue", link.getTarget() ); + assertEquals( "request target", "blue", link.getRequest().getTarget() ); WebResponse response = _wc.getResponse( link.getRequest() ); - assertEquals( "response target", "subframe", response.getFrameName() ); + assertEquals( "response target", "blue", response.getFrameName() ); link = response.getLinks()[0]; - assertEquals( "inherited link target", "subframe", link.getTarget() ); + assertEquals( "inherited link target", "blue", link.getTarget() ); } public void testInheritedLinkTargetInTable() throws Exception { + defineResource( "Start.html", + "<HTML><HEAD><TITLE>Initial</TITLE></HEAD>" + + "<FRAMESET cols=\"50%,50%\">" + + " <FRAME src=\"Initial.html\" name=\"red\">" + + " <FRAME name=\"subframe\">" + + "</FRAMESET></HTML>" ); defineWebPage( "Initial", "Here is a <a href=\"SimpleLink.html\" target=\"subframe\">simple link</a>." ); defineWebPage( "SimpleLink", "Here is <table><tr><td><a href=\"Initial.html\">another simple link</a>.</td></tr></table>" ); - WebLink link = _wc.getResponse( getHostPath() + "/Initial.html" ).getLinks()[0]; + WebLink link = _wc.getResponse( getHostPath() + "/Start.html" ).getSubframeContents( "red" ).getLinks()[0]; assertEquals( "explicit link target", "subframe", link.getTarget() ); assertEquals( "request target", "subframe", link.getRequest().getTarget() ); @@ -144,6 +157,12 @@ public void testInheritedFormTarget() throws Exception { + defineResource( "Start.html", + "<HTML><HEAD><TITLE>Initial</TITLE></HEAD>" + + "<FRAMESET cols=\"50%,50%\">" + + " <FRAME src=\"Initial.html\" name=\"red\">" + + " <FRAME name=\"subframe\">" + + "</FRAMESET></HTML>" ); defineWebPage( "Initial", "Here is a <a href=\"SimpleLink.html\" target=\"subframe\">simple link</a>." ); defineWebPage( "SimpleLink", "Here is a simple form: " + "<form method=GET action = \"/servlet/Login\" target=\"subframe\"><B>" + @@ -151,7 +170,7 @@ "<br><Input type=submit value = \"Log in\">" + "</form>" ); - WebLink link = _wc.getResponse( getHostPath() + "/Initial.html" ).getLinks()[0]; + WebLink link = _wc.getResponse( getHostPath() + "/Start.html" ).getSubframeContents( "red" ).getLinks()[0]; assertEquals( "explicit link target", "subframe", link.getTarget() ); assertEquals( "request target", "subframe", link.getRequest().getTarget() ); Index: WebFrameTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebFrameTest.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- WebFrameTest.java 2 Apr 2003 16:47:57 -0000 1.17 +++ WebFrameTest.java 13 Jun 2004 20:57:28 -0000 1.18 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * -* Copyright (c) 2000-2003, Russell Gold +* Copyright (c) 2000-2004, Russell Gold * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -239,12 +239,14 @@ defineResource( "SuperFrames.html", "<HTML><HEAD><TITLE>Initial</TITLE></HEAD>" + "<FRAMESET cols=\"50%,50%\">" + - " <FRAME src=\"Frames.html\" name=\"red\">" + - " <FRAME src=\"Frames.html\" name=\"blue\">" + + " <FRAME src=\"Frames.html\" name=\"crimson\">" + + " <FRAME src=\"Form.html\" name=\"blue\">" + "</FRAMESET></HTML>" ); WebResponse response = _wc.getResponse( getHostPath() + "/SuperFrames.html" ); - assertEquals( "red:red subframe", _wc.getFrameContents( "red:red" ), - response.getSubframeContents( "red" ).getSubframeContents( "red" ) ); + WebResponse frameContents = _wc.getFrameContents( "red" ); + WebResponse subframeContents = response.getSubframeContents( "crimson" ).getSubframeContents( "red" ); + assertEquals( "crimson.red subframe", frameContents, + subframeContents ); } @@ -255,14 +257,13 @@ " <FRAME src=\"Frames.html\" name=\"red\">" + " <FRAME src=\"Frames.html\" name=\"blue\">" + "</FRAMESET></HTML>" ); - WebResponse response = _wc.getResponse( getHostPath() + "/SuperFrames.html" ); - String topFrameNames[] = response.getFrameNames(); - WebResponse topRedFrame = _wc.getFrameContents( topFrameNames[0] ); - String frameNames[] = topRedFrame.getFrameNames(); - - _wc.getResponse( _wc.getFrameContents( frameNames[0] ).getLinks()[0].getRequest() ); - WebResponse frameContent = _wc.getResponse( _wc.getFrameContents( frameNames[1] ).getLinks()[0].getRequest() ); - assertTrue( "Second response not the same as source frame contents", frameContent == _wc.getFrameContents( frameNames[0] ) ); + _wc.getResponse( getHostPath() + "/SuperFrames.html" ); + FrameSelector nestedRedFrame = _wc.getFrameContents( "red" ).getSubframeContents( "red" ).getFrame(); + FrameSelector nestedBlueFrame = _wc.getFrameContents( "red" ).getSubframeContents( "blue" ).getFrame(); + + _wc.getResponse( _wc.getFrameContents( nestedRedFrame ).getLinks()[0].getRequest() ); + WebResponse frameContent = _wc.getFrameContents( nestedBlueFrame ).getLinks()[0].click(); + assertTrue( "Second response not the same as source frame contents", frameContent == _wc.getFrameContents( nestedRedFrame ) ); assertEquals( "URL for second request", getHostPath() + "/Linker.html", frameContent.getURL().toExternalForm() ); } @@ -274,13 +275,11 @@ " <FRAME src=\"Frames.html\" name=\"red\">" + " <FRAME src=\"Frames.html\" name=\"blue\">" + "</FRAMESET></HTML>" ); - WebResponse response = _wc.getResponse( getHostPath() + "/SuperFrames.html" ); - String topFrameNames[] = response.getFrameNames(); - WebResponse topRedFrame = _wc.getFrameContents( topFrameNames[0] ); - String frameNames[] = topRedFrame.getFrameNames(); + _wc.getResponse( getHostPath() + "/SuperFrames.html" ); + FrameSelector nestedRedFrame = _wc.getFrameContents( "red" ).getSubframeContents( "red" ).getFrame(); - _wc.getResponse( _wc.getFrameContents( frameNames[0] ).getLinks()[0].getRequest() ); - WebResponse frameContent = _wc.getResponse( _wc.getFrameContents( frameNames[0] ).getLinks()[0].getRequest() ); + _wc.getFrameContents( nestedRedFrame ).getLinks()[0].click(); + WebResponse frameContent = _wc.getResponse( _wc.getFrameContents( nestedRedFrame ).getLinks()[0].getRequest() ); assertTrue( "Second response not the same as source frame contents", frameContent == _wc.getFrameContents( "_top" ) ); assertEquals( "URL for second request", getHostPath() + "/Form.html", frameContent.getURL().toExternalForm() ); assertEquals( "Number of active frames", 1, _wc.getFrameNames().length ); Index: WebWindowTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebWindowTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- WebWindowTest.java 5 Feb 2003 16:07:40 -0000 1.4 +++ WebWindowTest.java 13 Jun 2004 20:57:28 -0000 1.5 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * - * Copyright (c) 2002-2003, Russell Gold + * Copyright (c) 2002-2004, Russell Gold * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -44,6 +44,8 @@ public WebWindowTest( String name ) { super( name ); } + + public void testNewTarget() throws Exception { defineResource( "goHere", "You made it!" ); defineWebPage( "start", "<a href='goHere' id='go' target='_blank'>here</a>" ); @@ -52,11 +54,12 @@ assertEquals( "Number of initial windows", 1, wc.getOpenWindows().length ); WebWindow main = wc.getMainWindow(); WebResponse initialPage = main.getResponse( getHostPath() + "/start.html" ); - initialPage.getLinkWithID( "go" ).click(); + WebResponse newPage = initialPage.getLinkWithID( "go" ).click(); assertEquals( "Number of windows after following link", 2, wc.getOpenWindows().length ); assertEquals( "Main page in original window", initialPage, main.getCurrentPage() ); WebWindow other = wc.getOpenWindows()[1]; assertEquals( "New window contents", "You made it!", other.getCurrentPage().getText() ); + assertEquals( "Return from open", "You made it!", newPage.getText() ); main.close(); assertTrue( "Original main window is not closed", main.isClosed() ); @@ -67,6 +70,40 @@ } + public void testUnknownTarget() throws Exception { + defineResource( "goHere", "You made it!" ); + defineWebPage( "start", "<a href='goHere' id='go' target='somewhere'>here</a>" ); + + WebClient wc = new WebConversation(); + WebResponse initialPage = wc.getResponse( getHostPath() + "/start.html" ); + initialPage.getLinkWithID( "go" ).click(); + assertEquals( "Number of windows after following link", 2, wc.getOpenWindows().length ); + WebWindow other = wc.getOpenWindows()[1]; + assertEquals( "New window contents", "You made it!", other.getCurrentPage().getText() ); + } + + + public void testTargetInAnotherWindow() throws Exception { + defineWebPage( "linker", "<a href='start.html' target='_blank'>start</a>" ); + defineResource( "Frames.html", "<html>" + + "<frameset cols=\"20%,80%\">" + + " <frame src=\"linker.html\" name=\"here\">" + + " <frame name=\"somewhere\">" + + "</frameset></html>" ); + defineResource( "goHere", "You made it!" ); + defineWebPage( "start", "<a href='goHere' id='go' target='somewhere'>here</a>" ); + + WebClient wc = new WebConversation(); + WebResponse initialPage = wc.getResponse( getHostPath() + "/Frames.html" ); + initialPage.getSubframeContents( "here" ).getLinkWith( "start" ).click(); + assertEquals( "# Open windows", 2, wc.getOpenWindows().length ); + WebWindow other = wc.getOpenWindows()[1]; + WebResponse result = other.getCurrentPage().getLinkWithID( "go" ).click(); + assertEquals( "New frame contents", "You made it!", result.getText() ); + assertSame( "'somewhere' frame", result, initialPage.getSubframeContents( "somewhere") ); + } + + public void testCloseOnlyWindow() throws Exception { defineResource( "goHere", "You made it!" ); WebConversation wc = new WebConversation(); |
From: Russell G. <rus...@us...> - 2004-06-13 20:57:46
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6276/test/com/meterware/servletunit Modified Files: HttpServletResponseTest.java JUnitServletTest.java Log Message: Major rework of target functionality Index: HttpServletResponseTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/HttpServletResponseTest.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- HttpServletResponseTest.java 12 Feb 2004 17:46:29 -0000 1.11 +++ HttpServletResponseTest.java 13 Jun 2004 20:57:28 -0000 1.12 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * -* Copyright (c) 2000-2003, Russell Gold +* Copyright (c) 2000-2004, Russell Gold * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -54,7 +54,7 @@ public void testDefaultResponse() throws Exception { ServletUnitHttpResponse servletResponse = new ServletUnitHttpResponse(); - WebResponse response = new ServletUnitWebResponse( null, "_self", null, servletResponse ); + WebResponse response = new ServletUnitWebResponse( null, FrameSelector.TOP_FRAME, null, servletResponse ); assertEquals( "Contents", "", response.getText() ); } @@ -66,7 +66,7 @@ PrintWriter pw = servletResponse.getWriter(); pw.println( "<html><head><title>Sample Page</title></head><body></body></html>" ); - WebResponse response = new ServletUnitWebResponse( null, "_self", null, servletResponse ); + WebResponse response = new ServletUnitWebResponse( null, FrameSelector.TOP_FRAME, null, servletResponse ); assertEquals( "Status code", HttpServletResponse.SC_OK, response.getResponseCode() ); assertEquals( "Content type", "text/html", response.getContentType() ); assertEquals( "Title", "Sample Page", response.getTitle() ); @@ -87,7 +87,7 @@ pw.print( page ); pw.close(); - WebResponse response = new ServletUnitWebResponse( null, "_self", null, servletResponse ); + WebResponse response = new ServletUnitWebResponse( null, FrameSelector.TOP_FRAME, null, servletResponse ); assertEquals( "Character set", "iso-8859-8", response.getCharacterSet() ); assertEquals( "Title", hebrewTitle, response.getTitle() ); } @@ -99,7 +99,7 @@ ServletOutputStream sos = servletResponse.getOutputStream(); sos.println( "<html><head><title>Sample Page</title></head><body></body></html>" ); - WebResponse response = new ServletUnitWebResponse( null, "_self", null, servletResponse ); + WebResponse response = new ServletUnitWebResponse( null, FrameSelector.TOP_FRAME, null, servletResponse ); assertEquals( "Status code", HttpServletResponse.SC_OK, response.getResponseCode() ); assertEquals( "Content type", "text/html", response.getContentType() ); assertEquals( "Title", "Sample Page", response.getTitle() ); Index: JUnitServletTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/JUnitServletTest.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- JUnitServletTest.java 4 May 2003 12:37:32 -0000 1.9 +++ JUnitServletTest.java 13 Jun 2004 20:57:28 -0000 1.10 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * - * Copyright (c) 2001-2003, Russell Gold + * Copyright (c) 2001-2004, Russell Gold * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -19,10 +19,7 @@ * DEALINGS IN THE SOFTWARE. * *******************************************************************************************************************/ -import com.meterware.httpunit.WebRequest; -import com.meterware.httpunit.WebResponse; -import com.meterware.httpunit.WebTable; -import com.meterware.httpunit.HttpUnitUtils; +import com.meterware.httpunit.*; import java.io.IOException; import java.io.PrintWriter; @@ -255,7 +252,7 @@ static class MyFactory implements InvocationContextFactory { private static ServletRunner _runner; - public InvocationContext newInvocation( ServletUnitClient client, String targetFrame, WebRequest request, Dictionary clientHeaders, byte[] messageBody ) throws IOException, MalformedURLException { + public InvocationContext newInvocation( ServletUnitClient client, FrameSelector targetFrame, WebRequest request, Dictionary clientHeaders, byte[] messageBody ) throws IOException, MalformedURLException { return new InvocationContextImpl( client, _runner, targetFrame, request, clientHeaders, messageBody ); } } |
From: Russell G. <rus...@us...> - 2004-06-13 20:56:53
|
Update of /cvsroot/httpunit/httpunit/examples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5770/examples Modified Files: Example.java Log Message: Fix inadvertant reformatting Index: Example.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/examples/Example.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Example.java 4 Jun 2004 01:20:02 -0000 1.4 +++ Example.java 13 Jun 2004 20:56:44 -0000 1.5 @@ -1 +1,28 @@ -import com.meterware.httpunit.*;/** This is a simple example of using HttpUnit to read and understand web pages. **/public class Example { public static void main( String[] params ) { try { // create the conversation object which will maintain state for us WebConversation wc = new WebConversation(); // Obtain the main page on the meterware web site WebRequest request = new GetMethodWebRequest( "http://www.meterware.com" ); WebResponse response = wc.getResponse( request ); // find the link which contains the string "HttpUnit" and click it WebLink httpunitLink = response.getFirstMatchingLink( WebLink.MATCH_CONTAINED_TEXT, "HttpUnit" ); response = httpunitLink.click(); // print out the number of links on the HttpUnit main page System.out.println( "The HttpUnit main page contains " + response.getLinks().length + " links" ); } catch (Exception e) { System.err.println( "Exception: " + e ); } }} \ No newline at end of file +import com.meterware.httpunit.*; + +/** This is a simple example of using HttpUnit to read and understand web pages. **/ +public class Example { + + + public static void main( String[] params ) { + try { + // create the conversation object which will maintain state for us + WebConversation wc = new WebConversation(); + + // Obtain the main page on the meterware web site + WebRequest request = new GetMethodWebRequest( "http://www.meterware.com" ); + WebResponse response = wc.getResponse( request ); + + // find the link which contains the string "HttpUnit" and click it + WebLink httpunitLink = response.getFirstMatchingLink( WebLink.MATCH_CONTAINED_TEXT, "HttpUnit" ); + response = httpunitLink.click(); + + // print out the number of links on the HttpUnit main page + System.out.println( "The HttpUnit main page contains " + response.getLinks().length + " links" ); + + } catch (Exception e) { + System.err.println( "Exception: " + e ); + } + } +} + |
From: Russell G. <rus...@us...> - 2004-06-04 01:20:12
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7568/test/com/meterware/httpunit Modified Files: FormParametersTest.java FormSubmitTest.java WebClientTest.java Log Message: Added newUnvalidateRequest methods Index: FormParametersTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FormParametersTest.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- FormParametersTest.java 15 Mar 2004 02:42:16 -0000 1.22 +++ FormParametersTest.java 4 Jun 2004 01:20:03 -0000 1.23 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * -* Copyright (c) 2000-2003, Russell Gold +* Copyright (c) 2000-2004, Russell Gold * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -51,7 +51,7 @@ } - public void testChoiceParameterValidationBypass() throws Exception { + public void testChoiceParameterValidationBypassDeprecated() throws Exception { HttpUnitOptions.setParameterValuesValidated( false ); defineWebPage( "Default", "<form method=GET action = \"/ask\">" + "<Select name=colors><Option>blue<Option>red</Select>" + @@ -69,6 +69,23 @@ } + public void testChoiceParameterValidationBypass() throws Exception { + defineWebPage( "Default", "<form method=GET action = \"/ask\">" + + "<Select name=colors><Option>blue<Option>red</Select>" + + "<Select name=fish><Option value=red>snapper<Option value=pink>salmon</select>" + + "<Select name=media multiple size=2><Option>TV<Option>Radio</select>" + + "<Input type=submit name=submit value=submit></form>" ); + WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); + WebRequest request = page.getForms()[0].newUnvalidatedRequest(); + request.setParameter( "noSuchControl", "green" ); + request.setParameter( "colors", "green" ); + request.setParameter( "fish", "purple" ); + request.setParameter( "media", "CDRom" ); + request.setParameter( "colors", new String[] { "blue", "red" } ); + request.setParameter( "fish", new String[] { "red", "pink" } ); + } + + public void testChoiceParameterValidation() throws Exception { defineWebPage( "Default", "<form method=GET action = \"/ask\">" + "<Select name=colors><Option>blue<Option>red</Select>" + @@ -77,7 +94,6 @@ "<Input type=submit></form>" ); WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); WebRequest request = page.getForms()[0].getRequest(); - HttpUnitOptions.setParameterValuesValidated( true ); validateSetParameterRejected( request, "noSuchControl", "green", "setting of non-existent control" ); validateSetParameterRejected( request, "colors", "green", "setting of undefined value" ); validateSetParameterRejected( request, "fish", "snapper", "setting of display value" ); @@ -95,6 +111,23 @@ public void testTextParameterValidationBypass() throws Exception { + defineWebPage( "Default", "<form method=GET action = \"/ask\">" + + "<Input type=text name=color>" + + "<Input type=password name=password>" + + "<Input type=hidden name=secret>" + + "<Input type=submit></form>" ); + WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); + WebRequest request = page.getForms()[0].newUnvalidatedRequest(); + request.setParameter( "color", "green" ); + request.setParameter( "password", "purple" ); + request.setParameter( "secret", "value" ); + request.setParameter( "colors", new String[] { "blue", "red" } ); + request.setParameter( "fish", new String[] { "red", "pink" } ); + request.setParameter( "secret", new String[] { "red", "pink" } ); + } + + + public void testTextParameterValidationBypassDeprecated() throws Exception { HttpUnitOptions.setParameterValuesValidated( false ); defineWebPage( "Default", "<form method=GET action = \"/ask\">" + "<Input type=text name=color>" + @@ -120,7 +153,6 @@ "<Input type=submit></form>" ); WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); WebRequest request = page.getForms()[0].getRequest(); - HttpUnitOptions.setParameterValuesValidated( true ); request.setParameter( "color", "green" ); request.setParameter( "password", "purple" ); request.setParameter( "secret", "value" ); @@ -142,7 +174,6 @@ assertTrue( "Should have called 'secret' hidden", form.isHiddenParameter( "secret") ); WebRequest request = form.getRequest(); - HttpUnitOptions.setParameterValuesValidated( true ); validateSetParameterRejected( request, "secret", new String[] { "red" }, "setting hidden field to wrong value" ); form.getScriptableObject().setParameterValue( "secret", "new" ); @@ -155,7 +186,6 @@ "<Input type=submit></form>" ); WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); WebRequest request = page.getForms()[0].getRequest(); - HttpUnitOptions.setParameterValuesValidated( true ); try { request.setParameter( "secret", "zork" ); fail( "Should have rejected set of unknown parameter" ); @@ -173,7 +203,6 @@ WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); WebForm form = page.getForms()[0]; WebRequest request = form.getRequest(); - HttpUnitOptions.setParameterValuesValidated( true ); assertEquals( "Number of parameters named 'password'", 1, form.getNumTextParameters( "password" ) ); assertEquals( "Number of parameters named 'color'", 2, form.getNumTextParameters( "color" ) ); @@ -186,6 +215,19 @@ public void testRadioButtonValidationBypass() throws Exception { + defineWebPage( "Default", "<form method=GET action = \"/ask\">" + + "<Input type=radio name=color value=red>" + + "<Input type=radio name=color value=blue>" + + "<Input type=radio name=color value=green>" + + "<Input type=submit></form>" ); + WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); + WebRequest request = page.getForms()[0].newUnvalidatedRequest(); + request.setParameter( "color", "black" ); + request.setParameter( "color", new String[] { "blue", "red" } ); + } + + + public void testRadioButtonValidationBypassDeprecated() throws Exception { HttpUnitOptions.setParameterValuesValidated( false ); defineWebPage( "Default", "<form method=GET action = \"/ask\">" + "<Input type=radio name=color value=red>" + @@ -207,7 +249,6 @@ "<Input type=submit></form>" ); WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); WebRequest request = page.getForms()[0].getRequest(); - HttpUnitOptions.setParameterValuesValidated( true ); assertEquals( "color options", new String[] { "red", "blue", "green" }, page.getForms()[0].getOptionValues( "color" ) ); assertEquals( "color names", new String[] { "Crimson", "Aquamarine", "Chartreuse" }, page.getForms()[0].getOptions( "color" ) ); request.setParameter( "color", "red" ); @@ -217,7 +258,7 @@ } - public void testCheckboxValidationBypass() throws Exception { + public void testCheckboxValidationBypassDeprecated() throws Exception { defineWebPage( "Default", "<form method=GET action = \"/ask\">" + "<Input type=checkbox name=use_color>" + "<Input type=checkbox name=color value=red>" + @@ -231,6 +272,19 @@ } + public void testCheckboxValidationBypass() throws Exception { + defineWebPage( "Default", "<form method=GET action = \"/ask\">" + + "<Input type=checkbox name=use_color>" + + "<Input type=checkbox name=color value=red>" + + "<Input type=checkbox name=color value=blue>" + + "<Input type=submit></form>" ); + WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); + WebRequest request = page.getForms()[0].newUnvalidatedRequest(); + request.setParameter( "use_color", "red" ); + request.setParameter( "color", "green" ); + } + + public void testCheckboxValidation() throws Exception { defineWebPage( "Default", "<form method=GET action = 'ask?color='>" + "<Input type=checkbox name=use_color>" + @@ -389,8 +443,7 @@ WebRequest wr = form.getRequest(); assertEquals( "File from validated request", file.getAbsolutePath(), wr.getParameterValues( "File" )[0] ); - HttpUnitOptions.setParameterValuesValidated( false ); - wr = form.getRequest(); + wr = form.newUnvalidatedRequest(); assertEquals( "File from unvalidated request", file.getAbsolutePath(), wr.getParameterValues( "File" )[0] ); } Index: FormSubmitTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FormSubmitTest.java,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- FormSubmitTest.java 23 Jun 2003 23:54:04 -0000 1.31 +++ FormSubmitTest.java 4 Jun 2004 01:20:03 -0000 1.32 @@ -318,13 +318,12 @@ public void testImageButtonNoValueUncheckedPositionalSubmit() throws Exception { - HttpUnitOptions.setParameterValuesValidated( false ); defineWebPage( "Default", "<form method='GET' action='test.jsp'>" + "<input type='image' src='image.gif' name='aButton'>" + "</form>" ); WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); WebForm form = page.getForms()[0]; - WebRequest request = form.getRequest( form.getSubmitButton( "aButton" ), 20, 5 ); + WebRequest request = form.newUnvalidatedRequest( form.getSubmitButton( "aButton" ), 20, 5 ); assertEqualQueries( getHostPath() + "/test.jsp?aButton.x=20&aButton.y=5", request.getURL().toExternalForm() ); } @@ -443,18 +442,18 @@ WebForm otherForm = other.getForms()[0]; WebForm wrongForm = wrong.getForms()[0]; - HttpUnitOptions.setParameterValuesValidated( true ); form.getRequest( otherForm.getSubmitButtons()[0] ); - HttpUnitOptions.setParameterValuesValidated( false ); - form.getRequest( wrongForm.getSubmitButtons()[0] ); - - HttpUnitOptions.setParameterValuesValidated( true ); try { form.getRequest( wrongForm.getSubmitButtons()[0] ); fail( "Failed to reject illegal button" ); } catch (IllegalRequestParameterException e) { } + + form.newUnvalidatedRequest( wrongForm.getSubmitButtons()[0] ); + + HttpUnitOptions.setParameterValuesValidated( false ); + form.getRequest( wrongForm.getSubmitButtons()[0] ); } Index: WebClientTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebClientTest.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- WebClientTest.java 17 Sep 2003 01:21:15 -0000 1.16 +++ WebClientTest.java 4 Jun 2004 01:20:03 -0000 1.17 @@ -62,6 +62,8 @@ wc.getResponse( "http://no.such.host" ); fail( "Should have rejected the request" ); } catch (UnknownHostException e) { + } catch (IOException e) { + if (!(e.getCause() instanceof UnknownHostException)) throw e; } } |
From: Russell G. <rus...@us...> - 2004-06-04 01:20:12
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7568/src/com/meterware/httpunit Modified Files: GetMethodWebRequest.java HeaderOnlyWebRequest.java HttpUnitOptions.java MessageBodyWebRequest.java PostMethodWebRequest.java WebForm.java WebRequest.java Log Message: Added newUnvalidateRequest methods Index: GetMethodWebRequest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/GetMethodWebRequest.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- GetMethodWebRequest.java 31 Oct 2002 00:25:45 -0000 1.17 +++ GetMethodWebRequest.java 4 Jun 2004 01:20:03 -0000 1.18 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * -* Copyright (c) 2000-2002, Russell Gold +* Copyright (c) 2000-2002, 2004, Russell Gold * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -63,14 +63,6 @@ /** - * Constructs a web request for a form. - **/ - GetMethodWebRequest( WebForm sourceForm, SubmitButton button, int x, int y ) { - super( sourceForm, button, x, y ); - } - - - /** * Constructs a web request for a form submitted from JavaScript. **/ GetMethodWebRequest( WebForm sourceForm ) { @@ -86,6 +78,14 @@ } + /** + * Constructs a web request for a form. + **/ + GetMethodWebRequest( WebForm sourceForm, ParameterHolder parameterHolder, SubmitButton button, int x, int y ) { + super( sourceForm, parameterHolder, button, x, y ); + } + + } Index: HeaderOnlyWebRequest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HeaderOnlyWebRequest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- HeaderOnlyWebRequest.java 31 Oct 2002 00:25:45 -0000 1.1 +++ HeaderOnlyWebRequest.java 4 Jun 2004 01:20:03 -0000 1.2 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * - * Copyright (c) 2002, Russell Gold + * Copyright (c) 2002,2004, Russell Gold * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -68,12 +68,12 @@ HeaderOnlyWebRequest( WebRequestSource requestSource ) { - super( requestSource ); + super( requestSource, WebRequest.newParameterHolder( requestSource ) ); } - HeaderOnlyWebRequest( WebForm sourceForm, SubmitButton button, int x, int y ) { - super( sourceForm, button, x, y ); + HeaderOnlyWebRequest( WebForm sourceForm, ParameterHolder parameterHolder, SubmitButton button, int x, int y ) { + super( sourceForm, parameterHolder, button, x, y ); } Index: HttpUnitOptions.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpUnitOptions.java,v retrieving revision 1.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- HttpUnitOptions.java 1 Oct 2003 12:11:14 -0000 1.40 +++ HttpUnitOptions.java 4 Jun 2004 01:20:03 -0000 1.41 @@ -218,6 +218,8 @@ /** * Returns true if form parameter settings are checked. + * + * @deprecated use WebForm#newUnvalidatedRequest() to obtain a request without parameter validation. **/ public static boolean getParameterValuesValidated() { return _parameterValuesValidated; @@ -230,6 +232,8 @@ * <b>Note:</b> this only applies to a WebRequest created after this setting is changed. A request created * with this option disabled will not only not be checked for correctness, its parameter submission * order will not be guaranteed, and changing parameters will not trigger Javascript onChange / onClick events. + * + * @deprecated use WebForm#newUnvalidatedRequest() to obtain a request without parameter validation. **/ public static void setParameterValuesValidated( boolean validated ) { _parameterValuesValidated = validated; Index: MessageBodyWebRequest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/MessageBodyWebRequest.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- MessageBodyWebRequest.java 15 Sep 2003 12:05:12 -0000 1.10 +++ MessageBodyWebRequest.java 4 Jun 2004 01:20:03 -0000 1.11 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * -* Copyright (c) 2001-2002, Russell Gold +* Copyright (c) 2001-2004, Russell Gold * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -57,7 +57,15 @@ * Constructs a web request for a form submitted via a button. **/ protected MessageBodyWebRequest( WebForm sourceForm, SubmitButton button, int x, int y ) { - super( sourceForm, button, x, y ); + this( sourceForm, WebRequest.newParameterHolder( sourceForm ), button, x, y ); + } + + + /** + * Constructs a web request for a form submitted via a button. + **/ + protected MessageBodyWebRequest( WebForm sourceForm, ParameterHolder parameterHolder, SubmitButton button, int x, int y ) { + super( sourceForm, parameterHolder, button, x, y ); } @@ -65,7 +73,7 @@ * Constructs a web request for a form submitted via script. **/ protected MessageBodyWebRequest( WebForm sourceForm ) { - super( sourceForm ); + super( sourceForm, WebRequest.newParameterHolder( sourceForm ) ); } Index: PostMethodWebRequest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/PostMethodWebRequest.java,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- PostMethodWebRequest.java 19 Aug 2002 18:52:26 -0000 1.25 +++ PostMethodWebRequest.java 4 Jun 2004 01:20:03 -0000 1.26 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * -* Copyright (c) 2000-2002, Russell Gold +* Copyright (c) 2000-2002, 2004, Russell Gold * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -124,6 +124,11 @@ } + public PostMethodWebRequest( WebForm sourceForm, ParameterHolder parameterHolder, SubmitButton button, int x, int y ) { + super( sourceForm, parameterHolder, button, x, y ); + } + + /** * Constructs a web request for a form submitted via a script. **/ Index: WebForm.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v retrieving revision 1.88 retrieving revision 1.89 diff -u -r1.88 -r1.89 --- WebForm.java 15 Mar 2004 02:42:16 -0000 1.88 +++ WebForm.java 4 Jun 2004 01:20:03 -0000 1.89 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * -* Copyright (c) 2000-2003, Russell Gold +* Copyright (c) 2000-2004, Russell Gold * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -262,7 +262,39 @@ if (getMethod().equalsIgnoreCase( "post" )) { return new PostMethodWebRequest( this, button, x, y ); } else { - return new GetMethodWebRequest( this, button, x, y ); + return new GetMethodWebRequest( this, WebRequest.newParameterHolder( this ), button, x, y ); + } + } + + + /** + * Creates and returns a web request which includes the specified button. If no button is specified, will include + * the default button, if any. No parameter validation will be done on the returned request and no scripts + * will be run when it is submitted. + **/ + public WebRequest newUnvalidatedRequest( SubmitButton button ) { + return newUnvalidatedRequest( button, 0, 0 ); + } + + + /** + * Creates and returns a web request which includes the specified button and position. If no button is specified, + * will include the default button, if any. No parameter validation will be done on the returned request + * and no scripts will be run when it is submitted. + **/ + public WebRequest newUnvalidatedRequest( SubmitButton button, int x, int y ) { + if (button == null) button = getDefaultButton(); + + SubmitButton[] buttons = getSubmitButtons(); + for (int i = 0; i < buttons.length; i++) { + buttons[i].setPressed( false ); + } + button.setPressed( true ); + + if (getMethod().equalsIgnoreCase( "post" )) { + return new PostMethodWebRequest( this, new UncheckedParameterHolder( this ), button, x, y ); + } else { + return new GetMethodWebRequest( this, new UncheckedParameterHolder( this ), button, x, y ); } } @@ -445,6 +477,15 @@ /** + * Creates and returns a web request based on the current state of this form. No parameter validation will be done + * and there is no guarantee over the order of parameters transmitted. + */ + public WebRequest newUnvalidatedRequest() { + return newUnvalidatedRequest( (SubmitButton) null ); + } + + + /** * Returns the scriptable delegate. */ Index: WebRequest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequest.java,v retrieving revision 1.57 retrieving revision 1.58 diff -u -r1.57 -r1.58 --- WebRequest.java 15 Sep 2003 12:05:11 -0000 1.57 +++ WebRequest.java 4 Jun 2004 01:20:03 -0000 1.58 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * -* Copyright (c) 2000-2003, Russell Gold +* Copyright (c) 2000-2004, Russell Gold * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -333,8 +333,8 @@ /** * Constructs a web request from a form. **/ - protected WebRequest( WebForm sourceForm, SubmitButton button, int x, int y ) { - this( sourceForm ); + protected WebRequest( WebForm sourceForm, ParameterHolder parameterHolder, SubmitButton button, int x, int y ) { + this( sourceForm, parameterHolder ); if (button != null && button.isImageButton() && button.getName().length() > 0) { _button = button; _parameterHolder.selectImageButtonPosition( _button, x, y ); @@ -342,14 +342,14 @@ } - protected WebRequest( WebRequestSource requestSource ) { - this( requestSource.getBaseURL(), requestSource.getRelativePage(), requestSource.getPageFrame(), requestSource.getTarget(), newParameterHolder( requestSource ) ); + protected WebRequest( WebRequestSource requestSource, ParameterHolder parameterHolder ) { + this( requestSource.getBaseURL(), requestSource.getRelativePage(), requestSource.getPageFrame(), requestSource.getTarget(), parameterHolder ); _webRequestSource = requestSource; setHeaderField( "Referer", requestSource.getBaseURL().toExternalForm() ); } - private static ParameterHolder newParameterHolder( WebRequestSource requestSource ) { + static ParameterHolder newParameterHolder( WebRequestSource requestSource ) { if (HttpUnitOptions.getParameterValuesValidated()) { return requestSource; } else { |
From: Russell G. <rus...@us...> - 2004-06-04 01:20:11
|
Update of /cvsroot/httpunit/httpunit/sitedocs/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7568/sitedocs/doc Modified Files: faq.xml Log Message: Added newUnvalidateRequest methods Index: faq.xml =================================================================== RCS file: /cvsroot/httpunit/httpunit/sitedocs/doc/faq.xml,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- faq.xml 2 Mar 2004 10:51:39 -0000 1.6 +++ faq.xml 4 Jun 2004 01:20:03 -0000 1.7 @@ -104,9 +104,8 @@ hidden parameters directly, HttpUnit stops you from doing it in your code as part of its validation of parameters against the form containing them. If you have to change these values, you have a couple of choices: <ul><li>Rather than setting the parameters directly on the form, call - <a href="api/com/meterware/httpunit/HttpUnitOptions.html#setParameterValuesValidated(boolean)"> - <code>HttpUnitOptions.setParameterValuesValidated( false )</code></a> and then call - <a href="api/com/meterware/httpunit/WebForm.html#getRequest()"><code>WebForm.getRequest()</code></a> + <a href="api/com/meterware/httpunit/WebForm.html#newUnvalidatedRequest()"> + <code>WebForm.newUnvalidatedRequest()</code></a> (specifying any submit button information if necessary) to obtain a <tt>WebRequest</tt> copied from the form but not tied to it. You will then be able to set any values you like in this request. Note that parameter order is not guaranteed when such a request is submitted, nor are any JavaScript events fired.</li> |
From: Russell G. <rus...@us...> - 2004-06-04 01:20:11
|
Update of /cvsroot/httpunit/httpunit/examples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7568/examples Modified Files: Example.java Log Message: Added newUnvalidateRequest methods Index: Example.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/examples/Example.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Example.java 25 Nov 2002 13:52:45 -0000 1.3 +++ Example.java 4 Jun 2004 01:20:02 -0000 1.4 @@ -1 +1 @@ -import com.meterware.httpunit.*; /** This is a simple example of using HttpUnit to read and understand web pages. **/ public class Example { public static void main( String[] params ) { try { // create the conversation object which will maintain state for us WebConversation wc = new WebConversation(); // Obtain the main page on the meterware web site WebRequest request = new GetMethodWebRequest( "http://www.meterware.com" ); WebResponse response = wc.getResponse( request ); // find the link which contains the string "HttpUnit" and click it WebLink httpunitLink = response.getFirstMatchingLink( WebLink.MATCH_CONTAINED_TEXT, "HttpUnit" ); response = httpunitLink.click(); // print out the number of links on the HttpUnit main page System.out.println( "The HttpUnit main page contains " + response.getLinks().length + " links" ); } catch (Exception e) { System.err.println( "Exception: " + e ); } } } \ No newline at end of file +import com.meterware.httpunit.*;/** This is a simple example of using HttpUnit to read and understand web pages. **/public class Example { public static void main( String[] params ) { try { // create the conversation object which will maintain state for us WebConversation wc = new WebConversation(); // Obtain the main page on the meterware web site WebRequest request = new GetMethodWebRequest( "http://www.meterware.com" ); WebResponse response = wc.getResponse( request ); // find the link which contains the string "HttpUnit" and click it WebLink httpunitLink = response.getFirstMatchingLink( WebLink.MATCH_CONTAINED_TEXT, "HttpUnit" ); response = httpunitLink.click(); // print out the number of links on the HttpUnit main page System.out.println( "The HttpUnit main page contains " + response.getLinks().length + " links" ); } catch (Exception e) { System.err.println( "Exception: " + e ); } }} \ No newline at end of file |
From: Russell G. <rus...@us...> - 2004-06-04 01:20:11
|
Update of /cvsroot/httpunit/httpunit/site/com/meterware/xml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7568/site/com/meterware/xml Modified Files: DocumentSemantics.java Log Message: Added newUnvalidateRequest methods Index: DocumentSemantics.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/site/com/meterware/xml/DocumentSemantics.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- DocumentSemantics.java 17 Jun 2003 11:15:03 -0000 1.4 +++ DocumentSemantics.java 4 Jun 2004 01:20:02 -0000 1.5 @@ -106,7 +106,7 @@ Object subElement = method.invoke( elementObject, NO_ARGS ); interpretNode( child, subElement ); } catch (NoSuchMethodException e) { - setContentsAsProperty( elementObject, beanInfo, child, child.getNodeName() ); + setContentsAsProperty( elementObject, beanInfo, child, toPropertyName( child.getNodeName() ) ); } catch (SecurityException e) { e.printStackTrace(); //To change body of catch statement use Options | File Templates. } |
From: Russell G. <rus...@us...> - 2004-06-04 01:20:11
|
Update of /cvsroot/httpunit/httpunit/doc/tutorial In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7568/doc/tutorial Modified Files: arrow_yellow.gif Log Message: Added newUnvalidateRequest methods Index: arrow_yellow.gif =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/tutorial/arrow_yellow.gif,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 Binary files /tmp/cvsuEmctz and /tmp/cvsrIK3dZ differ |
From: Russell G. <rus...@us...> - 2004-06-04 01:20:11
|
Update of /cvsroot/httpunit/httpunit/doc/images In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7568/doc/images Modified Files: HttpUnit.jpg Log Message: Added newUnvalidateRequest methods Index: HttpUnit.jpg =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/images/HttpUnit.jpg,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 Binary files /tmp/cvsLaQhqt and /tmp/cvs26tF5S differ |
From: Russell G. <rus...@us...> - 2004-06-04 01:20:11
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7568/doc Modified Files: release_notes.txt Log Message: Added newUnvalidateRequest methods Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.331 retrieving revision 1.332 diff -u -r1.331 -r1.332 --- release_notes.txt 20 Apr 2004 16:35:09 -0000 1.331 +++ release_notes.txt 4 Jun 2004 01:20:02 -0000 1.332 @@ -13,6 +13,12 @@ Revision History: + 3-Jun-2004 + Additions: + 1. WebForm now supports the newUnvalidatedRequest method, which should be used in preference to + HttpUnitOptions.setParametersValidated( false ). This creates a web request copied from the form + but not tied to it, so that parameters can be set without validation. + 20-Apr-2004 Problems fixed: 1. PseudoServer now accepts a full http URL to permit testing of interaction with proxy servers. @@ -484,7 +490,7 @@ 2-Oct-2002 1.4.6 Acknowledgements: - Thanks to Ville Skyttä for removing the test dependency on xerces. + Thanks to Ville Skytt� for removing the test dependency on xerces. Thanks to Donald Ball for pointing out the problem with the behavior of Select.selectedIndex. Thanks to Jin Zhao for help in expanding the search possibilities for links. @@ -724,7 +730,7 @@ of link URLs with parameters and fragments. Thanks to Paul Frantz and Dave Glowacki for finding and fixing problems with parsing of link parameter names without values. Thanks to Didier Besset for new WebForm methods: hasParameterNamed and hasParameterStartingWithPrefix - Thanks to Peter Roßbach for catching some typos in the tutorial. + Thanks to Peter Ro�bach for catching some typos in the tutorial. Thanks to Benoit Xhenseval for adding a mechanism to handle HTML parser errors. Thanks to Benoit Xhenseval for optimizing the use of DOMs and StringBuffers. Thanks to Bradley Smith for implementing getParameterNames in ServletUnit. |
From: Russell G. <rus...@us...> - 2004-04-20 16:36:19
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1655/doc Modified Files: release_notes.txt Log Message: Support proxy client testing Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.330 retrieving revision 1.331 diff -u -r1.330 -r1.331 --- release_notes.txt 15 Mar 2004 02:42:16 -0000 1.330 +++ release_notes.txt 20 Apr 2004 16:35:09 -0000 1.331 @@ -13,6 +13,10 @@ Revision History: +20-Apr-2004 + Problems fixed: + 1. PseudoServer now accepts a full http URL to permit testing of interaction with proxy servers. + 14-Mar-2004 Additions: 1. RFE #909922: ServletUnit now supports HttpServletRequest.getHeaders |
From: Russell G. <rus...@us...> - 2004-04-20 16:36:18
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/pseudoserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1655/test/com/meterware/pseudoserver Modified Files: PseudoServerTest.java Log Message: Support proxy client testing Index: PseudoServerTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/pseudoserver/PseudoServerTest.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- PseudoServerTest.java 17 Oct 2003 13:58:10 -0000 1.13 +++ PseudoServerTest.java 20 Apr 2004 16:35:26 -0000 1.14 @@ -21,12 +21,12 @@ *******************************************************************************************************************/ import junit.framework.TestSuite; +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.Socket; -import java.io.OutputStream; -import java.io.InputStream; -import java.io.IOException; -import java.io.BufferedInputStream; public class PseudoServerTest extends HttpUserAgentTest { @@ -84,6 +84,28 @@ } + /** + * This tests simple access to the server without using any client classes. + */ + public void testProxyGetViaSocket() throws Exception { + defineResource( "http://someserver.com/sample", "Get this", "text/plain" ); + Socket socket = new Socket( "localhost", getHostPort() ); + OutputStream os = socket.getOutputStream(); + InputStream is = new BufferedInputStream( socket.getInputStream() ); + + sendHTTPLine( os, "GET http://someserver.com/sample HTTP/1.0" ); + sendHTTPLine( os, "Host: someserver.com" ); + sendHTTPLine( os, "" ); + + StringBuffer sb = new StringBuffer(); + int b; + while (-1 != (b = is.read())) sb.append( (char) b ); + String result = sb.toString(); + assertTrue( "Did not find matching protocol", result.startsWith( "HTTP/1.0" ) ); + assertTrue( "Did not find expected text", result.indexOf( "Get this" ) > 0 ); + } + + private void sendHTTPLine( OutputStream os, final String line ) throws IOException { os.write( line.getBytes() ); os.write( 13 ); |
From: Russell G. <rus...@us...> - 2004-04-20 16:36:07
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/pseudoserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1655/src/com/meterware/pseudoserver Modified Files: PseudoServer.java Log Message: Support proxy client testing Index: PseudoServer.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/pseudoserver/PseudoServer.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- PseudoServer.java 17 Oct 2003 13:58:09 -0000 1.15 +++ PseudoServer.java 20 Apr 2004 16:35:21 -0000 1.16 @@ -242,7 +242,7 @@ private String asResourceName( String rawName ) { - if (rawName.startsWith( "/" )) { + if (rawName.startsWith( "http:" ) || rawName.startsWith( "/" )) { return escape( rawName ); } else { return escape( "/" + rawName ); |
From: Russell G. <rus...@us...> - 2004-04-20 16:36:07
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1655/test/com/meterware/httpunit Modified Files: WebPageTest.java Log Message: Support proxy client testing Index: WebPageTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebPageTest.java,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- WebPageTest.java 5 Dec 2003 04:06:53 -0000 1.34 +++ WebPageTest.java 20 Apr 2004 16:35:24 -0000 1.35 @@ -67,6 +67,20 @@ } + public void testProxyServerAccess() throws Exception { + defineResource( "http://someserver.com/sample", "Get this", "text/plain" ); + WebConversation wc = new WebConversation(); + try { + wc.setProxyServer( "localhost", getHostPort() ); + WebResponse wr = wc.getResponse( "http://someserver.com/sample" ); + String result = wr.getText(); + assertEquals( "Expected text", "Get this", result.trim() ); + } finally { + wc.clearProxyServer(); + } + } + + public void testTitle() throws Exception { defineResource( "SimplePage.html", "<html><head><title>A Sample Page</title></head>\n" + |