httpunit-commit Mailing List for httpunit (Page 18)
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-29 23:17:42
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13185/src/com/meterware/httpunit Modified Files: ParsedHTML.java WebClient.java Log Message: Catch attempts to load included scripts from responses not obtained via getResponse() Index: ParsedHTML.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ParsedHTML.java,v retrieving revision 1.54 retrieving revision 1.55 diff -u -r1.54 -r1.55 --- ParsedHTML.java 27 Jun 2004 19:29:15 -0000 1.54 +++ ParsedHTML.java 29 Jun 2004 23:17:33 -0000 1.55 @@ -334,7 +334,9 @@ */ String getIncludedScript( String srcAttribute ) throws IOException { WebRequest req = new GetMethodWebRequest( getBaseURL(), srcAttribute ); - return getResponse().getWindow().getResource( req ).getText(); + WebWindow window = getResponse().getWindow(); + if (window == null) throw new IllegalStateException( "Unable to retrieve script included by this response, since it was loaded by getResource(). Use getResponse() instead."); + return window.getResource( req ).getText(); } Index: WebClient.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebClient.java,v retrieving revision 1.57 retrieving revision 1.58 diff -u -r1.57 -r1.58 --- WebClient.java 23 Jun 2004 01:30:17 -0000 1.57 +++ WebClient.java 29 Jun 2004 23:17:33 -0000 1.58 @@ -142,7 +142,7 @@ /** - * Returns the resource specified by the request. Does not update the client or load included framesets. + * Returns the resource specified by the request. Does not update the client or load included framesets or scripts. * May return null if the resource is a JavaScript URL which would normally leave the client unchanged. */ public WebResponse getResource( WebRequest request ) throws IOException { |
From: Russell G. <rus...@us...> - 2004-06-29 23:17:42
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13185/doc Modified Files: release_notes.txt Log Message: Catch attempts to load included scripts from responses not obtained via getResponse() Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.349 retrieving revision 1.350 diff -u -r1.349 -r1.350 --- release_notes.txt 29 Jun 2004 23:10:44 -0000 1.349 +++ release_notes.txt 29 Jun 2004 23:17:33 -0000 1.350 @@ -16,6 +16,8 @@ 29-Jun-2004 Additions: 1. rfe #766768: getText() methods now translate <br> tags as newlines. + 2. HttpUnit now catches an attempt to load an included script from a page included with "getResource" rather than + "getResponse." 28-Jun-2004 Additions: |
From: Russell G. <rus...@us...> - 2004-06-29 23:10:53
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12006/src/com/meterware/httpunit Modified Files: HttpUnitUtils.java NodeUtils.java Log Message: rfe #766768: getText() methods now translate <br> tags as newlines Index: HttpUnitUtils.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpUnitUtils.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- HttpUnitUtils.java 28 Jun 2004 23:18:16 -0000 1.15 +++ HttpUnitUtils.java 29 Jun 2004 23:10:44 -0000 1.16 @@ -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 @@ -206,12 +206,6 @@ } - private static String trimFromMiddle( String s, int ch ) { - int index = s.indexOf( ch ); - return s.substring( 0, index ) + s.substring( index+1 ); - } - - static class ClasspathEntityResolver implements EntityResolver { public InputSource resolveEntity( String publicID, String systemID ) { Index: NodeUtils.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/NodeUtils.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- NodeUtils.java 27 Jun 2004 19:29:15 -0000 1.19 +++ NodeUtils.java 29 Jun 2004 23:10:44 -0000 1.20 @@ -89,15 +89,12 @@ final StringBuffer sb = new StringBuffer(HttpUnitUtils.DEFAULT_TEXT_BUFFER_SIZE); NodeAction action = new NodeAction() { public boolean processElement( PreOrderTraversal traversal, Element node ) { - if (node.getNodeName().equalsIgnoreCase( "p" )) { + String nodeName = node.getNodeName().toLowerCase(); + if (nodeName.equals( "p" ) || nodeName.equals( "br" ) || nodeName.equalsIgnoreCase( "tr" )) { sb.append( "\n" ); - } else if (node.getNodeName().equalsIgnoreCase( "tr" )) { - sb.append( "\n" ); - } else if (node.getNodeName().equalsIgnoreCase( "td" )) { - sb.append( " | " ); - } else if (node.getNodeName().equalsIgnoreCase( "th" )) { + } else if (nodeName.equals( "td" ) || nodeName.equalsIgnoreCase( "th" )) { sb.append( " | " ); - } else if (node.getNodeName().equalsIgnoreCase( "img" ) && HttpUnitOptions.getImagesTreatedAsAltText()) { + } else if (nodeName.equals( "img" ) && HttpUnitOptions.getImagesTreatedAsAltText()) { sb.append( getNodeAttribute( node, "alt" ) ); } return true; |
From: Russell G. <rus...@us...> - 2004-06-29 23:10:53
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12006/test/com/meterware/httpunit Modified Files: TextBlockTest.java Log Message: rfe #766768: getText() methods now translate <br> tags as newlines Index: TextBlockTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/TextBlockTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- TextBlockTest.java 27 Jun 2004 19:29:15 -0000 1.1 +++ TextBlockTest.java 29 Jun 2004 23:10:45 -0000 1.2 @@ -22,6 +22,9 @@ import junit.framework.TestSuite; import org.xml.sax.SAXException; +import java.io.StringReader; +import java.io.BufferedReader; + /** * * @author <a href="mailto:rus...@ht...">Russell Gold</a> @@ -59,6 +62,18 @@ } + public void testTextConversion() throws Exception { + defineWebPage( "SimplePage", + "<p>Here is a line<br>followed by another</p>" ); + WebConversation wc = new WebConversation(); + WebResponse response = wc.getResponse( getHostPath() + "/SimplePage.html" ); + BufferedReader br = new BufferedReader( new StringReader( response.getTextBlocks()[0].getText() ) ); + assertEquals( "First line", "Here is a line", br.readLine() ); + assertEquals( "Second line", "followed by another", br.readLine() ); + br.readLine(); + } + + public void testHeaderDetection() throws Exception { defineWebPage( "SimplePage", "<h1>Here is a section</h1>\n" + |
From: Russell G. <rus...@us...> - 2004-06-29 23:10:53
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12006/doc Modified Files: release_notes.txt Log Message: rfe #766768: getText() methods now translate <br> tags as newlines Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.348 retrieving revision 1.349 diff -u -r1.348 -r1.349 --- release_notes.txt 28 Jun 2004 23:18:16 -0000 1.348 +++ release_notes.txt 29 Jun 2004 23:10:44 -0000 1.349 @@ -13,9 +13,13 @@ Revision History: +29-Jun-2004 + Additions: + 1. rfe #766768: getText() methods now translate <br> tags as newlines. + 28-Jun-2004 Additions: - 1. rfe #901172 "text/xhtml" is now recognized as a valid HTML "content-type" + 1. rfe #901172: "text/xhtml" is now recognized as a valid HTML "content-type" Problems fixed: 1. bug #959918: Javascript setting of numeric values included trailing zeros after the decimal point. |
From: Russell G. <rus...@us...> - 2004-06-28 23:18:25
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1654/test/com/meterware/httpunit Modified Files: WebLinkTest.java Log Message: bug #830856: WebLink URLs broken across lines are now handled correctly Index: WebLinkTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebLinkTest.java,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- WebLinkTest.java 23 Jun 2003 23:54:04 -0000 1.29 +++ WebLinkTest.java 28 Jun 2004 23:18:17 -0000 1.30 @@ -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 @@ -99,6 +99,17 @@ } + public void testLinkUrlAcrossLineBreaks() throws Exception { + WebConversation wc = new WebConversation(); + defineWebPage( "Initial", "<a id='midbreak' href='http://loc\nalhost/somewhere'</a>" + + "<a id='endbreak' href='http://localhost/somewhere\n'</a>" ); + + WebResponse response = wc.getResponse( getHostPath() + "/Initial.html" ); + assertEquals( "URL with break at end", "http://localhost/somewhere", response.getLinkWithID( "endbreak" ).getRequest().getURL().toExternalForm() ); + assertEquals( "URL across linebreak", "http://localhost/somewhere", response.getLinkWithID( "midbreak" ).getRequest().getURL().toExternalForm() ); + } + + public void testLinkReference() throws Exception { WebLink link = _simplePage.getLinks()[0]; assertEquals( "URLString", "/other.html", link.getURLString() ); @@ -133,7 +144,7 @@ link = _simplePage.getFirstMatchingLink( WebLink.MATCH_URL_STRING, "/other.html" ); assertNotNull( "an active link was not found", link ); - assertEquals( "active link text", "an active link", link.asText() ); + assertEquals( "active link text", "an active link", link.getText() ); link = _simplePage.getFirstMatchingLink( WebLink.MATCH_URL_STRING, "basic" ); assertNotNull( "the image link was not found", link ); @@ -170,7 +181,7 @@ public void testLinkText() throws Exception { WebLink link = _simplePage.getLinks()[0]; - assertEquals( "Link text", "an active link", link.asText() ); + assertEquals( "Link text", "an active link", link.getText() ); } @@ -180,7 +191,7 @@ WebResponse initialPage = wc.getResponse( getHostPath() + "/HasImage.html" ); WebLink link = initialPage.getLinks()[0]; - assertEquals( "Link text", "", link.asText().trim() ); + assertEquals( "Link text", "", link.getText().trim() ); initialPage.getLinkWithImageText("Blah Blah"); } |
From: Russell G. <rus...@us...> - 2004-06-28 23:18:25
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1654/src/com/meterware/httpunit Modified Files: HttpUnitUtils.java WebRequestSource.java Log Message: bug #830856: WebLink URLs broken across lines are now handled correctly Index: HttpUnitUtils.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpUnitUtils.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- HttpUnitUtils.java 27 Jun 2004 16:00:49 -0000 1.14 +++ HttpUnitUtils.java 28 Jun 2004 23:18:16 -0000 1.15 @@ -20,8 +20,6 @@ * *******************************************************************************************************************/ import java.util.StringTokenizer; -import java.io.IOException; -import java.net.URL; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -185,6 +183,35 @@ } + /** + * Trims not only whitespace from the ends, but also from the middle. Spaces within quotes are respected. + */ + static String trimAll( String s ) { + s = s.trim(); + if (s.indexOf( ' ' ) < 0) return s; + + boolean inQuotes = false; + StringBuffer sb = new StringBuffer(); + char[] chars = s.toCharArray(); + for (int i = 0; i < chars.length; i++) { + char aChar = chars[i]; + if (aChar == '"' || aChar == '\'' ) { + inQuotes = !inQuotes; + sb.append( aChar ); + } else if (inQuotes || (aChar > ' ')) { + sb.append( aChar ); + } + } + return sb.toString(); + } + + + private static String trimFromMiddle( String s, int ch ) { + int index = s.indexOf( ch ); + return s.substring( 0, index ) + s.substring( index+1 ); + } + + static class ClasspathEntityResolver implements EntityResolver { public InputSource resolveEntity( String publicID, String systemID ) { Index: WebRequestSource.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequestSource.java,v retrieving revision 1.35 retrieving revision 1.36 diff -u -r1.35 -r1.36 --- WebRequestSource.java 27 Jun 2004 19:29:15 -0000 1.35 +++ WebRequestSource.java 28 Jun 2004 23:18:16 -0000 1.36 @@ -153,7 +153,7 @@ protected String getRelativeURL() { - String result = trimFragment( getDestination() ); + String result = HttpUnitUtils.trimAll( trimFragment( getDestination() ) ); if (result.trim().length() == 0) result = getBaseURL().getFile(); return result; } |
From: Russell G. <rus...@us...> - 2004-06-28 23:18:24
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1654/doc Modified Files: release_notes.txt Log Message: bug #830856: WebLink URLs broken across lines are now handled correctly Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.347 retrieving revision 1.348 diff -u -r1.347 -r1.348 --- release_notes.txt 28 Jun 2004 23:13:24 -0000 1.347 +++ release_notes.txt 28 Jun 2004 23:18:16 -0000 1.348 @@ -20,13 +20,14 @@ Problems fixed: 1. bug #959918: Javascript setting of numeric values included trailing zeros after the decimal point. 2. bug #957882: URL path elements containing leading '.' were being stripped of those periods. + 3. bug #830856: WebLink URLs broken across lines are now handled correctly 27-Jun-2004 Thanks to Fabrizio Giustina for adding an entity-resolver to support local use of ServletUnit with a regular web.xml Additions: - 1. patch #915296: Local copies of the 2.2 and 2.3 web.xml dtds are now consulted if specified, rather than connecting to - the Sun website. + 1. patch #915296: Local copies of the 2.2 and 2.3 web.xml dtds are now consulted if specified, + rather than connecting to the Sun website. 2. HTMLElement now supports a getText() method to return the text contents of any element 3. WebResponse now supports getTextBlocks and getFirstMatchingTextBlock to retrieve headers and paragraphs from a page. |
From: Russell G. <rus...@us...> - 2004-06-28 23:13:47
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv711/test/com/meterware/httpunit Modified Files: WebPageTest.java Log Message: from Andi Anderson: 'text/xhtml' now accepted as a valid html content type Index: WebPageTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebPageTest.java,v retrieving revision 1.35 retrieving revision 1.36 diff -u -r1.35 -r1.36 --- WebPageTest.java 20 Apr 2004 16:35:24 -0000 1.35 +++ WebPageTest.java 28 Jun 2004 23:13:24 -0000 1.36 @@ -81,6 +81,25 @@ } + public void testHtmlRequirement() throws Exception { + defineResource( "TextPage.txt", "Just text", "text/plain" ); + 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" ); + WebConversation wc = new WebConversation(); + try { + wc.getResponse( getHostPath() + "/TextPage.txt" ).getReceivedPage().getTitle(); + fail( "Should have rejected attempt to get a title from a text page" ); + } catch (NotHTMLException e ) {} + + WebResponse simplePage = wc.getResponse( getHostPath() + "/SimplePage.html" ); + assertEquals( "HTML Title", "A Sample Page", simplePage.getReceivedPage().getTitle() ); + + WebResponse structuredPage = wc.getResponse( getHostPath() + "/StructuredPage.html" ); + assertEquals( "XHTML Title", "A Structured Page", structuredPage.getReceivedPage().getTitle() ); + } + + public void testTitle() throws Exception { defineResource( "SimplePage.html", "<html><head><title>A Sample Page</title></head>\n" + |
From: Russell G. <rus...@us...> - 2004-06-28 23:13:47
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv711/src/com/meterware/httpunit Modified Files: WebResponse.java Log Message: from Andi Anderson: 'text/xhtml' now accepted as a valid html content type Index: WebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v retrieving revision 1.129 retrieving revision 1.130 diff -u -r1.129 -r1.130 --- WebResponse.java 27 Jun 2004 19:29:15 -0000 1.129 +++ WebResponse.java 28 Jun 2004 23:13:24 -0000 1.130 @@ -49,6 +49,11 @@ abstract 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 int UNINITIALIZED_INT = -2; + private FrameSelector _frame; private String _baseTarget; @@ -71,7 +76,7 @@ * Returns true if the response is HTML. **/ public boolean isHTML() { - return getContentType().equalsIgnoreCase( HTML_CONTENT ); + return getContentType().equalsIgnoreCase( HTML_CONTENT ) || getContentType().equalsIgnoreCase( XHTML_CONTENT ); } @@ -875,10 +880,6 @@ //--------------------------------- private members -------------------------------------- - final private static String HTML_CONTENT = "text/html"; - - final private static int UNINITIALIZED_INT = -2; - private WebWindow _window; private HTMLPage _page; |
From: Russell G. <rus...@us...> - 2004-06-28 23:13:33
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv711/doc Modified Files: release_notes.txt Log Message: from Andi Anderson: 'text/xhtml' now accepted as a valid html content type Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.346 retrieving revision 1.347 diff -u -r1.346 -r1.347 --- release_notes.txt 28 Jun 2004 23:08:51 -0000 1.346 +++ release_notes.txt 28 Jun 2004 23:13:24 -0000 1.347 @@ -14,6 +14,9 @@ Revision History: 28-Jun-2004 + Additions: + 1. rfe #901172 "text/xhtml" is now recognized as a valid HTML "content-type" + Problems fixed: 1. bug #959918: Javascript setting of numeric values included trailing zeros after the decimal point. 2. bug #957882: URL path elements containing leading '.' were being stripped of those periods. |
From: Russell G. <rus...@us...> - 2004-06-28 23:09:00
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32249/test/com/meterware/httpunit Modified Files: NormalizeURLTest.java Log Message: bug #957882: Don't remove leading periods in url path elements Index: NormalizeURLTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/NormalizeURLTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- NormalizeURLTest.java 4 May 2003 15:09:05 -0000 1.1 +++ NormalizeURLTest.java 28 Jun 2004 23:08:52 -0000 1.2 @@ -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 @@ -28,6 +28,7 @@ /** * Verifies handling of URLs with odd features. * @author <a href="mailto:ddk...@us...">David D. Kilzer</a> + * @author <a href="mailto:rus...@ht...">Russell Gold</a> **/ public class NormalizeURLTest extends HttpUnitTest { @@ -342,4 +343,10 @@ } + public void testPathElementLeadingDot() throws Exception { + WebRequest request = new GetMethodWebRequest( "http://host/context/.src/page" ); + assertEquals( "URL", request.getURL().toExternalForm(), "http://host/context/.src/page" ); + } + + } |
From: Russell G. <rus...@us...> - 2004-06-28 23:09:00
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32249/src/com/meterware/httpunit Modified Files: WebRequest.java Log Message: bug #957882: Don't remove leading periods in url path elements Index: WebRequest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequest.java,v retrieving revision 1.60 retrieving revision 1.61 diff -u -r1.60 -r1.61 --- WebRequest.java 23 Jun 2004 01:30:17 -0000 1.60 +++ WebRequest.java 28 Jun 2004 23:08:51 -0000 1.61 @@ -118,13 +118,13 @@ private String getNormalizedURL( String url ) { if (url.lastIndexOf( "//" ) > url.indexOf( "://" ) + 1) return getNormalizedURL( stripDoubleSlashes( url ) ); if (url.indexOf( "/.." ) > 0) return getNormalizedURL( stripUpNavigation( url ) ); - if (url.indexOf( "/." ) > 0) return getNormalizedURL( stripInPlaceNavigation( url ) ); + if (url.indexOf( "/./" ) > 0) return getNormalizedURL( stripInPlaceNavigation( url ) ); return url; } private String stripInPlaceNavigation( String url ) { - int i = url.lastIndexOf( "/." ); + int i = url.lastIndexOf( "/./" ); return url.substring( 0, i+1 ) + url.substring( i+2 ); } |
From: Russell G. <rus...@us...> - 2004-06-28 23:09:00
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32249/doc Modified Files: release_notes.txt Log Message: bug #957882: Don't remove leading periods in url path elements Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.345 retrieving revision 1.346 diff -u -r1.345 -r1.346 --- release_notes.txt 28 Jun 2004 23:06:02 -0000 1.345 +++ release_notes.txt 28 Jun 2004 23:08:51 -0000 1.346 @@ -16,6 +16,7 @@ 28-Jun-2004 Problems fixed: 1. bug #959918: Javascript setting of numeric values included trailing zeros after the decimal point. + 2. bug #957882: URL path elements containing leading '.' were being stripped of those periods. 27-Jun-2004 Thanks to Fabrizio Giustina for adding an entity-resolver to support local use of ServletUnit with a regular web.xml |
From: Russell G. <rus...@us...> - 2004-06-28 23:06:22
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31596/test/com/meterware/httpunit/javascript Modified Files: FormScriptingTest.java Log Message: bug #959918: trim trailing zeros when setting parameters from Javascript Index: FormScriptingTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/FormScriptingTest.java,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- FormScriptingTest.java 9 Mar 2004 21:49:18 -0000 1.29 +++ FormScriptingTest.java 28 Jun 2004 23:06:06 -0000 1.30 @@ -153,6 +153,32 @@ } + /** + * Verifies bug #959918 + */ + public void testNumericParameterSetting() throws Exception { + defineResource( "DoIt?id=1234", "You made it!" ); + defineResource( "OnCommand.html", "<html><head>" + + "<script>" + + " function myFunction(value) {" + + " document.mainForm.id = value;" + + " document.mainForm.submit();" + + " }</script>" + + "</head>" + + "<body>" + + "<form name=mainForm action='DoIt'>" + + " <a href='javascript:myFunction(1234)'>View Asset</a>" + + " <input type='hidden' name='id'>" + + "</form>" + + "</body></html>" ); + WebConversation wc = new WebConversation(); + WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); + + response.getLinks()[ 0 ].click(); + assertEquals( "Result of submit", "You made it!", wc.getCurrentPage().getText() ); + } + + public void testEnablingDisabledSubmitButtonViaScript() throws Exception { defineResource( "DoIt?color=green&change=success", "You made it!" ); defineResource( "OnCommand.html", "<html><head></head>" + |
From: Russell G. <rus...@us...> - 2004-06-28 23:06:15
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31596/src/com/meterware/httpunit Modified Files: WebForm.java Log Message: bug #959918: trim trailing zeros when setting parameters from Javascript Index: WebForm.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v retrieving revision 1.90 retrieving revision 1.91 diff -u -r1.90 -r1.91 --- WebForm.java 13 Jun 2004 20:57:25 -0000 1.90 +++ WebForm.java 28 Jun 2004 23:06:05 -0000 1.91 @@ -672,12 +672,30 @@ public void set( String propertyName, Object value ) { if (propertyName.equals( "target" )) { setTargetAttribute( value.toString() ); + } else if (value instanceof String) { + setParameterValue( propertyName, (String) value ); + } else if (value instanceof Number) { + setParameterValue( propertyName, roundedValue( (Number) value ) ); } else { super.set( propertyName, value ); } } + /** + * Trim off any trailing zeros (and the decimal point if the result is an integer). + */ + private String roundedValue( Number number ) { + String rawNumber = number.toString(); + if (rawNumber.indexOf('.') == -1) return rawNumber; + + int index = rawNumber.length(); + while (rawNumber.charAt( index-1 ) == '0') index--; + if (rawNumber.charAt( index-1 ) == '.') index--; + return rawNumber.substring( 0, index ); + } + + public void setParameterValue( String name, String value ) { final Object scriptableObject = getParameter( name ).getScriptableObject(); if (scriptableObject instanceof ScriptableDelegate) { |
From: Russell G. <rus...@us...> - 2004-06-28 23:06:15
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31596/doc Modified Files: release_notes.txt Log Message: bug #959918: trim trailing zeros when setting parameters from Javascript Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.344 retrieving revision 1.345 diff -u -r1.344 -r1.345 --- release_notes.txt 27 Jun 2004 19:29:14 -0000 1.344 +++ release_notes.txt 28 Jun 2004 23:06:02 -0000 1.345 @@ -13,6 +13,10 @@ Revision History: +28-Jun-2004 + Problems fixed: + 1. bug #959918: Javascript setting of numeric values included trailing zeros after the decimal point. + 27-Jun-2004 Thanks to Fabrizio Giustina for adding an entity-resolver to support local use of ServletUnit with a regular web.xml |
From: Russell G. <rus...@us...> - 2004-06-27 19:29:25
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23042/src/com/meterware/httpunit Modified Files: HTMLElement.java HTMLElementBase.java HTMLSegment.java NodeUtils.java ParsedHTML.java TableCell.java WebLink.java WebRequestSource.java WebResponse.java WebTable.java Added Files: BlockElement.java Log Message: Support text block abstraction ***** Error reading new file[Errno 2] No such file or directory: 'BlockElement.java' Index: HTMLElement.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HTMLElement.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- HTMLElement.java 19 Sep 2003 18:53:43 -0000 1.4 +++ HTMLElement.java 27 Jun 2004 19:29:15 -0000 1.5 @@ -71,4 +71,10 @@ * Returns the delegate which supports scripting this element. */ ScriptableDelegate getScriptableDelegate(); + + + /** + * Returns the contents of this element, converted to a string. + */ + String getText(); } Index: HTMLElementBase.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HTMLElementBase.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- HTMLElementBase.java 19 Sep 2003 18:53:43 -0000 1.5 +++ HTMLElementBase.java 27 Jun 2004 19:29:15 -0000 1.6 @@ -71,6 +71,20 @@ } + /** + * Returns the text value of this block. + **/ + public String getText() { + if (_node.getNodeType() == Node.TEXT_NODE) { + return _node.getNodeValue().trim(); + } else if (_node == null || !_node.hasChildNodes()) { + return ""; + } else { + return NodeUtils.asText( _node.getChildNodes() ).trim(); + } + } + + protected HTMLElementBase( Node node ) { _node = node; supportAttribute( "id" ); Index: HTMLSegment.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HTMLSegment.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- HTMLSegment.java 27 Aug 2003 02:16:06 -0000 1.12 +++ HTMLSegment.java 27 Jun 2004 19:29:15 -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 @@ -160,6 +160,13 @@ /** + * 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; + + + /** * Returns the top-level tables found in this HTML segment in the order in which * they appear. * @exception SAXException thrown if there is an error parsing the segment. Index: NodeUtils.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/NodeUtils.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- NodeUtils.java 4 Feb 2003 05:32:03 -0000 1.18 +++ NodeUtils.java 27 Jun 2004 19:29:15 -0000 1.19 @@ -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 @@ -55,7 +55,10 @@ public static String getNodeAttribute( Node node, String attributeName, String defaultValue ) { - Node attribute = node.getAttributes().getNamedItem( attributeName ); + NamedNodeMap attributes = node.getAttributes(); + if (attributes == null) return defaultValue; + + Node attribute = attributes.getNamedItem( attributeName ); return (attribute == null) ? defaultValue : attribute.getNodeValue(); } @@ -75,7 +78,7 @@ /** * Processes a text node. */ - public void processTextNodeValue( String value ); + public void processTextNode( PreOrderTraversal traversal, Node textNode ); } /** @@ -99,8 +102,8 @@ } return true; } - public void processTextNodeValue( String value ) { - sb.append( HTMLParserFactory.getHTMLParser().getCleanedText( value ) ); + public void processTextNode( PreOrderTraversal traversal, Node textNode ) { + sb.append( HTMLParserFactory.getHTMLParser().getCleanedText( textNode.getNodeValue() ) ); } }; new PreOrderTraversal( rootNodes ).perform( action ); @@ -162,7 +165,7 @@ } else { Node node = (Node) object; if (node.getNodeType() == Node.TEXT_NODE) { - action.processTextNodeValue( node.getNodeValue() ); + action.processTextNode( this, node ); } else if (node.getNodeType() != Node.ELEMENT_NODE) { continue; } else Index: ParsedHTML.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ParsedHTML.java,v retrieving revision 1.53 retrieving revision 1.54 diff -u -r1.53 -r1.54 --- ParsedHTML.java 24 Jun 2004 23:32:29 -0000 1.53 +++ ParsedHTML.java 27 Jun 2004 19:29:15 -0000 1.54 @@ -38,6 +38,8 @@ final static private HTMLElement[] NO_ELEMENTS = new HTMLElement[0]; + final static private String[] TEXT_ELEMENTS = { "p", "h1", "h2", "h3", "h4", "h5", "h6" }; + private Node _rootNode; private URL _baseURL; @@ -73,6 +75,9 @@ private ArrayList _linkList = new ArrayList(); private WebLink[] _links; + private ArrayList _blocksList = new ArrayList(); + private BlockElement[] _blocks; + private ArrayList _appletList = new ArrayList(); private WebApplet[] _applets; @@ -142,6 +147,19 @@ /** + * Returns the top-level block elements found in the page in the order in which they appear. + * @return + */ + public BlockElement[] getTextBlocks() { + if (_blocks == null) { + loadElements(); + _blocks = (BlockElement[]) _blocksList.toArray( new BlockElement[ _blocksList.size() ] ); + } + return _blocks; + } + + + /** * Returns the top-level tables found in the page in the order in which they appear. **/ public WebTable[] getTables() { @@ -328,19 +346,15 @@ } - abstract static class HTMLElementFactory { - abstract HTMLElement toHTMLElement( NodeUtils.PreOrderTraversal pot, ParsedHTML parsedHTML, Element element ); + static class HtmlElementRecorder { - void recordElement( NodeUtils.PreOrderTraversal pot, Element element, ParsedHTML parsedHTML ) { - HTMLElement htmlElement = toHTMLElement( pot, parsedHTML, element ); + protected void recordHtmlElement( NodeUtils.PreOrderTraversal pot, Node node, HTMLElement htmlElement ) { if (htmlElement != null) { - addToMaps( pot, element, htmlElement ); + addToMaps( pot, node, htmlElement ); addToLists( pot, htmlElement ); } } - protected boolean isRecognized( ClientProperties properties ) { return true; } - protected boolean addToContext() { return false; } protected void addToLists( NodeUtils.PreOrderTraversal pot, HTMLElement htmlElement ) { for (Iterator i = pot.getContexts(); i.hasNext();) { Object o = i.next(); @@ -348,13 +362,27 @@ } } - protected void addToMaps( NodeUtils.PreOrderTraversal pot, Element element, HTMLElement htmlElement ) { + protected void addToMaps( NodeUtils.PreOrderTraversal pot, Node node, HTMLElement htmlElement ) { for (Iterator i = pot.getContexts(); i.hasNext();) { Object o = i.next(); - if (o instanceof ParsedHTML) ((ParsedHTML) o).addToMaps( element, htmlElement ); + if (o instanceof ParsedHTML) ((ParsedHTML) o).addToMaps( node, htmlElement ); } } + } + + + abstract static class HTMLElementFactory extends HtmlElementRecorder { + abstract HTMLElement toHTMLElement( NodeUtils.PreOrderTraversal pot, ParsedHTML parsedHTML, Element element ); + + void recordElement( NodeUtils.PreOrderTraversal pot, Element element, ParsedHTML parsedHTML ) { + HTMLElement htmlElement = toHTMLElement( pot, parsedHTML, element ); + recordHtmlElement( pot, element, htmlElement ); + } + + protected boolean isRecognized( ClientProperties properties ) { return true; } + protected boolean addToContext() { return false; } + final protected ParsedHTML getParsedHTML( NodeUtils.PreOrderTraversal pot ) { return (ParsedHTML) getClosestContext( pot, ParsedHTML.class ); } @@ -408,6 +436,13 @@ } + static class TextBlockFactory extends HTMLElementFactory { + HTMLElement toHTMLElement( NodeUtils.PreOrderTraversal pot, ParsedHTML parsedHTML, Element element ) { + return parsedHTML.toTextBlock( element ); + } + } + + static class ScriptFactory extends HTMLElementFactory { HTMLElement toHTMLElement( NodeUtils.PreOrderTraversal pot, ParsedHTML parsedHTML, Element element ) { @@ -559,6 +594,10 @@ _htmlFactoryClasses.put( "script", new ScriptFactory() ); _htmlFactoryClasses.put( "noscript", new NoScriptFactory() ); + for (int i = 0; i < TEXT_ELEMENTS.length; i++) { + _htmlFactoryClasses.put( TEXT_ELEMENTS[i], new TextBlockFactory() ); + } + for (Iterator i = Arrays.asList( FormControl.getControlElementTags() ).iterator(); i.hasNext();) { _htmlFactoryClasses.put( i.next(), new FormControlFactory() ); } @@ -584,7 +623,13 @@ return true; } - public void processTextNodeValue( String value ) { + public void processTextNode( NodeUtils.PreOrderTraversal pot, Node textNode ) { + if (textNode.getNodeValue().trim().length() == 0) return; + + Node parent = textNode.getParentNode(); + if (!parent.getNodeName().equalsIgnoreCase( "body" )) return; + if (pot.getClosestContext( ContentConcealer.class ) != null) return; + new HtmlElementRecorder().recordHtmlElement( pot, textNode, newTextBlock( textNode ) ); } }; NodeUtils.PreOrderTraversal nt = new NodeUtils.PreOrderTraversal( getRootNode() ); @@ -646,8 +691,18 @@ } - private void addToMaps( Element element, HTMLElement htmlElement ) { - _elements.put( element, htmlElement ); + private BlockElement toTextBlock( Element element ) { + return new BlockElement( _response, _frame, _baseURL, _baseTarget, element, _characterSet ); + } + + + private BlockElement newTextBlock( Node textNode ) { + return new BlockElement( _response, _frame, _baseURL, _baseTarget, textNode, _characterSet ); + } + + + private void addToMaps( Node node, HTMLElement htmlElement ) { + _elements.put( node, htmlElement ); if (htmlElement.getID() != null) _elementsByID.put( htmlElement.getID(), htmlElement ); if (htmlElement.getName() != null) addNamedElement( htmlElement.getName(), htmlElement ); } @@ -673,6 +728,7 @@ if (element instanceof WebApplet) return _appletList; if (element instanceof WebTable) return _tableList; if (element instanceof WebFrame) return _frameList; + if (element instanceof BlockElement) return _blocksList; return null; } @@ -764,6 +820,18 @@ /** + * 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 @@ -854,6 +922,7 @@ _applets = null; _tables = null; _frames = null; + _blocks = null; _updateElements = true; } Index: TableCell.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/TableCell.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- TableCell.java 13 Jun 2004 20:57:25 -0000 1.17 +++ TableCell.java 27 Jun 2004 19:29:15 -0000 1.18 @@ -30,9 +30,7 @@ /** * A single cell in an HTML table. **/ -public class TableCell extends ParsedHTML implements HTMLSegment, HTMLElement { - - private ScriptableDelegate _scriptable; +public class TableCell extends BlockElement { /** @@ -53,95 +51,10 @@ /** * Returns the text value of this cell. - **/ - public String asText() { - return getCellContentsAsText( _element ); - } - - - /** - * Returns a copy of the domain object model associated with this HTML segment. - **/ - public Node getDOM() { - return super.getDOM(); - } - - /** - * Returns the underlying HTML Element. + * @deprecated as of 1.5.5, use #getText() */ - public Element getElement() { - return _element; - } - -//-------------------------------- HTMLElement methods --------------------------------------- - - - /** - * Returns the ID associated with this element. IDs are unique throughout the HTML document. - **/ - public String getID() { - return getAttribute( "id" ); - } - - - public String getClassName() { - return getAttribute( "class" ); - } - - - /** - * Returns the name associated with this element. - **/ - public String getName() { - return getAttribute( "name" ); - } - - - /** - * Returns the title associated with this element. - **/ - public String getTitle() { - return getAttribute( "title" ); - } - - - /** - * Returns the delegate which supports scripting this element. - */ - public ScriptableDelegate getScriptableDelegate() { - if (_scriptable == null) { - _scriptable = new HTMLElementScriptable( this ); - _scriptable.setScriptEngine( getResponse().getScriptableObject().getDocument().getScriptEngine( _scriptable ) ); - } - return _scriptable; - } - - - public String getAttribute( final String name ) { - return NodeUtils.getNodeAttribute( _element, name ); - } - - - /** - * Returns true if this element may have an attribute with the specified name. - */ - public boolean isSupportedAttribute( String name ) { - return false; - } - - - public boolean equals( Object obj ) { - return obj instanceof TableCell && equals( (TableCell) obj ); - } - - - private boolean equals( TableCell cell ) { - return _element.equals( cell._element ); - } - - - public int hashCode() { - return _element.hashCode(); + public String asText() { + return getText(); } @@ -150,7 +63,6 @@ TableCell( WebResponse response, FrameSelector frame, Element cellNode, URL url, String parentTarget, String characterSet ) { super( response, frame, url, parentTarget, cellNode, characterSet ); - _element = cellNode; _colSpan = getAttributeValue( cellNode, "colspan", 1 ); _rowSpan = getAttributeValue( cellNode, "rowspan", 1 ); } @@ -159,25 +71,9 @@ //----------------------------------- private fields and methods ----------------------------------- - private Element _element; private int _colSpan; private int _rowSpan; - private String getCellContentsAsText( Node node ) { - if (node == null) { - return ""; - } else if (!node.hasChildNodes()) { - return ""; - } else { - return NodeUtils.asText( node.getChildNodes() ); - } - } - - - - private int getAttributeValue( Node node, String attributeName, int defaultValue ) { - return NodeUtils.getAttributeValue( node, attributeName, defaultValue ); - } } Index: WebLink.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebLink.java,v retrieving revision 1.42 retrieving revision 1.43 diff -u -r1.42 -r1.43 --- WebLink.java 13 Jun 2004 20:57:25 -0000 1.42 +++ WebLink.java 27 Jun 2004 19:29:15 -0000 1.43 @@ -68,18 +68,25 @@ /** * Returns the text value of this link. **/ - public String asText() { + public String getText() { if (getNode().getNodeName().equalsIgnoreCase( "area" )) { return getAttribute( "alt" ); - } else if (!getNode().hasChildNodes()) { - return ""; } else { - return NodeUtils.asText( getNode().getChildNodes() ).trim(); + return super.getText(); } } /** + * Returns the text value of this link. + * @deprecated use #getText instead + **/ + public String asText() { + return getText(); + } + + + /** * Submits a request as though the user had clicked on this link. Will also fire the 'onClick' event if defined. * If clicking results in submitting a request (that is, there is no 'onClick' event or it returns true, * this method will return the result of that submission; otherwise, it will Index: WebRequestSource.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequestSource.java,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- WebRequestSource.java 13 Jun 2004 20:57:27 -0000 1.34 +++ WebRequestSource.java 27 Jun 2004 19:29:15 -0000 1.35 @@ -289,6 +289,20 @@ } + /** + * Returns the text value of this block. + **/ + public String getText() { + if (_node.getNodeType() == Node.TEXT_NODE) { + return _node.getNodeValue().trim(); + } else if (_node == null || !_node.hasChildNodes()) { + return ""; + } else { + return NodeUtils.asText( _node.getChildNodes() ).trim(); + } + } + + String getAttribute( final String name, String defaultValue ) { return NodeUtils.getNodeAttribute( _node, name, defaultValue ); } Index: WebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v retrieving revision 1.128 retrieving revision 1.129 diff -u -r1.128 -r1.129 --- WebResponse.java 27 Jun 2004 16:59:48 -0000 1.128 +++ WebResponse.java 27 Jun 2004 19:29:15 -0000 1.129 @@ -490,6 +490,20 @@ } + public BlockElement[] getTextBlocks() throws SAXException { + return getReceivedPage().getTextBlocks(); + } + + + /** + * Returns the first link found in the page matching the specified criteria. + * @exception SAXException thrown if there is an error parsing the response. + **/ + public BlockElement getFirstMatchingTextBlock( HTMLElementPredicate predicate, Object criteria ) throws SAXException { + return getReceivedPage().getFirstMatchingTextBlock( predicate, criteria ); + } + + /** * Returns a copy of the domain object model tree associated with this response. * If the response is HTML, it will use a special parser which can transform HTML into an XML DOM. Index: WebTable.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebTable.java,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- WebTable.java 13 Jun 2004 20:57:27 -0000 1.28 +++ WebTable.java 27 Jun 2004 19:29:15 -0000 1.29 @@ -79,7 +79,7 @@ **/ public String getCellAsText( int row, int column ) { TableCell cell = getTableCell( row, column ); - return (cell == null) ? "" : cell.asText(); + return (cell == null) ? "" : cell.getText(); } @@ -207,7 +207,7 @@ if (getCells()[i][j] == null) { sb.append( "null" ); } else { - sb.append( getCells()[i][j].asText() ); + sb.append( getCells()[i][j].getText() ); } } sb.append( eol ); |
From: Russell G. <rus...@us...> - 2004-06-27 19:29:23
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23042/test/com/meterware/httpunit Modified Files: HtmlTablesTest.java HttpUnitSuite.java XMLPageTest.java Added Files: TextBlockTest.java Log Message: Support text block abstraction ***** Error reading new file[Errno 2] No such file or directory: 'TextBlockTest.java' Index: HtmlTablesTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/HtmlTablesTest.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- HtmlTablesTest.java 5 Dec 2003 04:06:53 -0000 1.18 +++ HtmlTablesTest.java 27 Jun 2004 19:29:15 -0000 1.19 @@ -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 @@ -281,17 +281,17 @@ assertNotNull("there is a table",table); TableCell cell = table.getTableCellWithID("id1"); assertNotNull("cell id1",cell); - assertEquals("Value of cell id1","value1",cell.asText()); + assertEquals("Value of cell id1","value1",cell.getText()); cell = table.getTableCellWithID("id2"); assertNotNull("cell id2",cell); - assertEquals("Value of cell id2","value2",cell.asText()); + assertEquals("Value of cell id2","value2",cell.getText()); // test non existent cell id cell = table.getTableCellWithID("nonExistingID"); assertNull("cell id2",cell); cell = (TableCell) page.getElementWithID( "id1" ); - assertEquals( "value of cell found from page", "value1", cell.asText() ); + assertEquals( "value of cell found from page", "value1", cell.getText() ); } /** @@ -299,8 +299,8 @@ */ public void testCellTagName() throws Exception { WebTable table = _wc.getResponse( getHostPath() + "/OneTable.html" ).getTables()[0]; - assertEquals("Tag name of header cell", table.getTableCell(0,0).getElement().getTagName().toUpperCase(), "TH"); - assertEquals("Tag name of non-header cell", table.getTableCell(0,1).getElement().getTagName().toUpperCase(), "TD"); + assertEquals("Tag name of header cell", table.getTableCell(0,0).getTagName().toUpperCase(), "TH"); + assertEquals("Tag name of non-header cell", table.getTableCell(0,1).getTagName().toUpperCase(), "TD"); } private WebConversation _wc; Index: HttpUnitSuite.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/HttpUnitSuite.java,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- HttpUnitSuite.java 4 May 2003 15:09:05 -0000 1.32 +++ HttpUnitSuite.java 27 Jun 2004 19:29:15 -0000 1.33 @@ -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 @@ -58,6 +58,7 @@ result.addTest( CookieTest.suite() ); result.addTest( ParsingTestSuite.suite() ); result.addTest( NormalizeURLTest.suite() ); + result.addTest( TextBlockTest.suite() ); if (HTMLParserFactory.getHTMLParser().getClass().getName().indexOf("NekoHTML") >= 0) result.addTest( NekoEnhancedScriptingTest.suite() ); addOptionalTestCase( result, "com.meterware.httpunit.XMLPageTest" ); Index: XMLPageTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/XMLPageTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- XMLPageTest.java 26 Dec 2002 04:59:35 -0000 1.2 +++ XMLPageTest.java 27 Jun 2004 19:29:15 -0000 1.3 @@ -4,12 +4,12 @@ * * Copyright (c) 2000-2002, 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 +* 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 * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and * to permit persons to whom the Software is furnished to do so, subject to the following conditions: * -* The above copyright notice and this permission notice shall be included in all copies or substantial portions +* The above copyright notice and this permission notice shall be included in all copies or substantial portions * of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO @@ -24,6 +24,7 @@ import junit.framework.TestSuite; import org.w3c.dom.Element; +import org.w3c.dom.Node; /** * A test for the XML handling functionality. @@ -33,8 +34,8 @@ public static void main(String args[]) { junit.textui.TestRunner.run( suite() ); } - - + + public static TestSuite suite() { return new TestSuite( XMLPageTest.class ); } @@ -76,7 +77,7 @@ } return true; } - public void processTextNodeValue( String value ) { + public void processTextNode( NodeUtils.PreOrderTraversal traversal, Node textNode ) { } } ); assertEquals( "Traversal result", "zero|xfirst|xsecond|xxnormal|xxsimple|xafter|end|", sb.toString() ); |
From: Russell G. <rus...@us...> - 2004-06-27 19:29:23
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23042/doc Modified Files: release_notes.txt Log Message: Support text block abstraction Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.343 retrieving revision 1.344 diff -u -r1.343 -r1.344 --- release_notes.txt 27 Jun 2004 16:59:48 -0000 1.343 +++ release_notes.txt 27 Jun 2004 19:29:14 -0000 1.344 @@ -19,6 +19,8 @@ Additions: 1. patch #915296: Local copies of the 2.2 and 2.3 web.xml dtds are now consulted if specified, rather than connecting to the Sun website. + 2. HTMLElement now supports a getText() method to return the text contents of any element + 3. WebResponse now supports getTextBlocks and getFirstMatchingTextBlock to retrieve headers and paragraphs from a page. 25-Jun-2004 Problems fixed: |
From: Russell G. <rus...@us...> - 2004-06-27 19:09:41
|
Update of /cvsroot/httpunit/httpunit/src/META-MF In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19071/src/META-MF Log Message: Directory /cvsroot/httpunit/httpunit/src/META-MF added to the repository |
From: Russell G. <rus...@us...> - 2004-06-27 16:59:56
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27058/test/com/meterware/httpunit/javascript Modified Files: ScriptingTest.java Log Message: bug #960307 meta tags within <noscript> tags were not being ignored when scripting was disabled Index: ScriptingTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java,v retrieving revision 1.61 retrieving revision 1.62 diff -u -r1.61 -r1.62 --- ScriptingTest.java 24 Jun 2004 23:32:30 -0000 1.61 +++ ScriptingTest.java 27 Jun 2004 16:59:48 -0000 1.62 @@ -721,4 +721,25 @@ } + public void testJavascriptDetectionTrick() throws Exception { + defineResource( "NoScript.html", "No javascript here" ); + defineResource( "HasScript.html", "Javascript is enabled!" ); + defineResource( "Start.html", "<html><head>" + + " <noscript>" + + " <meta http-equiv='refresh' content='0;url=NoScript.html>'" + + " </noscript></head>" + + "<body onload='document.form.submit()'>" + + "<form name='form' action='HasScript.html'></form>" + + "</body></html>" ); + WebConversation wc = new WebConversation(); + wc.getClientProperties().setAutoRefresh( true ); + WebResponse response = wc.getResponse( getHostPath() + "/Start.html" ); + assertEquals( "Result page", "Javascript is enabled!", response.getText() ); + + HttpUnitOptions.setScriptingEnabled( false ); + response = wc.getResponse( getHostPath() + "/Start.html" ); + assertEquals( "Result page", "No javascript here", response.getText() ); + } + + } |
From: Russell G. <rus...@us...> - 2004-06-27 16:59:56
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27058/src/com/meterware/httpunit Modified Files: WebResponse.java Log Message: bug #960307 meta tags within <noscript> tags were not being ignored when scripting was disabled Index: WebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v retrieving revision 1.127 retrieving revision 1.128 diff -u -r1.127 -r1.128 --- WebResponse.java 23 Jun 2004 01:30:17 -0000 1.127 +++ WebResponse.java 27 Jun 2004 16:59:48 -0000 1.128 @@ -940,6 +940,9 @@ if (tag.getName().equalsIgnoreCase( "base" )) processBaseTag( tag ); if (tag.getName().equalsIgnoreCase( "frameset" )) _hasSubframes = true; if (tag.getName().equalsIgnoreCase( "iframe" )) _hasSubframes = true; + if (tag.getName().equalsIgnoreCase( "noscript") && HttpUnitOptions.isScriptingEnabled()) { + do { tag = parser.getNextTag(); } while (tag.getName().equalsIgnoreCase( "/noscript") ); + } tag = parser.getNextTag(); } } |
From: Russell G. <rus...@us...> - 2004-06-27 16:59:56
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27058/doc Modified Files: release_notes.txt Log Message: bug #960307 meta tags within <noscript> tags were not being ignored when scripting was disabled Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.342 retrieving revision 1.343 diff -u -r1.342 -r1.343 --- release_notes.txt 27 Jun 2004 16:02:02 -0000 1.342 +++ release_notes.txt 27 Jun 2004 16:59:48 -0000 1.343 @@ -20,6 +20,10 @@ 1. patch #915296: Local copies of the 2.2 and 2.3 web.xml dtds are now consulted if specified, rather than connecting to the Sun website. +25-Jun-2004 + Problems fixed: + 1. bug #960307 meta tags within <noscript> tags were not being ignored when scripting was disabled + 24-Jun-2004 Problems fixed: 1. bug #978770 Clicking on a button outside of a form is now supported |
From: Russell G. <rus...@us...> - 2004-06-27 16:02:09
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17410/doc Modified Files: release_notes.txt Log Message: from Fabrizio Giustina: Added entity resolver to handle local DTDs for ServletUnit Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.341 retrieving revision 1.342 diff -u -r1.341 -r1.342 --- release_notes.txt 27 Jun 2004 16:00:49 -0000 1.341 +++ release_notes.txt 27 Jun 2004 16:02:02 -0000 1.342 @@ -17,7 +17,7 @@ Thanks to Fabrizio Giustina for adding an entity-resolver to support local use of ServletUnit with a regular web.xml Additions: - 1. Local copies of the 2.2 and 2.3 web.xml dtds are now consulted if specified, rather than connecting to + 1. patch #915296: Local copies of the 2.2 and 2.3 web.xml dtds are now consulted if specified, rather than connecting to the Sun website. 24-Jun-2004 |