httpunit-commit Mailing List for httpunit (Page 27)
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-06-19 01:26:20
|
Update of /cvsroot/httpunit/httpunit/site/com/meterware/website
In directory sc8-pr-cvs1:/tmp/cvs-serv10622/site/com/meterware/website
Modified Files:
Site.java
Log Message:
put SF logo on all pages
Index: Site.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/site/com/meterware/website/Site.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Site.java 26 May 2003 15:42:13 -0000 1.5
+++ Site.java 19 Jun 2003 01:26:17 -0000 1.6
@@ -255,11 +255,9 @@
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 );
- if (currentPage.isMainPage()) {
- 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 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 );
|
|
From: Russell G. <rus...@us...> - 2003-06-17 23:26:41
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/cookies
In directory sc8-pr-cvs1:/tmp/cvs-serv12536/src/com/meterware/httpunit/cookies
Modified Files:
CookieJar.java
Log Message:
fixed bug #750846: Cannot retrieve all cookie names when both global and site-specific cookies are defined.
Index: CookieJar.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/cookies/CookieJar.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- CookieJar.java 17 Jun 2003 11:08:25 -0000 1.4
+++ CookieJar.java 17 Jun 2003 23:26:38 -0000 1.5
@@ -101,7 +101,7 @@
names[i] = ((Cookie) _globalCookies.get(i)).getName();
}
for (int i = numGlobalCookies; i < names.length; i++) {
- names[ i + numGlobalCookies ] = ((Cookie) _cookies.get(i)).getName();
+ names[i] = ((Cookie) _cookies.get( i-numGlobalCookies )).getName();
}
return names;
}
|
|
From: Russell G. <rus...@us...> - 2003-06-17 23:26:41
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/cookies
In directory sc8-pr-cvs1:/tmp/cvs-serv12536/test/com/meterware/httpunit/cookies
Modified Files:
CookieTest.java
Log Message:
fixed bug #750846: Cannot retrieve all cookie names when both global and site-specific cookies are defined.
Index: CookieTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/cookies/CookieTest.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- CookieTest.java 17 Jun 2003 11:08:25 -0000 1.4
+++ CookieTest.java 17 Jun 2003 23:26:38 -0000 1.5
@@ -27,6 +27,7 @@
import junit.framework.TestSuite;
import junit.framework.Assert;
import junit.textui.TestRunner;
+import com.meterware.pseudoserver.HttpUserAgentTest;
/**
@@ -163,6 +164,10 @@
checkHeader( 1, jar, "first=ready;second=set;zero=nil", "www.meterware.com/servlets/standard/Count" );
checkHeader( 2, jar, "second=set;zero=nil", "www.meterware.com/servlets/special/Divide" );
checkHeader( 3, jar, "zero=go", "fancy.httpunit.org/servlets/AskMe" );
+
+ HttpUserAgentTest.assertMatchingSet( "Cookie names",
+ new String[] { "zero", "zero", "first", "second", "fourth" },
+ jar.getCookieNames() );
}
|
|
From: Russell G. <rus...@us...> - 2003-06-17 23:26:41
|
Update of /cvsroot/httpunit/httpunit/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv12536/doc
Modified Files:
release_notes.txt
Log Message:
fixed bug #750846: Cannot retrieve all cookie names when both global and site-specific cookies are defined.
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.303
retrieving revision 1.304
diff -u -r1.303 -r1.304
--- release_notes.txt 17 Jun 2003 11:17:45 -0000 1.303
+++ release_notes.txt 17 Jun 2003 23:26:38 -0000 1.304
@@ -14,6 +14,13 @@
Revision History:
17-Jun-2003
+Acknowledgements:
+ Thanks to Lloyd McKenzie for finding a problem with listing cookie names and suggesting a fix.
+
+Problems fixed:
+ 1. bug #750846: Cannot retrieve all cookie names when both global and site-specific cookies are defined.
+ 2. bug #744214: ServletUnit does not recognize subframes
+
Additions:
1. A new class CookieProperties now supports relaxing cookie matching rules for path, domain, or both.
2. It is now possible to define a CookieListener on CookieProperties to watch for cookie rejection events
|
|
From: Russell G. <rus...@us...> - 2003-06-17 23:23:05
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit In directory sc8-pr-cvs1:/tmp/cvs-serv11775/test/com/meterware/servletunit Modified Files: StatelessTest.java Log Message: #744214: ServletUnit does not recognize subframes Index: StatelessTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/StatelessTest.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- StatelessTest.java 17 Mar 2003 17:37:05 -0000 1.11 +++ StatelessTest.java 17 Jun 2003 23:23:02 -0000 1.12 @@ -20,6 +20,7 @@ * *******************************************************************************************************************/ import com.meterware.httpunit.*; +import com.meterware.pseudoserver.HttpUserAgentTest; import java.io.*; import java.net.HttpURLConnection; @@ -216,6 +217,21 @@ } + public void testFrameAccess() throws Exception { + ServletRunner sr = new ServletRunner(); + sr.registerServlet( "Frames", FrameTopServlet.class.getName() ); + sr.registerServlet( "RedFrame", SimpleGetServlet.class.getName() ); + sr.registerServlet( "BlueFrame", AccessCountServlet.class.getName() ); + + WebClient client = sr.newClient(); + WebRequest request = new GetMethodWebRequest( "http://host/Frames" ); + client.getResponse( request ); + HttpUserAgentTest.assertMatchingSet( "Frames defined for the conversation", new String[] { "_top", "red", "blue" }, client.getFrameNames() ); + WebResponse response = client.getFrameContents( "red" ); + assertEquals( "Frame contents", SimpleGetServlet.RESPONSE_TEXT, response.getText() ); + } + + static class SimpleGetServlet extends HttpServlet { static String RESPONSE_TEXT = "the desired content\r\n"; @@ -333,6 +349,22 @@ resp.setContentType( "text/plain" ); PrintWriter pw = resp.getWriter(); pw.print( "You posted " + req.getParameter( "login" ) + "," + req.getParameter( "password" ) ); + pw.close(); + } + + } + + + static class FrameTopServlet extends HttpServlet { + + protected void doGet( HttpServletRequest req, HttpServletResponse resp ) throws ServletException, IOException { + resp.setContentType( "text/html" ); + + PrintWriter pw = resp.getWriter(); + pw.println( "<html><head></head><frameset cols='20%,80&'>" ); + pw.println( "<frame src='RedFrame' name='red'>" ); + pw.println( "<frame src='BlueFrame' name='blue'>" ); + pw.println( "</frameset></html>" ); pw.close(); } |
|
From: Russell G. <rus...@us...> - 2003-06-17 23:23:05
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit
In directory sc8-pr-cvs1:/tmp/cvs-serv11775/src/com/meterware/servletunit
Modified Files:
InvocationContextImpl.java ServletUnitWebResponse.java
Log Message:
#744214: ServletUnit does not recognize subframes
Index: InvocationContextImpl.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/InvocationContextImpl.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- InvocationContextImpl.java 27 Feb 2003 23:36:02 -0000 1.13
+++ InvocationContextImpl.java 17 Jun 2003 23:23:02 -0000 1.14
@@ -98,7 +98,7 @@
cookie.setPath( _application.getContextPath() );
_response.addCookie( cookie );
}
- _webResponse = new ServletUnitWebResponse( _client, _target, _requestURL, _response );
+ _webResponse = new ServletUnitWebResponse( _client, _target, _requestURL, _response, _client.getExceptionsThrownOnErrorStatus() );
}
return _webResponse;
}
Index: ServletUnitWebResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitWebResponse.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ServletUnitWebResponse.java 22 Aug 2002 15:48:41 -0000 1.11
+++ ServletUnitWebResponse.java 17 Jun 2003 23:23:02 -0000 1.12
@@ -24,6 +24,7 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.URL;
+import java.net.HttpURLConnection;
import javax.servlet.http.HttpServletResponse;
@@ -39,10 +40,25 @@
* @param url the url from which the response was received
* @param response the response populated by the servlet
**/
- ServletUnitWebResponse( ServletUnitClient client, String target, URL url, HttpServletResponse response ) throws IOException {
+ ServletUnitWebResponse( ServletUnitClient client, String target, URL url, HttpServletResponse response, boolean throwExceptionOnError ) throws IOException {
super( client, target, url );
_response = (ServletUnitHttpResponse) response;
- defineRawInputStream( new ByteArrayInputStream( _response.getContents() ) );
+ /** make sure that any IO exception for HTML received page happens here, not later. **/
+ if (getResponseCode() < HttpURLConnection.HTTP_BAD_REQUEST || !throwExceptionOnError) {
+ defineRawInputStream( new ByteArrayInputStream( _response.getContents() ) );
+ if (getContentType().startsWith( "text" )) loadResponseText();
+ }
+ }
+
+
+ /**
+ * Constructs a response object from a servlet response.
+ * @param target the target frame on which the response will be displayed
+ * @param url the url from which the response was received
+ * @param response the response populated by the servlet
+ **/
+ ServletUnitWebResponse( ServletUnitClient client, String target, URL url, HttpServletResponse response ) throws IOException {
+ this( client, target, url, response, true );
}
|
|
From: Russell G. <rus...@us...> - 2003-06-17 23:23:05
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/pseudoserver
In directory sc8-pr-cvs1:/tmp/cvs-serv11775/src/com/meterware/pseudoserver
Modified Files:
HttpUserAgentTest.java
Log Message:
#744214: ServletUnit does not recognize subframes
Index: HttpUserAgentTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/pseudoserver/HttpUserAgentTest.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- HttpUserAgentTest.java 19 Mar 2003 15:26:06 -0000 1.9
+++ HttpUserAgentTest.java 17 Jun 2003 23:23:02 -0000 1.10
@@ -169,7 +169,7 @@
}
- protected void assertMatchingSet( String comment, Object[] expected, Object[] found ) {
+ public static void assertMatchingSet( String comment, Object[] expected, Object[] found ) {
Vector foundItems = new Vector();
for (int i = 0; i < found.length; i++) foundItems.addElement( found[ i ] );
@@ -197,7 +197,7 @@
}
- protected String asText( Object[] args ) {
+ public static String asText( Object[] args ) {
StringBuffer sb = new StringBuffer( "{" );
for (int i = 0; i < args.length; i++) {
if (i != 0) sb.append( "," );
|
|
From: Russell G. <rus...@us...> - 2003-06-17 11:17:48
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit
In directory sc8-pr-cvs1:/tmp/cvs-serv15604/src/com/meterware/servletunit
Modified Files:
ServletRunner.java
Log Message:
Add support for context parameters from invocation context
Index: ServletRunner.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletRunner.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- ServletRunner.java 27 Feb 2003 23:36:03 -0000 1.21
+++ ServletRunner.java 17 Jun 2003 11:17:45 -0000 1.22
@@ -132,6 +132,15 @@
/**
+ * Returns the value of the named context parameter found in the application definition.
+ */
+ public String getContextParameter( String name ) {
+ Object value = _application.getContextParameters().get( name );
+ return value == null ? null : value.toString();
+ }
+
+
+ /**
* Shuts down the servlet container, returning any resources held by it.
* Calls the destroy method of each active servlet.
*/
|
|
From: Russell G. <rus...@us...> - 2003-06-17 11:17:48
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit
In directory sc8-pr-cvs1:/tmp/cvs-serv15604/test/com/meterware/servletunit
Modified Files:
WebXMLTest.java
Log Message:
Add support for context parameters from invocation context
Index: WebXMLTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/WebXMLTest.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- WebXMLTest.java 19 Feb 2003 19:18:00 -0000 1.15
+++ WebXMLTest.java 17 Jun 2003 11:17:45 -0000 1.16
@@ -139,6 +139,7 @@
ServletRunner sr = new ServletRunner( toInputStream( wxs.asText() ) );
ServletUnitClient client = sr.newClient();
+ assertEquals( "Context parameter 'icecream'", "vanilla", sr.getContextParameter( "icecream" ) );
InvocationContext ic = client.newInvocation( "http://localhost/SimpleServlet" );
javax.servlet.ServletContext sc = ((HttpServlet) ic.getServlet()).getServletContext();
|
|
From: Russell G. <rus...@us...> - 2003-06-17 11:17:48
|
Update of /cvsroot/httpunit/httpunit/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv15604/doc
Modified Files:
release_notes.txt
Log Message:
Add support for context parameters from invocation context
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.302
retrieving revision 1.303
diff -u -r1.302 -r1.303
--- release_notes.txt 17 Jun 2003 11:08:25 -0000 1.302
+++ release_notes.txt 17 Jun 2003 11:17:45 -0000 1.303
@@ -18,6 +18,10 @@
1. A new class CookieProperties now supports relaxing cookie matching rules for path, domain, or both.
2. It is now possible to define a CookieListener on CookieProperties to watch for cookie rejection events
+ 4-Jun-2003
+Additions:
+ 1. You can now get the value of context parameters from a ServletRunner via the getContextParameter method
+
23-May-2002
Problems fixed:
1. bug #721989: scripts did not see id attributes of form controls.
|
|
From: Russell G. <rus...@us...> - 2003-06-17 11:16:19
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv15393/src/com/meterware/httpunit
Modified Files:
HTMLElement.java HTMLElementBase.java TableCell.java
WebRequestSource.java
Log Message:
Support className property
Index: HTMLElement.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HTMLElement.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- HTMLElement.java 26 Dec 2002 04:59:35 -0000 1.1
+++ HTMLElement.java 17 Jun 2003 11:16:15 -0000 1.2
@@ -37,6 +37,12 @@
/**
+ * Returns the class associated with this element.
+ **/
+ String getClassName();
+
+
+ /**
* Returns the name associated with this element.
**/
String getName();
Index: HTMLElementBase.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HTMLElementBase.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- HTMLElementBase.java 30 Dec 2002 21:46:54 -0000 1.2
+++ HTMLElementBase.java 17 Jun 2003 11:16:15 -0000 1.3
@@ -41,6 +41,11 @@
}
+ public String getClassName() {
+ return getAttribute( "class" );
+ }
+
+
public String getTitle() {
return getAttribute( "title" );
}
Index: TableCell.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/TableCell.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- TableCell.java 24 Mar 2003 03:22:09 -0000 1.12
+++ TableCell.java 17 Jun 2003 11:16:15 -0000 1.13
@@ -78,6 +78,11 @@
}
+ public String getClassName() {
+ return getAttribute( "class" );
+ }
+
+
/**
* Returns the name associated with this element.
**/
Index: WebRequestSource.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequestSource.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- WebRequestSource.java 23 May 2003 03:24:50 -0000 1.30
+++ WebRequestSource.java 17 Jun 2003 11:16:15 -0000 1.31
@@ -41,6 +41,14 @@
/**
+ * Returns the class associated with this request source.
+ **/
+ public String getClassName() {
+ return getAttribute( "class" );
+ }
+
+
+ /**
* Returns the name associated with this request source.
**/
public String getName() {
|
|
From: Russell G. <rus...@us...> - 2003-06-17 11:15:06
|
Update of /cvsroot/httpunit/httpunit/site/com/meterware/xml
In directory sc8-pr-cvs1:/tmp/cvs-serv15190/site/com/meterware/xml
Modified Files:
DocumentSemantics.java WriteableXMLElement.java
Log Message:
Support XML rewriting
Index: DocumentSemantics.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/site/com/meterware/xml/DocumentSemantics.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DocumentSemantics.java 27 May 2003 05:15:21 -0000 1.3
+++ DocumentSemantics.java 17 Jun 2003 11:15:03 -0000 1.4
@@ -35,6 +35,7 @@
import java.util.Date;
import java.io.File;
import java.io.IOException;
+import java.text.SimpleDateFormat;
/**
@@ -43,8 +44,10 @@
**/
public class DocumentSemantics {
+ private final static String LINE_BREAK = System.getProperty( "line.separator" );
private static final Class[] NO_ARG_CLASSES = new Class[0];
private static final Object[] NO_ARGS = new Object[0];
+ private static SimpleDateFormat DATE_FORMAT = new SimpleDateFormat( "d-MMM-yyyy" );
public static void build( Document document, Object documentRoot, String documentName ) {
try {
@@ -169,6 +172,7 @@
final PropertyDescriptor propertyDescriptor = getProperty( beanInfo, propertyName );
if (propertyDescriptor == null) return "";
Object result = propertyDescriptor.getReadMethod().invoke( template, NO_ARGS );
+ if (result instanceof Date) result = DATE_FORMAT.format( (Date) result );
return result == null ? "" : result.toString();
} catch (Exception e) {
e.printStackTrace();
@@ -182,6 +186,52 @@
return DocumentBuilderFactory.newInstance().newDocumentBuilder().parse( file );
} catch (ParserConfigurationException e) {
throw new RuntimeException( "Unable to create a parser for XML documents: " + e );
+ }
+ }
+
+
+ public static String generateXML( WriteableRootElement node ) {
+ StringBuffer sb = new StringBuffer( "<?xml version='1.0' ?>" ).append( LINE_BREAK );
+ appendElement( sb, node, "" );
+ return sb.toString();
+ }
+
+
+ private static void appendElement( StringBuffer sb, WriteableXMLElement element, String prefix ) {
+ sb.append( prefix ).append( '<' ).append( element.getElementName() );
+ String[] attributeNames = element.getAttributeNames();
+ for (int i = 0; i < attributeNames.length; i++) {
+ String attributeName = attributeNames[i];
+ if (element.isExplicitAttribute( attributeName )) {
+ sb.append( ' ' ).append( attributeName ).append( "='" ).append( getStringProperty( attributeName, element ) ).append( "'" );
+ }
+ }
+ boolean isEmpty = true;
+ final String contents = element.getContents();
+ if (contents != null) {
+ isEmpty = false;
+ sb.append( '>' );
+ sb.append( contents );
+ sb.append( "</" ).append( element.getElementName() ).append( '>' ).append( LINE_BREAK );
+ } else {
+ String[] nestedElementNames = element.getNestedElementNames();
+ for (int i = 0; i < nestedElementNames.length; i++) {
+ String nestedElementName = nestedElementNames[i];
+ WriteableXMLElement[] children = element.getNestedElements( nestedElementName );
+ for (int j = 0; j < children.length; j++) {
+ WriteableXMLElement child = children[j];
+ if (isEmpty) {
+ isEmpty = false;
+ sb.append( '>' ).append( LINE_BREAK );
+ }
+ appendElement( sb, child, prefix + " " );
+ }
+ }
+ if (isEmpty) {
+ sb.append( "/>" ).append( LINE_BREAK );
+ } else {
+ sb.append( prefix ).append( "</" ).append( element.getElementName() ).append( '>' ).append( LINE_BREAK );
+ }
}
}
Index: WriteableXMLElement.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/site/com/meterware/xml/WriteableXMLElement.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- WriteableXMLElement.java 18 May 2003 05:20:47 -0000 1.1
+++ WriteableXMLElement.java 17 Jun 2003 11:15:03 -0000 1.2
@@ -27,39 +27,38 @@
public interface WriteableXMLElement {
/**
- * Returns the names of the attributes of this element in the order in which they should be displayed.
+ * Returns the name of this element.
*/
- String[] getAttributeNames();
+ String getElementName();
/**
- * Returns the names of the nested elements of this element in the order in which they should be displayed.
+ * Returns the names of the attributes of this element in the order in which they should be displayed.
*/
- String[] getNestedElementNames();
+ String[] getAttributeNames();
/**
- * Returns all nested elements with the specified name.
+ * Returns true if the specified attribute should be written. Some attributes may be left implicit if they have
+ * their default values.
*/
- WriteableXMLElement[] getNestedElements( String elementName );
+ boolean isExplicitAttribute( String attributeName );
/**
- * Returns any text contents of this element.
+ * Returns the names of the nested elements of this element in the order in which they should be displayed.
*/
- String getContents();
+ String[] getNestedElementNames();
/**
- * Returns true if the specified attribute should be written. Some attributes may be left implicit if they have
- * their default values.
+ * Returns all nested elements with the specified name.
*/
- boolean isExplicitAttribute( String attributeName );
+ WriteableXMLElement[] getNestedElements( String elementName );
/**
- * Resets the specified attribute to its default value. Implementations may use this rather than an explicit
- * setter to decide whether to make an attribute explicit.
+ * Returns any text contents of this element.
*/
- void resetAttribute( String attributeName );
+ String getContents();
}
|
|
From: Russell G. <rus...@us...> - 2003-06-17 11:08:30
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/cookies
In directory sc8-pr-cvs1:/tmp/cvs-serv13759/test/com/meterware/httpunit/cookies
Modified Files:
CookieTest.java
Log Message:
Add cookie leniency and callbacks
Index: CookieTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/cookies/CookieTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CookieTest.java 23 May 2003 21:52:58 -0000 1.3
+++ CookieTest.java 17 Jun 2003 11:08:25 -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
@@ -25,6 +25,7 @@
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import junit.framework.Assert;
import junit.textui.TestRunner;
@@ -49,6 +50,12 @@
}
+ protected void setUp() throws Exception {
+ super.setUp();
+ CookieProperties.reset();
+ }
+
+
public void testSimpleCookies() throws Exception {
CookieJar jar = new CookieJar(
new TestSource( new URL( "http://www.meterware.com" ),
@@ -104,9 +111,7 @@
checkAcceptance( 5, false, "www.meterware.com/servlets/special", "meterware", null );
checkAcceptance( 6, false, "www.meterware.com/servlets/special", ".com", null );
checkAcceptance( 7, false, "www.meterware.com/servlets/special", ".httpunit.org", null );
-
- // N.B. This cookie should be rejected if we are using strict domain matching, but is accepted with lenient matching.
- checkAcceptance( 8, true, "www.some.meterware.com/servlets/special", ".meterware.com", null );
+ checkAcceptance( 8, false, "www.some.meterware.com/servlets/special", ".meterware.com", null );
}
@@ -180,6 +185,83 @@
private CookieJar newJar( String urlString, String setCookieHeader ) throws MalformedURLException {
return new CookieJar( new TestSource( new URL( "http://" + urlString ), setCookieHeader ) );
}
+
+
+ public void testLenientMatching() throws Exception {
+ CookieProperties.setDomainMatchingStrict( false );
+ checkAcceptance( 1, true, "www.some.meterware.com/servlets/special", ".meterware.com", null );
+ checkAcceptance( 2, false, "www.meterware.com/servlets/special", ".meterware.com", "/servlets/ordinary" );
+
+ CookieProperties.setPathMatchingStrict( false );
+ checkAcceptance( 3, true, "www.meterware.com/servlets/special", ".meterware.com", "/servlets/ordinary" );
+ checkMatching( 4, true, new URL( "http://www.meterware.com/servlets/sample" ), "www.meterware.com", "/servlets/sample/data" );
+ }
+
+
+ public void testRejectionCallbacks() throws Exception {
+ MockListener listener = new MockListener();
+ CookieProperties.addCookieListener( listener );
+
+ checkCallback( listener, 1, 0, "www.meterware.com/servlets/special", null, null );
+ checkCallback( listener, 2, CookieListener.PATH_NOT_PREFIX, "www.meterware.com/servlets/special", ".meterware.com", "/servlets/ordinary" );
+ checkCallback( listener, 3, CookieListener.DOMAIN_NO_STARTING_DOT, "www.meterware.com/servlets/special", "meterware.com", null );
+ checkCallback( listener, 4, CookieListener.DOMAIN_ONE_DOT, "www.meterware.com/servlets/special", ".com", null );
+ checkCallback( listener, 5, CookieListener.DOMAIN_NOT_SOURCE_SUFFIX, "www.meterware.com/servlets/special", ".httpunit.org", null );
+ checkCallback( listener, 6, CookieListener.DOMAIN_TOO_MANY_LEVELS, "www.some.meterware.com/servlets/special", ".meterware.com", null );
+ }
+
+
+ private void checkCallback( MockListener listener, int index, int status, String urlString,
+ String specifiedDomain, String specifiedPath ) throws MalformedURLException {
+ if (status == 0) {
+ listener.expectAcceptance( index );
+ } else if (status == CookieListener.PATH_NOT_PREFIX) {
+ listener.expectRejection( index, "name", status, specifiedPath );
+ } else {
+ listener.expectRejection( index, "name", status, specifiedDomain );
+ }
+ newJar( urlString, specifiedDomain, specifiedPath );
+ if (status != 0) listener.confirmRejection();
+ }
+
+
+ private class MockListener implements CookieListener {
+
+ private int _reason;
+ private String _attribute;
+ private String _cookieName;
+ private boolean _rejected;
+ private int _cookieNum;
+
+
+ void expectAcceptance( int cookieNum ) {
+ _cookieNum = cookieNum;
+ _reason = -1;
+ }
+
+
+ void expectRejection( int cookieNum, String cookieName, int reason, String attribute ) {
+ _cookieNum = cookieNum;
+ _reason = reason;
+ _attribute = attribute;
+ _cookieName = cookieName;
+ _rejected = false;
+ }
+
+
+ void confirmRejection() {
+ Assert.assertTrue( "Cookie " + _cookieNum + " was not logged as rejected", _rejected );
+ }
+
+
+ public void cookieRejected( String name, int reason, String attribute ) {
+ _rejected = true;
+ Assert.assertEquals( "Cookie " + _cookieNum + " rejection code", _reason, reason );
+ if (_attribute != null) Assert.assertEquals( "Cookie " + _cookieNum + " rejected attribute", _attribute, attribute );
+ if (_cookieName != null) Assert.assertEquals( "Cookie " + _cookieNum + " name", _cookieName, name );
+ }
+ }
+
private class TestSource implements CookieSource {
|
|
From: Russell G. <rus...@us...> - 2003-06-17 11:08:29
|
Update of /cvsroot/httpunit/httpunit/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv13759/doc
Modified Files:
release_notes.txt
Log Message:
Add cookie leniency and callbacks
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.301
retrieving revision 1.302
diff -u -r1.301 -r1.302
--- release_notes.txt 23 May 2003 21:55:11 -0000 1.301
+++ release_notes.txt 17 Jun 2003 11:08:25 -0000 1.302
@@ -13,12 +13,17 @@
Revision History:
+17-Jun-2003
+Additions:
+ 1. A new class CookieProperties now supports relaxing cookie matching rules for path, domain, or both.
+ 2. It is now possible to define a CookieListener on CookieProperties to watch for cookie rejection events
+
23-May-2002
Problems fixed:
1. bug #721989: scripts did not see id attributes of form controls.
2. bug #741965: cookies with explicit domain attributes are being rejected when their host is of the form HD
where D is the explicit domain attribute and H contains a dot. Apparently, most browsers ignore this
- rule. Now, so does HttpUnit.
+ rule. Now, so does HttpUnit, if CookieProperties.setDomainMatchingStrict( false ) is called.
22-May-2003
Problems fixed:
|
|
From: Russell G. <rus...@us...> - 2003-06-17 11:08:29
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/cookies
In directory sc8-pr-cvs1:/tmp/cvs-serv13759/src/com/meterware/httpunit/cookies
Modified Files:
Cookie.java CookieJar.java
Added Files:
CookieListener.java CookieProperties.java
Log Message:
Add cookie leniency and callbacks
***** Error reading new file[Errno 2] No such file or directory: 'CookieListener.java'
***** Error reading new file[Errno 2] No such file or directory: 'CookieProperties.java'
Index: Cookie.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/cookies/Cookie.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Cookie.java 4 Nov 2002 21:01:37 -0000 1.3
+++ Cookie.java 17 Jun 2003 11:08:25 -0000 1.4
@@ -111,7 +111,12 @@
boolean mayBeSentTo( URL url ) {
if (getDomain() == null) return true;
- return acceptHost( getDomain(), url.getHost() ) && url.getPath().startsWith( getPath() );
+ return acceptHost( getDomain(), url.getHost() ) && acceptPath( getPath(), url.getPath() );
+ }
+
+
+ private boolean acceptPath( String pathPattern, String hostPath ) {
+ return !CookieProperties.isPathMatchingStrict() || hostPath.startsWith( pathPattern );
}
Index: CookieJar.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/cookies/CookieJar.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CookieJar.java 23 May 2003 21:52:57 -0000 1.3
+++ CookieJar.java 17 Jun 2003 11:08:25 -0000 1.4
@@ -328,13 +328,21 @@
if (cookie.getPath() == null) {
cookie.setPath( getParentPath( _sourceURL.getPath() ) );
} else {
- if (!pathAttributeIsValid( _sourceURL.getPath(), cookie.getPath() )) return false;
+ int status = getPathAttributeStatus( cookie.getPath(), _sourceURL.getPath() );
+ if (status != CookieListener.ACCEPTED) {
+ reportCookieRejected( status, cookie.getPath(), cookie.getName() );
+ return false;
+ }
}
if (cookie.getDomain() == null) {
cookie.setDomain( _sourceURL.getHost() );
} else {
- if (!domainAttributeIsValid( cookie.getDomain(), _sourceURL.getHost() )) return false;
+ int status = getDomainAttributeStatus( cookie.getDomain(), _sourceURL.getHost() );
+ if (status != CookieListener.ACCEPTED) {
+ reportCookieRejected( status, cookie.getDomain(), cookie.getName() );
+ return false;
+ }
}
return true;
@@ -347,26 +355,35 @@
}
- private boolean pathAttributeIsValid( String sourcePath, String pathAttribute ) {
- return sourcePath.length() == 0 || sourcePath.startsWith( pathAttribute );
+ private int getPathAttributeStatus( String pathAttribute, String sourcePath ) {
+ if (!CookieProperties.isPathMatchingStrict() || sourcePath.length() == 0 || sourcePath.startsWith( pathAttribute )) {
+ return CookieListener.ACCEPTED;
+ } else {
+ return CookieListener.PATH_NOT_PREFIX;
+ }
}
- private boolean domainAttributeIsValid( String domainAttribute, String sourceHost ) {
- if (!domainAttribute.startsWith(".")) return false;
- if (domainAttribute.lastIndexOf('.') == 0) return false;
- if (!sourceHost.endsWith( domainAttribute )) return false;
- if (!isLenientMatching() && sourceHost.lastIndexOf( domainAttribute ) > sourceHost.indexOf( '.' )) return false;
- return true;
+ private int getDomainAttributeStatus( String domainAttribute, String sourceHost ) {
+ if (!domainAttribute.startsWith(".")) {
+ return CookieListener.DOMAIN_NO_STARTING_DOT;
+ } else if (domainAttribute.lastIndexOf('.') == 0) {
+ return CookieListener.DOMAIN_ONE_DOT;
+ } else if (!sourceHost.endsWith( domainAttribute )) {
+ return CookieListener.DOMAIN_NOT_SOURCE_SUFFIX;
+ } else if (CookieProperties.isDomainMatchingStrict() &&
+ sourceHost.lastIndexOf( domainAttribute ) > sourceHost.indexOf( '.' )) {
+ return CookieListener.DOMAIN_TOO_MANY_LEVELS;
+ } else {
+ return CookieListener.ACCEPTED;
+ }
}
- // set this to false to reject cookies when the host is of the form HD where D is the explicit domain attribute
- // and H contains a dot. Apparently, most browsers are lenient.
- private boolean isLenientMatching() {
- return true;
+ private boolean reportCookieRejected( int reason, String attribute, String source ) {
+ CookieProperties.reportCookieRejected( reason, attribute, source );
+ return false;
}
-
}
|
|
From: Russell G. <rus...@us...> - 2003-06-16 01:31:48
|
Update of /cvsroot/httpunit/httpunit/sitedocs/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv15024/sitedocs/doc
Modified Files:
citations.xml
Log Message:
Added Java Development with Ant citation
Index: citations.xml
===================================================================
RCS file: /cvsroot/httpunit/httpunit/sitedocs/doc/citations.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- citations.xml 18 May 2003 05:20:47 -0000 1.1
+++ citations.xml 16 Jun 2003 01:31:45 -0000 1.2
@@ -28,7 +28,12 @@
<section title="Book References">
<citation name="Java Extreme Programming Cookbook" url="http://www.oreilly.com/catalog/jextprockbk/">
March 2003: Eric M. Burke and Brian M. Coyner, O'Reilly & Associates.
- Detailed examples of XP development includes use of HttpUnit to develop web applications.
+ Detailed examples of XP development includes use of HttpUnit to develop web applications. Covers HttpUnit 1.4
+ </citation>
+
+ <citation name="Java Development with Ant" url="http://www.manning.com/hatcher/">
+ August 2002: Erik Hatcher and Steve Loughran, Manning Publications.
+ An excellant text on using ant for development. Also includes a chapter on HttpUnit. Covers HttpUnit 1.4
</citation>
<citation name="Java Tools for Extreme Programming: Mastering Open Source Tools, including Ant, JUnit, and Cactus"
@@ -37,4 +42,4 @@
Contains a simple example using HttpUnit and describes the API. Covers HttpUnit 1.4
</citation>
</section>
-</citations>
\ No newline at end of file
+</citations>
|
|
From: Russell G. <rus...@us...> - 2003-05-27 05:25:11
|
Update of /cvsroot/httpunit/httpunit/site/com/meterware/xml
In directory sc8-pr-cvs1:/tmp/cvs-serv424/site/com/meterware/xml
Modified Files:
DocumentSemantics.java
Log Message:
Show target exception when received
Index: DocumentSemantics.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/site/com/meterware/xml/DocumentSemantics.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DocumentSemantics.java 26 May 2003 15:42:13 -0000 1.2
+++ DocumentSemantics.java 27 May 2003 05:15:21 -0000 1.3
@@ -49,6 +49,8 @@
public static void build( Document document, Object documentRoot, String documentName ) {
try {
interpretNode( getRootNode( document ), documentRoot );
+ } catch (InvocationTargetException e) {
+ throw new RuntimeException( "Error interpreting document: " + documentName + ": " + e.getTargetException() );
} catch (Exception e) {
throw new RuntimeException( "Error interpreting document: " + documentName + ": " + e );
}
|
|
From: Russell G. <rus...@us...> - 2003-05-26 15:42:16
|
Update of /cvsroot/httpunit/httpunit/site/com/meterware/website
In directory sc8-pr-cvs1:/tmp/cvs-serv20538/site/com/meterware/website
Modified Files:
PageFragment.java Site.java SiteElement.java WebPage.java
Log Message:
Enhancements to site generator
Index: PageFragment.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/site/com/meterware/website/PageFragment.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PageFragment.java 18 May 2003 05:20:47 -0000 1.1
+++ PageFragment.java 26 May 2003 15:42:13 -0000 1.2
@@ -24,42 +24,46 @@
import org.xml.sax.InputSource;
import org.cyberneko.html.parsers.DOMParser;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import java.util.ArrayList;
import java.io.File;
import java.io.IOException;
import java.io.FileInputStream;
-import java.beans.IntrospectionException;
-import java.lang.reflect.InvocationTargetException;
-import java.text.ParseException;
import com.meterware.xml.DocumentSemantics;
import com.meterware.website.FragmentTemplate;
-import com.meterware.httpunit.site.Faq;
-import com.meterware.httpunit.site.News;
-import com.meterware.httpunit.site.Citations;
-import com.meterware.httpunit.site.Developers;
/**
*
- * @author <a href="mailto:rus...@ht...">Russell Gold</a>
+ * @author <a href="mailto:rus...@me...">Russell Gold</a>
**/
public class PageFragment {
private String _source;
+ private String _extract;
+ private static File _root;
- public String asText() throws IOException, SAXException, IntrospectionException, InvocationTargetException, IllegalAccessException, ParserConfigurationException, ParseException {
- File file = new File( _source );
- if (isXmlFile( file )) {
- return getXMLBasedFragment( file );
- } else if (isHtmlFile( file )) {
- return getHtmlBasedFragment( file );
- } else {
- return getTextFragment( file );
+
+ static void setRoot( File root ) {
+ _root = root;
+ }
+
+
+ public String asText() {
+ try {
+ File file = new File( _source );
+ if (!file.exists()) file = new File( _root, _source );
+ if (isXmlFile( file )) {
+ return getXMLBasedFragment( file );
+ } else if (isHtmlFile( file )) {
+ return getHtmlBasedFragment( file );
+ } else {
+ return getTextFragment( file );
+ }
+ } catch (SAXException e) {
+ throw new RuntimeException( "Error parsing " + _source + ": " + e );
+ } catch (IOException e) {
+ throw new RuntimeException( "Error reading " + _source + ": " + e );
}
}
@@ -80,7 +84,7 @@
private String getHtmlBasedFragment( File file ) throws IOException, SAXException {
- org.cyberneko.html.parsers.DOMParser parser = new DOMParser();
+ DOMParser parser = new DOMParser();
parser.parse( new InputSource( new FileInputStream( file ) ) );
Document document = parser.getDocument();
NodeList nl = document.getElementsByTagName( "body" );
@@ -124,21 +128,11 @@
}
- private String getXMLBasedFragment( File file ) throws SAXException, IOException, ParserConfigurationException, IntrospectionException, IllegalAccessException, InvocationTargetException, ParseException {
- Document document = parseDocument( file );
- FragmentTemplate template = FragmentTemplate.getTemplateFor( com.meterware.xml.DocumentSemantics.getRootNode( document ).getNodeName() );
- com.meterware.xml.DocumentSemantics.build( document, template );
- return template.asText();
- }
-
-
- private static Document parseDocument( File file ) throws SAXException, IOException, ParserConfigurationException {
- DocumentBuilder result;
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- result = factory.newDocumentBuilder();
- DocumentBuilder db = result;
- final Document document = db.parse( file );
- return document;
+ private String getXMLBasedFragment( File file ) throws SAXException, IOException {
+ Document document = DocumentSemantics.parseDocument( file );
+ FragmentTemplate template = FragmentTemplate.getTemplateFor( DocumentSemantics.getRootNode( document ).getNodeName() );
+ DocumentSemantics.build( document, template, file.getAbsolutePath() );
+ return _extract == null ? template.asText() : DocumentSemantics.getStringProperty( _extract, template );
}
@@ -146,4 +140,8 @@
_source = source;
}
+
+ public void setExtract( String extract ) {
+ _extract = extract;
+ }
}
Index: Site.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/site/com/meterware/website/Site.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Site.java 18 May 2003 14:14:44 -0000 1.4
+++ Site.java 26 May 2003 15:42:13 -0000 1.5
@@ -24,6 +24,7 @@
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.FactoryConfigurationError;
import org.xml.sax.SAXException;
import org.w3c.dom.Document;
@@ -42,6 +43,7 @@
**/
public class Site {
+ private ArrayList _commonElements = new ArrayList();
private ArrayList _pages = new ArrayList();
private String _project;
@@ -51,10 +53,11 @@
private CopyRight _copyRight;
- public static void generate( File siteFile, File directory ) throws SAXException, IOException, ParserConfigurationException, IntrospectionException, IllegalAccessException, InvocationTargetException, ParseException {
- Document document = parseDocument( siteFile );
+ public static void generate( File siteFile, File directory ) throws SAXException, IOException {
+ PageFragment.setRoot( siteFile.getParentFile() );
+ Document document = DocumentSemantics.parseDocument( siteFile );
Site site = new Site();
- DocumentSemantics.build( document, site );
+ DocumentSemantics.build( document, site, siteFile.getAbsolutePath() );
WebPage.setRoot( directory );
for (int i = 0; i < site._pages.size(); i++) {
@@ -64,8 +67,10 @@
}
- private static Document parseDocument( File file ) throws SAXException, IOException, ParserConfigurationException {
- return DocumentBuilderFactory.newInstance().newDocumentBuilder().parse( file );
+ public CommonElement createCommonElement() {
+ CommonElement element = new CommonElement();
+ _commonElements.add( element );
+ return element;
}
@@ -198,6 +203,34 @@
}
+ public class CommonElement {
+ private ArrayList _fragments = new ArrayList();
+ private String _div;
+
+
+ public PageFragment createFragment() {
+ PageFragment fragment = new PageFragment();
+ _fragments.add( fragment );
+ return fragment;
+ }
+
+
+ public void setDiv( String div ) {
+ _div = div;
+ }
+
+
+ public void appendTo( StringBuffer sb ) {
+ sb.append( "<div id='" ).append( _div ).append( "'>" ).append( FragmentTemplate.LINE_BREAK );
+ for (int i = 0; i < _fragments.size(); i++) {
+ PageFragment pageFragment = (PageFragment) _fragments.get( i );
+ sb.append( pageFragment.asText() ).append( FragmentTemplate.LINE_BREAK );
+ }
+ sb.append( "</div>" ).append( FragmentTemplate.LINE_BREAK );
+ }
+ }
+
+
class Template implements SiteTemplate {
public void appendPageHeader( StringBuffer sb, WebPage currentPage ) {
@@ -208,6 +241,11 @@
sb.append( "<image src='" ).append( relativeURL( currentPage.getLocation(), _logo ) ).append( "'/>" ).append( FragmentTemplate.LINE_BREAK );
sb.append( "<h1>" ).append( currentPage.getTitle() ).append( "</h1>" ).append( FragmentTemplate.LINE_BREAK );
appendMenu( sb, currentPage.getLocation() );
+
+ for (int i = 0; i < _commonElements.size(); i++) {
+ CommonElement commonElement = (CommonElement) _commonElements.get( i );
+ commonElement.appendTo( sb );
+ }
sb.append( "<div id='Content'>" ).append( FragmentTemplate.LINE_BREAK );
if (currentPage.isLicense()) sb.append( "<p>" ).append( _copyRight.getNotice() ).append( "</p>" ). append( FragmentTemplate.LINE_BREAK );
}
Index: SiteElement.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/site/com/meterware/website/SiteElement.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SiteElement.java 18 May 2003 05:20:47 -0000 1.1
+++ SiteElement.java 26 May 2003 15:42:13 -0000 1.2
@@ -35,7 +35,7 @@
**/
interface SiteElement {
- void generatePage( SiteTemplate template ) throws ParserConfigurationException, IllegalAccessException, SAXException, IOException, ParseException, IntrospectionException, InvocationTargetException;
+ void generatePage( SiteTemplate template );
void appendMenuItem( StringBuffer sb, SiteTemplate template, String currentLocation );
Index: WebPage.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/site/com/meterware/website/WebPage.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- WebPage.java 18 May 2003 05:20:47 -0000 1.1
+++ WebPage.java 26 May 2003 15:42:13 -0000 1.2
@@ -19,16 +19,10 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
-import org.xml.sax.SAXException;
-
-import javax.xml.parsers.ParserConfigurationException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.File;
import java.util.ArrayList;
-import java.beans.IntrospectionException;
-import java.lang.reflect.InvocationTargetException;
-import java.text.ParseException;
import com.meterware.website.MenuTarget;
import com.meterware.website.PageFragment;
@@ -93,20 +87,24 @@
}
- public void generatePage( SiteTemplate template ) throws ParserConfigurationException, IllegalAccessException, SAXException, IOException, ParseException, IntrospectionException, InvocationTargetException {
- StringBuffer sb = new StringBuffer();
- template.appendPageHeader( sb, this );
- for (int i = 0; i < _fragments.size(); i++) {
- PageFragment pageFragment = (PageFragment) _fragments.get( i );
- sb.append( pageFragment.asText() ).append( FragmentTemplate.LINE_BREAK );
+ public void generatePage( SiteTemplate template ) {
+ try {
+ StringBuffer sb = new StringBuffer();
+ template.appendPageHeader( sb, this );
+ for (int i = 0; i < _fragments.size(); i++) {
+ PageFragment pageFragment = (PageFragment) _fragments.get( i );
+ sb.append( pageFragment.asText() ).append( FragmentTemplate.LINE_BREAK );
+ }
+ template.appendPageFooter( sb, this );
+
+ File file = new File( _root, _location );
+ file.getParentFile().mkdir();
+ FileWriter fw = new FileWriter( file );
+ fw.write( sb.toString() );
+ fw.close();
+ } catch (IOException e) {
+ throw new RuntimeException( "Error writing page '" + e );
}
- template.appendPageFooter( sb, this );
-
- File file = new File( _root, _location );
- file.getParentFile().mkdir();
- FileWriter fw = new FileWriter( file );
- fw.write( sb.toString() );
- fw.close();
}
|
|
From: Russell G. <rus...@us...> - 2003-05-26 15:42:16
|
Update of /cvsroot/httpunit/httpunit/site/com/meterware/xml
In directory sc8-pr-cvs1:/tmp/cvs-serv20538/site/com/meterware/xml
Modified Files:
DocumentSemantics.java
Log Message:
Enhancements to site generator
Index: DocumentSemantics.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/site/com/meterware/xml/DocumentSemantics.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DocumentSemantics.java 18 May 2003 05:20:47 -0000 1.1
+++ DocumentSemantics.java 26 May 2003 15:42:13 -0000 1.2
@@ -22,7 +22,10 @@
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
import java.beans.Introspector;
@@ -30,7 +33,8 @@
import java.beans.BeanInfo;
import java.beans.PropertyDescriptor;
import java.util.Date;
-import java.text.ParseException;
+import java.io.File;
+import java.io.IOException;
/**
@@ -42,8 +46,12 @@
private static final Class[] NO_ARG_CLASSES = new Class[0];
private static final Object[] NO_ARGS = new Object[0];
- public static void build( Document document, Object documentRoot ) throws IntrospectionException, IllegalAccessException, InvocationTargetException, ParseException {
- interpretNode( getRootNode( document ), documentRoot );
+ public static void build( Document document, Object documentRoot, String documentName ) {
+ try {
+ interpretNode( getRootNode( document ), documentRoot );
+ } catch (Exception e) {
+ throw new RuntimeException( "Error interpreting document: " + documentName + ": " + e );
+ }
}
@@ -55,7 +63,7 @@
}
- private static void interpretNode( final Node node, Object elementObject ) throws IntrospectionException, IllegalAccessException, InvocationTargetException, ParseException {
+ private static void interpretNode( final Node node, Object elementObject ) throws IntrospectionException, IllegalAccessException, InvocationTargetException {
Class elementClass = elementObject.getClass();
BeanInfo beanInfo = Introspector.getBeanInfo( elementClass, Object.class );
NamedNodeMap nnm = node.getAttributes();
@@ -87,7 +95,7 @@
}
- private static void interpretNestedElement( Class elementClass, Object elementObject, BeanInfo beanInfo, Node child ) throws IllegalAccessException, InvocationTargetException, IntrospectionException, ParseException {
+ private static void interpretNestedElement( Class elementClass, Object elementObject, BeanInfo beanInfo, Node child ) throws IllegalAccessException, InvocationTargetException, IntrospectionException {
try {
Method method = elementClass.getMethod( getCreateMethodName( child.getNodeName() ), NO_ARG_CLASSES );
Object subElement = method.invoke( elementObject, NO_ARGS );
@@ -143,13 +151,36 @@
}
- private static PropertyDescriptor getProperty( BeanInfo beanInfo, String propertyName ) {
+ public static PropertyDescriptor getProperty( BeanInfo beanInfo, String propertyName ) {
PropertyDescriptor properties[] = beanInfo.getPropertyDescriptors();
for (int i = 0; i < properties.length; i++) {
PropertyDescriptor property = properties[i];
if (property.getName().equals( propertyName )) return property;
}
return null;
+ }
+
+
+ public static String getStringProperty( String propertyName, Object template ) {
+ try {
+ BeanInfo beanInfo = Introspector.getBeanInfo( template.getClass(), Object.class );
+ final PropertyDescriptor propertyDescriptor = getProperty( beanInfo, propertyName );
+ if (propertyDescriptor == null) return "";
+ Object result = propertyDescriptor.getReadMethod().invoke( template, NO_ARGS );
+ return result == null ? "" : result.toString();
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RuntimeException( "Unable to get '" + propertyName + "' property: " + e );
+ }
+ }
+
+
+ public static Document parseDocument( File file ) throws SAXException, IOException {
+ try {
+ return DocumentBuilderFactory.newInstance().newDocumentBuilder().parse( file );
+ } catch (ParserConfigurationException e) {
+ throw new RuntimeException( "Unable to create a parser for XML documents: " + e );
+ }
}
}
|
|
From: Russell G. <rus...@us...> - 2003-05-23 21:55:16
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript
In directory sc8-pr-cvs1:/tmp/cvs-serv20521/test/com/meterware/httpunit/javascript
Modified Files:
FormScriptingTest.java
Log Message:
bug #721989: support control ids as javascript element references
Index: FormScriptingTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/FormScriptingTest.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- FormScriptingTest.java 23 May 2003 03:09:27 -0000 1.22
+++ FormScriptingTest.java 23 May 2003 21:55:12 -0000 1.23
@@ -232,7 +232,7 @@
}
- public void testSubmitButtonScript() throws Exception { // XXX not sure this is the desired behavior
+ public void testSubmitButtonScript() throws Exception {
defineResource( "DoIt?color=green", "You made it!" );
defineResource( "OnCommand.html", "<html><head></head>" +
"<body>" +
@@ -792,5 +792,33 @@
}
+ public void testElementsByIDProperty() throws Exception {
+ defineResource( "index.html", "<html>\n" +
+ "<head>\n" +
+ "<title>JavaScript Form Elements by ID String Test</title>\n" +
+ "<script language='JavaScript' type='text/javascript'><!--\n" +
+ "function foo() {\n" +
+ " if (document.forms['formName']) {\n" +
+ " var form = document.forms['formName'];\n" +
+ " if (form.elements['inputID']) {\n" +
+ " form.elements['inputID'].value = 'Hello World!';\n" +
+ " }\n" +
+ " }\n" +
+ "}\n" +
+ "// --></script>\n" +
+ "</head>\n" +
+ "<body onLoad='foo();'>\n" +
+ "<h1>JavaScript Form Elements by ID String Test</h1>\n" +
+ "<form name='formName'>\n" +
+ " <input type='text' name='inputName' value='' id='inputID'>\n" +
+ "</form>\n" +
+ "</body>\n" +
+ "</html>\n"
+ );
+ WebConversation wc = new WebConversation();
+ WebResponse response = wc.getResponse( getHostPath() + "/index.html" );
+ WebForm form = response.getFormWithName( "formName" );
+ assertEquals( "Changed value", "Hello World!", form.getParameterValue( "inputName" ) );
+ }
}
|
|
From: Russell G. <rus...@us...> - 2003-05-23 21:55:15
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript
In directory sc8-pr-cvs1:/tmp/cvs-serv20521/src/com/meterware/httpunit/javascript
Modified Files:
JavaScript.java
Log Message:
bug #721989: support control ids as javascript element references
Index: JavaScript.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript/JavaScript.java,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -r1.52 -r1.53
--- JavaScript.java 2 Apr 2003 15:31:09 -0000 1.52
+++ JavaScript.java 23 May 2003 21:55:12 -0000 1.53
@@ -210,6 +210,11 @@
}
+ String getID() {
+ return _scriptable instanceof IdentifiedDelegate ? ((IdentifiedDelegate) _scriptable).getID() : "";
+ }
+
+
public boolean has( String propertyName, Scriptable scriptable ) {
return super.has( propertyName, scriptable ) ||
(_scriptable != null && _scriptable.get( propertyName ) != null);
@@ -817,9 +822,18 @@
public Object get( String name, Scriptable scriptable ) {
for (int i = 0; i < _contents.length; i++) {
JavaScriptEngine content = _contents[ i ];
+ if (name.equalsIgnoreCase( content.getID() )) return content;
+ }
+ for (int i = 0; i < _contents.length; i++) {
+ JavaScriptEngine content = _contents[ i ];
if (name.equalsIgnoreCase( content.getName() )) return content;
}
return super.get( name, scriptable );
+ }
+
+
+ protected JavaScriptEngine[] getContents() {
+ return _contents;
}
}
|
|
From: Russell G. <rus...@us...> - 2003-05-23 21:55:15
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/scripting
In directory sc8-pr-cvs1:/tmp/cvs-serv20521/src/com/meterware/httpunit/scripting
Modified Files:
Input.java
Added Files:
IdentifiedDelegate.java
Log Message:
bug #721989: support control ids as javascript element references
***** Error reading new file[Errno 2] No such file or directory: 'IdentifiedDelegate.java'
Index: Input.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/scripting/Input.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Input.java 17 Feb 2003 23:54:42 -0000 1.2
+++ Input.java 23 May 2003 21:55:12 -0000 1.3
@@ -28,10 +28,7 @@
*
* @author <a href="mailto:rus...@ht...">Russell Gold</a>
**/
-public interface Input extends NamedDelegate {
-
- String getName();
-
+public interface Input extends IdentifiedDelegate, NamedDelegate {
Object get( String propertyName );
|
|
From: Russell G. <rus...@us...> - 2003-05-23 21:55:15
|
Update of /cvsroot/httpunit/httpunit/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv20521/doc
Modified Files:
release_notes.txt
Log Message:
bug #721989: support control ids as javascript element references
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.300
retrieving revision 1.301
diff -u -r1.300 -r1.301
--- release_notes.txt 23 May 2003 03:24:49 -0000 1.300
+++ release_notes.txt 23 May 2003 21:55:11 -0000 1.301
@@ -13,6 +13,13 @@
Revision History:
+23-May-2002
+Problems fixed:
+ 1. bug #721989: scripts did not see id attributes of form controls.
+ 2. bug #741965: cookies with explicit domain attributes are being rejected when their host is of the form HD
+ where D is the explicit domain attribute and H contains a dot. Apparently, most browsers ignore this
+ rule. Now, so does HttpUnit.
+
22-May-2003
Problems fixed:
1. bug #722788: WebForm.submit() was not invoking the 'onClick' event of the specified submit button.
|
|
From: Russell G. <rus...@us...> - 2003-05-23 21:55:14
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv20521/src/com/meterware/httpunit
Modified Files:
FormControl.java
Log Message:
bug #721989: support control ids as javascript element references
Index: FormControl.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/FormControl.java,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- FormControl.java 6 May 2003 13:31:04 -0000 1.40
+++ FormControl.java 23 May 2003 21:55:11 -0000 1.41
@@ -316,6 +316,11 @@
}
+ public String getID() {
+ return FormControl.this.getID();
+ }
+
+
public Scriptable() {
super( FormControl.this );
}
|
|
From: Russell G. <rus...@us...> - 2003-05-23 21:53:01
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/cookies
In directory sc8-pr-cvs1:/tmp/cvs-serv19595/src/com/meterware/httpunit/cookies
Modified Files:
CookieJar.java
Log Message:
bug #741965: be more lenient in accepting cookie domains
Index: CookieJar.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/cookies/CookieJar.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CookieJar.java 4 Nov 2002 21:01:37 -0000 1.2
+++ CookieJar.java 23 May 2003 21:52:57 -0000 1.3
@@ -356,7 +356,14 @@
if (!domainAttribute.startsWith(".")) return false;
if (domainAttribute.lastIndexOf('.') == 0) return false;
if (!sourceHost.endsWith( domainAttribute )) return false;
- if (sourceHost.lastIndexOf( domainAttribute ) > sourceHost.indexOf( '.' )) return false;
+ if (!isLenientMatching() && sourceHost.lastIndexOf( domainAttribute ) > sourceHost.indexOf( '.' )) return false;
+ return true;
+ }
+
+
+ // set this to false to reject cookies when the host is of the form HD where D is the explicit domain attribute
+ // and H contains a dot. Apparently, most browsers are lenient.
+ private boolean isLenientMatching() {
return true;
}
|