[Httpunit-commit] CVS: httpunit/src/com/meterware/httpunit HTMLPage.java,1.15,1.16 WebResponse.java,
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2002-11-17 16:43:44
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv24639/src/com/meterware/httpunit
Modified Files:
HTMLPage.java WebResponse.java
Log Message:
Added support for Document.open / close
Index: HTMLPage.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HTMLPage.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- HTMLPage.java 3 Nov 2002 06:28:36 -0000 1.15
+++ HTMLPage.java 17 Nov 2002 16:43:40 -0000 1.16
@@ -232,6 +232,11 @@
Scriptable() {}
+
+
+ public void replaceText( String text, String contentType ) {
+ getResponse().replaceText( text, contentType );
+ }
}
Index: WebResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -r1.100 -r1.101
--- WebResponse.java 17 Nov 2002 00:17:07 -0000 1.100
+++ WebResponse.java 17 Nov 2002 16:43:41 -0000 1.101
@@ -248,7 +248,7 @@
* Returns a buffered input stream for reading the contents of this reply.
**/
public InputStream getInputStream() throws IOException {
- if (_inputStream == null) _inputStream = new ByteArrayInputStream( new byte[0] );
+ if (_inputStream == null) _inputStream = new ByteArrayInputStream( getText().getBytes() );
return _inputStream;
}
@@ -680,6 +680,17 @@
}
+ /**
+ * Constructs a response object.
+ * @param frameName the name of the frame to hold the response
+ * @param url the url from which the response was received
+ **/
+ protected WebResponse( WebClient client, String frameName, URL url, String text ) {
+ this( client, frameName, url );
+ _responseText = text;
+ }
+
+
final
protected void defineRawInputStream( InputStream inputStream ) throws IOException {
if (_inputStream != null || _responseText != null) {
@@ -724,6 +735,14 @@
}
+ void replaceText( String text, String contentType ) {
+ _responseText = text;
+ _inputStream = null;
+ _page = null;
+ _contentType = contentType;
+ }
+
+
/**
* Returns the frames found in the page in the order in which they appear.
**/
@@ -1100,8 +1119,7 @@
DefaultWebResponse( WebClient client, String target, URL url, String text ) {
- super( client, target, url );
- _responseText = text;
+ super( client, target, url, text );
}
@@ -1137,33 +1155,19 @@
}
}
+
public String[] getHeaderFields( String fieldName ) {
String value = getHeaderField( fieldName );
return value == null ? new String[0] : new String[]{ value };
}
- /**
- * Returns the text of the response (excluding headers) as a string. Use this method in preference to 'toString'
- * which may be used to represent internal state of this object.
- **/
- public String getText() {
- return _responseText;
- }
-
-
- /**
- * Returns an input stream for reading the contents of this reply.
- **/
- public InputStream getInputStream() {
- return new ByteArrayInputStream( _responseText.getBytes() );
- }
-
public String toString() {
- return "DefaultWebResponse [" + _responseText + "]";
+ try {
+ return "DefaultWebResponse [" + getText() + "]";
+ } catch (IOException e) { // should never happen
+ return "DefaultWebResponse [???]";
+ }
}
-
-
- private String _responseText;
}
|