httpunit-commit Mailing List for httpunit (Page 30)
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-05-04 15:09:08
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv23268/test/com/meterware/httpunit
Modified Files:
HttpUnitSuite.java
Added Files:
NormalizeURLTest.java
Log Message:
fixed bug #717280: Requests with '../' in them are not resolved properly
***** Error reading new file[Errno 2] No such file or directory: 'NormalizeURLTest.java'
Index: HttpUnitSuite.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/HttpUnitSuite.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- HttpUnitSuite.java 30 Dec 2002 21:46:56 -0000 1.31
+++ HttpUnitSuite.java 4 May 2003 15:09:05 -0000 1.32
@@ -57,6 +57,7 @@
result.addTest( WebAppletTest.suite() );
result.addTest( CookieTest.suite() );
result.addTest( ParsingTestSuite.suite() );
+ result.addTest( NormalizeURLTest.suite() );
if (HTMLParserFactory.getHTMLParser().getClass().getName().indexOf("NekoHTML") >= 0) result.addTest( NekoEnhancedScriptingTest.suite() );
addOptionalTestCase( result, "com.meterware.httpunit.XMLPageTest" );
|
|
From: Russell G. <rus...@us...> - 2003-05-04 12:45:14
|
Update of /cvsroot/httpunit/httpunit/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv23915/doc
Modified Files:
release_notes.txt
Log Message:
Support getOptions for radio buttons and checkboxes
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.293
retrieving revision 1.294
diff -u -r1.293 -r1.294
--- release_notes.txt 2 May 2003 22:20:39 -0000 1.293
+++ release_notes.txt 4 May 2003 12:45:10 -0000 1.294
@@ -17,6 +17,7 @@
Additions:
1. JUnitServlet now supports a value of 'xml' for the format parameter, generating a format compatible with
ant's XMLResultFormatter
+ 2. Form.getOptions() now works for radio buttons and checkboxes - as long as the desired name is located after the control.
4-Apr-2003
Acknowledgements:
|
|
From: Russell G. <rus...@us...> - 2003-05-04 12:45:14
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv23915/test/com/meterware/httpunit
Modified Files:
FormParametersTest.java
Log Message:
Support getOptions for radio buttons and checkboxes
Index: FormParametersTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FormParametersTest.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- FormParametersTest.java 6 Feb 2003 02:55:59 -0000 1.19
+++ FormParametersTest.java 4 May 2003 12:45:10 -0000 1.20
@@ -201,14 +201,15 @@
public void testRadioButtonValidation() throws Exception {
defineWebPage( "Default", "<form method=GET action = \"/ask\">" +
- "<Input type=radio name=color value=red>" +
- "<Input type=radio name=color value=blue>" +
- "<Input type=radio name=color value=green>" +
+ "<Input type=radio name=color value=red>Crimson" +
+ "<Input type=radio name=color value=blue>Aquamarine" +
+ "<Input type=radio name=color value=green>Chartreuse" +
"<Input type=submit></form>" );
WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" );
WebRequest request = page.getForms()[0].getRequest();
HttpUnitOptions.setParameterValuesValidated( true );
assertEquals( "color options", new String[] { "red", "blue", "green" }, page.getForms()[0].getOptionValues( "color" ) );
+ assertEquals( "color names", new String[] { "Crimson", "Aquamarine", "Chartreuse" }, page.getForms()[0].getOptions( "color" ) );
request.setParameter( "color", "red" );
request.setParameter( "color", "blue" );
validateSetParameterRejected( request, "color", "black", "setting radio buttons to unknown value" );
@@ -233,10 +234,11 @@
public void testCheckboxValidation() throws Exception {
defineWebPage( "Default", "<form method=GET action = 'ask?color='>" +
"<Input type=checkbox name=use_color>" +
- "<Input type=checkbox name=color value=red>" +
- "<Input type=checkbox name=color value=blue>" +
+ "<Input type=checkbox name=color value=red>Scarlet" +
+ "<Input type=checkbox name=color value=blue>Turquoise" +
"<Input type=submit></form>" );
WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" );
+ assertEquals( "Color values", new String[] { "Scarlet", "Turquoise" }, page.getForms()[0].getOptions( "color" ) );
WebRequest request = page.getForms()[0].getRequest();
request.setParameter( "use_color", "on" );
request.removeParameter( "use_color" );
|
|
From: Russell G. <rus...@us...> - 2003-05-04 12:45:14
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv23915/src/com/meterware/httpunit
Modified Files:
FormControl.java
Log Message:
Support getOptions for radio buttons and checkboxes
Index: FormControl.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/FormControl.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- FormControl.java 1 Apr 2003 13:42:09 -0000 1.38
+++ FormControl.java 4 May 2003 12:45:10 -0000 1.39
@@ -353,6 +353,8 @@
private String[] _value = new String[1];
private final boolean _isCheckedDefault;
+ private String[] _displayedValue;
+
protected ScriptableDelegate newScriptable() {
return new Scriptable();
@@ -385,10 +387,19 @@
public BooleanFormControl( WebForm form, Node node ) {
super( form, node );
+ _displayedValue = new String[] { readDisplayedValue( node ) };
_isChecked = _isCheckedDefault = NodeUtils.isNodeAttributePresent( node, "checked" );
}
+ private String readDisplayedValue( Node node ) {
+ Node nextSibling = node.getNextSibling();
+ while (nextSibling != null && nextSibling.getNodeType() != Node.TEXT_NODE && nextSibling.getNodeType() != Node.ELEMENT_NODE) nextSibling = nextSibling.getNextSibling();
+ if (nextSibling == null || nextSibling.getNodeType() != Node.TEXT_NODE) return "";
+ return nextSibling.getNodeValue();
+ }
+
+
boolean isChecked() {
return _isChecked;
}
@@ -421,6 +432,11 @@
}
+ String[] getDisplayedOptions() {
+ return _displayedValue;
+ }
+
+
void addValues( ParameterProcessor processor, String characterSet ) throws IOException {
if (isChecked() && !isDisabled()) processor.addParameter( getName(), getQueryValue(), characterSet );
}
@@ -506,6 +522,19 @@
FormControl[] buttons = getButtons();
for (int i = 0; i < buttons.length; i++) {
valueList.addAll( Arrays.asList( buttons[i].getOptionValues() ) );
+ }
+ return (String[]) valueList.toArray( new String[ valueList.size() ] );
+ }
+
+
+ /**
+ * Returns the options displayed for this radio button group.
+ */
+ String[] getDisplayedOptions() {
+ ArrayList valueList = new ArrayList();
+ FormControl[] buttons = getButtons();
+ for (int i = 0; i < buttons.length; i++) {
+ valueList.addAll( Arrays.asList( buttons[i].getDisplayedOptions() ) );
}
return (String[]) valueList.toArray( new String[ valueList.size() ] );
}
|
|
From: Russell G. <rus...@us...> - 2003-05-04 12:37:35
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit
In directory sc8-pr-cvs1:/tmp/cvs-serv20727/test/com/meterware/servletunit
Modified Files:
JUnitServletTest.java
Log Message:
remove debug message
Index: JUnitServletTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/JUnitServletTest.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- JUnitServletTest.java 2 May 2003 22:20:39 -0000 1.8
+++ JUnitServletTest.java 4 May 2003 12:37:32 -0000 1.9
@@ -171,7 +171,6 @@
WebResponse wr = client.getResponse( "http://localhost/JUnit?format=xml&test=" + ErrorTests.class.getName() );
assertEquals( "Content type", "text/xml", wr.getContentType() );
- System.out.println( "REG-> " + wr.getText() ); // TODO remove this line
DocumentBuilder builder = HttpUnitUtils.newParser();
Document document = builder.parse( wr.getInputStream() );
Element element = document.getDocumentElement();
|
|
From: Russell G. <rus...@us...> - 2003-05-02 22:20:43
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit
In directory sc8-pr-cvs1:/tmp/cvs-serv14937/src/com/meterware/servletunit
Modified Files:
JUnitServlet.java
Log Message:
Added xml format for JUnitServlet
Index: JUnitServlet.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/JUnitServlet.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- JUnitServlet.java 2 Apr 2003 15:28:56 -0000 1.4
+++ JUnitServlet.java 2 May 2003 22:20:39 -0000 1.5
@@ -73,6 +73,8 @@
private ResultsFormatter getResultsFormatter( String formatterName ) {
if ("text".equalsIgnoreCase( formatterName )) {
return new TextResultsFormatter();
+ } else if ("xml".equalsIgnoreCase( formatterName )) {
+ return new XMLResultsFormatter();
} else {
return new HTMLResultsFormatter();
}
@@ -158,35 +160,96 @@
static abstract class ResultsFormatter {
- String getContentType() {
- return "text/html";
- }
+
+ private static final char LF = 10;
+ private static final char CR = 13;
+
+
+ abstract String getContentType();
void displayResults( PrintWriter writer, String testClassName, String elapsedTimeString, TestResult testResult ) {
+ displayHeader( writer, testClassName, testResult, elapsedTimeString );
+ displayResults( writer, testResult );
+ displayFooter( writer );
+ }
+
+
+ protected abstract void displayHeader( PrintWriter writer, String testClassName, TestResult testResult, String elapsedTimeString );
+
+
+ protected abstract void displayResults( PrintWriter writer, TestResult testResult );
+
+
+ protected abstract void displayFooter( PrintWriter writer );
+
+
+ protected String sgmlEscape( String s ) {
+ StringBuffer result = new StringBuffer( s.length() );
+ char[] chars = s.toCharArray();
+ for (int i = 0; i < chars.length; i++) {
+ switch( chars[i] ) {
+ case '&':
+ result.append( "&" );
+ break;
+ case '<':
+ result.append( "<" );
+ break;
+ case '>':
+ result.append( ">" );
+ break;
+ case LF:
+ if (i > 0 && chars[i-1] == CR) {
+ result.append( chars[i] );
+ break;
+ }
+ case CR:
+ result.append( getLineBreak() );
+ default:
+ result.append( chars[i] );
+ }
+ }
+ return result.toString();
+ }
+
+
+ protected String getLineBreak() {
+ return "<br>";
+ }
+ }
+
+
+ abstract static class DisplayedResultsFormatter extends ResultsFormatter {
+
+ protected void displayHeader( PrintWriter writer, String testClassName, TestResult testResult, String elapsedTimeString ) {
displayHeader( writer, testClassName, getFormatted( testResult.runCount(), "test" ),
elapsedTimeString, testResult.wasSuccessful() ? "OK" : "Problems Occurred" );
+ }
+ protected void displayResults( PrintWriter writer, TestResult testResult ) {
if (!testResult.wasSuccessful()) {
displayProblems( writer, "failure", testResult.failureCount(), testResult.failures() );
displayProblems( writer, "error", testResult.errorCount(), testResult.errors() );
}
- displayFooter( writer );
}
- private String getFormatted( int count, String name ) {
- return count + " " + name + (count == 1 ? "" : "s");
- }
+ protected abstract void displayHeader( PrintWriter writer, String testClassName, String testCountText, String elapsedTimeString, String resultString );
- protected abstract void displayHeader( PrintWriter writer, String testClassName, String testCountText, String elapsedTimeString, String resultString );
+ protected abstract void displayProblemTitle( PrintWriter writer, String title );
- protected abstract void displayFooter( PrintWriter writer );
+ protected abstract void displayProblemDetailHeader( PrintWriter writer, int i, String testName );
+
+
+ protected abstract void displayProblemDetailFooter( PrintWriter writer );
- protected void displayProblems( PrintWriter writer, String kind, int count, Enumeration enumeration ) {
+ protected abstract void displayProblemDetail( PrintWriter writer, String message );
+
+
+ private void displayProblems( PrintWriter writer, String kind, int count, Enumeration enumeration ) {
if (count != 0) {
displayProblemTitle( writer, getFormatted( count, kind ) );
Enumeration e = enumeration;
@@ -204,20 +267,15 @@
}
- protected abstract void displayProblemTitle( PrintWriter writer, String title );
-
-
- protected abstract void displayProblemDetailHeader( PrintWriter writer, int i, String testName );
-
-
- protected abstract void displayProblemDetailFooter( PrintWriter writer );
+ private String getFormatted( int count, String name ) {
+ return count + " " + name + (count == 1 ? "" : "s");
+ }
- protected abstract void displayProblemDetail( PrintWriter writer, String message );
}
- static class TextResultsFormatter extends ResultsFormatter {
+ static class TextResultsFormatter extends DisplayedResultsFormatter {
String getContentType() {
return "text/plain";
@@ -256,7 +314,11 @@
}
- static class HTMLResultsFormatter extends ResultsFormatter {
+ static class HTMLResultsFormatter extends DisplayedResultsFormatter {
+
+ String getContentType() {
+ return "text/html";
+ }
protected void displayHeader( PrintWriter writer, String testClassName, String testCountText,
@@ -297,41 +359,78 @@
protected void displayProblemDetail( PrintWriter writer, String message ) {
- writer.println( htmlEscape( message ) );
+ writer.println( sgmlEscape( message ) );
}
+ }
- private static final char LF = 10;
- private static final char CR = 13;
- private String htmlEscape( String s ) {
- StringBuffer result = new StringBuffer( s.length() );
- char[] chars = s.toCharArray();
- for (int i = 0; i < chars.length; i++) {
- switch( chars[i] ) {
- case '&':
- result.append( "&" );
- break;
- case '<':
- result.append( "<" );
- break;
- case '>':
- result.append( ">" );
- break;
- case LF:
- if (i > 0 && chars[i-1] == CR) {
- result.append( chars[i] );
- break;
- }
- case CR:
- result.append( "<br>" );
- default:
- result.append( chars[i] );
+ static class XMLResultsFormatter extends ResultsFormatter {
+
+ String getContentType() {
+ return "text/xml;charset=UTF-8";
+ }
+
+
+ protected void displayHeader( PrintWriter writer, String testClassName, TestResult testResult, String elapsedTimeString ) {
+ writer.println( "<?xml version='1.0' encoding='UTF-8' ?>\n" +
+ "<testsuite name=" + asAttribute( testClassName ) +
+ " tests=" + asAttribute( testResult.runCount() ) +
+ " failures=" + asAttribute( testResult.failureCount() ) +
+ " errors=" + asAttribute( testResult.errorCount() ) +
+ " time=" + asAttribute( elapsedTimeString ) + ">" );
+ }
+
+
+ private String asAttribute( int value ) {
+ return '"' + Integer.toString( value ) + '"';
+ }
+
+
+ private String asAttribute( String value ) {
+ return '"' + sgmlEscape( value ) + '"';
+ }
+
+
+ protected void displayFooter( PrintWriter writer ) {
+ writer.println( "</testsuite>" );
+ }
+
+
+ protected void displayResults( PrintWriter writer, TestResult testResult ) {
+ displayResults( writer, "failure", testResult.failures() );
+ displayResults( writer, "error", testResult.errors() );
+ }
+
+
+ private void displayResults( PrintWriter writer, String failureNodeName, Enumeration resultsEnumeration ) {
+ for (Enumeration e = resultsEnumeration; e.hasMoreElements();) {
+ TestFailure failure = (TestFailure) e.nextElement();
+ writer.println( " <testcase name=" + asAttribute( failure.failedTest().toString() ) + ">" );
+ writer.print( " <" + failureNodeName + " type=" + asAttribute( failure.thrownException().getClass().getName() ) +
+ " message=" + asAttribute( failure.exceptionMessage() ) );
+ if (!displayException( failure )) {
+ writer.println( "/>" );
+ } else {
+ writer.println( ">" );
+ writer.print( sgmlEscape( BaseTestRunner.getFilteredTrace( failure.thrownException() ) ) );
+ writer.println( " </" + failureNodeName + ">" );
}
+ writer.println( " </testcase>" );
}
- return result.toString();
+ }
+
+
+ private boolean displayException( TestFailure failure ) {
+ return !failure.isFailure();
+ }
+
+
+ protected String getLineBreak() {
+ return "";
}
}
+
}
|
|
From: Russell G. <rus...@us...> - 2003-05-02 22:20:43
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit
In directory sc8-pr-cvs1:/tmp/cvs-serv14937/test/com/meterware/servletunit
Modified Files:
JUnitServletTest.java
Log Message:
Added xml format for JUnitServlet
Index: JUnitServletTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/JUnitServletTest.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- JUnitServletTest.java 1 Apr 2003 16:19:14 -0000 1.7
+++ JUnitServletTest.java 2 May 2003 22:20:39 -0000 1.8
@@ -22,6 +22,7 @@
import com.meterware.httpunit.WebRequest;
import com.meterware.httpunit.WebResponse;
import com.meterware.httpunit.WebTable;
+import com.meterware.httpunit.HttpUnitUtils;
import java.io.IOException;
import java.io.PrintWriter;
@@ -33,9 +34,13 @@
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import javax.xml.parsers.DocumentBuilder;
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
/**
*
@@ -139,6 +144,60 @@
assertEquals( "Failure header", "1 error", results[1][1] );
assertEquals( "Failure index 1", "1", results[2][0] );
assertTrue( "Test class not found", results[2][1].indexOf( '(' + ErrorTests.class.getName() + ')' ) >= 0 );
+ }
+
+
+ public void testSomeFailuresXMLFormat() throws Exception {
+ ServletUnitClient client = newClient();
+
+ WebResponse wr = client.getResponse( "http://localhost/JUnit?format=xml&test=" + FailingTests.class.getName() );
+ assertEquals( "Content type", "text/xml", wr.getContentType() );
+ DocumentBuilder builder = HttpUnitUtils.newParser();
+ Document document = builder.parse( wr.getInputStream() );
+ Element element = document.getDocumentElement();
+ assertEquals( "document element name", "testsuite", element.getNodeName() );
+ assertEquals( "number of tests", "3", element.getAttribute( "tests" ) );
+ assertEquals( "number of failures", "2", element.getAttribute( "failures" ) );
+ assertEquals( "number of errors", "0", element.getAttribute( "errors" ) );
+ NodeList nl = element.getElementsByTagName( "testcase" );
+ verifyElementWithNameHasFailureNode( "testAddition", nl, /* failed */ "failure", true );
+ verifyElementWithNameHasFailureNode( "testSubtraction", nl, /* failed */ "failure", true );
+ verifyElementWithNameHasFailureNode( "testMultiplication", nl, /* failed */ "failure", false );
+ }
+
+
+ public void testSomeErrorsXMLFormat() throws Exception {
+ ServletUnitClient client = newClient();
+
+ WebResponse wr = client.getResponse( "http://localhost/JUnit?format=xml&test=" + ErrorTests.class.getName() );
+ assertEquals( "Content type", "text/xml", wr.getContentType() );
+ System.out.println( "REG-> " + wr.getText() ); // TODO remove this line
+ DocumentBuilder builder = HttpUnitUtils.newParser();
+ Document document = builder.parse( wr.getInputStream() );
+ Element element = document.getDocumentElement();
+ assertEquals( "document element name", "testsuite", element.getNodeName() );
+ assertEquals( "number of tests", "2", element.getAttribute( "tests" ) );
+ assertEquals( "number of failures", "0", element.getAttribute( "failures" ) );
+ assertEquals( "number of errors", "1", element.getAttribute( "errors" ) );
+ NodeList nl = element.getElementsByTagName( "testcase" );
+ verifyElementWithNameHasFailureNode( "testAddition", nl, /* failed */ "error", true );
+ verifyElementWithNameHasFailureNode( "testMultiplication", nl, /* failed */ "error", false );
+ }
+
+
+ private void verifyElementWithNameHasFailureNode( String name, NodeList nl, String nodeName, boolean failed ) {
+ for (int i = 0; i < nl.getLength(); i++) {
+ Element element = (Element) nl.item(i);
+ if (element.getAttribute( "name" ).indexOf( name ) >= 0) {
+ if (failed) {
+ assertEquals( "no " + nodeName + " element found for test '" + name + "'", 1, element.getElementsByTagName( nodeName ).getLength() );
+ } else {
+ assertEquals( "unexpected " + nodeName + " element found for test '" + name + "'", 0, element.getElementsByTagName( nodeName ).getLength() );
+ }
+ return;
+ }
+ }
+ if (failed) fail( "No test result found for '" + name + "'" );
}
|
|
From: Russell G. <rus...@us...> - 2003-05-02 22:20:43
|
Update of /cvsroot/httpunit/httpunit/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv14937/doc
Modified Files:
favicon.ico release_notes.txt
Log Message:
Added xml format for JUnitServlet
Index: favicon.ico
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/favicon.ico,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
Binary files /tmp/cvs2FFt06 and /tmp/cvsgxEVK3 differ
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.292
retrieving revision 1.293
diff -u -r1.292 -r1.293
--- release_notes.txt 9 Apr 2003 16:11:24 -0000 1.292
+++ release_notes.txt 2 May 2003 22:20:39 -0000 1.293
@@ -13,6 +13,11 @@
Revision History:
+ 2-May-2003
+Additions:
+ 1. JUnitServlet now supports a value of 'xml' for the format parameter, generating a format compatible with
+ ant's XMLResultFormatter
+
4-Apr-2003
Acknowledgements:
Thanks to Andrew Bickerton for:
|
|
From: Russell G. <rus...@us...> - 2003-04-09 16:11:30
|
Update of /cvsroot/httpunit/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv2911
Modified Files:
build.xml
Log Message:
prepare for 1.5.3
Index: build.xml
===================================================================
RCS file: /cvsroot/httpunit/httpunit/build.xml,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -r1.64 -r1.65
--- build.xml 9 Mar 2003 20:35:44 -0000 1.64
+++ build.xml 9 Apr 2003 16:11:23 -0000 1.65
@@ -5,7 +5,7 @@
<project name="httpunit" default="jar" basedir=".">
<property name="name" value="httpunit" />
<property name="Name" value="HttpUnit" />
- <property name="version" value="1.5.2" />
+ <property name="version" value="1.5.3" />
<property name="debug" value="on" />
<property name="deprecation" value="off" />
|
|
From: Russell G. <rus...@us...> - 2003-04-09 16:11:30
|
Update of /cvsroot/httpunit/httpunit/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv2911/doc
Modified Files:
release_notes.txt
Log Message:
prepare for 1.5.3
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.291
retrieving revision 1.292
diff -u -r1.291 -r1.292
--- release_notes.txt 4 Apr 2003 14:51:26 -0000 1.291
+++ release_notes.txt 9 Apr 2003 16:11:24 -0000 1.292
@@ -15,126 +15,69 @@
Revision History:
4-Apr-2003
Acknowledgements:
- Thanks to George Murnock for adding WebResponse.getMatchingTables()
-
-Additions:
- 11. WebResponse and TableCell now have getMatchingTables to return all tables matching the specified criteria.
-
- 2-Apr-2003
-Acknowledgments:
+ Thanks to Andrew Bickerton for:
+ correcting the handling of document.open for non-HTML pages and new pages with base tags,
+ correcting the document.write append problem,
+ identifying the javascript parent frame update problem and suggesting a fix, and
+ showing how to handle responses with content-length 0.
+ Thanks to Brendan Boesen for:
+ adding a method to access session IDs in ServletUnitContext, and
+ correcting the session invalidation problem.
+ Thanks to Daniel Jasmin for fixing the handling of applet loading from archives.
+ Thanks to Mark Luty for supplying a test for the getElementsByName function.
+ Thanks to Ron Webster for designing the new HttpUnit logo.
Thanks to Sergey Bondarenko for supplying a test for getElementsByTagName
- Thanks to Andrew Bickerton for showing how to handle responses with content-length 0
+ Thanks to George Murnock for adding WebResponse.getMatchingTables()
Problems Fixed:
- 17. HttpUnit was delaying until a timeout when a zero-length response was received
-
-Additions:
- 10. Added support for getElementsByTagName to Document and Form
-
- 1-Apr-2003
-Additions:
- 9. Added format parameter for JUnitServlet: values are "text" or "html"
-
-Problems fixed:
- 15. HttpUnit now handles refresh headers without explicit URLs, defaulting to refreshing the containing page.
- 16. Bug #709979: Select.selectedIndex was returning -1 for a normal select box with no options explicitly selected.
-
-28-Mar-2003
-Acknowledgements:
- Thanks to Ron Webster for designing the new HttpUnit logo.
-
-27-Mar-2003
-Acknowledgements:
- Thanks to Mark Luty for supplying a test for the getElementsByName function.
-
-Additions:
- 8. Document.getElementsByName is now supported
-
-26-Mar-2003
-Problems fixed:
- 14. HttpUnit was chopping off javascript urls if they contained a '#' character.
-
-24-Mar-2003
-Acknowledgements:
- Thanks to Andrew Bickerton for identifying the javascript parent frame update problem and suggesting a fix.
-
-Problems fixed:
- 13. Following a javascript link which updated a parent frame via manipulating the location was causing a 'NoSuchFrame'
- exception to be thrown.
-
- 23-Mar-2003
-Problems fixed:
- 11. ServletUnit had not implemented HttpServletRequest.getURL();
- 12. ServletUnit was always supplying a charset parameter, even when not requested.
-
- 20-Mar-2003
-Problems fixed:
- 10. ServletUnit had not implemented HttpServletRequest.getContentLength();
-
- 19-Mar-2003
-Acknowledgements:
- Thanks to Brendan Boesen for correcting the session invalidation problem.
- Thanks to Andrew Bickerton for correcting the document.write append problem.
-
-Problems fixed:
- 8. ServletUnit was creating a new session if the current one was not valid, even if "create" was not specified.
- 9. calling document.write on a closed document was appending to rather than replacing its contents.
-
-Additions:
- 6. PseudoServer now handles persistent connections.
- 7. ClientProperties now supports a listener which allows for the override of DNS mapping, allowing a client
- to supply an actual IP address for a host programatically. The original Host header will be retained.
-
- 17-Mar-2003
-Problems fixed:
- 6. The Content-Length header was not being sent with requests in ServletUnit.
- 7. ServletUnit's HttpServletRequest.getIntHeader() always returned -1.
-
- 16-Mar-2003
-Acknowledgements:
- Thanks to Brendan Boesen for adding a method to access session IDs in ServletUnitContext.
-
-Additions:
- 4. You can now get at the stored session IDs in ServletUnitContext.
- 5. ServletUnit now supports HttpServletRequest.getRequestDispatch()
+ Content and Parsing
+ 1. Bug #700889: Under certain cases, multiple <script> sections in a document caused a problem where
+ only those HTML elements defined before the first one were actually available to the scripts.
+ 2. Bug #709979: Select.selectedIndex was returning -1 for a normal select box with no options explicitly selected.
+ 3. calling Document.open() on a non-HTML page no longer throws an exception.
+ 4. Rewriting a document now properly handles any <base> tags in the new document.
+ 5. Applets were not loading properly from applets if a codebase was specified in the <applet> tag.
+ 6. When loading a page triggered a script function which redirected to a new page in the same frame,
+ the WebResponse returned from getResponse was the triggering page. It is now the redirected page.
+ 7. HttpUnit now handles refresh headers without explicit URLs, defaulting to refreshing the containing page.
+ 8. HttpUnit was delaying until a timeout when a zero-length response was received
+ JavaScript
+ 9. calling document.write on a closed document was appending to rather than replacing its contents.
+ 10. Following a javascript link which updated a parent frame via manipulating the location was causing a 'NoSuchFrame'
+ exception to be thrown.
+ 11. HttpUnit was chopping off javascript urls if they contained a '#' character.
+ ServletUnit
+ 12. The Content-Length header was not being sent with requests.
+ 13. HttpServletRequest.getIntHeader() always returned -1.
+ 14. ServletUnit was creating a new session if the current one was not valid, even if "create" was not specified.
+ 15. ServletUnit had not implemented HttpServletRequest.getContentLength();
+ 16. ServletUnit had not implemented HttpServletRequest.getURL();
+ 17. ServletUnit was always supplying a charset parameter in the returned Content-Type header, even when not requested.
+
+Additions:
+ Content and Parsing
+ 1. WebResponse and TableCell now have getMatchingTables to return all tables matching the specified criteria.
+ JavaScript
+ 2. <noscript> nodes in the body of a page now show their content if a <script> earlier in the page is not recognized.
+ 3. Select.value is now supported.
+ 4. Added WebForm.getButton() method using HTMLPredicate to permit more generalized button searches.
+ 5. Document.getElementsByName is now supported
+ 6. Added support for getElementsByTagName to Document and Form
+ ServletUnit
+ 7. You can now get at the stored session IDs in ServletUnitContext.
+ 8. ServletUnit now supports HttpServletRequest.getRequestDispatch()
+ PseudoServer
+ 9. PseudoServer now handles persistent connections.
+ Extensibility
+ 10. ClientProperties now supports a listener which allows for the override of DNS mapping, allowing a client
+ to supply an actual IP address for a host programatically. The original Host header will be retained.
+ 11. Added format parameter for JUnitServlet: values are "text" or "html"
Notes:
- 1. The acceptCookies, acceptGzip, autoRefresh and autoForward properties have been moved from HttpUnitOptions to ClientProperties,
- permitting them to be set per WebClient rather than just globally. The old properties have been deprecated,
- and now access the defaults for ClientProperties. Tests which set the HttpUnitOptions properties before creating
- their WebClients will be unaffected.
-
- 14-Mar-2003
-Problems fixed:
- 5. When loading a page triggered a script function which redirected to a new page in the same frame,
- the WebResponse returned from getResponse was the triggering page. It is now the redirected page.
-
- 13-Mar-2003
-Additions:
- 2. Select.value is now supported.
- 3. Added WebForm.getButton() method using HTMLPredicate to permit more generalized button searches.
-
- 12-Mar-2003
-Acknowledgements:
- Thanks to Daniel Jasmin for fixing the handling of applet loading from archives.
-
-Problems fixed:
- 3. Applets were not loading properly from applets if a codebase was specified in the <applet> tag.
- 4. Bug #700889: Under certain cases, multiple <script> sections in a document caused a problem where only those HTML elements
- defined before the first one were actually available to the scripts.
-
- 9-Mar-2003
-Additions:
- 1. <noscript> nodes in the body of a page now show their content if a <script> earlier in the page is not recognized.
-
- 7-Mar-2003
-Acknowledgements:
- Thanks to Andrew Bickerton for correcting the handling of document.open for non-HTML pages and new pages with
- base tags.
-
-Problems fixed:
- 1. calling Document.open() on a non-HTML page no longer throws an exception.
- 2. Rewriting a document now properly handles any <base> tags in the new document.
+ 1. The acceptCookies, acceptGzip, autoRefresh and autoForward properties have been moved from HttpUnitOptions
+ to ClientProperties, permitting them to be set per WebClient rather than just globally. The old properties
+ have been deprecated, and now access the defaults for ClientProperties. Tests which set the HttpUnitOptions
+ properties before creating their WebClients will be unaffected.
3-Mar-2003 1.5.2
|
|
From: Russell G. <rus...@us...> - 2003-04-04 14:52:03
|
Update of /cvsroot/httpunit/httpunit/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv3493/doc
Modified Files:
release_notes.txt
Log Message:
George Murnock: added getMatchingTables
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.290
retrieving revision 1.291
diff -u -r1.290 -r1.291
--- release_notes.txt 2 Apr 2003 16:47:55 -0000 1.290
+++ release_notes.txt 4 Apr 2003 14:51:26 -0000 1.291
@@ -13,24 +13,31 @@
Revision History:
+ 4-Apr-2003
+Acknowledgements:
+ Thanks to George Murnock for adding WebResponse.getMatchingTables()
+
+Additions:
+ 11. WebResponse and TableCell now have getMatchingTables to return all tables matching the specified criteria.
+
2-Apr-2003
Acknowledgments:
Thanks to Sergey Bondarenko for supplying a test for getElementsByTagName
Thanks to Andrew Bickerton for showing how to handle responses with content-length 0
Problems Fixed:
- 1. HttpUnit was delaying until a timeout when a zero-length response was received
+ 17. HttpUnit was delaying until a timeout when a zero-length response was received
Additions:
- 1. Added support for getElementsByTagName to Document and Form
+ 10. Added support for getElementsByTagName to Document and Form
1-Apr-2003
Additions:
- 1. Added format parameter for JUnitServlet: values are "text" or "html"
+ 9. Added format parameter for JUnitServlet: values are "text" or "html"
Problems fixed:
- 1. HttpUnit now handles refresh headers without explicit URLs, defaulting to refreshing the containing page.
- 2. Bug #709979: Select.selectedIndex was returning -1 for a normal select box with no options explicitly selected.
+ 15. HttpUnit now handles refresh headers without explicit URLs, defaulting to refreshing the containing page.
+ 16. Bug #709979: Select.selectedIndex was returning -1 for a normal select box with no options explicitly selected.
28-Mar-2003
Acknowledgements:
@@ -41,28 +48,28 @@
Thanks to Mark Luty for supplying a test for the getElementsByName function.
Additions:
- 1. Document.getElementsByName is now supported
+ 8. Document.getElementsByName is now supported
26-Mar-2003
Problems fixed:
- 1. HttpUnit was chopping off javascript urls if they contained a '#' character.
+ 14. HttpUnit was chopping off javascript urls if they contained a '#' character.
24-Mar-2003
Acknowledgements:
Thanks to Andrew Bickerton for identifying the javascript parent frame update problem and suggesting a fix.
Problems fixed:
- 1. Following a javascript link which updated a parent frame via manipulating the location was causing a 'NoSuchFrame'
+ 13. Following a javascript link which updated a parent frame via manipulating the location was causing a 'NoSuchFrame'
exception to be thrown.
23-Mar-2003
Problems fixed:
- 1. ServletUnit had not implemented HttpServletRequest.getURL();
- 2. ServletUnit was always supplying a charset parameter, even when not requested.
+ 11. ServletUnit had not implemented HttpServletRequest.getURL();
+ 12. ServletUnit was always supplying a charset parameter, even when not requested.
20-Mar-2003
Problems fixed:
- 1. ServletUnit had not implemented HttpServletRequest.getContentLength();
+ 10. ServletUnit had not implemented HttpServletRequest.getContentLength();
19-Mar-2003
Acknowledgements:
@@ -70,26 +77,26 @@
Thanks to Andrew Bickerton for correcting the document.write append problem.
Problems fixed:
- 1. ServletUnit was creating a new session if the current one was not valid, even if "create" was not specified.
- 2. calling document.write on a closed document was appending to rather than replacing its contents.
+ 8. ServletUnit was creating a new session if the current one was not valid, even if "create" was not specified.
+ 9. calling document.write on a closed document was appending to rather than replacing its contents.
Additions:
- 1. PseudoServer now handles persistent connections.
- 2. ClientProperties now supports a listener which allows for the override of DNS mapping, allowing a client
+ 6. PseudoServer now handles persistent connections.
+ 7. ClientProperties now supports a listener which allows for the override of DNS mapping, allowing a client
to supply an actual IP address for a host programatically. The original Host header will be retained.
17-Mar-2003
Problems fixed:
- 1. The Content-Length header was not being sent with requests in ServletUnit.
- 2. ServletUnit's HttpServletRequest.getIntHeader() always returned -1.
+ 6. The Content-Length header was not being sent with requests in ServletUnit.
+ 7. ServletUnit's HttpServletRequest.getIntHeader() always returned -1.
16-Mar-2003
Acknowledgements:
Thanks to Brendan Boesen for adding a method to access session IDs in ServletUnitContext.
Additions:
- 1. You can now get at the stored session IDs in ServletUnitContext.
- 2. ServletUnit now supports HttpServletRequest.getRequestDispatch()
+ 4. You can now get at the stored session IDs in ServletUnitContext.
+ 5. ServletUnit now supports HttpServletRequest.getRequestDispatch()
Notes:
1. The acceptCookies, acceptGzip, autoRefresh and autoForward properties have been moved from HttpUnitOptions to ClientProperties,
@@ -99,21 +106,21 @@
14-Mar-2003
Problems fixed:
- 1. When loading a page triggered a script function which redirected to a new page in the same frame,
+ 5. When loading a page triggered a script function which redirected to a new page in the same frame,
the WebResponse returned from getResponse was the triggering page. It is now the redirected page.
13-Mar-2003
Additions:
- 1. Select.value is now supported.
- 2. Added WebForm.getButton() method using HTMLPredicate to permit more generalized button searches.
+ 2. Select.value is now supported.
+ 3. Added WebForm.getButton() method using HTMLPredicate to permit more generalized button searches.
12-Mar-2003
Acknowledgements:
Thanks to Daniel Jasmin for fixing the handling of applet loading from archives.
Problems fixed:
- 1. Applets were not loading properly from applets if a codebase was specified in the <applet> tag.
- 2. Bug #700889: Under certain cases, multiple <script> sections in a document caused a problem where only those HTML elements
+ 3. Applets were not loading properly from applets if a codebase was specified in the <applet> tag.
+ 4. Bug #700889: Under certain cases, multiple <script> sections in a document caused a problem where only those HTML elements
defined before the first one were actually available to the scripts.
9-Mar-2003
|
|
From: Russell G. <rus...@us...> - 2003-04-04 14:51:37
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv3493/src/com/meterware/httpunit
Modified Files:
HTMLSegment.java ParsedHTML.java WebResponse.java
Log Message:
George Murnock: added getMatchingTables
Index: HTMLSegment.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HTMLSegment.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- HTMLSegment.java 26 Dec 2002 15:33:56 -0000 1.8
+++ HTMLSegment.java 4 Apr 2003 14:51:27 -0000 1.9
@@ -144,6 +144,13 @@
/**
+ * Returns all tables found in the page matching the specified criteria.
+ * @exception SAXException thrown if there is an error parsing the response.
+ **/
+ public WebTable[] getMatchingTables( HTMLElementPredicate predicate, Object criteria ) throws SAXException;
+
+
+ /**
* Returns the first table in this HTML segment which has the specified text as the full text of
* its first non-blank row and non-blank column. Will recurse into any nested tables, as needed.
* @return the selected table, or null if none is found
Index: ParsedHTML.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ParsedHTML.java,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- ParsedHTML.java 2 Apr 2003 15:31:04 -0000 1.47
+++ ParsedHTML.java 4 Apr 2003 14:51:27 -0000 1.48
@@ -709,6 +709,15 @@
return getTableSatisfyingPredicate( getTables(), predicate, criteria );
}
+ /**
+ * Returns the tables in the response which match the specified predicate and value.
+ * Will recurse into any nested tables, as needed.
+ * @return the selected tables, or null if none are found
+ **/
+ public WebTable[] getMatchingTables( HTMLElementPredicate predicate, Object criteria ) {
+ return getTablesSatisfyingPredicate( getTables(), predicate, criteria );
+ }
+
/**
* Returns the first table in the response which has the specified text as the full text of
@@ -853,6 +862,39 @@
return null;
}
+
+ /**
+ * Returns the tables which match the specified criteria.
+ **/
+ private WebTable[] getTablesSatisfyingPredicate(WebTable[] tables, HTMLElementPredicate predicate, Object value) {
+ ArrayList matches = new ArrayList();
+ for (int i = 0; i < tables.length; i++) {
+ if (predicate.matchesCriteria(tables[i], value)) {
+ matches.add(tables[i]);
+ }
+ for (int j = 0; j < tables[i].getRowCount(); j++) {
+ for (int k = 0; k < tables[i].getColumnCount(); k++) {
+ TableCell cell = tables[i].getTableCell(j, k);
+ if (cell != null) {
+ WebTable[] innerTables = cell.getTables();
+ if (innerTables.length != 0) {
+ WebTable[] result = getTablesSatisfyingPredicate(innerTables, predicate, value);
+ if (result != null && result.length > 0) {
+ for (int l = 0; l < result.length; l++) {
+ matches.add(result[l]);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ if(matches.size() > 0) {
+ return (WebTable[]) matches.toArray( new WebTable[ matches.size() ] );
+ } else {
+ return null;
+ }
+ }
class WebIFrame extends WebFrame implements ContentConcealer {
Index: WebResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -r1.117 -r1.118
--- WebResponse.java 2 Apr 2003 16:47:56 -0000 1.117
+++ WebResponse.java 4 Apr 2003 14:51:28 -0000 1.118
@@ -455,6 +455,15 @@
}
+ /**
+ * Returns all tables found in the page matching the specified criteria.
+ * @exception SAXException thrown if there is an error parsing the response.
+ **/
+ public WebTable[] getMatchingTables( HTMLElementPredicate predicate, Object criteria ) throws SAXException {
+ return getReceivedPage().getMatchingTables( predicate, criteria );
+ }
+
+
/**
* Returns the first table in the response which has the specified text as the full text of
* its first non-blank row and non-blank column. Will recurse into any nested tables, as needed.
|
|
From: Russell G. <rus...@us...> - 2003-04-04 14:20:19
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv23124/src/com/meterware/httpunit
Modified Files:
Button.java WebWindow.java package.html
Log Message:
Javadoc cleanup
Index: Button.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/Button.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Button.java 13 Mar 2003 20:19:01 -0000 1.7
+++ Button.java 4 Apr 2003 14:20:11 -0000 1.8
@@ -28,6 +28,7 @@
/**
+ * A button in a form.
*
* @author <a href="mailto:rus...@ht...">Russell Gold</a>
**/
Index: WebWindow.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebWindow.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- WebWindow.java 24 Mar 2003 15:04:33 -0000 1.12
+++ WebWindow.java 4 Apr 2003 14:20:12 -0000 1.13
@@ -27,8 +27,9 @@
import org.xml.sax.SAXException;
/**
+ * A window managed by a {@link com.meterware.httpunit.WebClient WebClient}.
*
- * @author <a href="mailto:rus...@ac...">Russell Gold</a>
+ * @author <a href="mailto:rus...@ht...">Russell Gold</a>
**/
public class WebWindow {
@@ -47,6 +48,7 @@
/** True if this window has been closed. **/
private boolean _closed;
+
/**
* Returns the web client associated with this window.
*/
@@ -55,11 +57,17 @@
}
+ /**
+ * Returns true if this window has been closed.
+ */
public boolean isClosed() {
return _closed;
}
+ /**
+ * Closes this window.
+ */
public void close() {
if (!_closed) _client.close( this );
_closed = true;
Index: package.html
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/package.html,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- package.html 3 Nov 2002 17:37:37 -0000 1.5
+++ package.html 4 Apr 2003 14:20:12 -0000 1.6
@@ -15,13 +15,13 @@
<dt>xmlParserAPIs.jar</dt><dd>The interfaces for a W3-compliant XML parser. Required for interpreting either HTML or XML pages.</dd>
<dt>xercesImpl.jar</dt><dd>The <a href="http://xml.apache.org/xerces2-j/index.html">Xerces 2 implementation</a> of an XML parser.
NekoHTML requires this implementation.
-<dt>servlet.jar</dt><dd>The APIs and common classes for the Java Servlet 1.3 standard. Required for use with <a href="../servletunit-intro.html">ServletUnit.</a></dd>
+<dt>servlet.jar</dt><dd>The APIs and common classes for the Java Servlet 1.3 standard. Required for use with <a href="../../../../servletunit-intro.html">ServletUnit.</a></dd>
<dt>junit.jar</dt><dd><a href="http://www.junit.org">JUnit</a>, the unit test framework. Used to test HttpUnit and
recommended for writing tests that use HttpUnit.</dd>
-</dl>
-No longer included, but still supported, is <A HREF="http://lempinen.net/sami/jtidy">JTidy</A>, an alternate HTML parser/validator.
+<dt>tidy.jar</dt><dd><A HREF="http://lempinen.net/sami/jtidy">JTidy</A>, an alternate HTML parser/validator.
JTidy is a lot pickier about HTML structure than NekoHTML, and uses its own implementation of the DOM classes, rather than using those
-found in the xerces jar. Some JavaScript features, such as <code>document.write()</code> will only work with NekoHTML.
+found in the xerces jar. Some JavaScript features, such as <code>document.write()</code> will only work with NekoHTML.</dd>
+</dl>
<H2>Example</H2>
|
|
From: Russell G. <rus...@us...> - 2003-04-02 16:48:03
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv20744/test/com/meterware/httpunit
Modified Files:
WebFrameTest.java
Log Message:
Now handle zero-length responses
Index: WebFrameTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebFrameTest.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- WebFrameTest.java 23 Mar 2003 01:43:15 -0000 1.16
+++ WebFrameTest.java 2 Apr 2003 16:47:57 -0000 1.17
@@ -328,7 +328,6 @@
defineWebPage( "Linker", "<form action=redirect.html target=_self><input type=text name=sample value=z></form>" );
defineResource( "redirect.html?sample=z", "", HttpURLConnection.HTTP_MOVED_PERM );
addResourceHeader( "redirect.html?sample=z", "Location: " + getHostPath() + "/Target.html" );
- addResourceHeader( "redirect.html?sample=z", "Connection: close" ); // TODO see why this is needed and remove it
_wc.getResponse( getHostPath() + "/Frames.html" );
WebResponse response = _wc.getResponse( _wc.getFrameContents( "red" ).getForms()[0].getRequest() );
@@ -341,7 +340,6 @@
public void testSubFrameRedirect() throws Exception {
defineResource( "Linker.html", "", HttpURLConnection.HTTP_MOVED_PERM );
addResourceHeader( "Linker.html", "Location: " + getHostPath() + "/Target.html" );
- addResourceHeader( "Linker.html", "Connection: close" ); // TODO see why this is needed and remove it
_wc.getResponse( getHostPath() + "/Frames.html" );
assertMatchingSet( "Frames defined for the conversation", new String[] { "_top", "red", "blue" }, _wc.getFrameNames() );
|
|
From: Russell G. <rus...@us...> - 2003-04-02 16:48:02
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv20744/src/com/meterware/httpunit
Modified Files:
WebResponse.java
Log Message:
Now handle zero-length responses
Index: WebResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -r1.116 -r1.117
--- WebResponse.java 2 Apr 2003 15:31:06 -0000 1.116
+++ WebResponse.java 2 Apr 2003 16:47:56 -0000 1.117
@@ -815,11 +815,14 @@
InputStream inputStream = getInputStream();
try {
+ int bytesRemaining = getContentLength() < 0 ? Integer.MAX_VALUE : getContentLength();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[8 * 1024];
int count = 0;
do {
outputStream.write( buffer, 0, count );
+ bytesRemaining -= count;
+ if (bytesRemaining <= 0) break;
count = inputStream.read( buffer, 0, buffer.length );
} while (count != -1);
|
|
From: Russell G. <rus...@us...> - 2003-04-02 16:48:01
|
Update of /cvsroot/httpunit/httpunit/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv20744/doc
Modified Files:
release_notes.txt
Log Message:
Now handle zero-length responses
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.289
retrieving revision 1.290
diff -u -r1.289 -r1.290
--- release_notes.txt 2 Apr 2003 15:30:59 -0000 1.289
+++ release_notes.txt 2 Apr 2003 16:47:55 -0000 1.290
@@ -16,6 +16,11 @@
2-Apr-2003
Acknowledgments:
Thanks to Sergey Bondarenko for supplying a test for getElementsByTagName
+ Thanks to Andrew Bickerton for showing how to handle responses with content-length 0
+
+Problems Fixed:
+ 1. HttpUnit was delaying until a timeout when a zero-length response was received
+
Additions:
1. Added support for getElementsByTagName to Document and Form
|
|
From: Russell G. <rus...@us...> - 2003-04-02 15:31:45
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv5947/src/com/meterware/httpunit
Modified Files:
HTMLPage.java ParsedHTML.java WebForm.java
WebRequestSource.java WebResponse.java
Log Message:
Added getElementsByTagName support
Index: HTMLPage.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HTMLPage.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- HTMLPage.java 28 Mar 2003 03:22:33 -0000 1.28
+++ HTMLPage.java 2 Apr 2003 15:31:04 -0000 1.29
@@ -221,12 +221,12 @@
public ScriptableDelegate[] getElementsByName( String name ) {
- final HTMLElement[] elements = HTMLPage.this.getElementsByName( name );
- ScriptableDelegate[] result = new ScriptableDelegate[ elements.length ];
- for (int i = 0; i < elements.length; i++) {
- result[i] = elements[i].getScriptableDelegate();
- }
- return result;
+ return getDelegates( HTMLPage.this.getElementsByName( name ) );
+ }
+
+
+ public ScriptableDelegate[] getElementsByTagName( String name ) {
+ return getDelegates( HTMLPage.this.getElementsByTagName( HTMLPage.this.getRootNode(), name ) );
}
}
Index: ParsedHTML.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ParsedHTML.java,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- ParsedHTML.java 28 Mar 2003 03:22:33 -0000 1.46
+++ ParsedHTML.java 2 Apr 2003 15:31:04 -0000 1.47
@@ -21,6 +21,8 @@
*******************************************************************************************************************/
import org.w3c.dom.Element;
import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Document;
import java.net.URL;
import java.util.*;
@@ -167,6 +169,30 @@
}
+ HTMLElement[] getElementsByTagName( Node dom, String name ) {
+ loadElements();
+ if (dom instanceof Element) {
+ return getElementsFromList( ((Element) dom).getElementsByTagName( name ) );
+ } else {
+ return getElementsFromList( ((Document) dom).getElementsByTagName( name ) );
+ }
+ }
+
+
+ private HTMLElement[] getElementsFromList( NodeList nl ) {
+ HTMLElement[] elements = new HTMLElement[ nl.getLength() ];
+ for (int i = 0; i < elements.length; i++) {
+ Node node = nl.item(i);
+ elements[i] = (HTMLElement) _elements.get( node );
+ if (elements[i] == null) {
+ elements[i] = toDefaultElement( (Element) node );
+ _elements.put( node, elements[i] );
+ }
+ }
+ return elements;
+ }
+
+
/**
* Returns the form found in the page with the specified ID.
**/
@@ -796,7 +822,7 @@
//---------------------------------- private members --------------------------------
- private Node getRootNode() {
+ Node getRootNode() {
if (_rootNode == null) throw new IllegalStateException( "The root node has not been specified" );
return _rootNode;
}
Index: WebForm.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -r1.82 -r1.83
--- WebForm.java 14 Mar 2003 17:41:27 -0000 1.82
+++ WebForm.java 2 Apr 2003 15:31:05 -0000 1.83
@@ -588,6 +588,11 @@
}
+ public ScriptableDelegate[] getElementsByTagName( String name ) throws SAXException {
+ return getDelegates( getHTMLPage().getElementsByTagName( getNode(), name ) );
+ }
+
+
Scriptable() {
super( WebForm.this );
}
Index: WebRequestSource.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequestSource.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- WebRequestSource.java 27 Mar 2003 03:36:37 -0000 1.27
+++ WebRequestSource.java 2 Apr 2003 15:31:05 -0000 1.28
@@ -192,6 +192,14 @@
/**
+ * Returns the HTMLPage associated with this request source.
+ */
+ protected HTMLPage getHTMLPage() throws SAXException {
+ return _baseResponse.getReceivedPage();
+ }
+
+
+ /**
* Extracts any parameters specified as part of the destination URL, calling addPresetParameter for each one
* in the order in which they are found.
*/
Index: WebResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -r1.115 -r1.116
--- WebResponse.java 1 Apr 2003 12:55:24 -0000 1.115
+++ WebResponse.java 2 Apr 2003 15:31:06 -0000 1.116
@@ -954,7 +954,7 @@
}
- private HTMLPage getReceivedPage() throws SAXException {
+ HTMLPage getReceivedPage() throws SAXException {
if (_page == null) {
try {
_parsingPage = true;
|
|
From: Russell G. <rus...@us...> - 2003-04-02 15:31:39
|
Update of /cvsroot/httpunit/httpunit/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv5947/doc
Modified Files:
Javascript-support.html release_notes.txt
Log Message:
Added getElementsByTagName support
Index: Javascript-support.html
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/Javascript-support.html,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- Javascript-support.html 28 Mar 2003 03:22:32 -0000 1.36
+++ Javascript-support.html 2 Apr 2003 15:30:59 -0000 1.37
@@ -95,6 +95,7 @@
<li>close - closes the open document and replaces its contents with the written text</li>
<li>getElementById - returns the element in the document with the specified ID</li>
<li>getElementsByName - returns an array of all elements in the document with the specified name</li>
+<li>getElementsByTagName - returns an array of all elements in the document with the specified tag name</li>
<li>write - writes a string to the contents of the current open document</li>
<li>writeln - writes a line with carriage-return to the contents of the current open document</li>
</ul>
@@ -123,6 +124,7 @@
<ul>
<li>submit - submits the form</li>
<li>reset - resets the form controls to their default values</li>
+<li>getElementsByTagName - returns an array of all elements in the form with the specified tag name</li>
</ul>
<h3>Image</h3>
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.288
retrieving revision 1.289
diff -u -r1.288 -r1.289
--- release_notes.txt 1 Apr 2003 16:19:10 -0000 1.288
+++ release_notes.txt 2 Apr 2003 15:30:59 -0000 1.289
@@ -13,6 +13,12 @@
Revision History:
+ 2-Apr-2003
+Acknowledgments:
+ Thanks to Sergey Bondarenko for supplying a test for getElementsByTagName
+Additions:
+ 1. Added support for getElementsByTagName to Document and Form
+
1-Apr-2003
Additions:
1. Added format parameter for JUnitServlet: values are "text" or "html"
|
|
From: Russell G. <rus...@us...> - 2003-04-02 15:31:20
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript
In directory sc8-pr-cvs1:/tmp/cvs-serv5947/test/com/meterware/httpunit/javascript
Modified Files:
DocumentScriptingTest.java
Log Message:
Added getElementsByTagName support
Index: DocumentScriptingTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/DocumentScriptingTest.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- DocumentScriptingTest.java 19 Mar 2003 17:41:05 -0000 1.9
+++ DocumentScriptingTest.java 2 Apr 2003 15:31:12 -0000 1.10
@@ -40,6 +40,7 @@
super( name );
}
+
public void testDocumentTitle() throws Exception {
defineResource( "OnCommand.html", "<html><head><title>Amazing!</title></head>" +
"<body onLoad='alert(\"Window title is \" + document.title)'></body>" );
@@ -299,5 +300,36 @@
assertEquals("JavaScript no of forms", "No of forms: 1", wc.popNextAlert());
}
+
+ public void testTagProperty() throws Exception {
+ defineResource( "start.html",
+ "<html><head><script language='JavaScript'>" +
+ "function showFormsCount(oDOM){ " +
+ " var forms = oDOM.getElementsByTagName('form');" +
+ " for( i = 0; i < forms.length; i++) {" +
+ " alert( 'form with number ' + i + ' has ' + forms[i].getElementsByTagName('input').length + ' inputs' );" +
+ " }" +
+ "}" +
+ "function showAll() {" +
+ " showFormsCount(document);" +
+ "}" +
+ "</script></head><body onLoad='showAll();'>" +
+ "<a href='somewhere' name='there' title=second>here</a>" +
+ "<form name='perform1' title=fifth><input type='text' name='input' title='input1'></form>" +
+ "<form name='perform2' title=fifth><input type='text' name='input' title='input1'>" +
+ "<input type='hidden' name='input' title='input2'><input type='submit' name='doIt' title=sixth></form>" +
+ "</body></html>"
+ );
+ WebConversation wc = new WebConversation();
+ wc.getResponse( getHostPath() + "/start.html" );
+
+ assertElementTags( wc, "0", "1");
+ assertElementTags( wc, "1", "3");
+ }
+
+
+ private void assertElementTags( WebConversation wc, String number, final String counts) {
+ assertEquals( "form '" + number + "' message", "form with number " + number + " has " + counts +" inputs", wc.popNextAlert() );
+ }
}
|
|
From: Russell G. <rus...@us...> - 2003-04-02 15:31:17
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/scripting
In directory sc8-pr-cvs1:/tmp/cvs-serv5947/src/com/meterware/httpunit/scripting
Modified Files:
ScriptableDelegate.java
Log Message:
Added getElementsByTagName support
Index: ScriptableDelegate.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/scripting/ScriptableDelegate.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ScriptableDelegate.java 9 Mar 2003 20:35:48 -0000 1.7
+++ ScriptableDelegate.java 2 Apr 2003 15:31:12 -0000 1.8
@@ -1,4 +1,7 @@
package com.meterware.httpunit.scripting;
+
+import com.meterware.httpunit.HTMLElement;
+
/********************************************************************************************************************
* $Id$
*
@@ -111,6 +114,15 @@
public ScriptingEngine getScriptEngine( ScriptableDelegate child ) {
return getScriptEngine().newScriptingEngine( child );
+ }
+
+
+ protected ScriptableDelegate[] getDelegates( final HTMLElement[] elements ) {
+ ScriptableDelegate[] result = new ScriptableDelegate[ elements.length ];
+ for (int i = 0; i < elements.length; i++) {
+ result[i] = elements[i].getScriptableDelegate();
+ }
+ return result;
}
}
|
|
From: Russell G. <rus...@us...> - 2003-04-02 15:31:17
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript
In directory sc8-pr-cvs1:/tmp/cvs-serv5947/src/com/meterware/httpunit/javascript
Modified Files:
JavaScript.java
Log Message:
Added getElementsByTagName support
Index: JavaScript.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript/JavaScript.java,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- JavaScript.java 1 Apr 2003 16:19:12 -0000 1.51
+++ JavaScript.java 2 Apr 2003 15:31:09 -0000 1.52
@@ -318,6 +318,17 @@
throw new IllegalArgumentException( "Unknown ScriptableDelegate class: " + delegate.getClass() );
}
+
+ protected ElementArray toElementArray( ScriptableDelegate[] scriptables ) {
+ JavaScriptEngine[] elements = new JavaScriptEngine[ scriptables.length ];
+ for (int i = 0; i < elements.length; i++) {
+ elements[ i ] = (JavaScriptEngine) toScriptable( scriptables[ i ] );
+ }
+ ElementArray result = ElementArray.newElementArray( this );
+ result.initialize( elements );
+ return result;
+ }
+
}
@@ -483,19 +494,19 @@
public Scriptable jsGet_images() throws SAXException{
- if (_images == null) initializeImages();
+ if (_images == null) _images = toElementArray( getDelegate().getImages() );
return _images;
}
public Scriptable jsGet_links() throws SAXException {
- if (_links == null) initializeLinks();
+ if (_links == null) _links = toElementArray( getDelegate().getLinks() );
return _links;
}
public Scriptable jsGet_forms() throws SAXException {
- if (_forms == null) initializeForms();
+ if (_forms == null) _forms = toElementArray( getDelegate().getForms() );
return _forms;
}
@@ -506,14 +517,12 @@
public Object jsFunction_getElementsByName( String name ) {
- ScriptableDelegate scriptables[] = getDelegate().getElementsByName( name );
- JavaScriptEngine[] elements = new JavaScriptEngine[ scriptables.length ];
- for (int i = 0; i < elements.length; i++) {
- elements[ i ] = (JavaScriptEngine) toScriptable( scriptables[ i ] );
- }
- ElementArray result = ElementArray.newElementArray( this );
- result.initialize( elements );
- return result;
+ return toElementArray( getDelegate().getElementsByName( name ) );
+ }
+
+
+ public Object jsFunction_getElementsByTagName( String name ) {
+ return toElementArray( getDelegate().getElementsByTagName( name ) );
}
@@ -581,39 +590,6 @@
}
- private void initializeImages() {
- WebImage.Scriptable scriptables[] = getDelegate().getImages();
- Image[] images = new Image[ scriptables.length ];
- for (int i = 0; i < images.length; i++) {
- images[ i ] = (Image) toScriptable( scriptables[ i ] );
- }
- _images = ElementArray.newElementArray( this );
- _images.initialize( images );
- }
-
-
- private void initializeLinks() {
- WebLink.Scriptable scriptables[] = getDelegate().getLinks();
- Link[] links = new Link[ scriptables.length ];
- for (int i = 0; i < links.length; i++) {
- links[ i ] = (Link) toScriptable( scriptables[ i ] );
- }
- _links = ElementArray.newElementArray( this );
- _links.initialize( links );
- }
-
-
- private void initializeForms() {
- WebForm.Scriptable scriptables[] = getDelegate().getForms();
- Form[] forms = new Form[ scriptables.length ];
- for (int i = 0; i < forms.length; i++) {
- forms[ i ] = (Form) toScriptable( scriptables[ i ] );
- }
- _forms = ElementArray.newElementArray( this );
- _forms.initialize( forms );
- }
-
-
private HTMLPage.Scriptable getDelegate() {
return (HTMLPage.Scriptable) _scriptable;
}
@@ -917,6 +893,11 @@
initializeControls();
}
return _controls;
+ }
+
+
+ public Object jsFunction_getElementsByTagName( String name ) throws SAXException {
+ return toElementArray( getDelegate().getElementsByTagName( name ) );
}
|
|
From: Russell G. <rus...@us...> - 2003-04-02 15:29:05
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit
In directory sc8-pr-cvs1:/tmp/cvs-serv4679/src/com/meterware/servletunit
Modified Files:
JUnitServlet.java
Log Message:
Added default constructor
Index: JUnitServlet.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/JUnitServlet.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- JUnitServlet.java 1 Apr 2003 16:19:14 -0000 1.3
+++ JUnitServlet.java 2 Apr 2003 15:28:56 -0000 1.4
@@ -2,7 +2,7 @@
/********************************************************************************************************************
* $Id$
*
- * Copyright (c) 2001, 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
@@ -38,12 +38,17 @@
/**
- * A base class for a servlet which can run unit tests inside a servlet context.
+ * A servlet which can run unit tests inside a servlet context. It may be extended to provide InvocationContext-access
+ * to such tests if a container-specific implementation of InvocationContextFactory is provided.
+ * Combined with ServletTestCase, this would permit
+ * in-container tests of servlets in a fashion similar to that supported by ServletUnit.
*
- * @author <a href="mailto:rus...@ac...">Russell Gold</a>
+ * @author <a href="mailto:rus...@ht...">Russell Gold</a>
**/
-abstract
public class JUnitServlet extends HttpServlet {
+
+ public JUnitServlet() {
+ }
protected JUnitServlet( InvocationContextFactory factory ) {
|
|
From: Russell G. <rus...@us...> - 2003-04-01 16:19:46
|
Update of /cvsroot/httpunit/httpunit/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv29589/doc
Modified Files:
release_notes.txt
Log Message:
Added support for JUnitServlet text formatting
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.287
retrieving revision 1.288
diff -u -r1.287 -r1.288
--- release_notes.txt 1 Apr 2003 13:42:09 -0000 1.287
+++ release_notes.txt 1 Apr 2003 16:19:10 -0000 1.288
@@ -14,6 +14,9 @@
Revision History:
1-Apr-2003
+Additions:
+ 1. Added format parameter for JUnitServlet: values are "text" or "html"
+
Problems fixed:
1. HttpUnit now handles refresh headers without explicit URLs, defaulting to refreshing the containing page.
2. Bug #709979: Select.selectedIndex was returning -1 for a normal select box with no options explicitly selected.
|
|
From: Russell G. <rus...@us...> - 2003-04-01 16:19:18
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit
In directory sc8-pr-cvs1:/tmp/cvs-serv29589/test/com/meterware/servletunit
Modified Files:
JUnitServletTest.java
Log Message:
Added support for JUnitServlet text formatting
Index: JUnitServletTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/JUnitServletTest.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- JUnitServletTest.java 27 Feb 2003 23:36:06 -0000 1.6
+++ JUnitServletTest.java 1 Apr 2003 16:19:14 -0000 1.7
@@ -89,6 +89,14 @@
}
+ public void testAllTestsPassTextFormat() throws Exception {
+ ServletUnitClient client = newClient();
+ WebResponse wr = client.getResponse( "http://localhost/JUnit?format=text&test=" + PassingTests.class.getName() );
+ String expectedStart = PassingTests.class.getName() + " (1 test): OK";
+ assertTrue( "Results (" + wr.getText() + ") should start with '" + expectedStart, wr.getText().startsWith( expectedStart ) );
+ }
+
+
public void testSomeFailures() throws Exception {
ServletUnitClient client = newClient();
@@ -104,6 +112,16 @@
assertEquals( "Failure index 1", "1", results[2][0] );
assertEquals( "Failure index 2", "2", results[3][0] );
assertTrue( "Test class not found", results[2][1].indexOf( '(' + FailingTests.class.getName() + ')' ) >= 0 );
+ }
+
+
+ public void testSomeFailuresTextFormat() throws Exception {
+ ServletUnitClient client = newClient();
+
+ WebResponse wr = client.getResponse( "http://localhost/JUnit?format=text&test=" + FailingTests.class.getName() );
+ String expectedStart = FailingTests.class.getName() + " (3 tests): Problems Occurred";
+ assertTrue( "Results (" + wr.getText() + ") should start with: " + expectedStart, wr.getText().startsWith( expectedStart ) );
+ assertTrue( "Results (" + wr.getText() + ") should contain: 2 failures", wr.getText().indexOf( "2 failures" ) >= 0 );
}
|
|
From: Russell G. <rus...@us...> - 2003-04-01 16:19:18
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit
In directory sc8-pr-cvs1:/tmp/cvs-serv29589/src/com/meterware/servletunit
Modified Files:
JUnitServlet.java
Log Message:
Added support for JUnitServlet text formatting
Index: JUnitServlet.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/JUnitServlet.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JUnitServlet.java 30 Aug 2002 21:29:36 -0000 1.2
+++ JUnitServlet.java 1 Apr 2003 16:19:14 -0000 1.3
@@ -34,7 +34,6 @@
import junit.framework.Test;
import junit.framework.AssertionFailedError;
import junit.framework.TestResult;
-import junit.framework.TestCase;
import junit.framework.TestFailure;
@@ -53,16 +52,28 @@
protected void doGet( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {
- response.setContentType( "text/html" );
+ ResultsFormatter formatter = getResultsFormatter( request.getParameter( "format" ) );
+ response.setContentType( formatter.getContentType() );
final String testName = request.getParameter( "test" );
if (testName == null || testName.length() == 0) {
reportCannotRunTest( response.getWriter(), "No test class specified" );
} else {
- ServletTestRunner runner = new ServletTestRunner( testName, response.getWriter() );
+ ServletTestRunner runner = new ServletTestRunner( response.getWriter(), formatter );
+ runner.runTestSuite( testName );
}
response.getWriter().close();
}
+
+ private ResultsFormatter getResultsFormatter( String formatterName ) {
+ if ("text".equalsIgnoreCase( formatterName )) {
+ return new TextResultsFormatter();
+ } else {
+ return new HTMLResultsFormatter();
+ }
+ }
+
+
private InvocationContextFactory _factory;
@@ -72,24 +83,27 @@
class ServletTestRunner extends BaseTestRunner {
- private String _elapsedTime;
private PrintWriter _writer;
+ private ResultsFormatter _formatter;
- public ServletTestRunner( String testClassName, PrintWriter writer ) {
+ public ServletTestRunner( PrintWriter writer, ResultsFormatter formatter ) {
+ ServletTestCase.setInvocationContextFactory( _factory );
_writer = writer;
- _testClassName = testClassName;
+ _formatter = formatter;
+ }
+
+
+ void runTestSuite( String testClassName ) {
Test suite = getTest( testClassName );
- ServletTestCase.setInvocationContextFactory( _factory );
if (suite != null) {
- _testResult = new TestResult();
- _testResult.addListener( this );
+ TestResult testResult = new TestResult();
+ testResult.addListener( this );
long startTime= System.currentTimeMillis();
- suite.run(_testResult);
+ suite.run( testResult );
long endTime= System.currentTimeMillis();
- _elapsedTime = elapsedTimeAsString( endTime-startTime );
- displayResults( _writer );
+ _formatter.displayResults( _writer, testClassName, elapsedTimeAsString( endTime-startTime ), testResult );
}
}
@@ -135,56 +149,157 @@
return new StandardTestSuiteLoader();
}
+ }
- void displayResults( PrintWriter writer ) {
- writer.println( "<html><head><title>Test Suite: " + _testClassName + "</title>" );
- writer.println( "<style type='text/css'>" );
- writer.println( "<!--" );
- writer.println( " td.detail { font-size:smaller; vertical-align: top }" );
- writer.println( " -->" );
- writer.println( "</style></head><body>" );
- writer.println( "<table id='results' border='1'><tr>" );
- writer.println( "<td>" + getFormatted( _testResult.runCount(), "test" ) + "</td>" );
- writer.println( "<td>Time: " + _elapsedTime + "</td>" );
- if (_testResult.wasSuccessful()) {
- writer.println( "<td>OK</td></tr>" );
- } else {
- writer.println( "<td>Problems Occurred</td></tr>" );
- displayProblems( writer, "failure", _testResult.failureCount(), _testResult.failures() );
- displayProblems( writer, "error", _testResult.errorCount(), _testResult.errors() );
+ static abstract class ResultsFormatter {
+ String getContentType() {
+ return "text/html";
+ }
+
+
+ void displayResults( PrintWriter writer, String testClassName, String elapsedTimeString, TestResult testResult ) {
+ displayHeader( writer, testClassName, getFormatted( testResult.runCount(), "test" ),
+ elapsedTimeString, testResult.wasSuccessful() ? "OK" : "Problems Occurred" );
+
+ if (!testResult.wasSuccessful()) {
+ displayProblems( writer, "failure", testResult.failureCount(), testResult.failures() );
+ displayProblems( writer, "error", testResult.errorCount(), testResult.errors() );
}
- writer.println( "</table>" );
- writer.println( "</body></html>" );
+ displayFooter( writer );
+ }
+
+
+ private String getFormatted( int count, String name ) {
+ return count + " " + name + (count == 1 ? "" : "s");
}
- private void displayProblems( PrintWriter writer, String title, int count, Enumeration enumeration ) {
+ protected abstract void displayHeader( PrintWriter writer, String testClassName, String testCountText, String elapsedTimeString, String resultString );
+
+
+ protected abstract void displayFooter( PrintWriter writer );
+
+
+ protected void displayProblems( PrintWriter writer, String kind, int count, Enumeration enumeration ) {
if (count != 0) {
- writer.println( "<tr><td colspan=3>" + getFormatted( count, title ) + "</td></tr>" );
+ displayProblemTitle( writer, getFormatted( count, kind ) );
Enumeration e = enumeration;
for (int i = 1; e.hasMoreElements(); i++) {
TestFailure failure = (TestFailure) e.nextElement();
- writer.println( "<tr><td class='detail' align='right'>" + i + "</td>" );
- writer.println( "<td class='detail'>" + failure.failedTest() + "</td><td class='detail'>" );
+ displayProblemDetailHeader( writer, i, failure.failedTest().toString() );
if (failure.thrownException() instanceof AssertionFailedError) {
- writer.println( htmlEscape( failure.thrownException().getMessage() ) );
+ displayProblemDetail( writer, failure.thrownException().getMessage() );
} else {
- writer.println( htmlEscape( getFilteredTrace( failure.thrownException() ) ) );
+ displayProblemDetail( writer, BaseTestRunner.getFilteredTrace( failure.thrownException() ) );
}
- writer.println( "</td></tr>" );
+ displayProblemDetailFooter( writer );
}
}
}
- private static final char LF = 10;
- private static final char CR = 13;
- private String getFormatted( int count, String name ) {
- return count + " " + name + (count == 1 ? "" : "s");
+ protected abstract void displayProblemTitle( PrintWriter writer, String title );
+
+
+ protected abstract void displayProblemDetailHeader( PrintWriter writer, int i, String testName );
+
+
+ protected abstract void displayProblemDetailFooter( PrintWriter writer );
+
+
+ protected abstract void displayProblemDetail( PrintWriter writer, String message );
+ }
+
+
+ static class TextResultsFormatter extends ResultsFormatter {
+
+ String getContentType() {
+ return "text/plain";
+ }
+
+
+ protected void displayHeader( PrintWriter writer, String testClassName, String testCountText,
+ String elapsedTimeString, String resultString ) {
+ writer.println( testClassName + " (" + testCountText + "): " + resultString );
}
+ protected void displayFooter( PrintWriter writer ) {
+ }
+
+
+ protected void displayProblemTitle( PrintWriter writer, String title ) {
+ writer.println();
+ writer.println( title + ':' );
+ }
+
+
+ protected void displayProblemDetailHeader( PrintWriter writer, int i, String testName ) {
+ writer.println( i + ". " + testName + ":" );
+ }
+
+
+ protected void displayProblemDetailFooter( PrintWriter writer ) {
+ writer.println();
+ }
+
+
+ protected void displayProblemDetail( PrintWriter writer, String message ) {
+ writer.println( message );
+ }
+ }
+
+
+ static class HTMLResultsFormatter extends ResultsFormatter {
+
+
+ protected void displayHeader( PrintWriter writer, String testClassName, String testCountText,
+ String elapsedTimeString, String resultString ) {
+ writer.println( "<html><head><title>Test Suite: " + testClassName + "</title>" );
+ writer.println( "<style type='text/css'>" );
+ writer.println( "<!--" );
+ writer.println( " td.detail { font-size:smaller; vertical-align: top }" );
+ writer.println( " -->" );
+ writer.println( "</style></head><body>" );
+ writer.println( "<table id='results' border='1'><tr>" );
+ writer.println( "<td>" + testCountText + "</td>" );
+ writer.println( "<td>Time: " + elapsedTimeString + "</td>" );
+ writer.println( "<td>" + resultString + "</td></tr>" );
+ }
+
+
+ protected void displayFooter( PrintWriter writer ) {
+ writer.println( "</table>" );
+ writer.println( "</body></html>" );
+ }
+
+
+ protected void displayProblemTitle( PrintWriter writer, String title ) {
+ writer.println( "<tr><td colspan=3>" + title + "</td></tr>" );
+ }
+
+
+ protected void displayProblemDetailHeader( PrintWriter writer, int i, String testName ) {
+ writer.println( "<tr><td class='detail' align='right'>" + i + "</td>" );
+ writer.println( "<td class='detail'>" + testName + "</td><td class='detail'>" );
+ }
+
+
+ protected void displayProblemDetailFooter( PrintWriter writer ) {
+ writer.println( "</td></tr>" );
+ }
+
+
+ protected void displayProblemDetail( PrintWriter writer, String message ) {
+ writer.println( htmlEscape( message ) );
+ }
+
+
+ private static final char LF = 10;
+ private static final char CR = 13;
+
+
private String htmlEscape( String s ) {
StringBuffer result = new StringBuffer( s.length() );
char[] chars = s.toCharArray();
@@ -212,10 +327,6 @@
}
return result.toString();
}
-
-
- private TestResult _testResult;
- private String _testClassName;
}
}
|