vmassol 01/11/12 13:14:11
Modified: src/test/share/org/apache/cactus
TestAbstractTestCase_InterceptorTestCase.java
src/test/share/org/apache/cactus/mock
MockHttpURLConnection.java
Log:
there was a bug in the HttpURLConnection mock ... Actually I don't remember why I
implemented it in the stupid way it was ... can't rememeber the idea I had ... but it
now seems a bad idea, so it's been corrected and is now working correctly again ... :)
Revision Changes Path
1.10 +3 -3
jakarta-cactus/src/test/share/org/apache/cactus/TestAbstractTestCase_InterceptorTestCase.java
Index: TestAbstractTestCase_InterceptorTestCase.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/src/test/share/org/apache/cactus/TestAbstractTestCase_InterceptorTestCase.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- TestAbstractTestCase_InterceptorTestCase.java 2001/10/28 11:27:36 1.9
+++ TestAbstractTestCase_InterceptorTestCase.java 2001/11/12 21:14:11 1.10
@@ -68,7 +68,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Vincent Massol</a>
*
- * @version $Id: TestAbstractTestCase_InterceptorTestCase.java,v 1.9 2001/10/28
11:27:36 vmassol Exp $
+ * @version $Id: TestAbstractTestCase_InterceptorTestCase.java,v 1.10 2001/11/12
21:14:11 vmassol Exp $
*/
public class TestAbstractTestCase_InterceptorTestCase
extends AbstractTestCase
@@ -110,8 +110,8 @@
// Set the values expected by Http Unit. Note: only the test
// cases that have an end method with an HttpUnit WebReponse
// will use the HttpURLConnection.
- connection.addGetHeaderFieldValue("HTTP/1.1 200 OK");
- connection.addGetInputStream(new ByteArrayInputStream(
+ connection.setExpectedGetHeaderField("HTTP/1.1 200 OK");
+ connection.setExpectedGetInputStream(new ByteArrayInputStream(
"".getBytes()));
// Create a WebResponse object and call the end method
1.5 +22 -32
jakarta-cactus/src/test/share/org/apache/cactus/mock/MockHttpURLConnection.java
Index: MockHttpURLConnection.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/src/test/share/org/apache/cactus/mock/MockHttpURLConnection.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- MockHttpURLConnection.java 2001/09/14 20:26:01 1.4
+++ MockHttpURLConnection.java 2001/11/12 21:14:11 1.5
@@ -62,48 +62,46 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Vincent Massol</a>
*
- * @version $Id: MockHttpURLConnection.java,v 1.4 2001/09/14 20:26:01 pier Exp $
+ * @version $Id: MockHttpURLConnection.java,v 1.5 2001/11/12 21:14:11 vmassol Exp $
*/
public class MockHttpURLConnection extends HttpURLConnection
{
/**
* Store the header fields that the <code>getHeaderField()</code> will
- * return (for each call, the last entry of the vector will be returned
- * and removed from the vector).
+ * return.
*/
- private Vector getHeaderFieldValues = new Vector();
+ private String getHeaderFieldValue;
/**
- * Store the input streams that the <code>getHeaderField()</code> will
- * return (for each call, the last entry of the vector will be returned
- * and removed from the vector).
+ * Store the input streams that the <code>getInputStream()</code> will
+ * return.
*/
- private Vector getInputStreamValues = new Vector();
+ private InputStream getInputStreamValue;
// -----------------------------------------------------------------------
// Methods added on top of those found in HttpURLConnection
// -----------------------------------------------------------------------
/**
- * Add a new header field value to the vector of values that will be
- * returned by <code>getHeaderField()</code>.
+ * Sets the header field value that will be returned by
+ * <code>getHeaderField()</code>.
*
- * @param theValue the header file value to add
+ * @param theValue the header field value
*/
- public void addGetHeaderFieldValue(String theValue)
+ public void setExpectedGetHeaderField(String theValue)
{
- this.getHeaderFieldValues.addElement(theValue);
+ this.getHeaderFieldValue = theValue;
}
/**
- * Add a new input stream to the vector of values that will be
- * returned by <code>getInputStream()</code>.
+ * Sets the input stream value that will be returned by
+ * <code>getInputStream()</code>.
*
- * @param theValue the input stream to add
+ * @param theValue the input stream value
*/
- public void addGetInputStream(InputStream theValue)
+ public void setExpectedGetInputStream(InputStream theValue)
{
- this.getInputStreamValues.addElement(theValue);
+ this.getInputStreamValue = theValue;
}
// -----------------------------------------------------------------------
@@ -123,15 +121,11 @@
*/
public String getHeaderField(int fieldNumber)
{
- if (this.getHeaderFieldValues.isEmpty()) {
- throw new RuntimeException("Must call addGetHeaderFieldValue() " +
+ if (this.getHeaderFieldValue == null) {
+ throw new RuntimeException("Must call setExpectedGetHeaderField() " +
"first !");
}
- String result = (String)this.getHeaderFieldValues.elementAt(
- this.getHeaderFieldValues.size() - 1);
- this.getHeaderFieldValues.removeElementAt(
- this.getHeaderFieldValues.size() - 1);
- return result;
+ return this.getHeaderFieldValue;
}
/**
@@ -139,15 +133,11 @@
*/
public InputStream getInputStream()
{
- if (this.getInputStreamValues.isEmpty()) {
- throw new RuntimeException("Must call addGetInputStream() " +
+ if (this.getInputStreamValue == null) {
+ throw new RuntimeException("Must call setExpectedGetInputStream() " +
"first !");
}
- InputStream result = (InputStream)this.getInputStreamValues.elementAt(
- this.getInputStreamValues.size() - 1);
- this.getInputStreamValues.removeElementAt(
- this.getInputStreamValues.size() - 1);
- return result;
+ return this.getInputStreamValue;
}
// -----------------------------------------------------------------------
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>