You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by st...@apache.org on 2004/10/04 22:36:26 UTC
svn commit: rev 53745 - in incubator/beehive/trunk/netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder: server shared
Author: stocco
Date: Mon Oct 4 13:36:24 2004
New Revision: 53745
Modified:
incubator/beehive/trunk/netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/DefaultFilterData.java
incubator/beehive/trunk/netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/ResponseWrapper.java
incubator/beehive/trunk/netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/TestRecorderFilter.java
incubator/beehive/trunk/netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/shared/Constants.java
incubator/beehive/trunk/netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/shared/Logger.java
Log:
Changes to test recorder submitted on behalf of Patrick Osborne.
netui drt/checkin tests: PASS
Code Reviewed By E. O'Neil on email thread
Comments from P. Osborne
"* The Test Recorder (TR) had a bug where, in some cases, during record and/or playback the html captured by the TR did not match the html returned to the browser by the container. The bug was encountered in some usages of the jsp:forward tag in a jsp page, where the container desired to reset the jsp writer buffer. The fix consists of implementing the reset() and resetBuffer() methods in the ResponseWrapper to reset the TR output buffer when requested.
* Fixed a bug where in some cases the test recorder test links were not properly produced.
* Modified the string representation of exceptions during logging:
included exception messages and stack traces of nested exceptions.
* Added some debugging around request data - request params, headers, post params, etc."
Modified: incubator/beehive/trunk/netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/DefaultFilterData.java
==============================================================================
--- incubator/beehive/trunk/netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/DefaultFilterData.java (original)
+++ incubator/beehive/trunk/netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/DefaultFilterData.java Mon Oct 4 13:36:24 2004
@@ -94,6 +94,9 @@
// capture request data, this may not be necessary if we aren't recording or playing back.
reqData = RequestData.populate( (HttpServletRequest) request, new RequestData() );
+ if ( log.isDebugEnabled() ) {
+ log.debug( "request data( " + reqData + " )" );
+ }
}
protected void testForTestId( ServletRequest request ) {
Modified: incubator/beehive/trunk/netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/ResponseWrapper.java
==============================================================================
--- incubator/beehive/trunk/netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/ResponseWrapper.java (original)
+++ incubator/beehive/trunk/netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/ResponseWrapper.java Mon Oct 4 13:36:24 2004
@@ -39,7 +39,7 @@
private ByteArrayOutputStream output;
private PrintWriter writer;
private ServletOutputStream servletStream;
- private int statusCode = 200;
+ private int statusCode = SC_OK;
private String reason = "";
private String outputString = null;
@@ -98,6 +98,29 @@
if ( log.isDebugEnabled() ) {
log.debug( "setStatus() done" );
}
+ }
+
+ public void reset() {
+ if ( log.isDebugEnabled() ) {
+ log.debug( "reset()" );
+ }
+ if ( isCommitted() ) {
+ throw new IllegalStateException( "response is already commited, reset not allowed" );
+ }
+ output.reset();
+ statusCode = SC_OK;
+ super.reset();
+ }
+
+ public void resetBuffer() {
+ if ( log.isDebugEnabled() ) {
+ log.debug( "resetBuffer()" );
+ }
+ if ( isCommitted() ) {
+ throw new IllegalStateException( "response is already commited, reset buffer not allowed" );
+ }
+ output.reset();
+ super.resetBuffer();
}
// package scoped
Modified: incubator/beehive/trunk/netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/TestRecorderFilter.java
==============================================================================
--- incubator/beehive/trunk/netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/TestRecorderFilter.java (original)
+++ incubator/beehive/trunk/netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/TestRecorderFilter.java Mon Oct 4 13:36:24 2004
@@ -452,6 +452,9 @@
if ( addLink ) {
int index = body.lastIndexOf( Constants.BODY_END );
if ( index == -1 ) {
+ index = body.lastIndexOf( Constants.BODY_END_CAPS );
+ }
+ if ( index == -1 ) {
if ( log.isDebugEnabled() ) {
log.debug( "</body> was not found:\nbody(" + body + ")" );
}
Modified: incubator/beehive/trunk/netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/shared/Constants.java
==============================================================================
--- incubator/beehive/trunk/netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/shared/Constants.java (original)
+++ incubator/beehive/trunk/netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/shared/Constants.java Mon Oct 4 13:36:24 2004
@@ -61,6 +61,7 @@
public static final String REQUEST_NEW_EXCEPTION_MARKER_ATTRIBUTE = "testRecorder.request.marked.exception.new";
public static final String STATE_STORAGE_KEY = "testRecorder.state.";
public static final String BODY_END = "</body>";
+ public static final String BODY_END_CAPS = "</BODY>";
public static final String NL = "\n";
public static final String EMPTY_STRING = "";
// 'cmd' values
Modified: incubator/beehive/trunk/netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/shared/Logger.java
==============================================================================
--- incubator/beehive/trunk/netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/shared/Logger.java (original)
+++ incubator/beehive/trunk/netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/shared/Logger.java Mon Oct 4 13:36:24 2004
@@ -145,12 +145,28 @@
}
}
- public static String format( Object m, Throwable t ) {
+ public static String format( final Object obj, final Throwable t ) {
if ( t == null ) {
- return m.toString();
+ return obj.toString();
+ }
+ Throwable ex = t;
+ StringBuffer sb = new StringBuffer( 512 );
+ sb.append( "object( " + obj + " )\n" );
+ while ( ex != null ) {
+ sb.append( format( ex ) + "\n");
+ ex = ex.getCause();
+ }
+ return sb.toString();
+ }
+
+ public static String format( Throwable t ) {
+ if ( t == null ) {
+ return "NULL";
}
StringWriter sw = new StringWriter();
t.printStackTrace( new PrintWriter( sw ) );
- return m + "\n\n" + "Throwable: " + t.toString() + "\nStack Trace:\n" + sw.toString();
+ return "throwable: msg( " + t.getMessage() + " )\ntoString( " + t.toString() +
+ " )\nstack trace:\n" + sw.toString();
}
+
}