httpunit-commit Mailing List for httpunit (Page 37)
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-11 04:32:03
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/pseudoserver
In directory sc8-pr-cvs1:/tmp/cvs-serv29478/src/com/meterware/pseudoserver
Modified Files:
HttpUserAgentTest.java
Log Message:
Support parameter overrides in request dispatcher
Index: HttpUserAgentTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/pseudoserver/HttpUserAgentTest.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- HttpUserAgentTest.java 26 Dec 2002 04:59:35 -0000 1.6
+++ HttpUserAgentTest.java 11 Feb 2003 04:32:00 -0000 1.7
@@ -2,7 +2,7 @@
/********************************************************************************************************************
* $Id$
*
- * Copyright (c) 2002, Russell Gold
+ * Copyright (c) 2002-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
@@ -136,12 +136,36 @@
}
- protected void assertMatchingSet( String comment, Object[] expected, Object[] found ) {
- Vector expectedItems = new Vector();
+ protected void assertMatchingSet( String comment, Object[] expected, Enumeration found ) {
Vector foundItems = new Vector();
+ while (found.hasMoreElements()) foundItems.addElement( found.nextElement() );
+
+ assertMatchingSet( comment, expected, foundItems );
+ }
+
+ private void assertMatchingSet( String comment, Object[] expected, Vector foundItems ) {
+ Vector expectedItems = new Vector();
for (int i = 0; i < expected.length; i++) expectedItems.addElement( expected[ i ] );
+ for (int i = 0; i < expected.length; i++) {
+ if (!foundItems.contains( expected[ i ] )) {
+ fail( comment + ": expected " + asText( expected ) + " but missing " + expected[ i ] );
+ } else {
+ foundItems.removeElement( expected[ i ] );
+ }
+ }
+
+ if (!foundItems.isEmpty()) fail( comment + ": expected " + asText( expected ) + " but found superfluous" + foundItems.firstElement() );
+ }
+
+
+ protected void assertMatchingSet( String comment, Object[] expected, Object[] found ) {
+ Vector foundItems = new Vector();
for (int i = 0; i < found.length; i++) foundItems.addElement( found[ i ] );
+
+ Vector expectedItems = new Vector();
+
+ for (int i = 0; i < expected.length; i++) expectedItems.addElement( expected[ i ] );
for (int i = 0; i < expected.length; i++) {
if (!foundItems.contains( expected[ i ] )) {
|
|
From: Russell G. <rus...@us...> - 2003-02-06 02:56:02
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv23587/src/com/meterware/httpunit
Modified Files:
FormControl.java FormParameter.java WebForm.java
Log Message:
Added WebForm.isHiddenParameter
Index: FormControl.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/FormControl.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- FormControl.java 5 Feb 2003 16:07:38 -0000 1.34
+++ FormControl.java 6 Feb 2003 02:55:58 -0000 1.35
@@ -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
@@ -133,6 +133,14 @@
/**
+ * Returns true if this control is hidden.
+ **/
+ boolean isHidden() {
+ return false;
+ }
+
+
+ /**
* Returns true if this control is disabled, meaning that it will not send a value to the server as part of a request.
**/
boolean isDisabled() {
@@ -698,6 +706,10 @@
void claimValue( List values ) {
}
+
+ boolean isHidden() {
+ return true;
+ }
}
Index: FormParameter.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/FormParameter.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- FormParameter.java 26 Dec 2002 18:55:18 -0000 1.4
+++ FormParameter.java 6 Feb 2003 02:55:58 -0000 1.5
@@ -2,7 +2,7 @@
/********************************************************************************************************************
* $Id$
*
- * Copyright (c) 2002, Russell Gold
+ * Copyright (c) 2002-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
@@ -171,6 +171,15 @@
FormControl[] controls = getControls();
for (int i = 0; i < controls.length; i++) {
if (!controls[i].isReadOnly()) return false;
+ }
+ return true;
+ }
+
+
+ public boolean isHiddenParameter() {
+ FormControl[] controls = getControls();
+ for (int i = 0; i < controls.length; i++) {
+ if (!controls[i].isHidden()) return false;
}
return true;
}
Index: WebForm.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -r1.75 -r1.76
--- WebForm.java 30 Dec 2002 21:46:55 -0000 1.75
+++ WebForm.java 6 Feb 2003 02:55:58 -0000 1.76
@@ -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
@@ -409,6 +409,15 @@
**/
public boolean isDisabledParameter( String name ) {
return getParameter( name ).isDisabledParameter();
+ }
+
+
+ /**
+ * Returns true if the named parameter is hidden. If more than one control exists with the same name,
+ * will return true only if all such controls are hidden.
+ **/
+ public boolean isHiddenParameter( String name ) {
+ return getParameter( name ).isHiddenParameter();
}
|
|
From: Russell G. <rus...@us...> - 2003-02-06 02:56:02
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv23587/test/com/meterware/httpunit
Modified Files:
FormParametersTest.java
Log Message:
Added WebForm.isHiddenParameter
Index: FormParametersTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FormParametersTest.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- FormParametersTest.java 20 Nov 2002 13:04:16 -0000 1.18
+++ FormParametersTest.java 6 Feb 2003 02:55:59 -0000 1.19
@@ -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
@@ -132,14 +132,19 @@
public void testHiddenParameters() throws Exception {
defineWebPage( "Default", "<form method=GET action = '/ask'>" +
- "<Input type=hidden name=secret value=value>" +
- "<Input type=submit></form>" );
+ "<Input type=text name=open value=value>" +
+ "<Input type=hidden name=secret value=value>" +
+ "<Input type=submit></form>" );
WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" );
- WebRequest request = page.getForms()[0].getRequest();
+
+ final WebForm form = page.getForms()[0];
+ assertFalse( "Should not call 'open' hidden", form.isHiddenParameter( "open") );
+ assertTrue( "Should have called 'secret' hidden", form.isHiddenParameter( "secret") );
+
+ WebRequest request = form.getRequest();
HttpUnitOptions.setParameterValuesValidated( true );
validateSetParameterRejected( request, "secret", new String[] { "red" }, "setting hidden field to wrong value" );
- WebForm form = page.getForms()[0];
form.getScriptableObject().setParameterValue( "secret", "new" );
assertEquals( "New hidden value", "new", form.getParameterValue( "secret" ) );
}
|
|
From: Russell G. <rus...@us...> - 2003-02-06 02:56:01
|
Update of /cvsroot/httpunit/httpunit/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv23587/doc
Modified Files:
release_notes.txt
Log Message:
Added WebForm.isHiddenParameter
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.250
retrieving revision 1.251
diff -u -r1.250 -r1.251
--- release_notes.txt 6 Feb 2003 01:33:11 -0000 1.250
+++ release_notes.txt 6 Feb 2003 02:55:58 -0000 1.251
@@ -14,8 +14,11 @@
5-Feb-2003
Acknowledgements:
Thanks to Navid Vahdat for ServletUnit fixes for invalid session handling and request dispatcher paths
+ Thanks to Daniel Sheppard for correcting the return status for HttpServletResponse.sendRedirect
+
Additions:
1. ServletUnit now supports HttpServletResponse.flushBuffer()
+ 2. WebForm.isHiddenParameter returns true if all parameters with the specified name are hidden
Problems Fixed:
1. Opening a non-HTML window via Javascript no longer raises a NotHTMLException.
@@ -25,7 +28,7 @@
4-Feb-2003
Acknowledgements:
- Thanks to Daniel Sheppard and Krystyna Polomski for identifying a problem with meta refresh tags.
+ Thanks to Daniel Sheppard for identifying a problem with meta refresh tags.
Additions:
1. Added support for <iframe> tag. IFrames work just like regular frames, except that they are embedded in a response
|
|
From: Russell G. <rus...@us...> - 2003-02-06 02:55:36
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit In directory sc8-pr-cvs1:/tmp/cvs-serv23455/test/com/meterware/servletunit Modified Files: HttpServletResponseTest.java Log Message: Corrected status from sendRedirect Index: HttpServletResponseTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/HttpServletResponseTest.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- HttpServletResponseTest.java 6 Feb 2003 01:33:11 -0000 1.7 +++ HttpServletResponseTest.java 6 Feb 2003 02:55:32 -0000 1.8 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * -* Copyright (c) 2000, 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 @@ -21,8 +21,6 @@ *******************************************************************************************************************/ import java.io.*; -import java.util.Enumeration; -import java.util.Vector; import java.util.Date; import java.text.SimpleDateFormat; @@ -109,7 +107,7 @@ public void testStreamWriterAfterOutputStream() throws Exception { ServletUnitHttpResponse servletResponse = new ServletUnitHttpResponse(); servletResponse.setContentType( "text/html" ); - ServletOutputStream sos = servletResponse.getOutputStream(); + servletResponse.getOutputStream(); try { servletResponse.getWriter(); fail( "Should have thrown IllegalStateException" ); @@ -182,7 +180,15 @@ headerList = servletResponse.getHeaderFields( "list" ); assertEquals( "setHeader did not replace the list header", headerList.length, 1 ); assertEquals( "header is wrong", "monkeyboy", headerList[ 0 ] ); + } + + public void testSendRedirect() throws Exception { + ServletUnitHttpResponse servletResponse = new ServletUnitHttpResponse(); + final String location = "http://localhost/newLocation"; + servletResponse.sendRedirect( location ); + assertEquals( "Redirected Location", location, servletResponse.getHeaderField( "Location" ) ); + assertEquals( "Status", 302, servletResponse.getStatus() ); } } |
|
From: Russell G. <rus...@us...> - 2003-02-06 02:55:35
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit
In directory sc8-pr-cvs1:/tmp/cvs-serv23455/src/com/meterware/servletunit
Modified Files:
ServletUnitHttpResponse.java
Log Message:
Corrected status from sendRedirect
Index: ServletUnitHttpResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpResponse.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- ServletUnitHttpResponse.java 6 Feb 2003 01:33:11 -0000 1.16
+++ ServletUnitHttpResponse.java 6 Feb 2003 02:55:32 -0000 1.17
@@ -118,7 +118,7 @@
* Relative URLs are not permitted here.
*/
public void sendRedirect( String location ) throws IOException {
- setStatus( HttpServletResponse.SC_MOVED_PERMANENTLY );
+ setStatus( HttpServletResponse.SC_MOVED_TEMPORARILY );
setHeader( "Location", location );
}
|
|
From: Russell G. <rus...@us...> - 2003-02-06 01:33:16
|
Update of /cvsroot/httpunit/httpunit/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv20202/doc
Modified Files:
release_notes.txt
Log Message:
ServletUnit bug fixes
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.249
retrieving revision 1.250
diff -u -r1.249 -r1.250
--- release_notes.txt 5 Feb 2003 16:07:37 -0000 1.249
+++ release_notes.txt 6 Feb 2003 01:33:11 -0000 1.250
@@ -12,8 +12,16 @@
Revision History:
5-Feb-2003
+Acknowledgements:
+ Thanks to Navid Vahdat for ServletUnit fixes for invalid session handling and request dispatcher paths
+Additions:
+ 1. ServletUnit now supports HttpServletResponse.flushBuffer()
+
Problems Fixed:
1. Opening a non-HTML window via Javascript no longer raises a NotHTMLException.
+ 2. ServletUnit now creates a new session if the requested session exists but is marked invalid
+ 3. ServletUnit was interpreting the getRequestDispatcher path as an absolute path. It now correctly treats it
+ as relative to the context root.
4-Feb-2003
Acknowledgements:
|
|
From: Russell G. <rus...@us...> - 2003-02-06 01:33:16
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit
In directory sc8-pr-cvs1:/tmp/cvs-serv20202/test/com/meterware/servletunit
Modified Files:
HttpServletRequestTest.java HttpServletResponseTest.java
NavigationTest.java
Log Message:
ServletUnit bug fixes
Index: HttpServletRequestTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/HttpServletRequestTest.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- HttpServletRequestTest.java 4 Feb 2003 19:17:33 -0000 1.11
+++ HttpServletRequestTest.java 6 Feb 2003 01:33:11 -0000 1.12
@@ -246,6 +246,36 @@
}
+ /**
+ * Verifies that a request for a session when the current one is invalid will result in a new session.
+ * @throws Exception
+ */
+ public void testSessionInvalidation() 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 );
+ request.addCookie( new Cookie( ServletUnitHttpSession.SESSION_COOKIE_NAME, context.newSession().getId() ) );
+
+ HttpSession session = request.getSession( /* create */ false );
+ String originalID = session.getId();
+ session.setAttribute( "Initial", new Integer(1) );
+
+ request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, context, new Hashtable(), NO_MESSAGE_BODY );
+ request.addCookie( new Cookie( ServletUnitHttpSession.SESSION_COOKIE_NAME, originalID ) );
+ session = request.getSession();
+ assertEquals( "Retrieved session ID", originalID, session.getId() );
+ assertEquals( "Attribute", new Integer(1), session.getAttribute( "Initial" ) );
+
+ session.invalidate();
+ request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, context, new Hashtable(), NO_MESSAGE_BODY );
+ request.addCookie( new Cookie( ServletUnitHttpSession.SESSION_COOKIE_NAME, originalID ) );
+ session = request.getSession();
+ assertNull( "Attribute should not exist", session.getAttribute( "Initial" ) );
+ assertFalse( "New session not created", originalID.equals( session.getId() ) );
+ }
+
+
public void testGetRequestURI() throws Exception {
ServletUnitContext context = new ServletUnitContext();
WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
Index: HttpServletResponseTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/HttpServletResponseTest.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- HttpServletResponseTest.java 3 Nov 2002 18:18:20 -0000 1.6
+++ HttpServletResponseTest.java 6 Feb 2003 01:33:11 -0000 1.7
@@ -30,7 +30,6 @@
import javax.servlet.http.*;
import junit.framework.Test;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
import com.meterware.httpunit.*;
@@ -127,6 +126,15 @@
fail( "Should have thrown IllegalStateException" );
} catch (IllegalStateException e) {
}
+ }
+
+
+ public void testUpdateAfterFlushBuffer() throws Exception {
+ ServletUnitHttpResponse servletResponse = new ServletUnitHttpResponse();
+ servletResponse.getWriter();
+ assertFalse( "Should not be committed yet", servletResponse.isCommitted() );
+ servletResponse.flushBuffer();
+ assertTrue( "Should be committed now", servletResponse.isCommitted() );
}
Index: NavigationTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/NavigationTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- NavigationTest.java 22 Jan 2002 15:25:16 -0000 1.3
+++ NavigationTest.java 6 Feb 2003 01:33:11 -0000 1.4
@@ -2,7 +2,7 @@
/********************************************************************************************************************
* $Id$
*
-* Copyright (c) 2000-2001, 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
@@ -20,7 +20,6 @@
*
*******************************************************************************************************************/
import java.io.*;
-import java.net.HttpURLConnection;
import javax.servlet.ServletException;
import javax.servlet.http.*;
@@ -64,12 +63,14 @@
public void testForward() throws Exception {
- ServletRunner sr = new ServletRunner();
- sr.registerServlet( "target", TargetServlet.class.getName() );
- sr.registerServlet( "origin", FowarderServlet.class.getName() );
+ WebXMLString wxs = new WebXMLString();
+ wxs.addServlet( "/target", TargetServlet.class );
+ wxs.addServlet( "/origin", FowarderServlet.class );
+
+ ServletRunner sr = new ServletRunner( wxs.asInputStream(), "/context" );
WebClient wc = sr.newClient();
- WebResponse response = wc.getResponse( "http://localhost/origin" );
+ WebResponse response = wc.getResponse( "http://localhost/context/origin" );
assertNotNull( "No response received", response );
assertEquals( "requested resource", TargetServlet.RESPONSE_TEXT, response.getText() );
assertEquals( "Returned cookie count", 0, response.getNewCookieNames().length );
|
|
From: Russell G. <rus...@us...> - 2003-02-06 01:33:16
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit
In directory sc8-pr-cvs1:/tmp/cvs-serv20202/src/com/meterware/servletunit
Modified Files:
ServletUnitHttpRequest.java ServletUnitHttpResponse.java
ServletUnitHttpSession.java ServletUnitServletContext.java
Log Message:
ServletUnit bug fixes
Index: ServletUnitHttpRequest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpRequest.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- ServletUnitHttpRequest.java 4 Feb 2003 19:17:32 -0000 1.20
+++ ServletUnitHttpRequest.java 6 Feb 2003 01:33:11 -0000 1.21
@@ -239,7 +239,7 @@
if (_session == null && getRequestedSessionId() != null) {
_session = _context.getSession( getRequestedSessionId() );
}
- if (_session == null && create) {
+ if (_session == null ? create : _session.isInvalid()) {
_session = _context.newSession();
}
return _session;
Index: ServletUnitHttpResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpResponse.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- ServletUnitHttpResponse.java 4 Nov 2002 21:01:38 -0000 1.15
+++ ServletUnitHttpResponse.java 6 Feb 2003 01:33:11 -0000 1.16
@@ -46,6 +46,7 @@
// rfc1123-date is "Sun, 06 Nov 1994 08:49:37 GMT"
private static final String RFC1123_DATE_SPEC = "EEE, dd MMM yyyy hh:mm:ss z";
+ private boolean _committed;
/**
@@ -377,11 +378,11 @@
/**
- * Returns a boolean indicating if the response has been committed. A commited response has
+ * Returns a boolean indicating if the response has been committed. A committed response has
* already had its status code and headers written.
**/
public boolean isCommitted() {
- return false; // XXX set true if flushBuffer has been called
+ return _committed;
}
@@ -390,7 +391,7 @@
* commits the response, meaning the status code and headers will be written.
**/
public void flushBuffer() throws IOException {
- throw new RuntimeException( "flushBuffer not implemented" );
+ _committed = true;
}
Index: ServletUnitHttpSession.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpSession.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ServletUnitHttpSession.java 22 Aug 2002 15:48:41 -0000 1.6
+++ ServletUnitHttpSession.java 6 Feb 2003 01:33:11 -0000 1.7
@@ -2,7 +2,7 @@
/********************************************************************************************************************
* $Id$
*
-* Copyright (c) 2000-2001, 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
@@ -40,7 +40,7 @@
* between client requests. You can set the maximum time interval with the setMaxInactiveInterval method.
**/
public int getMaxInactiveInterval() {
- if (_isInvalid) throw new IllegalStateException();
+ if (_invalid) throw new IllegalStateException();
return _maxInactiveInterval;
}
@@ -50,7 +50,7 @@
* if no user requests have been made of the session.
**/
public void setMaxInactiveInterval( int interval ) {
- if (_isInvalid) throw new IllegalStateException();
+ if (_invalid) throw new IllegalStateException();
_maxInactiveInterval = interval;
}
@@ -60,7 +60,7 @@
* The identifier is assigned by the servlet engine and is implementation dependent.
**/
public String getId() {
- if (_isInvalid) throw new IllegalStateException();
+ if (_invalid) throw new IllegalStateException();
return _id;
}
@@ -74,7 +74,7 @@
* been invalidated
**/
public long getCreationTime() {
- if (_isInvalid) throw new IllegalStateException();
+ if (_invalid) throw new IllegalStateException();
return _creationTime;
}
@@ -84,7 +84,7 @@
* as the number of milliseconds since midnight January 1, 1970 GMT.
**/
public long getLastAccessedTime() {
- if (_isInvalid) throw new IllegalStateException();
+ if (_invalid) throw new IllegalStateException();
return _lastAccessedTime;
}
@@ -104,7 +104,7 @@
* Invalidates this session and unbinds any objects bound to it.
**/
public void invalidate() {
- _isInvalid = true;
+ _invalid = true;
_values.clear();
}
@@ -145,7 +145,7 @@
* @deprecated as of JSDK 2.2, use getAttributeNames.
**/
public String[] getValueNames() {
- if (_isInvalid) throw new IllegalStateException();
+ if (_invalid) throw new IllegalStateException();
throw new RuntimeException( "getValueNames not implemented" );
}
@@ -154,7 +154,7 @@
* Returns the object bound with the specified name in this session or null if no object of that name exists.
**/
public Object getAttribute( String name ) {
- if (_isInvalid) throw new IllegalStateException();
+ if (_invalid) throw new IllegalStateException();
return _values.get( name );
}
@@ -164,7 +164,7 @@
* is already bound to the session, the object is replaced.
**/
public void setAttribute( String name, Object value ) {
- if (_isInvalid) throw new IllegalStateException();
+ if (_invalid) throw new IllegalStateException();
_values.put( name, value );
}
@@ -174,7 +174,7 @@
* have an object bound with the specified name, this method does nothing.
**/
public void removeAttribute( String name ) {
- if (_isInvalid) throw new IllegalStateException();
+ if (_invalid) throw new IllegalStateException();
_values.remove( name );
}
@@ -184,7 +184,7 @@
* This method is useful, for example, when you want to delete all the objects bound to this session.
**/
public Enumeration getAttributeNames() {
- if (_isInvalid) throw new IllegalStateException();
+ if (_invalid) throw new IllegalStateException();
return _values.keys();
}
@@ -246,6 +246,11 @@
}
+ boolean isInvalid() {
+ return _invalid;
+ }
+
+
//------------------------------------- private members ---------------------------------------
private static int _NextID = 1;
@@ -260,7 +265,7 @@
private long _lastAccessedTime = new Date().getTime();
- private boolean _isInvalid;
+ private boolean _invalid;
private Hashtable _values = new Hashtable();
Index: ServletUnitServletContext.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitServletContext.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ServletUnitServletContext.java 23 Jun 2002 23:52:39 -0000 1.10
+++ ServletUnitServletContext.java 6 Feb 2003 01:33:11 -0000 1.11
@@ -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
@@ -22,7 +22,6 @@
import java.io.File;
import java.io.FileInputStream;
-import java.io.IOException;
import java.io.FileNotFoundException;
import java.net.URL;
@@ -32,7 +31,6 @@
import java.util.Hashtable;
import java.util.Vector;
import java.util.Set;
-import java.util.Map;
import javax.servlet.*;
@@ -153,7 +151,7 @@
**/
public javax.servlet.RequestDispatcher getRequestDispatcher( String path ) {
try {
- URL url = new URL( "http", "localhost", path );
+ URL url = new URL( "http", "localhost", _application.getContextPath() + path );
return new RequestDispatcherImpl( _application.getServletRequest( url ).getServlet() );
} catch (ServletException e) {
return null;
|
|
From: Russell G. <rus...@us...> - 2003-02-05 16:08:12
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv7415/src/com/meterware/httpunit
Modified Files:
FormControl.java WebResponse.java
Log Message:
Check for HTML before trying to run scripts in new window
Index: FormControl.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/FormControl.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- FormControl.java 30 Dec 2002 21:46:54 -0000 1.33
+++ FormControl.java 5 Feb 2003 16:07:38 -0000 1.34
@@ -49,7 +49,13 @@
private final String _onClickEvent;
private final WebForm _form;
- FormControl( WebForm form ) {
+
+ static ScriptableDelegate newSelectionOption() {
+ return new SelectionFormControl.Option();
+ }
+
+
+ FormControl( WebForm form ) {
super( newEmptyNode( form ) );
_form = form;
_valueAttribute = "";
Index: WebResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v
retrieving revision 1.107
retrieving revision 1.108
diff -u -r1.107 -r1.108
--- WebResponse.java 5 Feb 2003 05:15:51 -0000 1.107
+++ WebResponse.java 5 Feb 2003 16:07:39 -0000 1.108
@@ -538,7 +538,7 @@
public static ScriptableDelegate newDelegate( String delegateClassName ) {
if (delegateClassName.equalsIgnoreCase( "Option" )) {
- return new SelectionFormControl.Option();
+ return FormControl.newSelectionOption();
} else {
throw new IllegalArgumentException( "No such scripting class supported: " + delegateClassName );
}
@@ -587,11 +587,13 @@
public void load() throws SAXException {
- final String[] scripts = getReceivedPage().getScripts();
- for (int i = 0; i < scripts.length; i++) {
- runScript( scripts[i] );
+ if (isHTML()) {
+ final String[] scripts = getReceivedPage().getScripts();
+ for (int i = 0; i < scripts.length; i++) {
+ runScript( scripts[i] );
+ }
+ doEvent( getReceivedPage().getOnLoadEvent() );
}
- doEvent( getReceivedPage().getOnLoadEvent() );
}
|
|
From: Russell G. <rus...@us...> - 2003-02-05 16:08:11
|
Update of /cvsroot/httpunit/httpunit/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv7415/doc
Modified Files:
release_notes.txt
Log Message:
Check for HTML before trying to run scripts in new window
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.248
retrieving revision 1.249
diff -u -r1.248 -r1.249
--- release_notes.txt 5 Feb 2003 05:15:51 -0000 1.248
+++ release_notes.txt 5 Feb 2003 16:07:37 -0000 1.249
@@ -11,6 +11,10 @@
Revision History:
+ 5-Feb-2003
+Problems Fixed:
+ 1. Opening a non-HTML window via Javascript no longer raises a NotHTMLException.
+
4-Feb-2003
Acknowledgements:
Thanks to Daniel Sheppard and Krystyna Polomski for identifying a problem with meta refresh tags.
|
|
From: Russell G. <rus...@us...> - 2003-02-05 16:07:44
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript
In directory sc8-pr-cvs1:/tmp/cvs-serv7415/test/com/meterware/httpunit/javascript
Modified Files:
ScriptingTest.java
Log Message:
Check for HTML before trying to run scripts in new window
Index: ScriptingTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- ScriptingTest.java 13 Dec 2002 12:57:11 -0000 1.48
+++ ScriptingTest.java 5 Feb 2003 16:07:40 -0000 1.49
@@ -245,10 +245,10 @@
public void testWindowOpen() throws Exception {
- defineResource( "Target.html", "You made it!" );
+ defineResource( "Target.txt", "You made it!", "text/plain" );
defineResource( "OnCommand.html", "<html><head><title>Amazing!</title></head>" +
"<body><script language='JavaScript'>var otherWindow;</script>" +
- "<a href='#' onClick=\"otherWindow = window.open( '" + getHostPath() + "/Target.html', 'sample' );\">go</a>" +
+ "<a href='#' onClick=\"otherWindow = window.open( '" + getHostPath() + "/Target.txt', 'sample' );\">go</a>" +
"<a href='#' onClick=\"otherWindow.close();\">go</a>" +
"<a href='#' onClick=\"alert( 'window is ' + (otherWindow.closed ? '' : 'not ') + 'closed' );\">go</a>" +
"</body></html>" );
|
|
From: Russell G. <rus...@us...> - 2003-02-05 16:07:44
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv7415/test/com/meterware/httpunit
Modified Files:
WebWindowTest.java
Log Message:
Check for HTML before trying to run scripts in new window
Index: WebWindowTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebWindowTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- WebWindowTest.java 11 Oct 2002 01:26:22 -0000 1.3
+++ WebWindowTest.java 5 Feb 2003 16:07:40 -0000 1.4
@@ -2,7 +2,7 @@
/********************************************************************************************************************
* $Id$
*
- * Copyright (c) 2002, Russell Gold
+ * Copyright (c) 2002-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
@@ -27,7 +27,7 @@
/**
*
- * @author <a href="mailto:rus...@ac...">Russell Gold</a>
+ * @author <a href="mailto:rus...@ht...">Russell Gold</a>
**/
public class WebWindowTest extends HttpUnitTest {
@@ -112,7 +112,7 @@
public void testWindowIndependence() throws Exception {
- defineResource( "next", "You made it!" );
+ defineResource( "next", "You made it!", "text/plain" );
defineWebPage( "goHere", "<a href='next' id=proceed>more</a>" );
defineWebPage( "start", "<a href='goHere.html' id='go' target='_blank'>here</a>" );
@@ -121,7 +121,7 @@
WebResponse initialPage = wc.getResponse( getHostPath() + "/start.html" );
initialPage.getLinkWithID( "go" ).click();
WebWindow other = wc.getOpenWindows()[1];
- WebResponse response = other.getResponse( other.getCurrentPage().getLinkWithID( "proceed" ).getRequest() );
+ other.getResponse( other.getCurrentPage().getLinkWithID( "proceed" ).getRequest() );
assertEquals( "Main page URL", getHostPath() + "/start.html", main.getCurrentPage().getURL().toExternalForm() );
assertEquals( "New window contents", "You made it!", other.getCurrentPage().getText() );
}
@@ -133,7 +133,7 @@
defineWebPage( "start", "<a href='goHere.html' id='go' target='_blank'>here</a>" );
WebClient wc = new WebConversation();
- WebWindow main = wc.getMainWindow();
+ wc.getMainWindow();
WebResponse initialPage = wc.getResponse( getHostPath() + "/start.html" );
initialPage.getLinkWithID( "go" ).click();
WebWindow other = wc.getOpenWindows()[1];
|
|
From: Russell G. <rus...@us...> - 2003-02-05 16:07:44
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript
In directory sc8-pr-cvs1:/tmp/cvs-serv7415/src/com/meterware/httpunit/javascript
Modified Files:
JavaScript.java
Log Message:
Check for HTML before trying to run scripts in new window
Index: JavaScript.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript/JavaScript.java,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- JavaScript.java 9 Jan 2003 18:02:24 -0000 1.44
+++ JavaScript.java 5 Feb 2003 16:07:39 -0000 1.45
@@ -179,6 +179,7 @@
private void handleScriptException( Exception e, String badScript ) {
final String errorMessage = badScript + " failed: " + e;
if (!(e instanceof EcmaError) && !(e instanceof EvaluatorException)) {
+ e.printStackTrace();
throw new RuntimeException( errorMessage );
} else if (isThrowExceptionsOnError()) {
throw new ScriptException( errorMessage );
|
|
From: Russell G. <rus...@us...> - 2003-02-05 05:15:54
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv27511/test/com/meterware/httpunit
Modified Files:
WebPageTest.java
Log Message:
Handle quotes in refresh tags
Index: WebPageTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebPageTest.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- WebPageTest.java 26 Dec 2002 04:59:35 -0000 1.27
+++ WebPageTest.java 5 Feb 2003 05:15:51 -0000 1.28
@@ -295,7 +295,7 @@
public void testMetaRefreshRequest() throws Exception {
String refreshURL = getHostPath() + "/NextPage.html";
String page = "<html><head><title>Sample</title>" +
- "<meta Http_equiv=refresh content='2;" + refreshURL + "'></head>\n" +
+ "<meta Http_equiv=refresh content='2;\"" + refreshURL + "\"'></head>\n" +
"<body>This has no data\n" +
"</body></html>\n";
defineResource( "SimplePage.html", page );
@@ -312,7 +312,7 @@
public void testMetaRefreshURLRequest() throws Exception {
String refreshURL = getHostPath() + "/NextPage.html";
String page = "<html><head><title>Sample</title>" +
- "<meta Http-equiv=refresh content='2;URL=NextPage.html'></head>\n" +
+ "<meta Http-equiv=refresh content='2;URL=\"NextPage.html\"></head>\n" +
"<body>This has no data\n" +
"</body></html>\n";
defineResource( "SimplePage.html", page );
|
|
From: Russell G. <rus...@us...> - 2003-02-05 05:15:54
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv27511/src/com/meterware/httpunit
Modified Files:
WebResponse.java
Log Message:
Handle quotes in refresh tags
Index: WebResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -r1.106 -r1.107
--- WebResponse.java 4 Feb 2003 05:32:03 -0000 1.106
+++ WebResponse.java 5 Feb 2003 05:15:51 -0000 1.107
@@ -912,10 +912,11 @@
private String getRefreshURL( String text ) {
text = text.trim();
if (!text.toUpperCase().startsWith( "URL" )) {
- return text;
+ return HttpUnitUtils.stripQuotes( text );
} else {
int splitIndex = text.indexOf( '=' );
- return text.substring( splitIndex+1 ).trim();
+ String value = text.substring( splitIndex+1 ).trim();
+ return HttpUnitUtils.stripQuotes( value );
}
}
|
|
From: Russell G. <rus...@us...> - 2003-02-05 05:15:54
|
Update of /cvsroot/httpunit/httpunit/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv27511/doc
Modified Files:
release_notes.txt
Log Message:
Handle quotes in refresh tags
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.247
retrieving revision 1.248
diff -u -r1.247 -r1.248
--- release_notes.txt 4 Feb 2003 19:17:23 -0000 1.247
+++ release_notes.txt 5 Feb 2003 05:15:51 -0000 1.248
@@ -12,10 +12,16 @@
Revision History:
4-Feb-2003
+Acknowledgements:
+ Thanks to Daniel Sheppard and Krystyna Polomski for identifying a problem with meta refresh tags.
+
Additions:
1. Added support for <iframe> tag. IFrames work just like regular frames, except that they are embedded in a response
without a <frameset> tag. IFrame support is controlled by the ClientProperties.iframeSupported property.
2. ServletUnit now handles https requests, marking them as "secure."
+
+Problems fixed:
+ 1. Quotes in refresh URL meta tags are now recognized and stripped.
13-Jan-2003
Notes: upgraded NekoHTML to 0.7.2 which no longer generates superfluous <form> tags.
|
|
From: Russell G. <rus...@us...> - 2003-02-04 19:18:11
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit
In directory sc8-pr-cvs1:/tmp/cvs-serv28379/test/com/meterware/servletunit
Modified Files:
HttpServletRequestTest.java
Log Message:
Add ServletUnit support for https protocol
Index: HttpServletRequestTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/HttpServletRequestTest.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- HttpServletRequestTest.java 3 Jan 2003 16:12:35 -0000 1.10
+++ HttpServletRequestTest.java 4 Feb 2003 19:17:33 -0000 1.11
@@ -268,6 +268,16 @@
}
+ public void testSecureProperty() throws Exception {
+ WebRequest wr = new GetMethodWebRequest( "http://localhost/simple");
+ ServletUnitHttpRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
+ assertFalse( "Incorrectly noted request as secure", request.isSecure() );
+
+ WebRequest secureReq = new GetMethodWebRequest( "https://localhost/simple");
+ request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, secureReq, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
+ assertTrue( "Request not marked as secure", request.isSecure() );
+ }
+
private void verifyLocales(ServletUnitHttpRequest request, Locale[] expectedLocales) {
assertNotNull( "No default locale found", request.getLocale() );
assertEquals( "default locale", expectedLocales[0], request.getLocale() );
|
|
From: Russell G. <rus...@us...> - 2003-02-04 19:18:07
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit
In directory sc8-pr-cvs1:/tmp/cvs-serv28379/src/com/meterware/servletunit
Modified Files:
ServletUnitHttpRequest.java
Log Message:
Add ServletUnit support for https protocol
Index: ServletUnitHttpRequest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpRequest.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- ServletUnitHttpRequest.java 3 Jan 2003 16:12:35 -0000 1.19
+++ ServletUnitHttpRequest.java 4 Feb 2003 19:17:32 -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
@@ -45,7 +45,8 @@
private ServletInputStreamImpl _inputStream;
private String _contentType;
- private Vector _locales;
+ private Vector _locales;
+ private boolean _secure;
/**
@@ -59,6 +60,7 @@
_headers.addEntries( clientHeaders );
_headers.addEntries( request.getHeaders() );
_messageBody = messageBody;
+ _secure = request.getURL().getProtocol().equalsIgnoreCase( "https" );
_contentType = (String) _headers.get( "Content-Type" );
if (context == null) throw new IllegalArgumentException( "Context must not be null" );
@@ -492,7 +494,7 @@
* Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
**/
public boolean isSecure() {
- throw new RuntimeException( "isSecure not implemented" );
+ return _secure;
}
|
|
From: Russell G. <rus...@us...> - 2003-02-04 19:18:06
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv28379/src/com/meterware/httpunit
Modified Files:
WebRequest.java
Added Files:
HttpsProtocolSupport.java
Log Message:
Add ServletUnit support for https protocol
***** Error reading new file[Errno 2] No such file or directory: 'HttpsProtocolSupport.java'
Index: WebRequest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequest.java,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -r1.52 -r1.53
--- WebRequest.java 25 Nov 2002 22:41:07 -0000 1.52
+++ WebRequest.java 4 Feb 2003 19:17:30 -0000 1.53
@@ -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
@@ -24,18 +24,12 @@
import java.io.InputStream;
import java.io.OutputStream;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.net.URLStreamHandler;
-import java.security.Provider;
-import java.security.Security;
-
import java.util.*;
/**
@@ -45,6 +39,7 @@
public class WebRequest {
private static URLStreamHandler JAVASCRIPT_STREAM_HANDLER = new JavascriptURLStreamHandler();
+ private static URLStreamHandler HTTPS_STREAM_HANDLER = new HttpsURLStreamHandler();
private SubmitButton _button;
/**
@@ -67,7 +62,6 @@
* Returns the final URL associated with this web request.
**/
public URL getURL() throws MalformedURLException {
- if (getURLBase() == null || getURLString().indexOf( ':' ) > 0) validateProtocol( getURLString() );
if (getURLBase() == null || getURLBase().toString().indexOf( "?" ) < 0) {
return newURL( getURLBase(), getURLString() );
} else {
@@ -84,7 +78,15 @@
private URL newURL( final URL base, final String spec ) throws MalformedURLException {
if (spec.toLowerCase().startsWith( "javascript:" )) {
return new URL( "javascript", null, -1, spec.substring( "javascript:".length() ), JAVASCRIPT_STREAM_HANDLER );
+ } else if (spec.toLowerCase().startsWith( "https:" ) && !HttpsProtocolSupport.hasHttpsSupport()) {
+ return new URL( "https", null, -1, spec.substring( "https:".length() ), HTTPS_STREAM_HANDLER );
} else {
+ if (getURLBase() == null || getURLString().indexOf( ':' ) > 0) {
+ if (getURLString().indexOf(':') <= 0) {
+ throw new RuntimeException( "No protocol specified in URL '" + getURLString() + "'" );
+ }
+ HttpsProtocolSupport.verifyProtocolSupport( getURLString().substring( 0, getURLString().indexOf( ':' ) ) );
+ }
return spec.startsWith( "?" ) ? new URL( base + spec ) : new URL( base, spec );
}
}
@@ -264,7 +266,7 @@
* Constructs a web request using an absolute URL string.
**/
protected WebRequest( String urlString ) {
- this( (URL) null, urlString );
+ this( null, urlString );
}
@@ -463,15 +465,6 @@
//--------------------------------------- private members ------------------------------------
- /** The name of the system parameter used by java.net to locate protocol handlers. **/
- private final static String PROTOCOL_HANDLER_PKGS = "java.protocol.handler.pkgs";
-
- /** The name of the JSSE class which provides support for SSL. **/
- private final static String SunJSSE_PROVIDER_CLASS = "com.sun.net.ssl.internal.ssl.Provider";
-
- /** The name of the JSSE class which supports the https protocol. **/
- private final static String SSL_PROTOCOL_HANDLER = "com.sun.net.ssl.internal.www.protocol";
-
private final ParameterHolder _parameterHolder;
private URL _urlBase;
@@ -480,67 +473,6 @@
private Hashtable _headers;
private WebRequestSource _webRequestSource;
- private boolean _httpsProtocolSupportEnabled;
-
-
- private void validateProtocol( String urlString ) {
- if (urlString.indexOf(':') <= 0) {
- throw new RuntimeException( "No protocol specified in URL '" + urlString + "'" );
- }
-
- String protocol = urlString.substring( 0, urlString.indexOf( ':' ) );
- if (protocol.equalsIgnoreCase( "http" )) {
- return;
- } else if (protocol.equalsIgnoreCase( "https" )) {
- validateHttpsProtocolSupport();
- }
- }
-
-
- void validateHttpsProtocolSupport() {
- if (!_httpsProtocolSupportEnabled) {
- verifyHttpsSupport();
- _httpsProtocolSupportEnabled = true;
- }
- }
-
-
- private static boolean hasProvider( Class providerClass ) {
- Provider[] list = Security.getProviders();
- for (int i = 0; i < list.length; i++) {
- if (list[i].getClass().equals( providerClass )) return true;
- }
- return false;
- }
-
- private static void verifyHttpsSupport() {
- if (System.getProperty( "java.version" ).startsWith( "1.1" )) {
- throw new RuntimeException( "https support requires Java 2" );
- } else {
- try {
- Class providerClass = Class.forName( SunJSSE_PROVIDER_CLASS );
- if (!hasProvider( providerClass )) Security.addProvider( (Provider) providerClass.newInstance() );
- registerSSLProtocolHandler();
- } catch (ClassNotFoundException e) {
- throw new RuntimeException( "https support requires the Java Secure Sockets Extension. See http://java.sun.com/products/jsse" );
- } catch (Throwable e) {
- throw new RuntimeException( "Unable to enable https support. Make sure that you have installed JSSE " +
- "as described in http://java.sun.com/products/jsse/install.html: " + e );
- }
- }
- }
-
-
- private static void registerSSLProtocolHandler() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
- String list = System.getProperty( PROTOCOL_HANDLER_PKGS );
- Method setMethod = System.class.getMethod( "setProperty", new Class[] { String.class, String.class } );
- if (list == null || list.length() == 0) {
- setMethod.invoke( null, new String[] { PROTOCOL_HANDLER_PKGS, SSL_PROTOCOL_HANDLER } );
- } else if (list.indexOf( SSL_PROTOCOL_HANDLER ) < 0) {
- setMethod.invoke( null, new String[] { PROTOCOL_HANDLER_PKGS, SSL_PROTOCOL_HANDLER + " | " + list } );
- }
- }
-
}
@@ -616,6 +548,17 @@
protected URLConnection openConnection( URL u ) throws IOException {
return null;
+ }
+}
+
+
+//======================================== class HttpsURLStreamHandler ============================================
+
+
+class HttpsURLStreamHandler extends URLStreamHandler {
+
+ protected URLConnection openConnection( URL u ) throws IOException {
+ throw new RuntimeException( "https support requires the Java Secure Sockets Extension. See http://java.sun.com/products/jsse" );
}
}
|
|
From: Russell G. <rus...@us...> - 2003-02-04 19:18:00
|
Update of /cvsroot/httpunit/httpunit/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv28379/doc
Modified Files:
favicon.ico release_notes.txt
Log Message:
Add ServletUnit support for https protocol
Index: favicon.ico
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/favicon.ico,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
Binary files /tmp/cvsvqvCmK and /tmp/cvsCzKrsk differ
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.246
retrieving revision 1.247
diff -u -r1.246 -r1.247
--- release_notes.txt 4 Feb 2003 05:32:03 -0000 1.246
+++ release_notes.txt 4 Feb 2003 19:17:23 -0000 1.247
@@ -15,6 +15,8 @@
Additions:
1. Added support for <iframe> tag. IFrames work just like regular frames, except that they are embedded in a response
without a <frameset> tag. IFrame support is controlled by the ClientProperties.iframeSupported property.
+ 2. ServletUnit now handles https requests, marking them as "secure."
+
13-Jan-2003
Notes: upgraded NekoHTML to 0.7.2 which no longer generates superfluous <form> tags.
|
|
From: Russell G. <rus...@us...> - 2003-02-04 19:17:55
|
Update of /cvsroot/httpunit/httpunit In directory sc8-pr-cvs1:/tmp/cvs-serv28379 Modified Files: project.xml Log Message: Add ServletUnit support for https protocol Index: project.xml =================================================================== RCS file: /cvsroot/httpunit/httpunit/project.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- project.xml 4 Feb 2003 05:32:02 -0000 1.2 +++ project.xml 4 Feb 2003 19:17:19 -0000 1.3 @@ -73,17 +73,53 @@ <dependencies> - <dependency> - <id>nekohtml</id> - <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.1</version> - <url>http://xml.apache.org/xerces2-j/index.html</url> - </dependency> + <dependency> + <id>nekohtml</id> + <version>0.7.1</version> + <url>http://www.apache.org/~andyc/neko/doc/html/index.html</url> + </dependency> + + <dependency> + <id>jtidy</id> + <version>4Aug2000r7</version> + <jar>jtidy-4aug2000r7-dev.jar</jar> + </dependency> + + <dependency> + <id>xml-apis</id> + <version>1.0.b2</version> + <url>http://xml.apache.org/xerces2-j/</url> + </dependency> + + <dependency> + <id>junit</id> + <version>3.8</version> + <url>http://www.junit.org/</url> + </dependency> + + <dependency> + <id>javamail</id> + <version>1.2</version> + <url>http://java.sun.com/</url> + </dependency> + + <dependency> + <id>jaf</id> + <version>1.0.2</version> + <url>http://java.sun.com/</url> + <jar>activation-1.0.2.jar</jar> + </dependency> + + <dependency> + <id>xerces</id> + <version>2.2.1</version> + <url>http://xml.apache.org/xerces2-j/</url> + </dependency> + + <dependency> + <id>rhino</id> + <version>2.3</version> + </dependency> <dependency> <id>servletapi</id> @@ -110,7 +146,7 @@ <!-- Unit test cases --> <unitTest> <includes> - <include>**/*.java</include> + <include>**/*Test.java</include> </includes> </unitTest> |
|
From: Russell G. <rus...@us...> - 2003-02-04 05:32:06
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv6354/src/com/meterware/httpunit
Modified Files:
ClientProperties.java HTMLPage.java NodeUtils.java
ParsedHTML.java TableCell.java WebApplet.java WebFrame.java
WebResponse.java WebTable.java
Log Message:
Added IFRAME support
Index: ClientProperties.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ClientProperties.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ClientProperties.java 8 Oct 2002 14:36:00 -0000 1.3
+++ ClientProperties.java 4 Feb 2003 05:32:03 -0000 1.4
@@ -2,7 +2,7 @@
/********************************************************************************************************************
* $Id$
*
- * Copyright (c) 2002, Russell Gold
+ * Copyright (c) 2002-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,7 +23,7 @@
/**
* A class which represents the properties of a web client.
*
- * @author <a href="mailto:rus...@ac...">Russell Gold</a>
+ * @author <a href="mailto:rus...@ht...">Russell Gold</a>
**/
public class ClientProperties {
@@ -129,6 +129,16 @@
}
+ public boolean isIframeSupported() {
+ return _iframeSupported;
+ }
+
+
+ public void setIframeSupported( boolean iframeSupported ) {
+ _iframeSupported = iframeSupported;
+ }
+
+
static ClientProperties cloneProperties() {
return new ClientProperties( getDefaultProperties() );
}
@@ -142,6 +152,8 @@
private int _availWidth = 800;
private int _availHeight = 600;
+ private boolean _iframeSupported = true;
+
private static ClientProperties _defaultProperties = new ClientProperties();
@@ -155,5 +167,6 @@
_applicationVersion = source._applicationVersion;
_userAgent = source._userAgent;
_platform = source._platform;
+ _iframeSupported = source._iframeSupported;
}
}
Index: HTMLPage.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HTMLPage.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- HTMLPage.java 10 Jan 2003 18:21:44 -0000 1.23
+++ HTMLPage.java 4 Feb 2003 05:32:03 -0000 1.24
@@ -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
@@ -46,8 +46,8 @@
private Scriptable _scriptable;
- HTMLPage( WebResponse response, URL baseURL, String baseTarget, String characterSet ) throws IOException, SAXException {
- super( response, baseURL, baseTarget, null, characterSet );
+ HTMLPage( WebResponse response, String frameName, URL baseURL, String baseTarget, String characterSet ) throws IOException, SAXException {
+ super( response, frameName, baseURL, baseTarget, null, characterSet );
}
Index: NodeUtils.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/NodeUtils.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- NodeUtils.java 26 Dec 2002 15:33:56 -0000 1.17
+++ NodeUtils.java 4 Feb 2003 05:32:03 -0000 1.18
@@ -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
@@ -19,7 +19,6 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
@@ -35,17 +34,6 @@
* Some common utilities for manipulating DOM nodes.
**/
class NodeUtils {
-
-
- public static NodeList getElementsByTagName( Node root, String tagName ) {
- if (root instanceof Document) {
- return ((Document) root).getElementsByTagName( tagName );
- } else if (root instanceof Element) {
- return ((Element) root).getElementsByTagName( tagName );
- } else {
- throw new RuntimeException( "root is neither an Element nor a Document" );
- }
- }
public static int getAttributeValue( Node node, String attributeName, int defaultValue ) {
Index: ParsedHTML.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ParsedHTML.java,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- ParsedHTML.java 30 Dec 2002 21:46:54 -0000 1.43
+++ ParsedHTML.java 4 Feb 2003 05:32:03 -0000 1.44
@@ -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,10 +23,7 @@
import org.w3c.dom.Node;
import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Arrays;
+import java.util.*;
import com.meterware.httpunit.scripting.ScriptableDelegate;
@@ -40,6 +37,8 @@
private URL _baseURL;
+ private String _frameName;
+
private String _baseTarget;
private String _characterSet;
@@ -70,9 +69,13 @@
private ArrayList _tableList = new ArrayList();
private WebTable[] _tables;
+ private ArrayList _frameList = new ArrayList();
+ private WebFrame[] _frames;
+
- ParsedHTML( WebResponse response, URL baseURL, String baseTarget, Node rootNode, String characterSet ) {
+ ParsedHTML( WebResponse response, String frameName, URL baseURL, String baseTarget, Node rootNode, String characterSet ) {
_response = response;
+ _frameName = frameName;
_baseURL = baseURL;
_baseTarget = baseTarget;
_rootNode = rootNode;
@@ -199,6 +202,7 @@
}
}
+ protected boolean isRecognized( ClientProperties properties ) { return true; }
protected boolean addToContext() { return false; }
protected void addToLists( NodeUtils.PreOrderTraversal pot, HTMLElement htmlElement ) {
for (Iterator i = pot.getContexts(); i.hasNext();) {
@@ -267,6 +271,30 @@
}
+ static class WebFrameFactory extends HTMLElementFactory {
+ HTMLElement toHTMLElement( NodeUtils.PreOrderTraversal pot, ParsedHTML parsedHTML, Element element ) {
+ return parsedHTML.toWebFrame( element );
+ }
+ }
+
+
+ static class WebIFrameFactory extends HTMLElementFactory {
+ HTMLElement toHTMLElement( NodeUtils.PreOrderTraversal pot, ParsedHTML parsedHTML, Element element ) {
+ return parsedHTML.toWebFrame( element );
+ }
+
+
+ protected boolean isRecognized( ClientProperties properties ) {
+ return properties.isIframeSupported();
+ }
+
+
+ protected boolean addToContext() {
+ return true;
+ }
+ }
+
+
static class WebImageFactory extends HTMLElementFactory {
HTMLElement toHTMLElement( NodeUtils.PreOrderTraversal pot, ParsedHTML parsedHTML, Element element ) {
return parsedHTML.toWebImage( element );
@@ -353,6 +381,8 @@
_htmlFactoryClasses.put( "tr", new TableRowFactory() );
_htmlFactoryClasses.put( "td", new TableCellFactory() );
_htmlFactoryClasses.put( "th", new TableCellFactory() );
+ _htmlFactoryClasses.put( "frame", new WebFrameFactory() );
+ _htmlFactoryClasses.put( "iframe", new WebIFrameFactory() );
for (Iterator i = Arrays.asList( FormControl.getControlElementTags() ).iterator(); i.hasNext();) {
_htmlFactoryClasses.put( i.next(), new FormControlFactory() );
@@ -371,7 +401,8 @@
NodeUtils.NodeAction action = new NodeUtils.NodeAction() {
public boolean processElement( NodeUtils.PreOrderTraversal pot, Element element ) {
HTMLElementFactory factory = getHTMLElementFactory( element.getNodeName().toLowerCase() );
- if (factory == null) return true;
+ if (factory == null || !factory.isRecognized( getClientProperties() )) return true;
+ if (pot.getClosestContext( WebFrame.class ) != null) return true;
if (!_elements.containsKey( element )) factory.recordElement( pot, element, ParsedHTML.this );
if (factory.addToContext()) pot.pushContext( _elements.get( element ) );
@@ -389,11 +420,22 @@
}
+ private ClientProperties getClientProperties() {
+ WebWindow window = _response.getWindow();
+ return window == null ? ClientProperties.getDefaultProperties() : window.getClient().getClientProperties();
+ }
+
+
private WebForm toWebForm( Element element ) {
return new WebForm( _response, _baseURL, _baseTarget, element, _characterSet );
}
+ private WebFrame toWebFrame( Element element ) {
+ return new WebFrame( _baseURL, element, _frameName );
+ }
+
+
private WebLink toLinkAnchor( Element child ) {
return (!isWebLink( child )) ? null : new WebLink( _response, _baseURL, _baseTarget, child );
}
@@ -415,7 +457,7 @@
private WebTable toWebTable( Element element ) {
- return new WebTable( _response, element, _baseURL, _baseTarget, _characterSet );
+ return new WebTable( _response, _frameName, element, _baseURL, _baseTarget, _characterSet );
}
@@ -437,6 +479,7 @@
if (element instanceof WebImage) return _imagesList;
if (element instanceof WebApplet) return _appletList;
if (element instanceof WebTable) return _tableList;
+ if (element instanceof WebFrame) return _frameList;
return null;
}
@@ -608,6 +651,7 @@
_images = null;
_applets = null;
_tables = null;
+ _frames = null;
_updateElements = true;
}
@@ -630,6 +674,18 @@
**/
Node getOriginalDOM() {
return getRootNode();
+ }
+
+
+ /**
+ * Returns the frames found in the page in the order in which they appear.
+ **/
+ public WebFrame[] getFrames() {
+ if (_frames == null) {
+ loadElements();
+ _frames = (WebFrame[]) _frameList.toArray( new WebFrame[ _frameList.size() ] );
+ }
+ return _frames;
}
Index: TableCell.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/TableCell.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- TableCell.java 30 Dec 2002 21:46:54 -0000 1.10
+++ TableCell.java 4 Feb 2003 05:32:03 -0000 1.11
@@ -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
@@ -114,8 +114,8 @@
//---------------------------------------- package methods -----------------------------------------
- TableCell( WebResponse response, Element cellNode, URL url, String parentTarget, String characterSet ) {
- super( response, url, parentTarget, cellNode, characterSet );
+ TableCell( WebResponse response, String frameName, Element cellNode, URL url, String parentTarget, String characterSet ) {
+ super( response, frameName, url, parentTarget, cellNode, characterSet );
_element = cellNode;
_colSpan = getAttributeValue( cellNode, "colspan", 1 );
_rowSpan = getAttributeValue( cellNode, "rowspan", 1 );
Index: WebApplet.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebApplet.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- WebApplet.java 30 Dec 2002 21:46:54 -0000 1.5
+++ WebApplet.java 4 Feb 2003 05:32:03 -0000 1.6
@@ -40,7 +40,7 @@
/**
* This class represents the embedding of an applet in a web page.
*
- * @author <a href="Oli...@HV...">Oliver Imbusch</a>
+ * @author <a href="mailto:Oli...@HV...">Oliver Imbusch</a>
* @author <a href="mailto:rus...@ht...">Russell Gold</a>
**/
public class WebApplet extends HTMLElementBase {
Index: WebFrame.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebFrame.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- WebFrame.java 10 Oct 2002 21:10:19 -0000 1.10
+++ WebFrame.java 4 Feb 2003 05:32:03 -0000 1.11
@@ -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
@@ -19,6 +19,8 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
+import com.meterware.httpunit.scripting.ScriptableDelegate;
+
import java.net.URL;
import org.w3c.dom.Node;
@@ -26,26 +28,37 @@
/**
* A frame in a web page.
**/
-class WebFrame {
+class WebFrame extends HTMLElementBase {
+
+
+ protected ScriptableDelegate newScriptable() {
+ return null;
+ }
+
+
+ protected ScriptableDelegate getParentDelegate() {
+ return null;
+ }
//---------------------------------------- package methods -----------------------------------------
WebFrame( URL baseURL, Node frameNode, String parentFrameName ) {
+ super( frameNode );
_element = frameNode;
_baseURL = baseURL;
_name = getFrameName( parentFrameName );
}
- String getName() {
+ String getFrameName() {
return _name;
}
private String getFrameName( String parentFrameName ) {
- final String relativeName = NodeUtils.getNodeAttribute( _element, "name" );
+ final String relativeName = super.getName();
if (relativeName.length() == 0) return toString();
else return getNestedFrameName( parentFrameName, relativeName );
}
@@ -80,7 +93,7 @@
WebRequest getInitialRequest() {
return new GetMethodWebRequest( _baseURL,
NodeUtils.getNodeAttribute( _element, "src" ),
- getName() );
+ getFrameName() );
}
Index: WebResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v
retrieving revision 1.105
retrieving revision 1.106
diff -u -r1.105 -r1.106
--- WebResponse.java 26 Dec 2002 04:59:35 -0000 1.105
+++ WebResponse.java 4 Feb 2003 05:32:03 -0000 1.106
@@ -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
@@ -34,8 +34,6 @@
import java.util.zip.GZIPInputStream;
import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -266,7 +264,7 @@
WebFrame[] frames = getFrames();
String[] result = new String[ frames.length ];
for (int i = 0; i < result.length; i++) {
- result[i] = frames[i].getName();
+ result[i] = frames[i].getFrameName();
}
return result;
@@ -788,8 +786,6 @@
final private static int UNINITIALIZED_INT = -2;
- private WebFrame[] _frames;
-
private WebWindow _window;
private HTMLPage _page;
@@ -855,10 +851,11 @@
private void readTags( byte[] rawMessage ) throws UnsupportedEncodingException, MalformedURLException {
ByteTagParser parser = new ByteTagParser( rawMessage );
ByteTag tag = parser.getNextTag();
- while (tag != null && !tag.getName().equalsIgnoreCase( "body" )) {
+ while (tag != null) {
if (tag.getName().equalsIgnoreCase( "meta" )) processMetaTag( tag );
if (tag.getName().equalsIgnoreCase( "base" )) processBaseTag( tag );
if (tag.getName().equalsIgnoreCase( "frameset" )) _hasSubframes = true;
+ if (tag.getName().equalsIgnoreCase( "iframe" )) _hasSubframes = true;
tag = parser.getNextTag();
}
}
@@ -955,23 +952,8 @@
private WebFrame[] getFrames() throws SAXException {
- if (_frames == null) {
- Vector list = new Vector();
- addFrameTags( list, "frame" );
- _frames = new WebFrame[ list.size() ];
- list.copyInto( _frames );
- }
-
- return _frames;
- }
-
+ return getReceivedPage().getFrames();
- private void addFrameTags( Vector list, String frameTagName ) throws SAXException {
- NodeList nl = NodeUtils.getElementsByTagName( getReceivedPage().getOriginalDOM(), frameTagName );
- for (int i = 0; i < nl.getLength(); i++) {
- Node child = nl.item(i);
- list.addElement( new WebFrame( getReceivedPage().getBaseURL(), child, _frameName ) );
- }
}
@@ -979,7 +961,7 @@
if (_page == null) {
try {
if (!isHTML()) throw new NotHTMLException( getContentType() );
- _page = new HTMLPage( this, _baseURL, _baseTarget, getCharacterSet() );
+ _page = new HTMLPage( this, _frameName, _baseURL, _baseTarget, getCharacterSet() );
_page.parse( getText(), _pageURL );
} catch (IOException e) {
e.printStackTrace();
Index: WebTable.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebTable.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- WebTable.java 30 Dec 2002 21:46:55 -0000 1.24
+++ WebTable.java 4 Feb 2003 05:32:03 -0000 1.25
@@ -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
@@ -241,7 +241,8 @@
private Element _dom;
private URL _url;
- private String _parentTarget;
+ private String _frameName;
+ private String _baseTarget;
private String _characterSet;
private WebResponse _response;
@@ -249,12 +250,13 @@
private TableCell[][] _cells;
- WebTable( WebResponse response, Node domTreeRoot, URL sourceURL, String parentTarget, String characterSet ) {
+ WebTable( WebResponse response, String frameName, Node domTreeRoot, URL sourceURL, String baseTarget, String characterSet ) {
super( domTreeRoot );
_response = response;
+ _frameName = frameName;
_dom = (Element) domTreeRoot;
_url = sourceURL;
- _parentTarget = parentTarget;
+ _baseTarget = baseTarget;
_characterSet = characterSet;
}
@@ -334,7 +336,7 @@
TableCell newTableCell( Element element ) {
- return new TableCell( _response, element, _url, _parentTarget, _characterSet );
+ return new TableCell( _response, _frameName, element, _url, _baseTarget, _characterSet );
}
|
|
From: Russell G. <rus...@us...> - 2003-02-04 05:32:06
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv6354/test/com/meterware/httpunit
Modified Files:
WebFrameTest.java
Log Message:
Added IFRAME support
Index: WebFrameTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebFrameTest.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- WebFrameTest.java 15 Jul 2002 16:42:44 -0000 1.13
+++ WebFrameTest.java 4 Feb 2003 05:32:03 -0000 1.14
@@ -2,7 +2,7 @@
/********************************************************************************************************************
* $Id$
*
-* Copyright (c) 2000-2001, 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
@@ -19,15 +19,11 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
-import java.net.URL;
import java.net.HttpURLConnection;
import junit.framework.Test;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
-import java.util.Vector;
-
/**
* A test of the web frame functionality.
@@ -69,7 +65,7 @@
public void testDefaultFrameNames() throws Exception {
defineWebPage( "Initial", "This is a trivial page" );
- WebResponse response = _wc.getResponse( getHostPath() + "/Initial.html" );
+ _wc.getResponse( getHostPath() + "/Initial.html" );
assertMatchingSet( "Frames defined for the conversation", new String[] { "_top" }, _wc.getFrameNames() );
}
@@ -109,7 +105,7 @@
public void testFrameLoading() throws Exception {
- WebResponse response = _wc.getResponse( getHostPath() + "/Frames.html" );
+ _wc.getResponse( getHostPath() + "/Frames.html" );
assertMatchingSet( "Frames defined for the conversation", new String[] { "_top", "red", "blue" }, _wc.getFrameNames() );
assertEquals( "Number of links in first frame", 1, _wc.getFrameContents( "red" ).getLinks().length );
@@ -352,14 +348,37 @@
}
- public void notestParentTarget() throws Exception {
- defineWebPage( "Linker", "This is a trivial page with <a href=Target.html target=_parent>one link</a>" );
+ public void testIFrameDetection() throws Exception {
+ defineWebPage( "Frame", "This is a trivial page with <a href='mailto:rus...@ht...'>one link</a>" +
+ "and <iframe name=center src='Contents.html'><form name=hidden></form></iframe>" );
+ defineWebPage( "Contents", "This is another page with <a href=Form.html>one link</a>" );
+ defineWebPage( "Form", "This is a page with a simple form: " +
+ "<form action=submit><input name=name><input type=submit></form>");
- _wc.getResponse( getHostPath() + "/Frames.html" );
- WebResponse response = _wc.getResponse( _wc.getFrameContents( "red" ).getLinks()[0].getRequest() );
- assertMatchingSet( "Frames defined for the conversation", new String[] { "_top" }, _wc.getFrameNames() );
- assertTrue( "Second response not the same as source frame contents", response == _wc.getFrameContents( "_top" ) );
- assertEquals( "URL for second request", getHostPath() + "/Target.html", response.getURL().toExternalForm() );
+ WebResponse response = _wc.getResponse( getHostPath() + "/Frame.html" );
+ WebRequest[] requests = response.getFrameRequests();
+ assertEquals( "Number of links in main frame", 1, response.getLinks().length );
+ assertEquals( "Number of forms in main frame", 0, response.getForms().length );
+ assertEquals( "Number of frame requests", 1, requests.length );
+ assertEquals( "Target for iframe request", "center", requests[0].getTarget() );
+
+ WebResponse contents = getFrameWithURL( _wc, "Contents" );
+ assertNotNull( "Contents not found", contents );
+ assertEquals( "Number of links in iframe", 1, _wc.getFrameContents( "center" ).getLinks().length );
+ }
+
+
+ public void testIFrameDisabled() throws Exception {
+ defineWebPage( "Frame", "This is a trivial page with <a href='mailto:rus...@ht...'>one link</a>" +
+ "and <iframe name=center src='Contents.html'><form name=hidden></form></iframe>" );
+ defineWebPage( "Contents", "This is another page with <a href=Form.html>one link</a>" );
+
+ _wc.getClientProperties().setIframeSupported( false );
+ WebResponse response = _wc.getResponse( getHostPath() + "/Frame.html" );
+ WebRequest[] requests = response.getFrameRequests();
+ assertEquals( "Number of links in main frame", 1, response.getLinks().length );
+ assertEquals( "Number of forms in main frame", 1, response.getForms().length );
+ assertEquals( "Number of frame requests", 0, requests.length );
}
|
|
From: Russell G. <rus...@us...> - 2003-02-04 05:32:05
|
Update of /cvsroot/httpunit/httpunit/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv6354/doc
Modified Files:
release_notes.txt todo.txt
Log Message:
Added IFRAME support
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.245
retrieving revision 1.246
diff -u -r1.245 -r1.246
--- release_notes.txt 13 Jan 2003 21:57:30 -0000 1.245
+++ release_notes.txt 4 Feb 2003 05:32:03 -0000 1.246
@@ -11,7 +11,11 @@
Revision History:
-13-Jan-2002
+ 4-Feb-2003
+Additions:
+ 1. Added support for <iframe> tag. IFrames work just like regular frames, except that they are embedded in a response
+ without a <frameset> tag. IFrame support is controlled by the ClientProperties.iframeSupported property.
+13-Jan-2003
Notes: upgraded NekoHTML to 0.7.2 which no longer generates superfluous <form> tags.
10-Jan-2003
Index: todo.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/todo.txt,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- todo.txt 14 Oct 2002 18:27:42 -0000 1.39
+++ todo.txt 4 Feb 2003 05:32:03 -0000 1.40
@@ -1,13 +1,7 @@
-High priority:
-o Support cookie paths
-
Medium priority:
-o Support optional tags which hide their contents (as in IFRAME, OBJECT, etc.)
+o Support optional tags which hide their contents (as in OBJECT, etc.)
o Check conformance with RFC 2109 - not currently sending $Version=1 string
o Documentation, Documentation
-
-JavaScript priorities:
-o Document.write - some more parser work is needed for this to work
Possibles:
|