httpunit-commit Mailing List for httpunit (Page 38)
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...> - 2003-02-04 05:32:05
|
Update of /cvsroot/httpunit/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv6354
Modified Files:
project.xml
Log Message:
Added IFRAME support
Index: project.xml
===================================================================
RCS file: /cvsroot/httpunit/httpunit/project.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- project.xml 25 Nov 2002 14:17:45 -0000 1.1
+++ project.xml 4 Feb 2003 05:32:02 -0000 1.2
@@ -3,7 +3,7 @@
<pomVersion>3</pomVersion>
<name>httpunit</name>
<id>httpunit</id>
- <currentVersion>1.5.0-dev</currentVersion>
+ <currentVersion>1.5.1-dev</currentVersion>
<organization>
<name>Meterware</name>
<url>http://www.meterware.com/</url>
@@ -75,21 +75,32 @@
<dependency>
<id>nekohtml</id>
- <version>0.68</version>
+ <version>0.7.1</version>
<url>http://www.apache.org/~andyc/neko/doc/html/index.html</url>
</dependency>
<dependency>
<id>xerces</id>
- <version>2.2</version>
+ <version>2.2.1</version>
<url>http://xml.apache.org/xerces2-j/index.html</url>
</dependency>
- </dependencies>
+ <dependency>
+ <id>servletapi</id>
+ <version>2.3</version>
+ <url>http://java.sun.com</url>
+ </dependency>
+
+ <dependency>
+ <id>junit</id>
+ <version>3.8.1</version>
+ <url>http://www.junit.org</url>
+ </dependency>
+ </dependencies>
<build>
- <nagEmailAddress></nagEmailAddress>
+ <nagEmailAddress>rus...@ht...</nagEmailAddress>
<sourceDirectory>src</sourceDirectory>
<unitTestSourceDirectory>test</unitTestSourceDirectory>
|
|
From: Russell G. <rus...@us...> - 2003-01-13 21:58:09
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1:/tmp/cvs-serv18943/doc Modified Files: faq.html release_notes.txt Log Message: Upgraded to NekoHTML 0.7.2 Index: faq.html =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/faq.html,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- faq.html 3 Nov 2002 18:18:19 -0000 1.22 +++ faq.html 13 Jan 2003 21:57:29 -0000 1.23 @@ -50,16 +50,12 @@ <A NAME="charset"><h3>Why isn't HttpUnit handling my non-English pages?</h3></A> -Older versions of HttpUnit (through 1.2) incorrectly assumed that all pages were in the default character set for the client platform. -As of version 1.2.1, HttpUnit correctly recognizes the charset parameter of the Content-type header which may -specify an alternative character set; -when none is specified, HTML 1.1 says that the character set is to be taken as iso-8859-1. +When no Content-Type header is specified, HTML 1.1 says that the character set is to be taken as iso-8859-1. Unfortunately, some HTTP servers do not send this parameter correctly, and many browsers incorrectly use this -as an indication that they should -determine the character set in some other fashion. To imitate this behavior, HttpUnit allows you to set the expected character +as an indication that they should determine the character set in some other fashion. To imitate this behavior, +HttpUnit allows you to set the expected character set for future pages by calling HttpUnitOptions.setDefaultCharacterSet(). This setting will not apply to those -pages for which the server specifies -the character set. +pages for which the server specifies the character set. <p> Non-English form handling is supported as well. Any parameter values entered into a form will be encoded as the same character set as the document containing the form. The server code will then have to handle those characters @@ -78,15 +74,15 @@ <h2>Form Handling Problems</h2> <A NAME="buttons"><h3>HttpUnit is not finding the buttons and parameters in my forms. What is wrong?</h3></A> -If you are using JTidy (the HTML parser originally used by HttpUnit), this can happen when your HTML is not valid. -Most browsers are extremely forgiving of bad HTML; however, JTidy is not. It expects tags to be nested according to the HTML -specification and will reject any that are not. JTidy can display error messages to tell you what is wrong. To see them, -call <code>HttpUnitOptions.setParserWarningsEnabled( true )</code> before retrieving your HTML page. -Once you have corrected any errors, HttpUnit should see your form buttons and parameters. +Usually this indicates some poor nesting of <form> tags. Browsers are extremely forgiving of bad HTML, even +handling cases where it is impossible to turn that HTML into a DOM. When a parser encounters such code, it tries +to "fix it" which may not generate exactly the intended results. As of version 1.5.2, HttpUnit is a lot more forgiving, +considering controls to belong to the last opened <form> tag, even it was presumed to have been closed. This +seems to match what most browsers do. Under some circumstances switching among the supported parsers may give different +results. -The <a href="http://www.apache.org/~andyc/neko/doc/html/">NekoHTML parser</a>, a much more forgiving parser, is the -parser used by default as of HttpUnit 1.5. It is strongly recommended that you use it in preference to JTidy, -as it should correct problems like this. +Note that JTidy can display error messages to tell you when there are problems with your HTML. To see them, +call <code>HttpUnitOptions.setParserWarningsEnabled( true )</code> before retrieving your HTML page. <A name="#hidden"><h3>Why can't I change hidden parameter values?</h3></A> By default, HttpUnit verifies any parameter value changes against the form containing them. Since a user cannot directly Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.244 retrieving revision 1.245 diff -u -r1.244 -r1.245 --- release_notes.txt 10 Jan 2003 18:21:41 -0000 1.244 +++ release_notes.txt 13 Jan 2003 21:57:30 -0000 1.245 @@ -11,6 +11,9 @@ Revision History: +13-Jan-2002 + Notes: upgraded NekoHTML to 0.7.2 which no longer generates superfluous <form> tags. + 10-Jan-2003 Thanks to Alex Beggs for noting the mishandling of non-JavaScript scripts and providing a test case. |
|
From: Russell G. <rus...@us...> - 2003-01-13 21:57:45
|
Update of /cvsroot/httpunit/httpunit/jars In directory sc8-pr-cvs1:/tmp/cvs-serv18943/jars Modified Files: jars.txt nekohtml.jar Log Message: Upgraded to NekoHTML 0.7.2 Index: jars.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/jars/jars.txt,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- jars.txt 18 Dec 2002 13:09:55 -0000 1.8 +++ jars.txt 13 Jan 2003 21:57:34 -0000 1.9 @@ -6,7 +6,7 @@ xerces 2.2 jtidy 04aug2000r7 rhino 1.5preR4 (patched) -NekoHTML 0.7.1 +NekoHTML 0.7.2 (for testing HttpUnit only) mail (javamail 1.2) Index: nekohtml.jar =================================================================== RCS file: /cvsroot/httpunit/httpunit/jars/nekohtml.jar,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 Binary files /tmp/cvsWTatQV and /tmp/cvs8eaZ6G differ |
|
From: Russell G. <rus...@us...> - 2003-01-10 18:22:32
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript
In directory sc8-pr-cvs1:/tmp/cvs-serv20754/test/com/meterware/httpunit/javascript
Modified Files:
NekoEnhancedScriptingTest.java
Log Message:
Now ignoring non-JavaScript scripts
Index: NekoEnhancedScriptingTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/NekoEnhancedScriptingTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- NekoEnhancedScriptingTest.java 15 Nov 2002 03:06:10 -0000 1.2
+++ NekoEnhancedScriptingTest.java 10 Jan 2003 18:21:48 -0000 1.3
@@ -65,4 +65,33 @@
}
+ public void testUnknownScript() throws Exception {
+ defineWebPage( "FunkyScript",
+ "<SCRIPT>" +
+ "var stuff='<A href=\"#\">Default JavaScript Working</A><BR>';" +
+ "document.writeln(stuff);" +
+ "</SCRIPT>" +
+ "<SCRIPT Language='JavaScript'>" +
+ "var stuff='<A href=\"#\">JavaScript Working</A><BR>';" +
+ "document.writeln(stuff);" +
+ "</SCRIPT>" +
+ "<SCRIPT Language='JavaScript1.2'>" +
+ "var stuff='<A href=\"#\">JavaScript 1.2 Working</A><BR>';" +
+ "document.writeln(stuff);" +
+ "</SCRIPT>" +
+ "<SCRIPT Language='VBScript'>" +
+ "Dim stuff" +
+ "stuff = '<A href=\"#\">VBScript</A><BR>'" +
+ "document.writeln(stuff)" +
+ "</SCRIPT>" );
+ WebConversation wc = new WebConversation();
+ WebResponse wr = wc.getResponse( getHostPath() + "/FunkyScript.html" );
+ assertNotNull( "No default script link found", wr.getLinkWith( "Default JavaScript Working" ) );
+ assertNotNull( "No default script link found", wr.getLinkWith( "JavaScript Working" ) );
+ assertNotNull( "No default script link found", wr.getLinkWith( "JavaScript 1.2 Working" ) );
+ assertNull( "VBScript link found", wr.getLinkWith( "VBScript" ) );
+ }
+
+
+
}
|
|
From: Russell G. <rus...@us...> - 2003-01-10 18:22:32
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv20754/src/com/meterware/httpunit
Modified Files:
HTMLPage.java
Log Message:
Now ignoring non-JavaScript scripts
Index: HTMLPage.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HTMLPage.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- HTMLPage.java 30 Dec 2002 21:46:54 -0000 1.22
+++ HTMLPage.java 10 Jan 2003 18:21:44 -0000 1.23
@@ -80,6 +80,8 @@
ArrayList scripts = new ArrayList();
for (int i = 0; i < nl.getLength(); i++) {
Node scriptNode = nl.item(i);
+ String language = NodeUtils.getNodeAttribute( scriptNode, "language", null );
+ if (language != null && !language.startsWith( "JavaScript ")) continue;
String scriptLocation = NodeUtils.getNodeAttribute( scriptNode, "src", null );
if (scriptLocation == null) {
scripts.add( NodeUtils.asText( scriptNode.getChildNodes() ) );
|
|
From: Russell G. <rus...@us...> - 2003-01-10 18:22:32
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/parsing
In directory sc8-pr-cvs1:/tmp/cvs-serv20754/src/com/meterware/httpunit/parsing
Modified Files:
ScriptFilter.java
Log Message:
Now ignoring non-JavaScript scripts
Index: ScriptFilter.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/parsing/ScriptFilter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ScriptFilter.java 25 Dec 2002 15:23:11 -0000 1.2
+++ ScriptFilter.java 10 Jan 2003 18:21:46 -0000 1.3
@@ -91,7 +91,7 @@
private boolean isSupportedScript( QName element, XMLAttributes attrs ) {
if (!element.rawname.equalsIgnoreCase( "script" ) || attrs == null) return false;
String value = attrs.getValue( "language" );
- return value != null && value.toLowerCase().startsWith( SCRIPT_TYPE );
+ return value == null || value.toLowerCase().startsWith( SCRIPT_TYPE );
}
|
|
From: Russell G. <rus...@us...> - 2003-01-10 18:22:21
|
Update of /cvsroot/httpunit/httpunit/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv20754/doc
Modified Files:
release_notes.txt
Added Files:
favicon.ico
Log Message:
Now ignoring non-JavaScript scripts
--- NEW FILE ---
ª
ªª
ªª
ªª
ªª
ªª
ªª
ªª
ªª
ªª
ªª
ªªª
ª
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.243
retrieving revision 1.244
diff -u -r1.243 -r1.244
--- release_notes.txt 9 Jan 2003 18:02:24 -0000 1.243
+++ release_notes.txt 10 Jan 2003 18:21:41 -0000 1.244
@@ -11,9 +11,15 @@
Revision History:
+10-Jan-2003
+ Thanks to Alex Beggs for noting the mishandling of non-JavaScript scripts and providing a test case.
+
+Problems fixed:
+ 1. Scripts marked as something besides JavaScript are now ignored.
+
9-Jan-2003
- Acknolwedgements:
- 1. Thanks to James Howe for noting the mispelling of the getElementById method
+ Acknowledgements:
+ Thanks to James Howe for noting the mispelling of the getElementById method
Problems fixed:
1. Corrected spelling of getElementById
|
|
From: Russell G. <rus...@us...> - 2003-01-09 18:02:27
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript
In directory sc8-pr-cvs1:/tmp/cvs-serv6038/src/com/meterware/httpunit/javascript
Modified Files:
JavaScript.java
Log Message:
fixed spelling of getElementById
Index: JavaScript.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript/JavaScript.java,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- JavaScript.java 30 Dec 2002 21:46:56 -0000 1.43
+++ JavaScript.java 9 Jan 2003 18:02:24 -0000 1.44
@@ -492,7 +492,7 @@
}
- public Object jsFunction_getElementWithID( String id ) {
+ public Object jsFunction_getElementById( String id ) {
return toScriptable( getDelegate().getElementWithID( id ) );
}
|
|
From: Russell G. <rus...@us...> - 2003-01-09 18:02:27
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript
In directory sc8-pr-cvs1:/tmp/cvs-serv6038/test/com/meterware/httpunit/javascript
Modified Files:
HTMLElementTest.java
Log Message:
fixed spelling of getElementById
Index: HTMLElementTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/HTMLElementTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- HTMLElementTest.java 30 Dec 2002 21:46:57 -0000 1.1
+++ HTMLElementTest.java 9 Jan 2003 18:02:24 -0000 1.2
@@ -48,7 +48,7 @@
defineResource( "start.html",
"<html><head><script language='JavaScript'>" +
"function showTitle( id ) {" +
- " alert( 'element with id ' + id + ' has title ' + document.getElementWithID( id ).title );" +
+ " alert( 'element with id ' + id + ' has title ' + document.getElementById( id ).title );" +
"}" +
"function showAll() {" +
" showTitle( 'there' ); showTitle( 'perform' ); showTitle( 'doIt' );" +
@@ -60,7 +60,7 @@
"<form id='perform' title=fifth><input type='submit' id='doIt' title=sixth></form>" +
"</td></tr></table></div>" );
WebConversation wc = new WebConversation();
- WebResponse wr = wc.getResponse( getHostPath() + "/start.html" );
+ wc.getResponse( getHostPath() + "/start.html" );
assertElementTitle( wc, "there", "second" );
assertElementTitle( wc, "perform", "fifth" );
|
|
From: Russell G. <rus...@us...> - 2003-01-09 18:02:27
|
Update of /cvsroot/httpunit/httpunit/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv6038/doc
Modified Files:
Javascript-support.html release_notes.txt
Log Message:
fixed spelling of getElementById
Index: Javascript-support.html
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/Javascript-support.html,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- Javascript-support.html 30 Dec 2002 21:46:52 -0000 1.33
+++ Javascript-support.html 9 Jan 2003 18:02:23 -0000 1.34
@@ -93,7 +93,7 @@
<ul>
<li>open - opens a document for writing, optionally specifying a MIME type</li>
<li>close - closes the open document and replaces its contents with the written text</li>
-<li>getElementByID - returns the element in the document with the specified ID</li>
+<li>getElementById - returns the element in the document with the specified ID</li>
<li>write - writes a string to the contents of the current open document</li>
<li>writeln - writes a line with carriage-return to the contents of the current open document</li>
</ul>
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.242
retrieving revision 1.243
diff -u -r1.242 -r1.243
--- release_notes.txt 3 Jan 2003 16:12:34 -0000 1.242
+++ release_notes.txt 9 Jan 2003 18:02:24 -0000 1.243
@@ -11,6 +11,13 @@
Revision History:
+ 9-Jan-2003
+ Acknolwedgements:
+ 1. Thanks to James Howe for noting the mispelling of the getElementById method
+
+Problems fixed:
+ 1. Corrected spelling of getElementById
+
3-Jan-2003
Additions:
1. ServletRunner.shutDown() will invoke the destroy() methods of any servlets which have been invoked
|
|
From: Russell G. <rus...@us...> - 2003-01-03 16:12:38
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit
In directory sc8-pr-cvs1:/tmp/cvs-serv18497/test/com/meterware/servletunit
Modified Files:
HttpServletRequestTest.java StatelessTest.java
Log Message:
miscellaneous servletunit enhancments
Index: HttpServletRequestTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/HttpServletRequestTest.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- HttpServletRequestTest.java 25 Oct 2002 00:19:25 -0000 1.9
+++ HttpServletRequestTest.java 3 Jan 2003 16:12:35 -0000 1.10
@@ -2,7 +2,7 @@
/********************************************************************************************************************
* $Id$
*
-* Copyright (c) 2000-2001, Russell Gold
+* Copyright (c) 2000-2003 by 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
@@ -38,6 +38,8 @@
/**
* Tests the ServletUnitHttpRequest class.
+ *
+ * @author <a href="mailto:rus...@ht...">Russell Gold</a>
**/
public class HttpServletRequestTest extends ServletUnitTest {
@@ -53,6 +55,25 @@
public HttpServletRequestTest( String name ) {
super( name );
+ }
+
+
+ public void testHeaderAccess() throws Exception {
+ WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
+ wr.setHeaderField( "sample", "value" );
+ HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
+ assertEquals( "sample header value", "value", request.getHeader( "sample") );
+
+ assertContains( "Header names", "sample", request.getHeaderNames() );
+ }
+
+
+ private void assertContains( String comment, String string, Enumeration headerNames ) {
+ while (headerNames != null && headerNames.hasMoreElements()) {
+ String name = (String) headerNames.nextElement();
+ if (name.equalsIgnoreCase( string )) return;
+ }
+ fail( comment + " does not contain " + string );
}
Index: StatelessTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/StatelessTest.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- StatelessTest.java 22 Aug 2002 20:18:32 -0000 1.9
+++ StatelessTest.java 3 Jan 2003 16:12:35 -0000 1.10
@@ -2,7 +2,7 @@
/********************************************************************************************************************
* $Id$
*
- * Copyright (c) 2000-2002, Russell Gold
+ * Copyright (c) 2000-2003, 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
@@ -42,6 +42,8 @@
/**
* Tests support for stateless HttpServlets.
+ *
+ * @author <a href="mailto:rus...@ht...">Russell Gold</a>
**/
public class StatelessTest extends TestCase {
@@ -76,12 +78,17 @@
public void testServletCaching() throws Exception {
final String resourceName = "something/interesting";
+ assertEquals( "Initial instances of servlet class", 0, AccessCountServlet.getNumInstances() );
ServletRunner sr = new ServletRunner();
sr.registerServlet( resourceName, AccessCountServlet.class.getName() );
WebRequest request = new GetMethodWebRequest( "http://localhost/" + resourceName );
assertEquals( "First reply", "1", sr.getResponse( request ).getText().trim() );
+ assertEquals( "Instances of servlet class after first call", 1, AccessCountServlet.getNumInstances() );
assertEquals( "Second reply", "2", sr.getResponse( request ).getText().trim() );
+ assertEquals( "Instances of servlet class after first call", 1, AccessCountServlet.getNumInstances() );
+ sr.shutDown();
+ assertEquals( "Instances of servlet class after shutdown", 0, AccessCountServlet.getNumInstances() );
}
@@ -218,6 +225,25 @@
static class AccessCountServlet extends HttpServlet {
private int _numAccesses;
+
+ private static int _numInstances = 0;
+
+
+ public void init() throws ServletException {
+ super.init();
+ _numInstances++;
+ }
+
+
+ public void destroy() {
+ super.destroy();
+ _numInstances--;
+ }
+
+
+ public static int getNumInstances() {
+ return _numInstances;
+ }
protected void doGet( HttpServletRequest req, HttpServletResponse resp ) throws ServletException, IOException {
|
|
From: Russell G. <rus...@us...> - 2003-01-03 16:12:37
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit
In directory sc8-pr-cvs1:/tmp/cvs-serv18497/src/com/meterware/servletunit
Modified Files:
ServletRunner.java ServletUnitHttpRequest.java
WebApplication.java
Log Message:
miscellaneous servletunit enhancments
Index: ServletRunner.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletRunner.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- ServletRunner.java 17 Oct 2002 23:50:49 -0000 1.19
+++ ServletRunner.java 3 Jan 2003 16:12:35 -0000 1.20
@@ -2,7 +2,7 @@
/********************************************************************************************************************
* $Id$
*
-* Copyright (c) 2000-2002, Russell Gold
+* Copyright (c) 2000-2003, 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
@@ -23,14 +23,9 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
-import java.net.URL;
import java.util.Dictionary;
import java.util.Hashtable;
-import javax.servlet.Servlet;
-import javax.servlet.ServletException;
-import javax.servlet.http.Cookie;
-
import com.meterware.httpunit.HttpUnitUtils;
import com.meterware.httpunit.WebRequest;
import com.meterware.httpunit.WebResponse;
@@ -41,6 +36,8 @@
/**
* This class acts as a test environment for servlets.
+ *
+ * @author <a href="mailto:rus...@ht...">Russell Gold</a>
**/
public class ServletRunner {
@@ -131,6 +128,15 @@
**/
public WebResponse getResponse( String url ) throws MalformedURLException, IOException, SAXException {
return getClient().getResponse( url );
+ }
+
+
+ /**
+ * Shuts down the servlet container, returning any resources held by it.
+ * Calls the destroy method of each active servlet.
+ */
+ public void shutDown() {
+ _application.destroyServlets();
}
Index: ServletUnitHttpRequest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpRequest.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- ServletUnitHttpRequest.java 3 Nov 2002 22:44:13 -0000 1.18
+++ ServletUnitHttpRequest.java 3 Jan 2003 16:12:35 -0000 1.19
@@ -148,7 +148,7 @@
* in which case this method returns null.
**/
public Enumeration getHeaderNames() {
- return null;
+ return _headers.keys();
}
Index: WebApplication.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/WebApplication.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- WebApplication.java 21 Oct 2002 13:34:19 -0000 1.15
+++ WebApplication.java 3 Jan 2003 16:12:35 -0000 1.16
@@ -2,7 +2,7 @@
/********************************************************************************************************************
* $Id$
*
- * Copyright (c) 2001-2002, Russell Gold
+ * Copyright (c) 2001-2003, 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
@@ -50,7 +50,7 @@
* This class represents the information recorded about a single web
* application. It is usually extracted from web.xml.
*
- * @author <a href="mailto:rus...@ac...">Russell Gold</a>
+ * @author <a href="mailto:rus...@ht...">Russell Gold</a>
* @author <a href="ba...@we...">Donald Ball</a>
**/
class WebApplication {
@@ -126,6 +126,14 @@
}
+ /**
+ * Calls the destroy method for every active servlet.
+ */
+ void destroyServlets() {
+ _servletMapping.destroyServlets();
+ }
+
+
ServletRequest getServletRequest( URL url ) {
return _servletMapping.get( url );
}
@@ -392,6 +400,11 @@
}
+ synchronized void destroyServlet() {
+ if (_servlet != null) _servlet.destroy();
+ }
+
+
String getClassName() {
return _className;
}
@@ -437,7 +450,7 @@
SecurityConstraintImpl( Element root ) throws SAXException {
final NodeList roleNames = root.getElementsByTagName( "role-name" );
- for (int i = 0; i < roleNames.getLength(); i++) _roles.add( getTextValue( (Element) roleNames.item( i ) ) );
+ for (int i = 0; i < roleNames.getLength(); i++) _roles.add( getTextValue( roleNames.item( i ) ) );
final NodeList resources = root.getElementsByTagName( "web-resource-collection" );
for (int i = 0; i < resources.getLength(); i++) _resources.add( new WebResourceCollection( (Element) resources.item( i ) ) );
@@ -471,7 +484,7 @@
WebResourceCollection( Element root ) throws SAXException {
final NodeList urlPatterns = root.getElementsByTagName( "url-pattern" );
- for (int i = 0; i < urlPatterns.getLength(); i++) _urlPatterns.add( getTextValue( (Element) urlPatterns.item( i ) ) );
+ for (int i = 0; i < urlPatterns.getLength(); i++) _urlPatterns.add( getTextValue( urlPatterns.item( i ) ) );
}
@@ -559,6 +572,11 @@
String getPathInfo( String servletName ) {
return null;
}
+
+
+ public void destroyServlet() {
+ getConfiguration().destroyServlet();
+ }
}
@@ -642,6 +660,22 @@
return urlFile;
} else {
return urlFile.substring( 0, urlFile.indexOf( '?' ) );
+ }
+ }
+
+
+ public void destroyServlets() {
+ if (_defaultMapping != null) _defaultMapping.destroyServlet();
+ destroyServlets( _exactMatches );
+ destroyServlets( _extensions );
+ destroyServlets( _urlTree );
+ }
+
+
+ private void destroyServlets( Map exactMatches ) {
+ for (Iterator iterator = exactMatches.values().iterator(); iterator.hasNext();) {
+ ServletMapping servletMapping = (ServletMapping) iterator.next();
+ servletMapping.destroyServlet();
}
}
|
|
From: Russell G. <rus...@us...> - 2003-01-03 16:12:37
|
Update of /cvsroot/httpunit/httpunit/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv18497/doc
Modified Files:
release_notes.txt
Log Message:
miscellaneous servletunit enhancments
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.241
retrieving revision 1.242
diff -u -r1.241 -r1.242
--- release_notes.txt 30 Dec 2002 21:46:52 -0000 1.241
+++ release_notes.txt 3 Jan 2003 16:12:34 -0000 1.242
@@ -11,6 +11,12 @@
Revision History:
+ 3-Jan-2003
+Additions:
+ 1. ServletRunner.shutDown() will invoke the destroy() methods of any servlets which have been invoked
+ through that servlet runner.
+ 2. ServletUnit now supports HttpServletRequest.getHeaderNames
+
30-Dec-2002
Additions:
1. Added support for document.getElementByID
|
|
From: Russell G. <rus...@us...> - 2002-12-30 21:47:29
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript
In directory sc8-pr-cvs1:/tmp/cvs-serv25347/src/com/meterware/httpunit/javascript
Modified Files:
JavaScript.java
Log Message:
Added document.getElementByID support
Index: JavaScript.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript/JavaScript.java,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- JavaScript.java 13 Dec 2002 12:57:11 -0000 1.42
+++ JavaScript.java 30 Dec 2002 21:46:56 -0000 1.43
@@ -96,6 +96,7 @@
ScriptableObject.defineClass( scope, Options.class );
ScriptableObject.defineClass( scope, Option.class );
ScriptableObject.defineClass( scope, ElementArray.class );
+ ScriptableObject.defineClass( scope, HTMLElement.class );
}
@@ -276,8 +277,10 @@
/**
* Converts a scriptable delegate obtained from a subobject into the appropriate Rhino-compatible Scriptable.
**/
- final Scriptable toScriptable( ScriptableDelegate delegate ) {
- if (delegate.getScriptEngine() instanceof Scriptable) {
+ final Object toScriptable( ScriptableDelegate delegate ) {
+ if (delegate == null) {
+ return NOT_FOUND;
+ } else if (delegate.getScriptEngine() instanceof Scriptable) {
return (Scriptable) delegate.getScriptEngine();
} else {
try {
@@ -302,6 +305,7 @@
if (delegate instanceof SelectionOptions) return "Options";
if (delegate instanceof SelectionOption) return "Option";
if (delegate instanceof Input) return "Control";
+ if (delegate instanceof DocumentElement) return "HTMLElement";
throw new IllegalArgumentException( "Unknown ScriptableDelegate class: " + delegate.getClass() );
}
@@ -488,6 +492,11 @@
}
+ public Object jsFunction_getElementWithID( String id ) {
+ return toScriptable( getDelegate().getElementWithID( id ) );
+ }
+
+
public Object jsGet_location() {
return _parent == null ? NOT_FOUND : getWindow().jsGet_location();
}
@@ -817,9 +826,14 @@
}
- abstract static public class HTMLElement extends JavaScriptEngine {
+ static public class HTMLElement extends JavaScriptEngine {
private Document _document;
+
+
+ public String getClassName() {
+ return "HTMLElement";
+ }
public Document jsGet_document() {
|
|
From: Russell G. <rus...@us...> - 2002-12-30 21:47:29
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv25347/src/com/meterware/httpunit
Modified Files:
FormControl.java HTMLElementBase.java HTMLPage.java
ParsedHTML.java TableCell.java WebApplet.java WebForm.java
WebLink.java WebTable.java
Added Files:
HTMLElementScriptable.java
Log Message:
Added document.getElementByID support
***** Error reading new file[Errno 2] No such file or directory: 'HTMLElementScriptable.java'
Index: FormControl.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/FormControl.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- FormControl.java 26 Dec 2002 18:55:18 -0000 1.32
+++ FormControl.java 30 Dec 2002 21:46:54 -0000 1.33
@@ -49,10 +49,7 @@
private final String _onClickEvent;
private final WebForm _form;
- private Scriptable _scriptable;
-
-
- FormControl( WebForm form ) {
+ FormControl( WebForm form ) {
super( newEmptyNode( form ) );
_form = form;
_valueAttribute = "";
@@ -100,15 +97,8 @@
}
- /**
- * Returns a scriptable object which can act as a proxy for this control.
- */
- public ScriptableDelegate getScriptableDelegate() {
- if (_scriptable == null) {
- _scriptable = newScriptable();
- _scriptable.setScriptEngine( getForm().getScriptableObject().getScriptEngine( _scriptable ) );
- }
- return _scriptable;
+ protected ScriptableDelegate getParentDelegate() {
+ return getForm().getScriptableDelegate();
}
@@ -234,7 +224,7 @@
* Creates and returns a scriptable object for this control. Subclasses should override this if they use a different
* implementation of Scriptable.
*/
- protected Scriptable newScriptable() {
+ protected ScriptableDelegate newScriptable() {
return new Scriptable();
}
@@ -304,7 +294,7 @@
}
- class Scriptable extends ScriptableDelegate implements Input {
+ class Scriptable extends HTMLElementScriptable implements Input {
public String getName() {
return FormControl.this.getName();
@@ -327,6 +317,11 @@
super.set( propertyName, value );
}
}
+
+
+ public Scriptable() {
+ super( FormControl.this );
+ }
}
}
@@ -340,7 +335,7 @@
private final boolean _isCheckedDefault;
- protected FormControl.Scriptable newScriptable() {
+ protected ScriptableDelegate newScriptable() {
return new Scriptable();
}
@@ -615,7 +610,7 @@
}
- protected FormControl.Scriptable newScriptable() {
+ protected ScriptableDelegate newScriptable() {
return new Scriptable();
}
@@ -723,7 +718,7 @@
private UploadFileSpec _fileToUpload;
- protected FormControl.Scriptable newScriptable() {
+ protected ScriptableDelegate newScriptable() {
return new Scriptable();
}
@@ -857,7 +852,7 @@
}
- protected FormControl.Scriptable newScriptable() {
+ protected ScriptableDelegate newScriptable() {
return new Scriptable();
}
Index: HTMLElementBase.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HTMLElementBase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- HTMLElementBase.java 26 Dec 2002 04:59:35 -0000 1.1
+++ HTMLElementBase.java 30 Dec 2002 21:46:54 -0000 1.2
@@ -19,9 +19,8 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
-import com.meterware.httpunit.scripting.ScriptableDelegate;
-
import org.w3c.dom.Node;
+import com.meterware.httpunit.scripting.ScriptableDelegate;
/**
@@ -33,6 +32,8 @@
class HTMLElementBase implements HTMLElement {
private Node _node;
+ private ScriptableDelegate _scriptable;
+
public String getID() {
@@ -51,10 +52,14 @@
/**
- * Returns the delegate which supports scripting this element.
+ * Returns a scriptable object which can act as a proxy for this control.
*/
public ScriptableDelegate getScriptableDelegate() {
- throw new RuntimeException( "No scripting support for " + getClass().getName() );
+ if (_scriptable == null) {
+ _scriptable = newScriptable();
+ _scriptable.setScriptEngine( getParentDelegate().getScriptEngine( _scriptable ) );
+ }
+ return _scriptable;
}
@@ -76,4 +81,19 @@
protected Node getNode() {
return _node;
}
+
+
+ /**
+ * Creates and returns a scriptable object for this control. Subclasses should override this if they use a different
+ * implementation of Scriptable.
+ */
+ abstract protected ScriptableDelegate newScriptable();
+
+
+ /**
+ * Returns the scriptable delegate which can provide the scriptable delegate for this element.
+ */
+ abstract protected ScriptableDelegate getParentDelegate();
+
+
}
Index: HTMLPage.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HTMLPage.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- HTMLPage.java 25 Dec 2002 15:23:11 -0000 1.21
+++ HTMLPage.java 30 Dec 2002 21:46:54 -0000 1.22
@@ -248,6 +248,12 @@
public String getCookie() {
return getResponse().getCookieHeader();
}
+
+
+ public ScriptableDelegate getElementWithID( String id ) {
+ final HTMLElement elementWithID = HTMLPage.this.getElementWithID( id );
+ return elementWithID == null ? null : elementWithID.getScriptableDelegate();
+ }
}
Index: ParsedHTML.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ParsedHTML.java,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- ParsedHTML.java 26 Dec 2002 20:50:48 -0000 1.42
+++ ParsedHTML.java 30 Dec 2002 21:46:54 -0000 1.43
@@ -28,6 +28,8 @@
import java.util.Iterator;
import java.util.Arrays;
+import com.meterware.httpunit.scripting.ScriptableDelegate;
+
/**
* @author <a href="mailto:rus...@ht...">Russell Gold</a>
* @author <a href="mailto:bx...@bi...">Benoit Xhenseval</a>
@@ -226,6 +228,25 @@
}
+ static class DefaultElementFactory extends HTMLElementFactory {
+
+ HTMLElement toHTMLElement( NodeUtils.PreOrderTraversal pot, ParsedHTML parsedHTML, Element element ) {
+ if (element.getAttribute( "id" ).equals( "" )) return null;
+ return parsedHTML.toDefaultElement( element );
+ }
+
+ protected void addToLists( NodeUtils.PreOrderTraversal pot, HTMLElement htmlElement ) {}
+ }
+
+
+ private HTMLElement toDefaultElement( Element element ) {
+ return new HTMLElementBase( element ) {
+ protected ScriptableDelegate newScriptable() { return new HTMLElementScriptable( this ); }
+ protected ScriptableDelegate getParentDelegate() { return getResponse().getScriptableObject().getDocument(); }
+ };
+ }
+
+
static class WebFormFactory extends HTMLElementFactory {
HTMLElement toHTMLElement( NodeUtils.PreOrderTraversal pot, ParsedHTML parsedHTML, Element element ) {
return parsedHTML.toWebForm( element );
@@ -257,6 +278,7 @@
HTMLElement toHTMLElement( NodeUtils.PreOrderTraversal pot, ParsedHTML parsedHTML, Element element ) {
return parsedHTML.toWebApplet( element );
}
+ protected boolean addToContext() { return true; }
}
@@ -319,6 +341,7 @@
private static HashMap _htmlFactoryClasses = new HashMap();
+ private static HTMLElementFactory _defaultFactory = new DefaultElementFactory();
static {
_htmlFactoryClasses.put( "a", new WebLinkFactory() );
@@ -337,7 +360,8 @@
}
private static HTMLElementFactory getHTMLElementFactory( String tagName ) {
- return (HTMLElementFactory) _htmlFactoryClasses.get( tagName );
+ final HTMLElementFactory factory = (HTMLElementFactory) _htmlFactoryClasses.get( tagName );
+ return factory != null ? factory : _defaultFactory;
}
Index: TableCell.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/TableCell.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- TableCell.java 26 Dec 2002 15:33:56 -0000 1.9
+++ TableCell.java 30 Dec 2002 21:46:54 -0000 1.10
@@ -32,7 +32,9 @@
**/
public class TableCell extends ParsedHTML implements HTMLSegment, HTMLElement {
-
+ private ScriptableDelegate _scriptable;
+
+
/**
* Returns the number of columns spanned by this cell.
**/
@@ -96,7 +98,11 @@
* Returns the delegate which supports scripting this element.
*/
public ScriptableDelegate getScriptableDelegate() {
- throw new RuntimeException( "No scripting support for " + getClass().getName() );
+ if (_scriptable == null) {
+ _scriptable = new HTMLElementScriptable( this );
+ _scriptable.setScriptEngine( getResponse().getScriptableObject().getDocument().getScriptEngine( _scriptable ) );
+ }
+ return _scriptable;
}
Index: WebApplet.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebApplet.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- WebApplet.java 26 Dec 2002 04:59:35 -0000 1.4
+++ WebApplet.java 30 Dec 2002 21:46:54 -0000 1.5
@@ -34,6 +34,7 @@
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
+import com.meterware.httpunit.scripting.ScriptableDelegate;
/**
@@ -205,6 +206,16 @@
throw new RuntimeException( e.toString() );
} catch (SAXException e) {
}
+ }
+
+
+ protected ScriptableDelegate newScriptable() {
+ return new HTMLElementScriptable( this );
+ }
+
+
+ protected ScriptableDelegate getParentDelegate() {
+ return _response.getScriptableObject().getDocument();
}
}
Index: WebForm.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -r1.74 -r1.75
--- WebForm.java 27 Dec 2002 05:09:38 -0000 1.74
+++ WebForm.java 30 Dec 2002 21:46:55 -0000 1.75
@@ -510,7 +510,7 @@
}
- public class Scriptable extends ScriptableDelegate implements NamedDelegate {
+ public class Scriptable extends HTMLElementScriptable implements NamedDelegate {
public String getAction() { return WebForm.this.getAction(); }
public void setAction( String newAction ) { setDestination( newAction ); _presetParameters = null; }
@@ -535,7 +535,7 @@
return getTarget();
} else {
final FormParameter parameter = getParameter( propertyName );
- return parameter == UNKNOWN_PARAMETER ? null : parameter.getScriptableObject();
+ return parameter == UNKNOWN_PARAMETER ? super.get( propertyName ) : parameter.getScriptableObject();
}
}
@@ -570,6 +570,11 @@
result[i] = controls[i].getScriptableDelegate();
}
return result;
+ }
+
+
+ Scriptable() {
+ super( WebForm.this );
}
}
Index: WebLink.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebLink.java,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- WebLink.java 26 Dec 2002 15:33:56 -0000 1.37
+++ WebLink.java 30 Dec 2002 21:46:55 -0000 1.38
@@ -101,7 +101,12 @@
}
- public class Scriptable extends ScriptableDelegate implements NamedDelegate {
+ public class Scriptable extends HTMLElementScriptable implements NamedDelegate {
+
+ public Scriptable() {
+ super( WebLink.this );
+ }
+
public String getName() {
return WebLink.this.getName();
Index: WebTable.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebTable.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- WebTable.java 26 Dec 2002 15:33:56 -0000 1.23
+++ WebTable.java 30 Dec 2002 21:46:55 -0000 1.24
@@ -24,6 +24,7 @@
import java.util.*;
import org.w3c.dom.*;
+import com.meterware.httpunit.scripting.ScriptableDelegate;
/**
* This class represents a table in an HTML page.
@@ -226,6 +227,16 @@
}
+ protected ScriptableDelegate newScriptable() {
+ return new HTMLElementScriptable( this );
+ }
+
+
+ protected ScriptableDelegate getParentDelegate() {
+ return _response.getScriptableObject().getDocument();
+ }
+
+
//----------------------------------- private members -----------------------------------
private Element _dom;
@@ -331,6 +342,15 @@
_cells.add( cell );
}
+
+ protected ScriptableDelegate newScriptable() {
+ return new HTMLElementScriptable( this );
+ }
+
+
+ protected ScriptableDelegate getParentDelegate() {
+ return _response.getScriptableObject().getDocument();
+ }
}
|
|
From: Russell G. <rus...@us...> - 2002-12-30 21:47:26
|
Update of /cvsroot/httpunit/httpunit/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv25347/doc
Modified Files:
Javascript-support.html release_notes.txt
Log Message:
Added document.getElementByID support
Index: Javascript-support.html
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/Javascript-support.html,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- Javascript-support.html 27 Dec 2002 05:09:38 -0000 1.32
+++ Javascript-support.html 30 Dec 2002 21:46:52 -0000 1.33
@@ -93,11 +93,18 @@
<ul>
<li>open - opens a document for writing, optionally specifying a MIME type</li>
<li>close - closes the open document and replaces its contents with the written text</li>
+<li>getElementByID - returns the element in the document with the specified ID</li>
<li>write - writes a string to the contents of the current open document</li>
<li>writeln - writes a line with carriage-return to the contents of the current open document</li>
</ul>
-<h3>Form</h3>
+<h3>HTMLElement</h3>
+<h4>properties</h4>
+<ul>
+<li>title - r/o the title attribute of the element</li>
+</ul>
+
+<h3>Form (inherits from HTMLElement)</h3>
<h4>properties</h4>
<ul>
<li>action - r/w the action associated with the form</li>
@@ -123,7 +130,7 @@
<li>src - read/write - the relative URL of the image</li>
</ul>
-<h3>Link</h3>
+<h3>Link (inherits from HTMLElement)</h3>
<h4>properties</h4>
<ul>
<li>href - read/write - the URL associated with the link</li>
@@ -134,7 +141,7 @@
<li>onMouseOver - invoked when link.mouseOver() is invoked<li>
</ul>
-<h3>Input (and subclasses)</h3>
+<h3>Input (inherits from HTMLElement)</h3>
<h4>properties</h4>
<ul>
<li>form - read-only - the form containing the input</li>
@@ -145,13 +152,13 @@
<li>focus() - a no-op</li>
</ul>
-<h3>Button</h3>
+<h3>Button (inherits from Input)</h3>
<h4>events</h4>
<ul>
<li>onClick - invoked when button.click() is called</li>
</ul>
-<h3>Text</h3>
+<h3>Text (inherits from Input)</h3>
<h4>properties</h4>
<ul>
<li>value - read/write - the current text value</li>
@@ -161,7 +168,7 @@
<li>onChange - invoked when the value of the control is changed via form.setParameter</li>
</ul>
-<h3>TextArea</h3>
+<h3>TextArea (inherits from Input)</h3>
<h4>properties</h4>
<ul>
<li>value - read/write - the current text value</li>
@@ -171,13 +178,13 @@
<li>onChange - invoked when the value of the control is changed via form.setParameter</li>
</ul>
-<h3>Hidden</h3>
+<h3>Hidden (inherits from Input)</h3>
<h4>properties</h4>
<ul>
<li>value - read/write - the current text value</li>
</ul>
-<h3>Password</h3>
+<h3>Password (inherits from Input)</h3>
<h4>properties</h4>
<ul>
<li>value - read/write - the current text value</li>
@@ -187,7 +194,7 @@
<li>onChange - invoked when the value of the control is changed via form.setParameter</li>
</ul>
-<h3>Checkbox</h3>
+<h3>Checkbox (inherits from Input)</h3>
<h4>properties</h4>
<ul>
<li>checked - read/write - the state of the checkbox</li>
@@ -199,7 +206,7 @@
<li>onClick - invoked when the state of the control is changed via form.setParameter or form.removeParameter</li>
</ul>
-<h3>Radio</h3>
+<h3>Radio (inherits from Input)</h3>
<h4>properties</h4>
<ul>
<li>checked - read/write - the state of the radio button</li>
@@ -211,7 +218,7 @@
<li>onClick - invoked when the state of the control is changed via form.setParameter</li>
</ul>
-<h3>Select</h3>
+<h3>Select (inherits from Input)</h3>
<h4>properties</h4>
<ul>
<li>length - read-only - the number of options associated with the control</li>
@@ -224,7 +231,7 @@
<li>onChange - invoked when the value of the control is changed via form.setParameter</li>
</ul>
-<h3>Option</h3>
+<h3>Option (inherits from Input)</h3>
<h4>constructor</h4>
You may construct an Option object and assign it to an element in the Select.options array
<h4>properties</h4>
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.240
retrieving revision 1.241
diff -u -r1.240 -r1.241
--- release_notes.txt 27 Dec 2002 13:43:11 -0000 1.240
+++ release_notes.txt 30 Dec 2002 21:46:52 -0000 1.241
@@ -11,6 +11,11 @@
Revision History:
+30-Dec-2002
+Additions:
+ 1. Added support for document.getElementByID
+ 2. all HTML elements with id attributes are now accessible
+
27-Dec-2002
Additions:
1. Added getFragmentIdentifier() to WebRequestSource (parent of WebLink, WebForm, and WebImage)
@@ -27,26 +32,26 @@
25-Dec-2002
Notes:
- get...WithID was incorrectly doing case insensitive matches. It is now case-sensitive, since that is the way the
- ID attribute is defined.
+ 1. get...WithID was incorrectly doing case insensitive matches. It is now case-sensitive, since that is the way the
+ ID attribute is defined.
24-Dec-2002
Additions:
- HTMLParserFactory now supports methods to explicitly select the parser without playing with the class path.
- This includes support for additional parsers not bundled with HttpUnit.
+ 1. HTMLParserFactory now supports methods to explicitly select the parser without playing with the class path.
+ This includes support for additional parsers not bundled with HttpUnit.
22-Dec-2002
Thanks to John Sinclair for noting the lack of line breaks in manifest.mf and proposing a fix
Problems fixed:
- The manifest.mf file now has line breaks between properties
+ 1. The manifest.mf file now has line breaks between properties
19-Dec-2002
Thanks to Bernhard Wagner for adding some parser customization code.
Additions:
- You may call HTMLParserFactory.setPreserveTagCase and setReturnHTMLDocument to control whether the parser coerces
- the case of tags and attributes or returns a HTMLDocument object, respectively.
+ 1. You may call HTMLParserFactory.setPreserveTagCase and setReturnHTMLDocument to control whether the parser coerces
+ the case of tags and attributes or returns a HTMLDocument object, respectively.
18-Dec-2001
Acknowledgements:
|
|
From: Russell G. <rus...@us...> - 2002-12-30 21:47:01
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript
In directory sc8-pr-cvs1:/tmp/cvs-serv25347/test/com/meterware/httpunit/javascript
Modified Files:
JavaScriptTestSuite.java
Added Files:
HTMLElementTest.java
Log Message:
Added document.getElementByID support
***** Error reading new file[Errno 2] No such file or directory: 'HTMLElementTest.java'
Index: JavaScriptTestSuite.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/JavaScriptTestSuite.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JavaScriptTestSuite.java 9 Oct 2002 01:58:23 -0000 1.2
+++ JavaScriptTestSuite.java 30 Dec 2002 21:46:58 -0000 1.3
@@ -40,6 +40,7 @@
result.addTest( ScriptingTest.suite() );
result.addTest( DocumentScriptingTest.suite() );
result.addTest( FormScriptingTest.suite() );
+ result.addTest( HTMLElementTest.suite() );
return result;
}
}
|
|
From: Russell G. <rus...@us...> - 2002-12-30 21:47:00
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/applet In directory sc8-pr-cvs1:/tmp/cvs-serv25347/test/com/meterware/httpunit/applet Removed Files: AppletTest.java Log Message: Added document.getElementByID support |
|
From: Russell G. <rus...@us...> - 2002-12-30 21:47:00
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv25347/test/com/meterware/httpunit
Modified Files:
HttpUnitSuite.java
Added Files:
WebAppletTest.java
Log Message:
Added document.getElementByID support
***** Error reading new file[Errno 2] No such file or directory: 'WebAppletTest.java'
Index: HttpUnitSuite.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/HttpUnitSuite.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- HttpUnitSuite.java 24 Dec 2002 17:17:03 -0000 1.30
+++ HttpUnitSuite.java 30 Dec 2002 21:46:56 -0000 1.31
@@ -54,6 +54,7 @@
result.addTest( PseudoServerTest.suite() );
result.addTest( WebClientTest.suite() );
result.addTest( MessageBodyRequestTest.suite() );
+ result.addTest( WebAppletTest.suite() );
result.addTest( CookieTest.suite() );
result.addTest( ParsingTestSuite.suite() );
|
|
From: Russell G. <rus...@us...> - 2002-12-30 21:47:00
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/scripting In directory sc8-pr-cvs1:/tmp/cvs-serv25347/src/com/meterware/httpunit/scripting Added Files: DocumentElement.java Log Message: Added document.getElementByID support ***** Error reading new file[Errno 2] No such file or directory: 'DocumentElement.java' |
|
From: Russell G. <rus...@us...> - 2002-12-27 13:43:14
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv21436/test/com/meterware/httpunit
Modified Files:
WebLinkTest.java
Log Message:
Added getFragmentIdentifier
Index: WebLinkTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebLinkTest.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- WebLinkTest.java 14 Oct 2002 04:19:06 -0000 1.25
+++ WebLinkTest.java 27 Dec 2002 13:43:11 -0000 1.26
@@ -19,16 +19,8 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
-
-import java.net.URL;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
-import java.util.Vector;
-import java.util.Enumeration;
-
/**
* Tests for the WebLink class.
@@ -43,7 +35,7 @@
}
- public static Test suite() {
+ public static TestSuite suite() {
return new TestSuite( WebLinkTest.class );
}
@@ -58,10 +50,10 @@
defineResource( "SimplePage.html",
"<html><head><title>A Sample Page</title></head>\n" +
"<body>This has no forms but it does\n" +
- "have <a href=\"/other.html\" id=\"activeID\">an <b>active</b> link</A>\n" +
+ "have <a href='/other.html#middle' id='activeID'>an <b>active</b> link</A>\n" +
" and <a name=here>an anchor</a>\n" +
- "<a href=\"basic.html\" name=\"nextLink\"><IMG SRC=\"/images/arrow.gif\" ALT=\"Next -->\" WIDTH=1 HEIGHT=4></a>\n" +
- "<a href=\"another.html\" name=\"myLink\">some text</a>\n" +
+ "<a href='basic.html' name=\"nextLink\"><IMG SRC=\"/images/arrow.gif\" ALT=\"Next -->\" WIDTH=1 HEIGHT=4></a>\n" +
+ "<a href='another.html' name='myLink'>some text</a>\n" +
"</body></html>\n" );
WebConversation wc = new WebConversation();
@@ -151,6 +143,15 @@
link = _simplePage.getLinkWithName( "nextLink" );
assertNotNull( "the image link was not found", link );
assertEquals( "image link URL", getHostPath() + "/basic.html", link.getRequest().getURL().toExternalForm() );
+ }
+
+
+ public void testFragmentIdentifier() throws Exception {
+ WebLink link = (WebLink) _simplePage.getElementWithID( "activeID" );
+ assertNotNull( "the active link was not found", link );
+ assertEquals( "fragment identifier #1", "middle", link.getFragmentIdentifier() );
+
+ assertEquals( "fragment identifier #2", "", _simplePage.getLinks()[1].getFragmentIdentifier() );
}
|
|
From: Russell G. <rus...@us...> - 2002-12-27 13:43:14
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv21436/src/com/meterware/httpunit
Modified Files:
WebRequestSource.java
Log Message:
Added getFragmentIdentifier
Index: WebRequestSource.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequestSource.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- WebRequestSource.java 27 Dec 2002 05:09:38 -0000 1.22
+++ WebRequestSource.java 27 Dec 2002 13:43:11 -0000 1.23
@@ -20,8 +20,6 @@
*******************************************************************************************************************/
package com.meterware.httpunit;
-import com.meterware.httpunit.scripting.ScriptableDelegate;
-
import org.w3c.dom.Node;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
@@ -70,6 +68,20 @@
return WebFrame.getTargetFrameName( _pageFrame, getSpecifiedTarget() );
}
}
+
+
+ /**
+ * Returns the fragment identifier for this request source, used to identifier an element within an HTML document.
+ */
+ public String getFragmentIdentifier() {
+ final int hashIndex = getDestination().indexOf( '#' );
+ if (hashIndex < 0) {
+ return "";
+ } else {
+ return getDestination().substring( hashIndex+1 );
+ }
+ }
+
/**
* Returns a copy of the domain object model subtree associated with this entity.
|
|
From: Russell G. <rus...@us...> - 2002-12-27 13:43:14
|
Update of /cvsroot/httpunit/httpunit/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv21436/doc
Modified Files:
release_notes.txt
Log Message:
Added getFragmentIdentifier
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.239
retrieving revision 1.240
diff -u -r1.239 -r1.240
--- release_notes.txt 27 Dec 2002 05:09:38 -0000 1.239
+++ release_notes.txt 27 Dec 2002 13:43:11 -0000 1.240
@@ -11,6 +11,10 @@
Revision History:
+27-Dec-2002
+Additions:
+ 1. Added getFragmentIdentifier() to WebRequestSource (parent of WebLink, WebForm, and WebImage)
+
26-Dec-2002
Additions:
1. WebResponse and TableCell now support the getElementWithID method, which returns any supported HTMLElement, given its ID.
|
|
From: Russell G. <rus...@us...> - 2002-12-27 05:09:41
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv1498/src/com/meterware/httpunit
Modified Files:
WebForm.java WebRequestSource.java
Log Message:
Added JavaScript Form.target support
Index: WebForm.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -r1.73 -r1.74
--- WebForm.java 26 Dec 2002 18:55:18 -0000 1.73
+++ WebForm.java 27 Dec 2002 05:09:38 -0000 1.74
@@ -531,8 +531,25 @@
public Object get( String propertyName ) {
- final FormParameter parameter = getParameter( propertyName );
- return parameter == UNKNOWN_PARAMETER ? null : parameter.getScriptableObject();
+ if (propertyName.equals( "target" )) {
+ return getTarget();
+ } else {
+ final FormParameter parameter = getParameter( propertyName );
+ return parameter == UNKNOWN_PARAMETER ? null : parameter.getScriptableObject();
+ }
+ }
+
+
+ /**
+ * Sets the value of the named property. Will throw a runtime exception if the property does not exist or
+ * cannot accept the specified value.
+ **/
+ public void set( String propertyName, Object value ) {
+ if (propertyName.equals( "target" )) {
+ setTargetAttribute( value.toString() );
+ } else {
+ super.set( propertyName, value );
+ }
}
Index: WebRequestSource.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequestSource.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- WebRequestSource.java 26 Dec 2002 04:59:35 -0000 1.21
+++ WebRequestSource.java 27 Dec 2002 05:09:38 -0000 1.22
@@ -23,6 +23,7 @@
import com.meterware.httpunit.scripting.ScriptableDelegate;
import org.w3c.dom.Node;
+import org.w3c.dom.Element;
import org.xml.sax.SAXException;
import java.net.URL;
@@ -250,6 +251,11 @@
private String getSpecifiedTarget() {
return getAttribute( "target" );
+ }
+
+
+ protected void setTargetAttribute( String value ) {
+ ((Element) _node).setAttribute( "target", value );
}
|
|
From: Russell G. <rus...@us...> - 2002-12-27 05:09:41
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript
In directory sc8-pr-cvs1:/tmp/cvs-serv1498/test/com/meterware/httpunit/javascript
Modified Files:
FormScriptingTest.java
Log Message:
Added JavaScript Form.target support
Index: FormScriptingTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/FormScriptingTest.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- FormScriptingTest.java 27 Nov 2002 15:06:41 -0000 1.15
+++ FormScriptingTest.java 27 Dec 2002 05:09:38 -0000 1.16
@@ -440,6 +440,26 @@
}
+ public void testFormTargetProperty() throws Exception {
+ WebConversation wc = new WebConversation();
+ defineWebPage( "Default", "<form method=GET name='the_form' action = 'ask'>" +
+ "<Input type=text name=age>" +
+ "<Input type=submit value=Go>" +
+ "</form>" +
+ "<a href='#' name='doTell' onClick='document.the_form.target=\"_blank\";'>tell</a>" +
+ "<a href='#' name='doShow' onClick='alert( document.the_form.target );'>show</a>" );
+ WebResponse page = wc.getResponse( getHostPath() + "/Default.html" );
+ page.getLinkWithName( "doShow" ).click();
+ assertEquals( "Initial target", "_top", wc.popNextAlert() );
+ page.getLinkWithName( "doTell" ).click();
+ page.getLinkWithName( "doShow" ).click();
+ assertEquals( "Current target", "_blank", wc.popNextAlert() );
+
+ WebRequest request = page.getForms()[0].getRequest();
+ assertEquals( "_blank", request.getTarget() );
+ }
+
+
public void testFormValidationOnSubmit() throws Exception {
defineResource( "doIt?color=pink", "You got it!", "text/plain" );
defineResource( "OnCommand.html", "<html><head><script language='JavaScript'>" +
|