httpunit-commit Mailing List for httpunit (Page 15)
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-09-12 03:32:08
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32306/src/com/meterware/httpunit Modified Files: WebForm.java WebImage.java WebLink.java Log Message: bug #1013045: Form, Link, and Image id tags are now recognizable from JavaScript where a name tag would be Index: WebForm.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v retrieving revision 1.97 retrieving revision 1.98 diff -u -r1.97 -r1.98 --- WebForm.java 10 Aug 2004 20:28:52 -0000 1.97 +++ WebForm.java 12 Sep 2004 03:31:58 -0000 1.98 @@ -685,7 +685,7 @@ public String getName() { - return WebForm.this.getName(); + return WebForm.this.getID().length() != 0 ? WebForm.this.getID() : WebForm.this.getName(); } Index: WebImage.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebImage.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- WebImage.java 23 Jul 2004 01:31:04 -0000 1.11 +++ WebImage.java 12 Sep 2004 03:31:58 -0000 1.12 @@ -90,10 +90,15 @@ } - public class Scriptable extends ScriptableDelegate implements NamedDelegate { + public class Scriptable extends HTMLElementScriptable implements NamedDelegate { + + public Scriptable() { + super( WebImage.this ); + } + public String getName() { - return WebImage.this.getName(); + return WebImage.this.getID().length() != 0 ? WebImage.this.getID() : WebImage.this.getName(); } Index: WebLink.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebLink.java,v retrieving revision 1.45 retrieving revision 1.46 diff -u -r1.45 -r1.46 --- WebLink.java 8 Aug 2004 17:45:31 -0000 1.45 +++ WebLink.java 12 Sep 2004 03:31:58 -0000 1.46 @@ -115,7 +115,7 @@ public String getName() { - return WebLink.this.getName(); + return WebLink.this.getID().length() != 0 ? WebLink.this.getID() : WebLink.this.getName(); } |
From: Russell G. <rus...@us...> - 2004-09-12 03:32:08
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32306/doc Modified Files: release_notes.txt todo.txt Log Message: bug #1013045: Form, Link, and Image id tags are now recognizable from JavaScript where a name tag would be Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.367 retrieving revision 1.368 diff -u -r1.367 -r1.368 --- release_notes.txt 9 Sep 2004 22:32:40 -0000 1.367 +++ release_notes.txt 12 Sep 2004 03:31:57 -0000 1.368 @@ -13,6 +13,10 @@ Revision History: +10-Sep-2004: + Problems fixed: + 1. bug #1013045: Form, Link, and Image id tags are now recognizable from JavaScript where a name tag would be + 9-Sep-2004: Problems fixed: 1. Slashes in URL parameters were being misinterpeted as navigation Index: todo.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/todo.txt,v retrieving revision 1.43 retrieving revision 1.44 diff -u -r1.43 -r1.44 --- todo.txt 23 Jul 2004 04:04:24 -0000 1.43 +++ todo.txt 12 Sep 2004 03:31:57 -0000 1.44 @@ -1,6 +1,5 @@ High priority: -o behavior of request vs client headers does not match javascript - should possibly throw exception if any headers are not - settable on the request. +o Better JavaScript error reporting: use custom object rather than NOT_FOUND (verify evaluate to false...) o Writeable 'name' Javascript attribute o NoOp request when link is to same page w/o new parameters? |
From: Russell G. <rus...@us...> - 2004-09-12 03:32:08
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32306/test/com/meterware/httpunit/javascript Modified Files: HTMLElementTest.java Log Message: bug #1013045: Form, Link, and Image id tags are now recognizable from JavaScript where a name tag would be Index: HTMLElementTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/HTMLElementTest.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- HTMLElementTest.java 24 Jun 2004 23:35:18 -0000 1.6 +++ HTMLElementTest.java 12 Sep 2004 03:31:58 -0000 1.7 @@ -118,6 +118,28 @@ } + public void testNamePropertyWithIdAttribute() throws Exception { + defineResource( "start.html", + "<html><head><script language='JavaScript'>" + + "function showAll() {" + + " alert( 'element with name there has title ' + document.there.title );" + + " alert( 'element with name perform has title ' + document.perform.title );" + + " alert( 'element with name seeme has title ' + document.seeme.title );" + + "}</script>" + + "</head><body onLoad='showAll();'>" + + "<a href='somewhere' id='there' title=second>here</a>" + + "<form id='perform' title=fifth></form>" + + "<img id='seeme' title='haha' src='haha.jpg'>" + + "</td></tr></table></div></body></html>" ); + WebConversation wc = new WebConversation(); + wc.getResponse( getHostPath() + "/start.html" ); + + assertElementTitle( wc, "name", "there", "second" ); + assertElementTitle( wc, "name", "perform", "fifth" ); + assertElementTitle( wc, "name", "seeme", "haha" ); + } + + private void assertElementTitle( WebConversation wc, String propertyName, final String id, final String title ) { assertEquals( "element '" + id + "' message", "element with " + propertyName + ' ' + id + " has title " + title, wc.popNextAlert() ); } |
From: Russell G. <rus...@us...> - 2004-09-09 22:32:58
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27779/test/com/meterware/httpunit Modified Files: NormalizeURLTest.java Log Message: Handle slashes in url parameters Index: NormalizeURLTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/NormalizeURLTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- NormalizeURLTest.java 29 Jun 2004 23:55:22 -0000 1.3 +++ NormalizeURLTest.java 9 Sep 2004 22:32:41 -0000 1.4 @@ -356,4 +356,11 @@ } + public void testSlashesInParameter() throws Exception { + String desiredUrl = "http://localhost:8888/bug2295681/TestServlet?abc=abc&aaa=%%%&bbb=---%2d%2F%*%aa&ccc=ya...@ya...&ddd=aaa/../../&eee=/."; + WebRequest request = new GetMethodWebRequest( desiredUrl ); + assertEquals( "URL", desiredUrl, request.getURL().toExternalForm() ); + } + + } |
From: Russell G. <rus...@us...> - 2004-09-09 22:32:58
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27779/doc Modified Files: release_notes.txt Log Message: Handle slashes in url parameters Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.366 retrieving revision 1.367 diff -u -r1.366 -r1.367 --- release_notes.txt 9 Sep 2004 00:16:40 -0000 1.366 +++ release_notes.txt 9 Sep 2004 22:32:40 -0000 1.367 @@ -13,6 +13,10 @@ Revision History: + 9-Sep-2004: + Problems fixed: + 1. Slashes in URL parameters were being misinterpeted as navigation + 8-Sep-2004: Additions: 1. ServletRunner and ServletUnitClient now support a getSession() method to return the HTTP session to be used |
From: Russell G. <rus...@us...> - 2004-09-09 22:32:58
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27779/src/com/meterware/httpunit Modified Files: WebRequest.java Log Message: Handle slashes in url parameters Index: WebRequest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequest.java,v retrieving revision 1.62 retrieving revision 1.63 diff -u -r1.62 -r1.63 --- WebRequest.java 29 Jun 2004 23:55:22 -0000 1.62 +++ WebRequest.java 9 Sep 2004 22:32:41 -0000 1.63 @@ -116,10 +116,17 @@ private String getNormalizedURL( String url ) { - if (url.lastIndexOf( "//" ) > url.lastIndexOf( "://" ) + 1) return getNormalizedURL( stripDoubleSlashes( url ) ); - if (url.indexOf( "/.." ) > 0) return getNormalizedURL( stripUpNavigation( url ) ); - if (url.indexOf( "/./" ) > 0) return getNormalizedURL( stripInPlaceNavigation( url ) ); - return url; + int questionIndex = url.indexOf( '?' ); + if (questionIndex < 0) return getNormalizedPath( url ); + return getNormalizedPath( url.substring( 0, questionIndex ) ) + url.substring( questionIndex ); + } + + + private String getNormalizedPath( String path ) { + if (path.lastIndexOf( "//" ) > path.lastIndexOf( "://" ) + 1) return getNormalizedPath( stripDoubleSlashes( path ) ); + if (path.indexOf( "/.." ) > 0) return getNormalizedPath( stripUpNavigation( path ) ); + if (path.indexOf( "/./" ) > 0) return getNormalizedPath( stripInPlaceNavigation( path ) ); + return path; } |
From: Russell G. <rus...@us...> - 2004-09-09 00:16:55
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19281/test/com/meterware/servletunit Modified Files: JUnitServletTest.java StatefulTest.java Log Message: Support HttpSession access from ServletUnit client Index: JUnitServletTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/JUnitServletTest.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- JUnitServletTest.java 13 Jun 2004 20:57:28 -0000 1.10 +++ JUnitServletTest.java 9 Sep 2004 00:16:40 -0000 1.11 @@ -31,6 +31,7 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; import javax.xml.parsers.DocumentBuilder; import junit.framework.TestCase; @@ -255,5 +256,10 @@ 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 ); } + + + public HttpSession getSession( String sessionId, boolean create ) { + return null; + } } } Index: StatefulTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/StatefulTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- StatefulTest.java 25 Feb 2003 17:17:29 -0000 1.5 +++ StatefulTest.java 9 Sep 2004 00:16:40 -0000 1.6 @@ -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 @@ -105,6 +105,42 @@ } + public void testSessionPreloading() throws Exception { + final String resourceName1 = "something/interesting/start"; + final String resourceName2 = "something/continue"; + + ServletRunner sr = new ServletRunner(); + sr.registerServlet( resourceName1, StatefulServlet.class.getName() ); + sr.registerServlet( resourceName2, StatefulServlet.class.getName() ); + ServletUnitClient wc = sr.newClient(); + + wc.getSession( true ).setAttribute( "color", "green" ); + WebRequest request = new GetMethodWebRequest( "http://localhost/" + resourceName2 ); + WebResponse response = wc.getResponse( request ); + assertNotNull( "No response received", response ); + assertEquals( "content type", "text/plain", response.getContentType() ); + assertEquals( "requested resource", "You posted green", response.getText() ); + assertEquals( "Returned cookie count", 0, response.getNewCookieNames().length ); + } + + + public void testSessionAccess() throws Exception { + final String resourceName1 = "something/interesting/start"; + final String resourceName2 = "something/continue"; + + ServletRunner sr = new ServletRunner(); + sr.registerServlet( resourceName1, StatefulServlet.class.getName() ); + sr.registerServlet( resourceName2, StatefulServlet.class.getName() ); + + WebRequest request = new PostMethodWebRequest( "http://localhost/" + resourceName1 ); + request.setParameter( "color", "yellow" ); + sr.getResponse( request ); + + assertNotNull( "No session was created", sr.getSession( false ) ); + assertEquals( "Color attribute in session", "yellow", sr.getSession( false ).getAttribute( "color" ) ); + } + + public void testInvocationContext() throws Exception { final String resourceName = "something/interesting"; |
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19281/src/com/meterware/servletunit Modified Files: InvocationContextFactory.java ServletRunner.java ServletUnitClient.java ServletUnitContext.java ServletUnitHttpRequest.java Log Message: Support HttpSession access from ServletUnit client Index: InvocationContextFactory.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/InvocationContextFactory.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- InvocationContextFactory.java 13 Jun 2004 20:57:28 -0000 1.6 +++ InvocationContextFactory.java 9 Sep 2004 00:16:40 -0000 1.7 @@ -22,6 +22,7 @@ import com.meterware.httpunit.WebRequest; import com.meterware.httpunit.FrameSelector; +import javax.servlet.http.HttpSession; import java.io.IOException; import java.net.MalformedURLException; import java.util.Dictionary; @@ -39,4 +40,9 @@ **/ public InvocationContext newInvocation( ServletUnitClient client, FrameSelector targetFrame, WebRequest request, Dictionary clientHeaders, byte[] messageBody ) throws IOException, MalformedURLException; + + /** + * Returns the session with the specified ID; if none exists or the session is invalid, will create a new session if the create flag is true. + */ + public HttpSession getSession( String sessionId, boolean create ); } Index: ServletRunner.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletRunner.java,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- ServletRunner.java 26 Aug 2004 23:11:33 -0000 1.26 +++ ServletRunner.java 9 Sep 2004 00:16:40 -0000 1.27 @@ -34,6 +34,8 @@ import org.xml.sax.InputSource; import org.xml.sax.SAXException; +import javax.servlet.http.HttpSession; + /** * This class acts as a test environment for servlets. @@ -160,6 +162,16 @@ /** + * Returns the session to be used by the next request. + * @param create if true, will create a new session if no valid session is defined. + * @since 1.5.5 + */ + public HttpSession getSession( boolean create ) { + return getClient().getSession( create ); + } + + + /** * Returns the value of the named context parameter found in the application definition. */ public String getContextParameter( String name ) { @@ -232,6 +244,10 @@ 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 ); } + + public HttpSession getSession( String sessionId, boolean create ) { + return _context.getValidSession( sessionId, null, create ); + } }; Index: ServletUnitClient.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitClient.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- ServletUnitClient.java 13 Jun 2004 20:57:28 -0000 1.13 +++ ServletUnitClient.java 9 Sep 2004 00:16:40 -0000 1.14 @@ -26,6 +26,7 @@ import java.net.MalformedURLException; import javax.servlet.ServletException; +import javax.servlet.http.HttpSession; import org.xml.sax.SAXException; @@ -86,6 +87,18 @@ } + /** + * Returns the session that would be used by the next request (if it asks for one). + * @param create if true, will create a new session if no valid session is defined. + * @since 1.5.5 + */ + public HttpSession getSession( boolean create ) { + HttpSession session = _invocationContextFactory.getSession( getCookieValue( ServletUnitHttpSession.SESSION_COOKIE_NAME ), create ); + if (session != null) putCookie( ServletUnitHttpSession.SESSION_COOKIE_NAME, session.getId() ); + return session; + } + + //-------------------------------- WebClient methods -------------------------------------- Index: ServletUnitContext.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitContext.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- ServletUnitContext.java 15 Feb 2004 06:42:01 -0000 1.7 +++ ServletUnitContext.java 9 Sep 2004 00:16:40 -0000 1.8 @@ -53,6 +53,29 @@ /** + * Returns an appropriate session for a request. If no cached session is + * @param sessionId + * @param session the session cached by previous requests. May be null. + * @param create + * @return + */ + ServletUnitHttpSession getValidSession( String sessionId, ServletUnitHttpSession session, boolean create ) { + if (session == null && sessionId != null) { + session = getSession( sessionId ); + } + + if (session != null && session.isInvalid()) { + session = null; + } + + if (session == null && create) { + session = newSession(); + } + return session; + } + + + /** * Returns the session with the specified ID, if any. **/ ServletUnitHttpSession getSession( String id ) { Index: ServletUnitHttpRequest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpRequest.java,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- ServletUnitHttpRequest.java 8 Aug 2004 17:41:11 -0000 1.34 +++ ServletUnitHttpRequest.java 9 Sep 2004 00:16:40 -0000 1.35 @@ -243,17 +243,7 @@ * If create is false and the request has no valid HttpSession, this method returns null. **/ public HttpSession getSession( boolean create ) { - if (_session == null && getRequestedSessionId() != null) { - _session = _context.getSession( getRequestedSessionId() ); - } - - if (_session != null && _session.isInvalid()) { - _session = null; - } - - if (_session == null && create) { - _session = _context.newSession(); - } + _session = _context.getValidSession( getRequestedSessionId(), _session, create ); return _session; } |
From: Russell G. <rus...@us...> - 2004-09-09 00:16:55
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19281/doc Modified Files: release_notes.txt Log Message: Support HttpSession access from ServletUnit client Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.365 retrieving revision 1.366 diff -u -r1.365 -r1.366 --- release_notes.txt 26 Aug 2004 23:11:33 -0000 1.365 +++ release_notes.txt 9 Sep 2004 00:16:40 -0000 1.366 @@ -13,6 +13,11 @@ Revision History: + 8-Sep-2004: + Additions: + 1. ServletRunner and ServletUnitClient now support a getSession() method to return the HTTP session to be used + by the next request or modified by the last request. + 25-Aug-2004: Additions: 1. ServletRunner now takes a reference to a web.xml as a File object in its constructor. |
From: Russell G. <rus...@us...> - 2004-08-26 23:11:46
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21622/test/com/meterware/servletunit Modified Files: WebXMLTest.java Log Message: Modified ServletRunner constructor to accept File object for web.xml Index: WebXMLTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/WebXMLTest.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- WebXMLTest.java 27 Jun 2004 16:00:50 -0000 1.21 +++ WebXMLTest.java 26 Aug 2004 23:11:33 -0000 1.22 @@ -21,10 +21,7 @@ *******************************************************************************************************************/ import com.meterware.httpunit.*; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.PrintWriter; -import java.io.UnsupportedEncodingException; +import java.io.*; import java.net.URL; import java.util.Properties; import java.util.List; @@ -61,8 +58,9 @@ WebXMLString wxs = new WebXMLString(); wxs.addServlet( "/SimpleServlet", SimpleGetServlet.class ); + File webXml = createWebXml( wxs ); - ServletRunner sr = new ServletRunner( new ByteArrayInputStream( wxs.asText().getBytes() ) ); + ServletRunner sr = new ServletRunner( webXml.getAbsolutePath() ); WebRequest request = new GetMethodWebRequest( "http://localhost/SimpleServlet" ); WebResponse response = sr.getResponse( request ); assertNotNull( "No response received", response ); @@ -71,6 +69,15 @@ } + private File createWebXml( WebXMLString wxs ) throws IOException { + File webXml = new File( "examples/META-INF/web.xml" ); + FileOutputStream fos = new FileOutputStream( webXml ); + fos.write( wxs.asText().getBytes() ); + fos.close(); + return webXml; + } + + public void testBasicAuthenticationConfig() throws Exception { WebXMLString wxs = new WebXMLString(); wxs.requireBasicAuthentication( "SampleRealm" ); @@ -201,10 +208,11 @@ wxs.requireFormAuthentication( "Sample Realm", "/Logon", "/Error" ); wxs.addSecureURL( "SecureArea1", "/Example/SimpleServlet" ); wxs.addAuthorizedRole( "SecureArea1", "supervisor" ); + File webXml = createWebXml( wxs ); - ServletRunner sr = new ServletRunner( wxs.asInputStream() ); + ServletRunner sr = new ServletRunner( webXml, "/samples" ); ServletUnitClient wc = sr.newClient(); - WebResponse response = wc.getResponse( "http://localhost/Example/SimpleServlet" ); + WebResponse response = wc.getResponse( "http://localhost/samples/Example/SimpleServlet" ); WebForm form = response.getFormWithID( "login" ); assertNotNull( "did not find login form", form ); @@ -216,7 +224,7 @@ assertEquals( "content type", "text/html", response.getContentType() ); assertEquals( "requested resource", SimpleGetServlet.RESPONSE_TEXT, response.getText() ); - InvocationContext ic = wc.newInvocation( "http://localhost/Example/SimpleServlet" ); + InvocationContext ic = wc.newInvocation( "http://localhost/samples/Example/SimpleServlet" ); assertEquals( "Authenticated user", "Me", ic.getRequest().getRemoteUser() ); assertTrue( "User assigned to 'bogus' role", !ic.getRequest().isUserInRole( "bogus" ) ); assertTrue( "User not assigned to 'supervisor' role", ic.getRequest().isUserInRole( "supervisor" ) ); |
From: Russell G. <rus...@us...> - 2004-08-26 23:11:46
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21622/src/com/meterware/servletunit Modified Files: ServletRunner.java WebApplication.java Log Message: Modified ServletRunner constructor to accept File object for web.xml Index: ServletRunner.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletRunner.java,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- ServletRunner.java 13 Jun 2004 20:57:28 -0000 1.25 +++ ServletRunner.java 26 Aug 2004 23:11:33 -0000 1.26 @@ -53,6 +53,7 @@ /** * Constructor which expects the full path to the web.xml for the * application. + * @deprecated as of 1.5.5, use {@link ServletRunner(File)} * * @param webXMLFileSpec the full path to the web.xml file */ @@ -65,13 +66,39 @@ /** * Constructor which expects the full path to the web.xml for the * application and a context path under which to mount it. + * @deprecated as of 1.5.5, use {@link ServletRunner(File,String)} * * @param webXMLFileSpec the full path to the web.xml file * @param contextPath the context path */ public ServletRunner( String webXMLFileSpec, String contextPath ) throws IOException, SAXException { - File webXMLFile = new File( webXMLFileSpec ); - _application = new WebApplication( HttpUnitUtils.newParser().parse( webXMLFileSpec ), webXMLFile.getParentFile().getParentFile(), contextPath ); + this( new File( webXMLFileSpec ), contextPath ); + } + + + /** + * Constructor which expects a File object representing the web.xml for the + * application. + * + * @param webXml the web.xml file + * @since 1.5.5 + */ + public ServletRunner( File webXml ) throws IOException, SAXException { + _application = new WebApplication( HttpUnitUtils.newParser().parse( webXml ) ); + completeInitialization( null ); + } + + + /** + * Constructor which expects a File object representing the web.xml for the + * application and a context path under which to mount it. + * + * @param webXml the web.xml file + * @param contextPath the context path + * @since 1.5.5 + */ + public ServletRunner( File webXml, String contextPath ) throws IOException, SAXException { + _application = new WebApplication( HttpUnitUtils.newParser().parse( webXml ), webXml.getParentFile().getParentFile(), contextPath ); completeInitialization( contextPath ); } Index: WebApplication.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/WebApplication.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- WebApplication.java 26 Feb 2004 17:36:47 -0000 1.23 +++ WebApplication.java 26 Aug 2004 23:11:33 -0000 1.24 @@ -458,8 +458,8 @@ } else if (authenticationMethod.equalsIgnoreCase( "FORM" )) { _useFormAuthentication = true; if (_authenticationRealm.length() == 0) throw new SAXException( "No realm specified for FORM Authorization" ); - _loginURL = new URL( "http", "localhost", XMLUtils.getChildNodeValue( loginConfigElement, "form-login-page" ) ); - _errorURL = new URL( "http", "localhost", XMLUtils.getChildNodeValue( loginConfigElement, "form-error-page" ) ); + _loginURL = new URL( "http", "localhost", _contextPath + XMLUtils.getChildNodeValue( loginConfigElement, "form-login-page" ) ); + _errorURL = new URL( "http", "localhost", _contextPath + XMLUtils.getChildNodeValue( loginConfigElement, "form-error-page" ) ); } } } |
From: Russell G. <rus...@us...> - 2004-08-26 23:11:45
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21622/doc Modified Files: release_notes.txt Log Message: Modified ServletRunner constructor to accept File object for web.xml Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.364 retrieving revision 1.365 diff -u -r1.364 -r1.365 --- release_notes.txt 10 Aug 2004 20:28:51 -0000 1.364 +++ release_notes.txt 26 Aug 2004 23:11:33 -0000 1.365 @@ -13,6 +13,10 @@ Revision History: +25-Aug-2004: + Additions: + 1. ServletRunner now takes a reference to a web.xml as a File object in its constructor. + 10-Aug-2004: Additions: 1. rfe #901172: "application/xhtml+xml" is now recognized as a valid HTML "content-type" |
From: Russell G. <rus...@us...> - 2004-08-10 20:29:05
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25417/test/com/meterware/httpunit Modified Files: FormParametersTest.java WebPageTest.java Log Message: Minor cleanup Index: FormParametersTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FormParametersTest.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- FormParametersTest.java 4 Jun 2004 01:20:03 -0000 1.23 +++ FormParametersTest.java 10 Aug 2004 20:28:53 -0000 1.24 @@ -440,6 +440,8 @@ form.setParameter( "File", new UploadFileSpec[] { new UploadFileSpec( file ) } ); assertEquals( "Selected filename", file.getAbsolutePath(), form.getParameterValue( "File" ) ); + form.setParameter( "File", file ); + WebRequest wr = form.getRequest(); assertEquals( "File from validated request", file.getAbsolutePath(), wr.getParameterValues( "File" )[0] ); Index: WebPageTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebPageTest.java,v retrieving revision 1.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- WebPageTest.java 28 Jul 2004 09:02:26 -0000 1.39 +++ WebPageTest.java 10 Aug 2004 20:28:53 -0000 1.40 @@ -83,6 +83,8 @@ defineResource( "SimplePage.html", "<html><head><title>A Sample Page</title></head><body>Something here</body></html>", "text/html" ); defineResource( "StructuredPage.html", "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML Basic 1.0//EN' 'http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd'>" + "<html><head><title>A Structured Page</title></head><body>Something here</body></html>", "text/xhtml" ); + defineResource( "XHTMLPage.html", "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML Basic 1.0//EN' 'http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd'>" + + "<html><head><title>An XHTML Page</title></head><body>Something here</body></html>", "application/xhtml+xml" ); WebConversation wc = new WebConversation(); try { wc.getResponse( getHostPath() + "/TextPage.txt" ).getReceivedPage().getTitle(); @@ -94,6 +96,9 @@ WebResponse structuredPage = wc.getResponse( getHostPath() + "/StructuredPage.html" ); assertEquals( "XHTML Title", "A Structured Page", structuredPage.getReceivedPage().getTitle() ); + + WebResponse xhtmlPage = wc.getResponse( getHostPath() + "/XHTMLPage.html" ); + assertEquals( "XHTML Title", "An XHTML Page", xhtmlPage.getReceivedPage().getTitle() ); } |
From: Russell G. <rus...@us...> - 2004-08-10 20:29:03
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25417/doc Modified Files: release_notes.txt Log Message: Minor cleanup Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.363 retrieving revision 1.364 diff -u -r1.363 -r1.364 --- release_notes.txt 9 Aug 2004 22:13:49 -0000 1.363 +++ release_notes.txt 10 Aug 2004 20:28:51 -0000 1.364 @@ -13,6 +13,11 @@ Revision History: +10-Aug-2004: + Additions: + 1. rfe #901172: "application/xhtml+xml" is now recognized as a valid HTML "content-type" + 2. Added convenience method setParameter( String, File ) to simplify file uploading + 9-Aug-2004 Problems fixed: 1. When a form has no action specified and its URL contains parameters whose names match those of parameters |
From: Russell G. <rus...@us...> - 2004-08-10 20:29:03
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25417/src/com/meterware/httpunit Modified Files: HttpWebResponse.java ParameterHolder.java WebForm.java WebRequestSource.java WebResponse.java Log Message: Minor cleanup Index: HttpWebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpWebResponse.java,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- HttpWebResponse.java 23 Jun 2004 01:30:17 -0000 1.32 +++ HttpWebResponse.java 10 Aug 2004 20:28:52 -0000 1.33 @@ -213,12 +213,13 @@ System.out.println( "Header:: " + connection.getHeaderField(0) ); } for (int i = 1; true; i++) { - String key = connection.getHeaderFieldKey( i ); - if (key == null) break; + String headerFieldKey = connection.getHeaderFieldKey( i ); + String headerField = connection.getHeaderField(i); + if (headerFieldKey == null || headerField == null) break; if (HttpUnitOptions.isLoggingHttpHeaders()) { - System.out.println( "Header:: " + connection.getHeaderFieldKey( i ) + ": " + connection.getHeaderField(i) ); + System.out.println( "Header:: " + headerFieldKey + ": " + headerField ); } - addHeader( connection.getHeaderFieldKey( i ).toUpperCase(), connection.getHeaderField( i ) ); + addHeader( headerFieldKey.toUpperCase(), headerField ); } if (connection.getContentType() != null) { Index: ParameterHolder.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ParameterHolder.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- ParameterHolder.java 20 Aug 2003 12:06:15 -0000 1.7 +++ ParameterHolder.java 10 Aug 2004 20:28:52 -0000 1.8 @@ -20,6 +20,7 @@ * *******************************************************************************************************************/ import java.io.IOException; +import java.io.File; /** @@ -87,6 +88,16 @@ /** + * Sets the single value of a file upload parameter in a form. + * A more convenient way to do this than using {@link #setParameter(String,UploadFileSpec[])} + * @since 1.5.5 + */ + public void setParameter( String name, File file ) { + setParameter( name, new UploadFileSpec[] { new UploadFileSpec( file ) } ); + } + + + /** * Sets the multiple values of a file upload parameter in a web request. **/ abstract Index: WebForm.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v retrieving revision 1.96 retrieving revision 1.97 diff -u -r1.96 -r1.97 --- WebForm.java 9 Aug 2004 22:13:51 -0000 1.96 +++ WebForm.java 10 Aug 2004 20:28:52 -0000 1.97 @@ -23,6 +23,7 @@ import com.meterware.httpunit.scripting.ScriptableDelegate; import java.io.IOException; +import java.io.File; import java.net.URL; import java.util.ArrayList; import java.util.HashMap; Index: WebRequestSource.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequestSource.java,v retrieving revision 1.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- WebRequestSource.java 23 Jul 2004 04:04:27 -0000 1.39 +++ WebRequestSource.java 10 Aug 2004 20:28:52 -0000 1.40 @@ -27,6 +27,7 @@ import java.net.URL; import java.util.StringTokenizer; import java.io.IOException; +import java.io.File; abstract Index: WebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v retrieving revision 1.134 retrieving revision 1.135 diff -u -r1.134 -r1.135 --- WebResponse.java 8 Aug 2004 17:45:32 -0000 1.134 +++ WebResponse.java 10 Aug 2004 20:28:52 -0000 1.135 @@ -49,7 +49,8 @@ public class WebResponse implements HTMLSegment, CookieSource { final private static String HTML_CONTENT = "text/html"; - final private static String XHTML_CONTENT = "text/xhtml"; + final private static String XHTML_CONTENT = "application/xhtml+xml"; + final private static String FAUX_XHTML_CONTENT = "text/xhtml"; final private static int UNINITIALIZED_INT = -2; @@ -75,7 +76,9 @@ * Returns true if the response is HTML. **/ public boolean isHTML() { - return getContentType().equalsIgnoreCase( HTML_CONTENT ) || getContentType().equalsIgnoreCase( XHTML_CONTENT ); + return getContentType().equalsIgnoreCase( HTML_CONTENT ) || + getContentType().equalsIgnoreCase( FAUX_XHTML_CONTENT ) || + getContentType().equalsIgnoreCase( XHTML_CONTENT ); } |
From: Russell G. <rus...@us...> - 2004-08-09 22:14:06
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5000/src/com/meterware/httpunit Modified Files: WebForm.java Log Message: Handle form parameters matching preset parameters Index: WebForm.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v retrieving revision 1.95 retrieving revision 1.96 diff -u -r1.95 -r1.96 --- WebForm.java 28 Jul 2004 09:11:07 -0000 1.95 +++ WebForm.java 9 Aug 2004 22:13:51 -0000 1.96 @@ -523,9 +523,14 @@ /** - * Records a parameter defined by including it in the destination URL. + * Records a parameter defined by including it in the destination URL. Ignores any parameters whose name matches + * a form control. **/ protected void addPresetParameter( String name, String value ) { + FormControl[] formControls = getFormControls(); + for (int i = 0; i < formControls.length; i++) { + if (formControls[i].getName().equals( name)) return; + } _presets.add( new PresetFormParameter( this, name, value ) ); } |
From: Russell G. <rus...@us...> - 2004-08-09 22:14:02
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5000/test/com/meterware/httpunit Modified Files: FormSubmitTest.java Log Message: Handle form parameters matching preset parameters Index: FormSubmitTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FormSubmitTest.java,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- FormSubmitTest.java 4 Jun 2004 01:20:03 -0000 1.32 +++ FormSubmitTest.java 9 Aug 2004 22:13:52 -0000 1.33 @@ -487,6 +487,21 @@ } + public void testNoActionSuppliedWhenBaseHasParamsSetByTheForm() throws Exception { + defineResource( "abc/form?param1=value¶m2=value", "<form name=\"test\">" + + " <input type=\"text\" name='param2'>" + + " <input type=\"submit\" name=\"apply\" value=\"Apply\">" + + "</form>" ); + + WebResponse wr = _wc.getResponse( getHostPath() + "/abc/form?param1=value¶m2=value" ); + WebForm form = wr.getForms()[0]; + WebRequest req = form.getRequest( "apply" ); + req.setParameter( "param2", "test" ); + assertEquals( getHostPath() + "/abc/form?param1=value¶m2=test&apply=Apply", + req.getURL().toExternalForm() ); + } + + public void testPostActionParametersAfterSetAction() throws Exception { defineWebPage( "abc/form", "<form name=\"test\" method='POST' action='stop?ready=yes'>" + " <input type=\"text\" name=\"aTextField\">" + |
From: Russell G. <rus...@us...> - 2004-08-09 22:14:02
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5000/doc Modified Files: release_notes.txt Log Message: Handle form parameters matching preset parameters Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.362 retrieving revision 1.363 diff -u -r1.362 -r1.363 --- release_notes.txt 8 Aug 2004 17:45:30 -0000 1.362 +++ release_notes.txt 9 Aug 2004 22:13:49 -0000 1.363 @@ -13,6 +13,11 @@ Revision History: + 9-Aug-2004 + Problems fixed: + 1. When a form has no action specified and its URL contains parameters whose names match those of parameters + in the form, the form values are used instead. + 8-Aug-2004 Thanks to Guillaume Dandurand <Gui...@cn...> for supplying code to get the onload event when the page is a frameset rather than a regular page. |
From: Russell G. <rus...@us...> - 2004-08-08 17:46:12
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21970/src/com/meterware/httpunit Modified Files: BlockElement.java HTMLSegment.java NodeUtils.java ParsedHTML.java WebLink.java WebResponse.java Added Files: TextBlock.java WebList.java Log Message: Added preliminary support for lists ***** Error reading new file[Errno 2] No such file or directory: 'TextBlock.java' ***** Error reading new file[Errno 2] No such file or directory: 'WebList.java' Index: BlockElement.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/BlockElement.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- BlockElement.java 27 Jun 2004 19:29:15 -0000 1.1 +++ BlockElement.java 8 Aug 2004 17:45:30 -0000 1.2 @@ -30,13 +30,7 @@ * * @author <a href="mailto:rus...@ht...">Russell Gold</a> **/ -public class BlockElement extends ParsedHTML implements HTMLSegment, HTMLElement { - - /** Predicate to match part or all of a block's class attribute. **/ - public final static HTMLElementPredicate MATCH_CLASS; - - /** Predicate to match the tag associated with a block (case insensitive). **/ - public final static HTMLElementPredicate MATCH_TAG; +abstract public class BlockElement extends ParsedHTML implements HTMLSegment, HTMLElement { private ScriptableDelegate _scriptable; @@ -163,22 +157,4 @@ protected int getAttributeValue( Node node, String attributeName, int defaultValue ) { return NodeUtils.getAttributeValue( node, attributeName, defaultValue ); } - - - static { - MATCH_CLASS = new HTMLElementPredicate() { - public boolean matchesCriteria( Object htmlElement, Object criteria ) { - if (criteria == null) criteria = ""; - return ((BlockElement) htmlElement).getClassName().equalsIgnoreCase( criteria.toString() ); - }; - }; - - - MATCH_TAG = new HTMLElementPredicate() { - public boolean matchesCriteria( Object htmlElement, Object criteria ) { - if (criteria == null) criteria = ""; - return criteria.toString().equalsIgnoreCase( ((BlockElement) htmlElement).getTagName() ); - }; - }; - } } Index: HTMLSegment.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HTMLSegment.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- HTMLSegment.java 27 Jun 2004 19:29:15 -0000 1.13 +++ HTMLSegment.java 8 Aug 2004 17:45:30 -0000 1.14 @@ -163,7 +163,7 @@ * Returns the top-level block elements found in the page in the order in which they appear. * @exception SAXException thrown if there is an error parsing the segment. */ - public BlockElement[] getTextBlocks() throws SAXException; + public TextBlock[] getTextBlocks() throws SAXException; /** Index: NodeUtils.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/NodeUtils.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- NodeUtils.java 29 Jun 2004 23:10:44 -0000 1.20 +++ NodeUtils.java 8 Aug 2004 17:45:30 -0000 1.21 @@ -26,6 +26,7 @@ import java.util.Stack; import java.util.Iterator; +import java.util.ListIterator; import com.meterware.httpunit.parsing.HTMLParserFactory; @@ -137,7 +138,32 @@ public Iterator getContexts() { - return _traversalContext.iterator(); + Stack stack = _traversalContext; + return getTopDownIterator( stack ); + } + + + public Object getRootContext() { + return _traversalContext.firstElement(); + } + + + private Iterator getTopDownIterator( final Stack stack ) { + return new Iterator() { + private ListIterator _forwardIterator = stack.listIterator( stack.size() ); + + public boolean hasNext() { + return _forwardIterator.hasPrevious(); + } + + public Object next() { + return _forwardIterator.previous(); + } + + public void remove() { + _forwardIterator.remove(); + } + }; } Index: ParsedHTML.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ParsedHTML.java,v retrieving revision 1.58 retrieving revision 1.59 diff -u -r1.58 -r1.59 --- ParsedHTML.java 23 Jul 2004 01:31:04 -0000 1.58 +++ ParsedHTML.java 8 Aug 2004 17:45:31 -0000 1.59 @@ -76,7 +76,7 @@ private WebLink[] _links; private ArrayList _blocksList = new ArrayList(); - private BlockElement[] _blocks; + private TextBlock[] _blocks; private ArrayList _appletList = new ArrayList(); private WebApplet[] _applets; @@ -150,16 +150,35 @@ * Returns the top-level block elements found in the page in the order in which they appear. * @return */ - public BlockElement[] getTextBlocks() { + public TextBlock[] getTextBlocks() { if (_blocks == null) { loadElements(); - _blocks = (BlockElement[]) _blocksList.toArray( new BlockElement[ _blocksList.size() ] ); + _blocks = (TextBlock[]) _blocksList.toArray( new TextBlock[ _blocksList.size() ] ); } return _blocks; } /** + * Returns the first text block found in the page which matches the specified predicate and value. + */ + public TextBlock getFirstMatchingTextBlock( HTMLElementPredicate predicate, Object criteria ) { + TextBlock[] blocks = getTextBlocks(); + for (int i = 0; i < blocks.length; i++) { + if (predicate.matchesCriteria( blocks[i], criteria )) return blocks[i]; + } + return null; + } + + + public TextBlock getNextTextBlock( TextBlock block ) { + int index = _blocksList.indexOf( block ); + if (index < 0 || index == _blocksList.size() - 1) return null; + return (TextBlock) _blocksList.get( index+1 ); + } + + + /** * Returns the top-level tables found in the page in the order in which they appear. **/ public WebTable[] getTables() { @@ -394,7 +413,7 @@ } protected ParsedHTML getRootContext( NodeUtils.PreOrderTraversal pot ) { - return (ParsedHTML) pot.getContexts().next(); + return (ParsedHTML) pot.getRootContext(); } } @@ -442,6 +461,22 @@ HTMLElement toHTMLElement( NodeUtils.PreOrderTraversal pot, ParsedHTML parsedHTML, Element element ) { return parsedHTML.toTextBlock( element ); } + + + protected boolean addToContext() { + return true; + } + + + protected void addToLists( NodeUtils.PreOrderTraversal pot, HTMLElement htmlElement ) { + for (Iterator i = pot.getContexts(); i.hasNext();) { + Object o = i.next(); + if (!(o instanceof ParsedHTML)) continue; + ((ParsedHTML) o).addToList( htmlElement ); + break; + } + } + } @@ -584,6 +619,42 @@ } + static class WebListFactory extends HTMLElementFactory { + HTMLElement toHTMLElement( NodeUtils.PreOrderTraversal pot, ParsedHTML parsedHTML, Element element ) { + return parsedHTML.toOrderedList( element ); + } + + protected boolean addToContext() { return true; } + + protected void addToLists( NodeUtils.PreOrderTraversal pot, HTMLElement htmlElement ) { + TextBlock textBlock = getTextBlock( pot ); + if (textBlock != null) textBlock.addList( (WebList) htmlElement ); + } + + private TextBlock getTextBlock( NodeUtils.PreOrderTraversal pot ) { + return (TextBlock) getClosestContext( pot, TextBlock.class ); + } + } + + + static class ListItemFactory extends HTMLElementFactory { + HTMLElement toHTMLElement( NodeUtils.PreOrderTraversal pot, ParsedHTML parsedHTML, Element element ) { + WebList webList = getWebList( pot ); + if (webList == null) return null; + return webList.addNewItem( element ); + } + + private WebList getWebList( NodeUtils.PreOrderTraversal pot ) { + return (WebList) getClosestContext( pot, WebList.class ); + } + + protected boolean addToContext() { return true; } + + protected void addToLists( NodeUtils.PreOrderTraversal pot, HTMLElement htmlElement ) { + } + } + + private static HashMap _htmlFactoryClasses = new HashMap(); private static HTMLElementFactory _defaultFactory = new DefaultElementFactory(); @@ -601,6 +672,9 @@ _htmlFactoryClasses.put( "iframe", new WebIFrameFactory() ); _htmlFactoryClasses.put( "script", new ScriptFactory() ); _htmlFactoryClasses.put( "noscript", new NoScriptFactory() ); + _htmlFactoryClasses.put( "ol", new WebListFactory() ); + _htmlFactoryClasses.put( "ul", new WebListFactory() ); + _htmlFactoryClasses.put( "li", new ListItemFactory() ); for (int i = 0; i < TEXT_ELEMENTS.length; i++) { _htmlFactoryClasses.put( TEXT_ELEMENTS[i], new TextBlockFactory() ); @@ -699,13 +773,18 @@ } - private BlockElement toTextBlock( Element element ) { - return new BlockElement( _response, _frame, _baseURL, _baseTarget, element, _characterSet ); + private TextBlock toTextBlock( Element element ) { + return new TextBlock( _response, _frame, _baseURL, _baseTarget, element, _characterSet ); + } + + + private TextBlock newTextBlock( Node textNode ) { + return new TextBlock( _response, _frame, _baseURL, _baseTarget, textNode, _characterSet ); } - private BlockElement newTextBlock( Node textNode ) { - return new BlockElement( _response, _frame, _baseURL, _baseTarget, textNode, _characterSet ); + private WebList toOrderedList( Element element ) { + return new WebList( _response, _frame, _baseURL, _baseTarget, element, _characterSet ); } @@ -828,18 +907,6 @@ /** - * Returns the first text block found in the page which matches the specified predicate and value. - */ - public BlockElement getFirstMatchingTextBlock( HTMLElementPredicate predicate, Object criteria ) { - BlockElement[] blocks = getTextBlocks(); - for (int i = 0; i < blocks.length; i++) { - if (predicate.matchesCriteria( blocks[i], criteria )) return blocks[i]; - } - return null; - } - - - /** * Returns the first table in the response which matches the specified predicate and value. * Will recurse into any nested tables, as needed. * @return the selected table, or null if none is found Index: WebLink.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebLink.java,v retrieving revision 1.44 retrieving revision 1.45 diff -u -r1.44 -r1.45 --- WebLink.java 23 Jul 2004 01:31:04 -0000 1.44 +++ WebLink.java 8 Aug 2004 17:45:31 -0000 1.45 @@ -192,14 +192,14 @@ MATCH_TEXT = new HTMLElementPredicate() { public boolean matchesCriteria( Object htmlElement, Object criteria ) { - return HttpUnitUtils.matches( ((WebLink) htmlElement).asText(), (String) criteria ); + return HttpUnitUtils.matches( ((WebLink) htmlElement).getText(), (String) criteria ); }; }; MATCH_CONTAINED_TEXT = new HTMLElementPredicate() { public boolean matchesCriteria( Object htmlElement, Object criteria ) { - return HttpUnitUtils.contains( ((WebLink) htmlElement).asText(), (String) criteria ); + return HttpUnitUtils.contains( ((WebLink) htmlElement).getText(), (String) criteria ); }; }; Index: WebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v retrieving revision 1.133 retrieving revision 1.134 diff -u -r1.133 -r1.134 --- WebResponse.java 28 Jul 2004 09:02:25 -0000 1.133 +++ WebResponse.java 8 Aug 2004 17:45:32 -0000 1.134 @@ -494,16 +494,30 @@ } - public BlockElement[] getTextBlocks() throws SAXException { + /** + * Returns an array of text blocks found in the page. + * @since 1.5.5 + */ + public TextBlock[] getTextBlocks() throws SAXException { return getReceivedPage().getTextBlocks(); } /** + * Returns the text block after the specified block, if any. + * @since 1.5.5 + */ + public TextBlock getNextTextBlock( TextBlock block ) throws SAXException { + return getReceivedPage().getNextTextBlock( block ); + } + + + /** * Returns the first link found in the page matching the specified criteria. + * @since 1.5.5 * @exception SAXException thrown if there is an error parsing the response. **/ - public BlockElement getFirstMatchingTextBlock( HTMLElementPredicate predicate, Object criteria ) throws SAXException { + public TextBlock getFirstMatchingTextBlock( HTMLElementPredicate predicate, Object criteria ) throws SAXException { return getReceivedPage().getFirstMatchingTextBlock( predicate, criteria ); } |
From: Russell G. <rus...@us...> - 2004-08-08 17:46:09
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21970/doc Modified Files: release_notes.txt Log Message: Added preliminary support for lists Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.361 retrieving revision 1.362 diff -u -r1.361 -r1.362 --- release_notes.txt 8 Aug 2004 17:41:10 -0000 1.361 +++ release_notes.txt 8 Aug 2004 17:45:30 -0000 1.362 @@ -21,6 +21,9 @@ 1. A frameset 'onload' event is now invoked after all of its subframes have been loaded 2. ServletUnit's HttpServletRequest.getCookies() method was only returning the first cookie defined in the request + Additions: + 1. Added preliminary support for lists + 28-Jul-2004 Additions: 1. rfe #986876: The WebClient.addCookie method has been deprecated, since its behavior is actually a bit confusing |
From: Russell G. <rus...@us...> - 2004-08-08 17:45:44
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21970/test/com/meterware/httpunit Modified Files: TextBlockTest.java Log Message: Added preliminary support for lists Index: TextBlockTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/TextBlockTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TextBlockTest.java 29 Jun 2004 23:10:45 -0000 1.2 +++ TextBlockTest.java 8 Aug 2004 17:45:32 -0000 1.3 @@ -20,7 +20,6 @@ * *******************************************************************************************************************/ import junit.framework.TestSuite; -import org.xml.sax.SAXException; import java.io.StringReader; import java.io.BufferedReader; @@ -56,7 +55,7 @@ WebResponse response = wc.getResponse( getHostPath() + "/SimplePage.html" ); assertEquals( "Number of paragraphs", 3, response.getTextBlocks().length ); assertEquals( "First paragraph", "This has no forms or links since we don't care about them", response.getTextBlocks()[0].getText() ); - BlockElement comment = response.getFirstMatchingTextBlock( BlockElement.MATCH_CLASS, "comment" ); + BlockElement comment = response.getFirstMatchingTextBlock( TextBlock.MATCH_CLASS, "comment" ); assertNotNull( "Did not find a comment paragraph", comment ); assertEquals( "Comment paragraph", "But it does have three paragraphs", comment.getText() ); } @@ -82,27 +81,55 @@ "<p>Some more text</p>" ); WebConversation wc = new WebConversation(); WebResponse response = wc.getResponse( getHostPath() + "/SimplePage.html" ); - BlockElement header1 = response.getFirstMatchingTextBlock( BlockElement.MATCH_TAG, "H1" ); + TextBlock header1 = response.getFirstMatchingTextBlock( TextBlock.MATCH_TAG, "H1" ); assertNotNull( "Did not find the H1 header", header1 ); assertEquals( "H1 header", "Here is a section", header1.getText() ); - BlockElement header2 = response.getFirstMatchingTextBlock( BlockElement.MATCH_TAG, "h2" ); + TextBlock header2 = response.getFirstMatchingTextBlock( TextBlock.MATCH_TAG, "h2" ); assertNotNull( "Did not find the h2 header", header2 ); assertEquals( "H2 header", "A subsection", header2.getText() ); - assertEquals( "Text under header 1", "with some text", response.getTextBlocks()[ getBlockIndex( response, header1 )+1 ].getText() ); + assertEquals( "Text under header 1", "with some text", response.getNextTextBlock( header1 ).getText() ); } - private static int getBlockIndex( WebResponse response, BlockElement header1 ) throws SAXException { - int index = -1; - BlockElement[] blocks = response.getTextBlocks(); - for (int i = 0; i < blocks.length; i++) { - BlockElement block = blocks[i]; - if (block == header1) { - index = i; - break; - } - } - return index; + public void testEmbeddedLinks() throws Exception { + defineWebPage( "SimplePage", + "<h1>Here is a section</h1>\n" + + "<p>with a <a id='httpunit' href='http://httpunit.org'>link to the home page</a></p>" ); + WebConversation wc = new WebConversation(); + WebResponse response = wc.getResponse( getHostPath() + "/SimplePage.html" ); + BlockElement paragraph = response.getTextBlocks()[1]; + assertNotNull( "Did not retrieve any links", paragraph.getLinks() ); + assertNotNull( "Did not find the httpunit link", paragraph.getLinkWithID( "httpunit" ) ); + assertNull( "Should not have found the httpunit link in the header", response.getTextBlocks()[0].getLinkWithID( "httpunit" ) ); + assertNotNull( "Did not find the home page link", paragraph.getFirstMatchingLink( WebLink.MATCH_CONTAINED_TEXT, "home page" ) ); + assertEquals( "embedded link url", "http://httpunit.org", paragraph.getLinkWithID( "httpunit" ).getRequest().getURL().toExternalForm() ); + } + + + public void testEmbeddedLists() throws Exception { + defineWebPage( "SimplePage", + "<h1>Here is a section</h1>\n" + + "<p id='ordered'><ol><li>One<li>Two<li>Three</ol></p>" + + "<p id='unordered'><ul><li>Red<li>Green<li>Blue</ul></p>" ); + WebConversation wc = new WebConversation(); + WebResponse response = wc.getResponse( getHostPath() + "/SimplePage.html" ); + TextBlock paragraph = (TextBlock) response.getElementWithID( "ordered" ); + WebList[] lists = paragraph.getLists(); + assertTrue( "No lists found", lists.length > 0); + WebList orderedList = lists[0]; + assertEquals( "ordered list type", WebList.ORDERED_LIST, orderedList.getListType() ); + assertEquals( "ordered list size", 3, orderedList.getItems().length ); + assertEquals( "Second ordered list item", "Two", orderedList.getItems()[1].getText() ); + } + + + public void ntestFormattingDetection() throws Exception { + String expectedText = "Here is some bold text and some bold italic text"; + defineWebPage( "FormattedPage", "<p>Here is some <b>bold</b> text and some <b><i>bold italic</i></b> text</p>" ); + WebConversation wc = new WebConversation(); + WebResponse response = wc.getResponse( getHostPath() + "/FormattedPage.html" ); + TextBlock paragraph = response.getTextBlocks()[0]; + assertMatchingSet( "Attributes for word 'bold'", new String[] { "b" }, paragraph.getFormats( expectedText.indexOf( "bold" ))); } } |
From: Russell G. <rus...@us...> - 2004-08-08 17:41:20
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21460/test/com/meterware/servletunit Modified Files: HttpServletRequestTest.java Log Message: Fix HttpServletRequest to return all cookies, not just the first Index: HttpServletRequestTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/HttpServletRequestTest.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- HttpServletRequestTest.java 15 Mar 2004 02:42:16 -0000 1.22 +++ HttpServletRequestTest.java 8 Aug 2004 17:41:11 -0000 1.23 @@ -238,14 +238,16 @@ public void testSetCookieViaRequestHeader() throws Exception { WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" ); - wr.setHeaderField( "Cookie", "flavor=vanilla"); + wr.setHeaderField( "Cookie", "flavor=vanilla,variety=sandwich"); ServletUnitHttpRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY ); Cookie[] cookies = request.getCookies(); assertNotNull( "No cookies found", cookies ); - assertEquals( "Num cookies found", 1, cookies.length ); - assertEquals( "Cookie name", "flavor", cookies[0].getName() ); - assertEquals( "Cookie value", "vanilla", cookies[0].getValue() ); + assertEquals( "Num cookies found", 2, cookies.length ); + assertEquals( "Cookie 1 name", "flavor", cookies[0].getName() ); + assertEquals( "Cookie 1 value", "vanilla", cookies[0].getValue() ); + assertEquals( "Cookie 2 name", "variety", cookies[1].getName() ); + assertEquals( "Cookie 2 value", "sandwich", cookies[1].getValue() ); } |
From: Russell G. <rus...@us...> - 2004-08-08 17:41:20
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21460/doc Modified Files: release_notes.txt Log Message: Fix HttpServletRequest to return all cookies, not just the first Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.360 retrieving revision 1.361 diff -u -r1.360 -r1.361 --- release_notes.txt 8 Aug 2004 17:38:18 -0000 1.360 +++ release_notes.txt 8 Aug 2004 17:41:10 -0000 1.361 @@ -19,6 +19,7 @@ Problems fixed: 1. A frameset 'onload' event is now invoked after all of its subframes have been loaded + 2. ServletUnit's HttpServletRequest.getCookies() method was only returning the first cookie defined in the request 28-Jul-2004 Additions: |
From: Russell G. <rus...@us...> - 2004-08-08 17:41:19
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21460/src/com/meterware/servletunit Modified Files: ServletUnitHttpRequest.java Log Message: Fix HttpServletRequest to return all cookies, not just the first Index: ServletUnitHttpRequest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpRequest.java,v retrieving revision 1.33 retrieving revision 1.34 diff -u -r1.33 -r1.34 --- ServletUnitHttpRequest.java 15 Mar 2004 02:42:16 -0000 1.33 +++ ServletUnitHttpRequest.java 8 Aug 2004 17:41:11 -0000 1.34 @@ -770,12 +770,18 @@ String cookieHeader = (String) clientHeaders.get( "Cookie" ); if (cookieHeader == null) return; - StringTokenizer st = new StringTokenizer( cookieHeader, "=;" ); + StringTokenizer st = new StringTokenizer( cookieHeader, "," ); while (st.hasMoreTokens()) { - String name = st.nextToken(); - if (st.hasMoreTokens()) { - addCookie( new Cookie( name, st.nextToken() ) ); - } + addOneCookie( st.nextToken() ); + } + } + + + private void addOneCookie( String cookieDefinition ) { + StringTokenizer st = new StringTokenizer( cookieDefinition, "=;" ); + String name = st.nextToken(); + if (st.hasMoreTokens()) { + addCookie( new Cookie( name, st.nextToken() ) ); } } |
From: Russell G. <rus...@us...> - 2004-08-08 17:38:29
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21020/test/com/meterware/httpunit/javascript Modified Files: FrameScriptingTest.java Log Message: Support onload event for framesets Index: FrameScriptingTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/FrameScriptingTest.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- FrameScriptingTest.java 21 Jul 2004 01:07:33 -0000 1.6 +++ FrameScriptingTest.java 8 Aug 2004 17:38:19 -0000 1.7 @@ -223,7 +223,40 @@ /** - * Verifies that when JavaScript overwrites an empty frame, other empty frames stay empty. + * Verifies that the onload event of a frameset can access subframes. + */ + public void testFrameOnLoadEvent() throws Exception { + defineWebPage( "OneForm", "<form name='form'><input name=text value='nothing special'></form>"); + defineResource("Frames.html", + "<html><frameset onload='alert( green.document.form.text.value );'>" + + " <frame src='OneForm.html' name='green'>" + + " <frame name=blue>" + + "</frameset></htmlL>"); + + _wc.getResponse(getHostPath() + "/Frames.html"); + assertEquals( "On load message", "nothing special", _wc.popNextAlert() ); + } + + + /** + * Verifies that the onload event of a frameset runs even if there is a noframes tag present that contains a body tag. + */ + public void testFrameOnLoadEventWithNoFrames() throws Exception { + defineWebPage( "OneForm", "<form name='form'><input name=text value='nothing special'></form>"); + defineResource("Frames.html", + "<html><frameset onload='alert( green.document.form.text.value );'>" + + " <frame src='OneForm.html' name='green'>" + + " <frame name=blue>" + + " <noframes><body></body></noframes>" + + "</frameset></htmlL>"); + + _wc.getResponse(getHostPath() + "/Frames.html"); + assertEquals( "On load message", "nothing special", _wc.popNextAlert() ); + } + + + /** + * Verifies that IFrames can be found using their id. */ public void testIFrameAccessById() throws Exception { defineWebPage( "Frames", |