httpunit-commit Mailing List for httpunit (Page 21)
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-04-18 14:43:45
|
Update of /cvsroot/httpunit/httpunit/site/com/meterware/website In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24172/site/com/meterware/website Modified Files: Site.java Log Message: Allow non-sourceforge hosting for sites Index: Site.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/site/com/meterware/website/Site.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- Site.java 2 Mar 2004 10:51:39 -0000 1.7 +++ Site.java 18 Apr 2004 14:43:37 -0000 1.8 @@ -250,10 +250,12 @@ if (!currentPage.isLicense()) { sb.append( "<hr/><div style='position:relative'>" ).append( FragmentTemplate.LINE_BREAK ); sb.append( " <div>" ).append( _copyRight.getNotice() ).append( "</div>" ).append( FragmentTemplate.LINE_BREAK ); - sb.append( " <div class='sourceforge'>Hosted by <IMG SRC='http://sourceforge.net/sflogo.php?group_id=" ); - sb.append( _groupId ).append( "&type=1' width='88' height='31' border='0' alt='SourceForge Logo' " ); - sb.append( "naturalsizeflag='0' align='TOP'></div>" ); - sb.append( "</div>" ).append( FragmentTemplate.LINE_BREAK ); + if (_groupId != 0) { + sb.append( " <div class='sourceforge'>Hosted by <IMG SRC='http://sourceforge.net/sflogo.php?group_id=" ); + sb.append( _groupId ).append( "&type=1' width='88' height='31' border='0' alt='SourceForge Logo' " ); + sb.append( "naturalsizeflag='0' align='TOP'></div>" ); + sb.append( "</div>" ).append( FragmentTemplate.LINE_BREAK ); + } } sb.append( "</div>" ).append( FragmentTemplate.LINE_BREAK ); sb.append( "</body></html>" ); |
|
From: Russell G. <rus...@us...> - 2004-03-15 02:51:20
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22771/src/com/meterware/servletunit Modified Files: InvocationContextImpl.java ServletUnitHttpRequest.java Log Message: bug #872129: Cookie header set on a web request was ignored in servletunit Index: InvocationContextImpl.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/InvocationContextImpl.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- InvocationContextImpl.java 26 Feb 2004 17:36:47 -0000 1.15 +++ InvocationContextImpl.java 15 Mar 2004 02:42:16 -0000 1.16 @@ -26,10 +26,8 @@ import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; -import java.util.ArrayList; import java.util.Dictionary; import java.util.Stack; -import java.util.StringTokenizer; import javax.servlet.*; @@ -185,9 +183,6 @@ URL requestURL = request.getURL(); final ServletUnitHttpRequest suhr = new ServletUnitHttpRequest( _application.getServletRequest( requestURL ), request, runner.getContext(), clientHeaders, messageBody ); - Cookie[] cookies = getCookies( clientHeaders ); - for (int i = 0; i < cookies.length; i++) suhr.addCookie( cookies[i] ); - if (_application.usesBasicAuthentication()) suhr.readBasicAuthentication(); else if (_application.usesFormAuthentication()) suhr.readFormAuthentication(); @@ -200,7 +195,6 @@ } - private URL computeEffectiveUrl( HttpServletRequest request, URL requestURL ) { if (!_application.requiresAuthorization( requestURL ) || userIsAuthorized( request, requestURL ) ) { return requestURL; @@ -320,9 +314,6 @@ //------------------------------ private members --------------------------------------- - final private static Cookie[] NO_COOKIES = new Cookie[0]; - - private ServletUnitClient _client; private WebApplication _application; private String _target; @@ -330,23 +321,6 @@ private WebResponse _webResponse; - private Cookie[] getCookies( Dictionary clientHeaders ) { - String cookieHeader = (String) clientHeaders.get( "Cookie" ); - if (cookieHeader == null) return NO_COOKIES; - ArrayList cookies = new ArrayList(); - - StringTokenizer st = new StringTokenizer( cookieHeader, "=;" ); - while (st.hasMoreTokens()) { - String name = st.nextToken(); - if (st.hasMoreTokens()) { - String value = st.nextToken(); - cookies.add( new Cookie( name, value ) ); - } - } - return (Cookie[]) cookies.toArray( new Cookie[ cookies.size() ] ); - } - - private ExecutionContext getContext() { return (ExecutionContext) _contextStack.lastElement(); } Index: ServletUnitHttpRequest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpRequest.java,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- ServletUnitHttpRequest.java 14 Mar 2004 22:59:49 -0000 1.32 +++ ServletUnitHttpRequest.java 15 Mar 2004 02:42:16 -0000 1.33 @@ -63,6 +63,7 @@ _headers = new WebClient.HeaderDictionary(); _headers.addEntries( clientHeaders ); _headers.addEntries( request.getHeaders() ); + setCookiesFromHeader( _headers ); _messageBody = messageBody; _secure = request.getURL().getProtocol().equalsIgnoreCase( "https" ); @@ -695,7 +696,7 @@ //--------------------------------------------- package members ---------------------------------------------- - void addCookie( Cookie cookie ) { + private void addCookie( Cookie cookie ) { _cookies.addElement( cookie ); if (cookie.getName().equalsIgnoreCase( ServletUnitHttpSession.SESSION_COOKIE_NAME )) { _sessionID = cookie.getValue(); @@ -765,6 +766,20 @@ } + private void setCookiesFromHeader( Dictionary clientHeaders ) { + String cookieHeader = (String) clientHeaders.get( "Cookie" ); + if (cookieHeader == null) return; + + StringTokenizer st = new StringTokenizer( cookieHeader, "=;" ); + while (st.hasMoreTokens()) { + String name = st.nextToken(); + if (st.hasMoreTokens()) { + addCookie( new Cookie( name, st.nextToken() ) ); + } + } + } + + static class PrioritizedLocale implements Comparable { private Locale _locale; |
|
From: Russell G. <rus...@us...> - 2004-03-15 02:51:20
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22771/src/com/meterware/httpunit Modified Files: FormParameter.java WebClient.java WebForm.java Log Message: bug #872129: Cookie header set on a web request was ignored in servletunit Index: FormParameter.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/FormParameter.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- FormParameter.java 24 Jun 2003 22:40:36 -0000 1.6 +++ FormParameter.java 15 Mar 2004 02:42:16 -0000 1.7 @@ -100,13 +100,39 @@ } + public void toggleCheckbox( String value ) { + FormControl[] controls = getControls(); + for (int i = 0; i < controls.length; i++) { + FormControl control = controls[i]; + if (value.equals( control.getValueAttribute())) { + control.toggle(); + return; + } + } + throw new IllegalCheckboxParameterException( _name + "/" + value , "toggleCheckbox" ); + } + + public void setValue( boolean state ) { FormControl[] controls = getControls(); - if (controls.length != 1) throw new IllegalCheckboxParameterException( _name, "toggleCheckbox" ); + if (controls.length != 1) throw new IllegalCheckboxParameterException( _name, "setCheckbox" ); controls[0].setState( state ); } + public void setValue( String value, boolean state ) { + FormControl[] controls = getControls(); + for (int i = 0; i < controls.length; i++) { + FormControl control = controls[i]; + if (value.equals( control.getValueAttribute())) { + control.setState( state ); + return; + } + } + throw new IllegalCheckboxParameterException( _name + "/" + value , "setCheckbox" ); + } + + void setFiles( UploadFileSpec[] fileArray ) { ArrayList list = new ArrayList( fileArray.length ); list.addAll( Arrays.asList( fileArray ) ); Index: WebClient.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebClient.java,v retrieving revision 1.53 retrieving revision 1.54 diff -u -r1.53 -r1.54 --- WebClient.java 12 Feb 2004 05:36:29 -0000 1.53 +++ WebClient.java 15 Mar 2004 02:42:16 -0000 1.54 @@ -583,6 +583,12 @@ } } + + public boolean containsKey( Object key ) { + return super.containsKey( matchPreviousFieldName( key.toString() ) ); + } + + public Object get( Object fieldName ) { return (String) super.get( matchPreviousFieldName( fieldName.toString() ) ); } Index: WebForm.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v retrieving revision 1.87 retrieving revision 1.88 diff -u -r1.87 -r1.88 --- WebForm.java 5 Dec 2003 04:06:53 -0000 1.87 +++ WebForm.java 15 Mar 2004 02:42:16 -0000 1.88 @@ -548,6 +548,20 @@ /** + * Toggles the value of the specified checkbox parameter. + * @param name the name of the checkbox parameter + * @param value of the checkbox parameter + * @throws IllegalArgumentException if the specified parameter is not a checkbox or if there is no checkbox + * with the specified name and value. + */ + public void toggleCheckbox( String name, String value ) { + FormParameter parameter = getParameter( name ); + if (parameter == null) throw new NoSuchParameterException( name ); + parameter.toggleCheckbox( value ); + } + + + /** * Sets the value of the specified checkbox parameter. * @param name the name of the checkbox parameter * @param state the new state of the checkbox @@ -561,6 +575,21 @@ } + /** + * Sets the value of the specified checkbox parameter. + * @param name the name of the checkbox parameter + * @param value of the checkbox parameter + * @param state the new state of the checkbox + * @throws IllegalArgumentException if the specified parameter is not a checkbox or if there is no checkbox + * with the specified name and value. + */ + public void setCheckbox( String name, String value, boolean state ) { + FormParameter parameter = getParameter( name ); + if (parameter == null) throw new NoSuchParameterException( name ); + parameter.setValue( value, state ); + } + + public class Scriptable extends HTMLElementScriptable implements NamedDelegate { public String getAction() { return WebForm.this.getAction(); } public void setAction( String newAction ) { setDestination( newAction ); _presetParameters = null; } |
|
From: Russell G. <rus...@us...> - 2004-03-15 02:51:19
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22771/test/com/meterware/httpunit Modified Files: FormParametersTest.java Log Message: bug #872129: Cookie header set on a web request was ignored in servletunit Index: FormParametersTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FormParametersTest.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- FormParametersTest.java 24 Jun 2003 22:40:36 -0000 1.21 +++ FormParametersTest.java 15 Mar 2004 02:42:16 -0000 1.22 @@ -279,6 +279,17 @@ } catch (IllegalRequestParameterException e) { } + form.toggleCheckbox( "color", "red" ); + assertMatchingSet( "color checkboxes", new String[] { "red" }, form.getParameterValues( "color" ) ); + form.setCheckbox( "color", "blue", true ); + assertMatchingSet( "color checkboxes", new String[] { "red", "blue" }, form.getParameterValues( "color" ) ); + + try { + form.setCheckbox( "color", "green", true ); + fail( "Did not forbid setting checkbox with unknown value" ); + } catch (IllegalRequestParameterException e) { + } + } |
|
From: Russell G. <rus...@us...> - 2004-03-15 02:51:19
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22771/test/com/meterware/servletunit Modified Files: HttpServletRequestTest.java Log Message: bug #872129: Cookie header set on a web request was ignored in servletunit Index: HttpServletRequestTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/HttpServletRequestTest.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- HttpServletRequestTest.java 14 Mar 2004 22:59:49 -0000 1.21 +++ HttpServletRequestTest.java 15 Mar 2004 02:42:16 -0000 1.22 @@ -236,10 +236,10 @@ } - public void testSetCookies() throws Exception { + public void testSetCookieViaRequestHeader() throws Exception { WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" ); + wr.setHeaderField( "Cookie", "flavor=vanilla"); ServletUnitHttpRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY ); - request.addCookie( new Cookie( "flavor", "vanilla" ) ); Cookie[] cookies = request.getCookies(); assertNotNull( "No cookies found", cookies ); @@ -273,13 +273,14 @@ * will cause a session to be made available. */ public void testRetrieveSession() throws Exception { - WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" ); ServletUnitContext context = new ServletUnitContext(); - - ServletUnitHttpRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, context, new Hashtable(), NO_MESSAGE_BODY ); final ServletUnitHttpSession session = context.newSession(); final String sessionID = session.getId(); - request.addCookie( new Cookie( ServletUnitHttpSession.SESSION_COOKIE_NAME, sessionID ) ); + + WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" ); + wr.setHeaderField( "Cookie", ServletUnitHttpSession.SESSION_COOKIE_NAME + '=' + sessionID); + + ServletUnitHttpRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, context, new Hashtable(), NO_MESSAGE_BODY ); assertEquals( "Requested session ID defined in request", sessionID, request.getRequestedSessionId() ); assertSame( "Session returned when creation not requested", session, request.getSession( /* create */ false ) ); @@ -318,14 +319,14 @@ * Obtains a new session, invalidates it, and verifies that */ public void testSessionInvalidation() throws Exception { - WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" ); ServletUnitContext context = new ServletUnitContext(); - HttpSession originalSession = context.newSession(); String originalID = originalSession.getId(); + WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" ); + wr.setHeaderField( "Cookie", ServletUnitHttpSession.SESSION_COOKIE_NAME + '=' + originalID); + ServletUnitHttpRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, context, new Hashtable(), NO_MESSAGE_BODY ); - request.addCookie( new Cookie( ServletUnitHttpSession.SESSION_COOKIE_NAME, originalID ) ); originalSession.setAttribute( "Initial", new Integer( 1 ) ); Enumeration attributeNames = originalSession.getAttributeNames(); assertTrue( attributeNames.hasMoreElements() ); @@ -347,18 +348,18 @@ * Verifies that a request with a bad session ID causes a new session to be generated only when explicitly requested. */ public void testGetSessionWithBadCookie() throws Exception { - WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" ); ServletUnitContext context = new ServletUnitContext(); - ServletUnitHttpRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, context, new Hashtable(), NO_MESSAGE_BODY ); - HttpSession originalSession = context.newSession(); String originalID = originalSession.getId(); - request.addCookie( new Cookie( ServletUnitHttpSession.SESSION_COOKIE_NAME, originalID ) ); + + WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" ); + wr.setHeaderField( "Cookie", ServletUnitHttpSession.SESSION_COOKIE_NAME + '=' + originalID); + + ServletUnitHttpRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, context, new Hashtable(), NO_MESSAGE_BODY ); request.getSession(); - String badID = originalID + "BAD"; + wr.setHeaderField( "Cookie", ServletUnitHttpSession.SESSION_COOKIE_NAME + '=' + (originalID + "BAD")); request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, context, new Hashtable(), NO_MESSAGE_BODY ); - request.addCookie( new Cookie( ServletUnitHttpSession.SESSION_COOKIE_NAME, badID ) ); assertNull( "Unexpected session returned for bad cookie", request.getSession( false ) ); assertNotNull( "Should have returned session when asked", request.getSession( true )); |
|
From: Russell G. <rus...@us...> - 2004-03-15 02:51:19
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22771/doc Modified Files: release_notes.txt todo.txt Log Message: bug #872129: Cookie header set on a web request was ignored in servletunit Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.329 retrieving revision 1.330 diff -u -r1.329 -r1.330 --- release_notes.txt 9 Mar 2004 21:49:17 -0000 1.329 +++ release_notes.txt 15 Mar 2004 02:42:16 -0000 1.330 @@ -13,9 +13,17 @@ Revision History: +14-Mar-2004 + Additions: + 1. RFE #909922: ServletUnit now supports HttpServletRequest.getHeaders + 2. setCheckbox() and toggleCheckbox() have now been expanded to select one of a group of checkboxes by specifying + its name. + Problems fixed: + 1. bug #872129: Cookie header set on a web request was ignored in servletunit + 9-Mar-2004 Problems fixed: - 1. Support JavaScript changing "disabled" attribute on form controls + 1. bug #861866: Support JavaScript changing "disabled" attribute on form controls 2. Forms defined after a <script> section which accessed document.forms would not be found if document.forms was also accessed in a subsequent <script> section after the new form definition. Notes: Index: todo.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/todo.txt,v retrieving revision 1.41 retrieving revision 1.42 diff -u -r1.41 -r1.42 --- todo.txt 20 Aug 2003 12:06:14 -0000 1.41 +++ todo.txt 15 Mar 2004 02:42:16 -0000 1.42 @@ -1,4 +1,7 @@ High priority: +o behavior of request vs client headers does not match javascript - should possibly throw exception if any headers are not + settable on the request. + o Writeable 'name' Javascript attribute o NoOp request when link is to same page w/o new parameters? o Disable content-type header in MIME encoding? |
|
From: Russell G. <rus...@us...> - 2004-03-14 23:08:51
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10489/test/com/meterware/servletunit Modified Files: HttpServletRequestTest.java Log Message: rfe 909922: implement HttpServletRequest.getHeaders Index: HttpServletRequestTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/HttpServletRequestTest.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- HttpServletRequestTest.java 2 Mar 2004 10:54:15 -0000 1.20 +++ HttpServletRequestTest.java 14 Mar 2004 22:59:49 -0000 1.21 @@ -68,6 +68,11 @@ assertEquals( "sample header value", "value", request.getHeader( "sample") ); assertContains( "Header names", "sample", request.getHeaderNames() ); + Enumeration e = request.getHeaders( "Sample" ); + assertNotNull( "No header enumeration returned", e ); + assertTrue( "Enumeration is empty", e.hasMoreElements() ); + assertEquals( "first header", "value", e.nextElement() ); + assertFalse( "Enumeration has spurious header value", e.hasMoreElements() ); } |
|
From: Russell G. <rus...@us...> - 2004-03-14 23:08:51
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10489/src/com/meterware/servletunit Modified Files: ServletUnitHttpRequest.java Log Message: rfe 909922: implement HttpServletRequest.getHeaders Index: ServletUnitHttpRequest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpRequest.java,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- ServletUnitHttpRequest.java 2 Mar 2004 10:54:14 -0000 1.31 +++ ServletUnitHttpRequest.java 14 Mar 2004 22:59:49 -0000 1.32 @@ -621,7 +621,9 @@ * Returns all the values of the specified request header as an Enumeration of String objects. **/ public java.util.Enumeration getHeaders( String name ) { - throw new RuntimeException( "getHeaders not implemented" ); + Vector list = new Vector(); + if (_headers.containsKey( name )) list.add( _headers.get( name )); + return list.elements(); } |
|
From: Russell G. <rus...@us...> - 2004-03-09 22:14:57
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/scripting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15032/src/com/meterware/httpunit/scripting Modified Files: ScriptableDelegate.java ScriptingEngine.java Log Message: recache scripted elements before running script sections Index: ScriptableDelegate.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/scripting/ScriptableDelegate.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- ScriptableDelegate.java 23 Sep 2003 12:13:44 -0000 1.9 +++ ScriptableDelegate.java 9 Mar 2004 21:49:18 -0000 1.10 @@ -39,6 +39,7 @@ public boolean performEvent( String eventScript ) { return true; } public String evaluateScriptExpression( String urlString ) { return null; } public ScriptingEngine newScriptingEngine( ScriptableDelegate child ) { return this; } + public void clearCaches() {} }; Index: ScriptingEngine.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/scripting/ScriptingEngine.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- ScriptingEngine.java 23 Sep 2003 12:13:44 -0000 1.6 +++ ScriptingEngine.java 9 Mar 2004 21:49:18 -0000 1.7 @@ -57,4 +57,10 @@ */ public ScriptingEngine newScriptingEngine( ScriptableDelegate child ); + + /** + * Clears any cached values, permitting them to be recomputed as needed. + */ + public void clearCaches(); + } |
|
From: Russell G. <rus...@us...> - 2004-03-09 22:14:57
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15032/doc Modified Files: release_notes.txt Log Message: recache scripted elements before running script sections Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.328 retrieving revision 1.329 diff -u -r1.328 -r1.329 --- release_notes.txt 9 Mar 2004 20:32:30 -0000 1.328 +++ release_notes.txt 9 Mar 2004 21:49:17 -0000 1.329 @@ -16,6 +16,8 @@ 9-Mar-2004 Problems fixed: 1. Support JavaScript changing "disabled" attribute on form controls + 2. Forms defined after a <script> section which accessed document.forms would not be found if document.forms + was also accessed in a subsequent <script> section after the new form definition. Notes: 1. Upgraded NekoHTML to 0.9.1 2. Upgraded Xerces to 2.5.0 |
|
From: Russell G. <rus...@us...> - 2004-03-09 22:14:57
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/parsing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15032/src/com/meterware/httpunit/parsing Modified Files: ScriptFilter.java Log Message: recache scripted elements before running script sections Index: ScriptFilter.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/parsing/ScriptFilter.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ScriptFilter.java 9 Mar 2003 20:35:48 -0000 1.4 +++ ScriptFilter.java 9 Mar 2004 21:49:18 -0000 1.5 @@ -147,6 +147,7 @@ protected String getTranslatedScript( final String language, final String scriptText ) throws IOException { + _domParser.getScriptableDelegate().getScriptEngine().clearCaches(); return _domParser.getScriptableDelegate().runScript( language, scriptText ); } |
|
From: Russell G. <rus...@us...> - 2004-03-09 22:14:56
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15032/src/com/meterware/httpunit/javascript Modified Files: JavaScript.java Log Message: recache scripted elements before running script sections Index: JavaScript.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript/JavaScript.java,v retrieving revision 1.57 retrieving revision 1.58 diff -u -r1.57 -r1.58 --- JavaScript.java 27 Oct 2003 21:16:10 -0000 1.57 +++ JavaScript.java 9 Mar 2004 21:49:18 -0000 1.58 @@ -283,6 +283,10 @@ } + public void clearCaches() { + } + + protected static String toStringIfNotUndefined( Object object ) { return (object == null || Undefined.instance.equals( object )) ? null : object.toString(); } @@ -464,6 +468,11 @@ } + public void clearCaches() { + if (_document != null) _document.clearCaches(); + } + + protected StringBuffer getDocumentWriteBuffer() { return jsGet_document().getWriteBuffer(); } @@ -494,6 +503,11 @@ } + public void clearCaches() { + _forms = _links = _images = null; + } + + public String jsGet_title() throws SAXException { return getDelegate().getTitle(); } |
|
From: Russell G. <rus...@us...> - 2004-03-09 22:14:45
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15032/test/com/meterware/httpunit/javascript Modified Files: FormScriptingTest.java Log Message: recache scripted elements before running script sections Index: FormScriptingTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/FormScriptingTest.java,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- FormScriptingTest.java 9 Mar 2004 20:31:03 -0000 1.28 +++ FormScriptingTest.java 9 Mar 2004 21:49:18 -0000 1.29 @@ -1159,4 +1159,25 @@ assertMatchingSet("Values seen by JavaScript", expectedValues, collector.confirmPromptsSeen.toArray()); } + + public void testFormsCaching() throws Exception { + defineWebPage( "OnCommand", "<form>" + + " <input type='text' name='color' value='blue' >" + + "</form>" + + "<script type='JavaScript'>" + + " alert( document.forms[0].color.value );" + + "</script>" + + "<form>" + + " <input type='text' name='size' value='3' >" + + "</form>" + + "<script type='JavaScript'>" + + " alert( document.forms[1].size.value );" + + "</script>" ); + WebConversation wc = new WebConversation(); + wc.getResponse( getHostPath() + "/OnCommand.html" ); + assertEquals( "Message 1", "blue", wc.popNextAlert() ); + assertEquals( "Message 2", "3", wc.popNextAlert() ); + } + + } |
|
From: Russell G. <rus...@us...> - 2004-03-09 20:58:21
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27137/doc Modified Files: release_notes.txt Log Message: upgrade dependent jars Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.327 retrieving revision 1.328 diff -u -r1.327 -r1.328 --- release_notes.txt 3 Mar 2004 02:20:10 -0000 1.327 +++ release_notes.txt 9 Mar 2004 20:32:30 -0000 1.328 @@ -13,6 +13,16 @@ Revision History: +9-Mar-2004 + Problems fixed: + 1. Support JavaScript changing "disabled" attribute on form controls + Notes: + 1. Upgraded NekoHTML to 0.9.1 + 2. Upgraded Xerces to 2.5.0 + 3. Upgraded Rhino to 1.5R4.1 + + +Revision History: 1-Mar-2004 Acknowledgements: 1. Thanks to Dan Frankow for supplying an implementation of ServletContext.getMimeType and correcting the @@ -85,7 +95,7 @@ getAttribute() to handle any property defined in the underlying Node Additions: - 1. HTMLElement now supports a getAttribute method to return the value of any named attribute. + 1. Patch #795698: HTMLElement now supports a getAttribute method to return the value of any named attribute. 2. PseudoServer can now received chunked requests, and will not send a "Content-Length" header if a "Transfer-Encoding: chunked" has been defined. 3. Added support for javascript Input.tabindex and Text.maxlength properties (read-only) |
|
From: Russell G. <rus...@us...> - 2004-03-09 20:58:06
|
Update of /cvsroot/httpunit/httpunit/jars In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27137/jars Modified Files: jars.txt js.jar nekohtml.jar xercesImpl.jar xmlParserAPIs.jar Log Message: upgrade dependent jars Index: jars.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/jars/jars.txt,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- jars.txt 3 Mar 2003 19:44:22 -0000 1.11 +++ jars.txt 9 Mar 2004 20:32:31 -0000 1.12 @@ -3,10 +3,10 @@ (runtime) junit 3.8 servlet 2.3 -xerces 2.2 +xerces 2.5 jtidy 04aug2000r7 -rhino 1.5R4+ (patched) -NekoHTML 0.7.2 (patched) +rhino 1.5R4.1 +NekoHTML 0.9.1 (for testing HttpUnit only) mail (javamail 1.2) Index: js.jar =================================================================== RCS file: /cvsroot/httpunit/httpunit/jars/js.jar,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 Binary files /tmp/cvsJwCEgQ and /tmp/cvsntBSlo differ Index: nekohtml.jar =================================================================== RCS file: /cvsroot/httpunit/httpunit/jars/nekohtml.jar,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 Binary files /tmp/cvsPNYDW5 and /tmp/cvspQDp8D differ Index: xercesImpl.jar =================================================================== RCS file: /cvsroot/httpunit/httpunit/jars/xercesImpl.jar,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 Binary files /tmp/cvsUfJtNl and /tmp/cvsE7XziU differ Index: xmlParserAPIs.jar =================================================================== RCS file: /cvsroot/httpunit/httpunit/jars/xmlParserAPIs.jar,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 Binary files /tmp/cvsw4s83O and /tmp/cvsbZhmJn differ |
|
From: Russell G. <rus...@us...> - 2004-03-09 20:58:05
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/parsing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27137/test/com/meterware/httpunit/parsing Modified Files: HTMLParserListenerTest.java Log Message: upgrade dependent jars Index: HTMLParserListenerTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/parsing/HTMLParserListenerTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- HTMLParserListenerTest.java 28 Feb 2003 17:30:31 -0000 1.1 +++ HTMLParserListenerTest.java 9 Mar 2004 20:32:44 -0000 1.2 @@ -57,31 +57,38 @@ "<unknownTag>bla</unknownTag>" + "</body></html>\n" ); - WebConversation wc = new WebConversation(); - final ErrorHandler errorHandler = new ErrorHandler(); - HTMLParserFactory.addHTMLParserListener( errorHandler ); - WebRequest request = new GetMethodWebRequest( getHostPath() + "/BadPage.html" ); - wc.getResponse( request ); - assertTrue( "Should have found problems", errorHandler.foundProblems() ); - assertEquals( "Expected URL", request.getURL(), errorHandler.getBadURL() ); + final ErrorHandler errorHandler = new ErrorHandler( /* expectProblems */ true ); + try { + WebConversation wc = new WebConversation(); + HTMLParserFactory.addHTMLParserListener( errorHandler ); + WebRequest request = new GetMethodWebRequest( getHostPath() + "/BadPage.html" ); + wc.getResponse( request ); + assertTrue( "Should have found problems", errorHandler.foundProblems() ); + assertEquals( "Expected URL", request.getURL(), errorHandler.getBadURL() ); + } finally { + HTMLParserFactory.removeHTMLParserListener( errorHandler ); + } } public void testGoodHTMLPage() throws Exception { - defineResource( "SimplePage.html", - "<html>\n" + - "<head><title>A Sample Page</title></head>\n" + - "<body><p><b>Wrong embedded tags</b></p>\n" + - "have <a blef=\"other.html?a=1&b=2\">an invalid link</A>\n" + - "<IMG SRC=\"/images/arrow.gif\" alt=\"\" WIDTH=1 HEIGHT=4>\n" + - "</body></html>\n" ); - - WebConversation wc = new WebConversation(); - final ErrorHandler errorHandler = new ErrorHandler(); - HTMLParserFactory.addHTMLParserListener( errorHandler ); - WebRequest request = new GetMethodWebRequest( getHostPath() + "/SimplePage.html" ); - wc.getResponse( request ); - assertFalse( "Should not have found problems", errorHandler.foundProblems() ); + final ErrorHandler errorHandler = new ErrorHandler( /* expectProblems */ false ); + try { + defineResource( "SimplePage.html", + "<html>\n" + + "<head><title>A Sample Page</title></head>\n" + + "<body><p><b>OK embedded tags</b></p>\n" + + "have <a href=\"other.html?a=1&b=2\">an OK link</A>\n" + + "<IMG SRC=\"/images/arrow.gif\" alt=\"\" WIDTH=1 HEIGHT=4>\n" + + "</body></html>\n" ); + + WebConversation wc = new WebConversation(); + HTMLParserFactory.addHTMLParserListener( errorHandler ); + WebRequest request = new GetMethodWebRequest( getHostPath() + "/SimplePage.html" ); + wc.getResponse( request ); + } finally { + HTMLParserFactory.removeHTMLParserListener( errorHandler ); + } } @@ -98,15 +105,23 @@ static private class ErrorHandler implements HTMLParserListener { + private boolean _expectProblems; private boolean _foundProblems; private URL _badURL; + + public ErrorHandler( boolean expectProblems ) { + _expectProblems = expectProblems; + } + + public void warning( URL url, String msg, int line, int column ) { _foundProblems = true; _badURL = url; } public void error( URL url, String msg, int line, int column ) { + assertTrue( msg + " at line " + line + ", column " + column, _expectProblems ); _foundProblems = true; _badURL = url; } |
|
From: Russell G. <rus...@us...> - 2004-03-09 20:56:24
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26914/test/com/meterware/httpunit/javascript Modified Files: FormScriptingTest.java Log Message: enable setting the control 'disabled' attribute from javascript Index: FormScriptingTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/FormScriptingTest.java,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- FormScriptingTest.java 3 Mar 2004 02:20:11 -0000 1.27 +++ FormScriptingTest.java 9 Mar 2004 20:31:03 -0000 1.28 @@ -298,6 +298,33 @@ } } + public void testEnablingDisabledRadioButtonViaScript() throws Exception { + defineResource( "OnCommand.html", "<html><head></head>" + + "<body>" + + "<form name=spectrum action='DoIt'>" + + "<input type='radio' name='color' value='red' checked>" + + "<input type='radio' name='color' value='green' disabled>" + + "<input type=button name=enableChange id=enableChange value=Hello onClick='document.spectrum.color[1].disabled=false;'>" + + "<input type=submit name=change value=success>" + + "</form>" + + "</body></html>" ); + WebConversation wc = new WebConversation(); + WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); + WebForm form = response.getFormWithName( "spectrum" ); + + assertMatchingSet( "Color choices", new String[] { "red" }, form.getOptionValues( "color" ) ); + try { + form.setParameter( "color", "green" ); + fail( "Should not have been able to set color" ); + } catch (Exception e) {} + + form.getScriptableObject().doEvent( "document.spectrum.color[1].disabled=false" ); + + assertMatchingSet( "Color choices", new String[] { "red", "green" }, form.getOptionValues( "color" ) ); + form.setParameter( "color", "green" ); + } + + public void testSubmitViaScriptWithPostParams() throws Exception { defineResource( "/servlet/TestServlet?param3=value3¶m4=value4", new PseudoServlet() { public WebResource getPostResponse() throws IOException { |
|
From: Russell G. <rus...@us...> - 2004-03-09 20:56:23
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26914/src/com/meterware/httpunit Modified Files: Button.java FormControl.java Log Message: enable setting the control 'disabled' attribute from javascript Index: Button.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/Button.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- Button.java 3 Mar 2004 02:20:11 -0000 1.12 +++ Button.java 9 Mar 2004 20:31:03 -0000 1.13 @@ -53,8 +53,6 @@ Button( WebForm form, Node node ) { super( form, node ); _onClickEvent = NodeUtils.getNodeAttribute( node, "onclick" ); - - supportAttribute( "disabled" ); } @@ -121,15 +119,6 @@ public void click() throws IOException, SAXException { doButtonAction(); } - - - public void set( String propertyName, Object value ) { - if (propertyName.equalsIgnoreCase( "disabled" )) { - setDisabled( value instanceof Boolean && ((Boolean) value).booleanValue() ); - } else { - super.set( propertyName, value ); - } - } } Index: FormControl.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/FormControl.java,v retrieving revision 1.45 retrieving revision 1.46 diff -u -r1.45 -r1.46 --- FormControl.java 3 Mar 2004 02:20:11 -0000 1.45 +++ FormControl.java 9 Mar 2004 20:31:03 -0000 1.46 @@ -101,6 +101,7 @@ _onClickEvent = NodeUtils.getNodeAttribute( node, "onclick" ); supportAttribute( "tabindex" ); + supportAttribute( "disabled" ); } @@ -384,6 +385,8 @@ public void set( String propertyName, Object value ) { if (propertyName.equalsIgnoreCase( "value" )) { _valueAttribute = value.toString(); + } else if (propertyName.equalsIgnoreCase( "disabled" )) { + setDisabled( value instanceof Boolean && ((Boolean) value).booleanValue() ); } else { super.set( propertyName, value ); } |
|
From: Russell G. <rus...@us...> - 2004-03-03 02:40:20
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1799/doc Modified Files: release_notes.txt Log Message: Patch #812709 (from Michael Corum): Support JavaScript changing disabled attribute on Buttons Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.326 retrieving revision 1.327 diff -u -r1.326 -r1.327 --- release_notes.txt 3 Mar 2004 01:12:50 -0000 1.326 +++ release_notes.txt 3 Mar 2004 02:20:10 -0000 1.327 @@ -17,11 +17,13 @@ Acknowledgements: 1. Thanks to Dan Frankow for supplying an implementation of ServletContext.getMimeType and correcting the implementation of HttpSession.setAttribute when the value is null + 2. Thanks to Michael Corum for making the Button.disabled property settable from JavaScript. Problems fixed: 1. ServletUnit now applies character encoding in interpreting post parameters 2. Patch #873911: ServletUnit now supports ServletContext.getMimeType 3. Patch #873914: ServletUnit HttpSession.setAttribute( name, null ) now properly removes the named attribute + 4. Patch #812709: Support JavaScript changing "disabled" attribute on Buttons 26-Feb-2004 Additions: |
|
From: Russell G. <rus...@us...> - 2004-03-03 02:40:16
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1799/test/com/meterware/httpunit/javascript Modified Files: FormScriptingTest.java Log Message: Patch #812709 (from Michael Corum): Support JavaScript changing disabled attribute on Buttons Index: FormScriptingTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/FormScriptingTest.java,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- FormScriptingTest.java 5 Dec 2003 04:06:54 -0000 1.26 +++ FormScriptingTest.java 3 Mar 2004 02:20:11 -0000 1.27 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * - * Copyright (c) 2002, Russell Gold + * Copyright (c) 2002-2004, Russell Gold * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -30,6 +30,7 @@ import junit.textui.TestRunner; import junit.framework.TestSuite; +import org.xml.sax.SAXException; /** @@ -152,6 +153,151 @@ } + public void testEnablingDisabledSubmitButtonViaScript() throws Exception { + defineResource( "DoIt?color=green&change=success", "You made it!" ); + defineResource( "OnCommand.html", "<html><head></head>" + + "<body>" + + "<form name=spectrum action='DoIt'>" + + " <input type=text name=color value=green>" + + " <input type=button name=enableChange id=enableChange value=Hello onClick='document.spectrum.change.disabled=false;'>" + + " <input type=submit disabled name=change value=success>" + + "</form>" + + "</body></html>" ); + WebConversation wc = new WebConversation(); + WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); + WebForm form = response.getFormWithName( "spectrum" ); + + assertSubmitButtonDisabled( form ); + assertDisabledSubmitButtonCanNotBeClicked( form ); + + form = runJavaScriptToToggleEnabledStateOfButton( form, wc ); + + assertSubmitButtonEnabled( form ); + clickSubmitButtonToProveThatItIsEnabled( form ); + assertEquals( "Result of submit", "You made it!", wc.getCurrentPage().getText() ); + } + + public void testDisablingEnabledSubmitButtonViaScript() throws Exception { + defineResource( "DoIt?color=green&change=success", "You made it!" ); + defineResource( "OnCommand.html", "<html><head></head>" + + "<body>" + + "<form name=spectrum action='DoIt'>" + + " <input type=text name=color value=green>" + + " <input type=button name=enableChange id=enableChange value=Hello onClick='document.spectrum.change.disabled=true;'>" + + " <input type=submit name=change value=success>" + + "</form>" + + "</body></html>" ); + WebConversation wc = new WebConversation(); + WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); + WebForm form = response.getFormWithName( "spectrum" ); + + assertSubmitButtonEnabled( form ); + + form = runJavaScriptToToggleEnabledStateOfButton( form, wc ); + assertNotNull( form ); + + assertSubmitButtonDisabled( form ); + assertDisabledSubmitButtonCanNotBeClicked( form ); + } + + public void testEnablingDisabledNormalButtonViaScript() throws Exception { + defineResource( "DoIt?color=green", "You made it!" ); + defineResource( "OnCommand.html", "<html><head></head>" + + "<body>" + + "<form name=spectrum action='DoIt'>" + + " <input type=text name=color value=green>" + + " <input type=button name=enableChange id=enableChange value=Hello onClick='document.spectrum.changee.disabled=false;'>" + + " <input type=button disabled name=changee id=changee value=Hello onClick='document.spectrum.submit();'>" + + " <input type=submit name=change value=success>" + + "</form>" + + "</body></html>" ); + WebConversation wc = new WebConversation(); + WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); + WebForm form = response.getFormWithName( "spectrum" ); + + assertNormalButtonDisabled( form, "changee" ); + assertDisabledNormalButtonCanNotBeClicked( form, "changee" ); + + form = runJavaScriptToToggleEnabledStateOfButton( form, wc ); + + assertNormalButtonEnabled( form, "changee" ); + clickButtonToProveThatItIsEnabled( form, "changee" ); + assertEquals( "Result of submit", "You made it!", wc.getCurrentPage().getText() ); + } + + public void testDisablingEnableddNormalButtonViaScript() throws Exception { + defineResource( "DoIt?color=green", "You made it!" ); + defineResource( "OnCommand.html", "<html><head></head>" + + "<body>" + + "<form name=spectrum action='DoIt'>" + + " <input type=text name=color value=green>" + + " <input type=button name=enableChange id=enableChange value=Hello onClick='document.spectrum.changee.disabled=true;'>" + + " <input type=button name=changee id=changee value=Hello onClick='document.spectrum.submit();'>" + + " <input type=submit name=change value=success>" + + "</form>" + + "</body></html>" ); + WebConversation wc = new WebConversation(); + WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); + WebForm form = response.getFormWithName( "spectrum" ); + + assertNormalButtonEnabled( form, "changee" ); + form = runJavaScriptToToggleEnabledStateOfButton( form, wc ); + + assertNormalButtonDisabled( form, "changee" ); + assertDisabledNormalButtonCanNotBeClicked( form, "changee" ); + } + + private void assertSubmitButtonDisabled( WebForm form ) { + assertTrue( "Button should have been Disabled", form.getSubmitButton( "change" ).isDisabled() ); + } + + private void assertNormalButtonDisabled( WebForm form, String buttonID ) { + assertTrue( "Button should have been Disabled", form.getButtonWithID( buttonID ).isDisabled() ); + } + + private void assertSubmitButtonEnabled( WebForm form ) { + assertFalse( "Button should have been enabled or NOT-Disabled", form.getSubmitButton( "change" ).isDisabled() ); + } + + private void assertNormalButtonEnabled( WebForm form, String buttonID ) { + assertFalse( "Button should have been enabled or NOT-Disabled", form.getButtonWithID( buttonID ).isDisabled() ); + } + + private void clickSubmitButtonToProveThatItIsEnabled( WebForm form ) throws IOException, SAXException { + WebResponse response = form.submit(); + assertNotNull( response ); + } + + private void clickButtonToProveThatItIsEnabled( WebForm form, String buttonID ) throws IOException, SAXException { + form.getButtonWithID( buttonID ).click(); + } + + private WebForm runJavaScriptToToggleEnabledStateOfButton( WebForm form, WebConversation wc ) throws IOException, SAXException { + Button enableChange = form.getButtonWithID( "enableChange" ); + enableChange.click(); + WebResponse currentPage = wc.getCurrentPage(); + form = currentPage.getFormWithName( "spectrum" ); + return form; + } + + private void assertDisabledSubmitButtonCanNotBeClicked( WebForm form ) { + try { + SubmitButton button = form.getSubmitButton( "change" ); + form.submit( button ); + } catch (Exception e) { + assertTrue( e.toString().indexOf( "The specified button (name='change' value='success' is disabled and may not be used to submit this form" ) > -1 ); + } + } + + private void assertDisabledNormalButtonCanNotBeClicked( WebForm form, String buttonID ) { + try { + Button button = form.getButtonWithID( buttonID ); + button.click(); + } catch (Exception e) { + assertTrue( e.toString().indexOf( "Button 'changee' is disabled and may not be clicked" ) > -1 ); + } + } + public void testSubmitViaScriptWithPostParams() throws Exception { defineResource( "/servlet/TestServlet?param3=value3¶m4=value4", new PseudoServlet() { public WebResource getPostResponse() throws IOException { |
|
From: Russell G. <rus...@us...> - 2004-03-03 02:40:15
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1799/src/com/meterware/httpunit Modified Files: Button.java FormControl.java Log Message: Patch #812709 (from Michael Corum): Support JavaScript changing disabled attribute on Buttons Index: Button.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/Button.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- Button.java 5 Dec 2003 04:06:53 -0000 1.11 +++ Button.java 3 Mar 2004 02:20:11 -0000 1.12 @@ -44,6 +44,7 @@ return BUTTON_TYPE; } + Button( WebForm form ) { super( form ); } @@ -52,6 +53,8 @@ Button( WebForm form, Node node ) { super( form, node ); _onClickEvent = NodeUtils.getNodeAttribute( node, "onclick" ); + + supportAttribute( "disabled" ); } @@ -118,6 +121,15 @@ public void click() throws IOException, SAXException { doButtonAction(); } + + + public void set( String propertyName, Object value ) { + if (propertyName.equalsIgnoreCase( "disabled" )) { + setDisabled( value instanceof Boolean && ((Boolean) value).booleanValue() ); + } else { + super.set( propertyName, value ); + } + } } Index: FormControl.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/FormControl.java,v retrieving revision 1.44 retrieving revision 1.45 diff -u -r1.44 -r1.45 --- FormControl.java 5 Dec 2003 04:06:53 -0000 1.44 +++ FormControl.java 3 Mar 2004 02:20:11 -0000 1.45 @@ -45,7 +45,7 @@ private String _valueAttribute; private final boolean _readOnly; - private final boolean _disabled; + private boolean _disabled; private final String _onChangeEvent; private final String _onClickEvent; private final WebForm _form; @@ -162,6 +162,11 @@ } + void setDisabled( boolean disabled ) { + _disabled = disabled; + } + + /** * Returns true if this control is disabled, meaning that it will not send a value to the server as part of a request. **/ |
|
From: Russell G. <rus...@us...> - 2004-03-03 01:32:56
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20921/doc Modified Files: release_notes.txt Log Message: servlet unit patches: null session attribute, context mime types Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.325 retrieving revision 1.326 diff -u -r1.325 -r1.326 --- release_notes.txt 2 Mar 2004 10:54:14 -0000 1.325 +++ release_notes.txt 3 Mar 2004 01:12:50 -0000 1.326 @@ -13,9 +13,15 @@ Revision History: - 1-Mar-2004 - Problems fixed: - 1. ServletUnit now applies character encoding in interpreting post parameters +1-Mar-2004 + Acknowledgements: + 1. Thanks to Dan Frankow for supplying an implementation of ServletContext.getMimeType and correcting the + implementation of HttpSession.setAttribute when the value is null + + Problems fixed: + 1. ServletUnit now applies character encoding in interpreting post parameters + 2. Patch #873911: ServletUnit now supports ServletContext.getMimeType + 3. Patch #873914: ServletUnit HttpSession.setAttribute( name, null ) now properly removes the named attribute 26-Feb-2004 Additions: |
|
From: Russell G. <rus...@us...> - 2004-03-03 01:32:54
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20921/test/com/meterware/servletunit Modified Files: ConfigTest.java ServletUnitTest.java SessionTest.java Log Message: servlet unit patches: null session attribute, context mime types Index: ConfigTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/ConfigTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ConfigTest.java 19 Feb 2003 19:17:59 -0000 1.4 +++ ConfigTest.java 3 Mar 2004 01:12:51 -0000 1.5 @@ -87,6 +87,25 @@ } + public void testFileMimeType() throws Exception { + final String servlet1Name = "something/interesting"; + + ServletRunner sr = new ServletRunner(); + sr.registerServlet( servlet1Name, ConfigServlet.class.getName() ); + ServletUnitClient wc = sr.newClient(); + InvocationContext ic1 = wc.newInvocation( "http://localhost/" + servlet1Name ); + ServletContext context = ic1.getServlet().getServletConfig().getServletContext(); + checkMimeType( context, "sample.txt", "text/plain" ); + checkMimeType( context, "sample.html", "text/html" ); + checkMimeType( context, "sample.gif", "image/gif" ); + } + + + private void checkMimeType( ServletContext context, String fileName, String expectedMimeType ) { + assertEquals( "mime type for " + fileName, expectedMimeType, context.getMimeType( fileName ) ); + } + + static class ConfigServlet extends HttpServlet { static String RESPONSE_TEXT = "the desired content\r\n"; Index: ServletUnitTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/ServletUnitTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ServletUnitTest.java 20 Aug 2003 12:06:15 -0000 1.4 +++ ServletUnitTest.java 3 Mar 2004 01:12:51 -0000 1.5 @@ -20,6 +20,8 @@ * *******************************************************************************************************************/ import java.util.Vector; +import java.util.Enumeration; +import java.util.ArrayList; import junit.framework.TestCase; @@ -36,6 +38,13 @@ //------------------------------------ protected members ------------------------------------------ + protected Object[] toArray( Enumeration e ) { + ArrayList result = new ArrayList(); + while (e.hasMoreElements()) result.add( e.nextElement() ); + return result.toArray(); + } + + protected void assertMatchingSet( String comment, Object[] expected, Object[] found ) { Vector expectedItems = new Vector(); Vector foundItems = new Vector(); Index: SessionTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/SessionTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- SessionTest.java 20 Aug 2003 12:06:15 -0000 1.4 +++ SessionTest.java 3 Mar 2004 01:12:51 -0000 1.5 @@ -66,7 +66,7 @@ long accessedAt = session.getLastAccessedTime(); assertTrue( "Session is not marked as new", session.isNew() ); try { Thread.sleep( 50 ); } catch (InterruptedException e) {}; - assertEquals( "Initial access time", accessedAt, context.getSession( session.getId() ).getLastAccessedTime() ); + assertEquals( "Initial access time", accessedAt, context.getSession( session.getId() ).getLastAccessedTime() ); session.access(); assertTrue( "Last access time not changed", accessedAt != context.getSession( session.getId() ).getLastAccessedTime() ); assertTrue( "Session is still marked as new", !context.getSession( session.getId() ).isNew() ); @@ -74,6 +74,21 @@ } + public void testSessionAttributes() throws Exception { + ServletUnitContext context = new ServletUnitContext(); + ServletUnitHttpSession session = context.newSession(); + session.setAttribute( "first", new Integer(1) ); + session.setAttribute( "second", "two" ); + session.setAttribute( "third", "III" ); + + assertMatchingSet( "Attribute names", new String[] { "first", "second", "third" }, toArray( session.getAttributeNames() )); + + session.removeAttribute( "third" ); + session.setAttribute( "first", null ); + assertMatchingSet( "Attribute names", new String[] { "second" }, toArray( session.getAttributeNames() )); + } + + } |
|
From: Russell G. <rus...@us...> - 2004-03-03 01:32:54
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20921/src/com/meterware/servletunit Modified Files: ServletUnitHttpSession.java ServletUnitServletContext.java Log Message: servlet unit patches: null session attribute, context mime types Index: ServletUnitHttpSession.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpSession.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- ServletUnitHttpSession.java 15 Feb 2004 06:42:01 -0000 1.10 +++ ServletUnitHttpSession.java 3 Mar 2004 01:12:51 -0000 1.11 @@ -175,7 +175,9 @@ public void setAttribute( String name, Object value ) { if (_invalid) throw new IllegalStateException(); - if (!_values.containsKey( name )) { + if (value == null) { + removeAttribute( name ); + } else if (!_values.containsKey( name )) { _values.put( name, value ); _listenerDispatcher.sendAttributeAdded( this, name, value ); } else { Index: ServletUnitServletContext.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitServletContext.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- ServletUnitServletContext.java 15 Feb 2004 06:42:01 -0000 1.13 +++ ServletUnitServletContext.java 3 Mar 2004 01:12:51 -0000 1.14 @@ -24,8 +24,9 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; -import java.net.URL; import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; import java.util.Enumeration; import java.util.Hashtable; @@ -85,7 +86,7 @@ * "text/html" and "image/gif". **/ public java.lang.String getMimeType( String filePath ) { - return null; // XXX not implemented + return URLConnection.getFileNameMap().getContentTypeFor(filePath); } |
|
From: Russell G. <rus...@us...> - 2004-03-02 11:13:53
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27879/src/com/meterware/servletunit Modified Files: RequestContext.java ServletUnitHttpRequest.java Log Message: support request body encoding in ServletUnit Index: RequestContext.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/RequestContext.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- RequestContext.java 13 Feb 2003 20:25:55 -0000 1.2 +++ RequestContext.java 2 Mar 2004 10:54:14 -0000 1.3 @@ -23,6 +23,7 @@ import java.util.*; import java.net.URL; +import java.io.UnsupportedEncodingException; import javax.servlet.http.HttpServletRequest; @@ -37,6 +38,8 @@ private Hashtable _visibleParameters; private HttpServletRequest _parentRequest; private URL _url; + private byte[] _messageBody; + private String _messageEncoding; RequestContext( URL url ) { @@ -148,6 +151,10 @@ private Hashtable getParameters() { + if (_messageBody != null) { + loadParameters( getMessageBodyAsString() ); + _messageBody = null; + } if (_visibleParameters == null) { if (_parentRequest == null) { _visibleParameters = _parameters; @@ -168,4 +175,23 @@ } + private String getMessageBodyAsString() { + try { + return _messageEncoding == null ? new String( _messageBody ) : new String( _messageBody, _messageEncoding ); + } catch (UnsupportedEncodingException e) { + return ""; + } + } + + + void setMessageBody( byte[] bytes ) { + _messageBody = bytes; + } + + + public void setMessageEncoding( String messageEncoding ) { + _messageEncoding = messageEncoding; + } + + } Index: ServletUnitHttpRequest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpRequest.java,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- ServletUnitHttpRequest.java 26 Feb 2004 17:36:47 -0000 1.30 +++ ServletUnitHttpRequest.java 2 Mar 2004 10:54:14 -0000 1.31 @@ -22,6 +22,7 @@ import com.meterware.httpunit.WebRequest; import com.meterware.httpunit.WebClient; import com.meterware.httpunit.Base64; +import com.meterware.httpunit.HttpUnitUtils; import java.io.BufferedReader; import java.io.IOException; @@ -47,6 +48,7 @@ private Vector _locales; private boolean _secure; private RequestContext _requestContext; + private String _charset; /** @@ -63,12 +65,19 @@ _headers.addEntries( request.getHeaders() ); _messageBody = messageBody; _secure = request.getURL().getProtocol().equalsIgnoreCase( "https" ); - _contentType = (String) _headers.get( "Content-Type" ); - if (_headers.get( "Content-Length") == null) _headers.put( "Content-Length", Integer.toString( messageBody.length ) ); _requestContext = new RequestContext( request.getURL() ); + String contentTypeHeader = (String) _headers.get( "Content-Type" ); + if (contentTypeHeader != null) { + String[] res = HttpUnitUtils.parseContentTypeHeader( contentTypeHeader ); + _contentType = res[0]; + _charset = res[1]; + _requestContext.setMessageEncoding( _charset ); + } + if (_headers.get( "Content-Length") == null) _headers.put( "Content-Length", Integer.toString( messageBody.length ) ); + if (_messageBody != null && (_contentType == null || _contentType.indexOf( "x-www-form-urlencoded" ) >= 0 )) { - _requestContext.loadParameters( new String( _messageBody ) ); + _requestContext.setMessageBody( _messageBody ); } } @@ -344,7 +353,7 @@ * does not use character encoding. **/ public String getCharacterEncoding() { - return null; + return _charset; } @@ -647,8 +656,9 @@ * * @since 1.3 **/ - public void setCharacterEncoding( String s ) throws UnsupportedEncodingException { - // XXX implement me! + public void setCharacterEncoding( String charset ) throws UnsupportedEncodingException { + _charset = charset; + _requestContext.setMessageEncoding( charset ); } |