You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@beehive.apache.org by Patrick Osborne <pa...@bea.com> on 2004/10/04 18:42:01 UTC

Netui check-in request

Hi All,

I have a couple of modifications to the Test Recorder.

Fixes:
* 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.
* Some simple cleanup to netui\test\ant\testRecorder.xml

Thanks,
Patrick.

Re: Netui check-in request

Posted by Patrick Osborne <pa...@bea.com>.
Eddie thanks for reviewing the code.  I synced and looked at 
testRecorderCore.xml, it looks good but contains some items that are no 
longer necessary during playback.  What I'm going to do is submit the TR 
code fixes in this check-in request and put together a separate check-in 
request for build modifiications.  So here are the fixes in this diff file:

* 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.

Cheers,
Patrick.


Eddie O'Neil wrote:

> Patrick--
>
>   These are good bug fixes; I believe that I've changed the 
> testRecorder.xml file last week in a way that you'll need to sync and 
> work those changes into testRecorderCore.xml.  Then, re-spin your diff 
> and someone will get it in.
>
>   Also, one of the other changes below removes the error checking for 
> the TR's config.jar from the "playback" target.  It'd be good to also 
> remove that from "run.suite" and move the error checking code into 
> "playback.tests" which is called by both of these other target.
>
> Thanks for the patch!
>
> Eddie
>
>
>
> Patrick Osborne wrote:
>
>>
>> Hi All,
>>
>> I have a couple of modifications to the Test Recorder.
>>
>> Fixes:
>> * 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.
>> * Some simple cleanup to netui\test\ant\testRecorder.xml
>>
>> Thanks,
>> Patrick.
>>
>>
>> ------------------------------------------------------------------------
>>
>> Index: netui/test/ant/testRecorder.xml
>> ===================================================================
>> --- netui/test/ant/testRecorder.xml    (revision 47607)
>> +++ netui/test/ant/testRecorder.xml    (working copy)
>> @@ -201,12 +201,10 @@
>>              </or>
>>          </condition>
>>  
>> -        <echo>config.jar: ${_config.jar}</echo>
>>          <echo>log4j.config: ${log4j.config}</echo>
>>          <echo>playback list: ${_list}</echo>
>>          <echo>playback categories: ${_categories}</echo>
>>          <echo>playback webapps: ${playback.webapps}</echo>
>> -        <echo>playback config jar: ${_config.jar}</echo>
>>          <echo>test.recorder.classpath: 
>> ${test.recorder.classpath}</echo>
>>  
>>          <junit dir="${netui.ant.dir}" fork="true" 
>> errorproperty="playback.drt.error" 
>> failureproperty="playback.drt.failure" @@ -221,7 +219,7 @@
>>              <sysproperty key="test.recorder.run.tests" 
>> value="${_list}"/>
>>              <sysproperty key="test.recorder.run.categories" 
>> value="${_categories}"/>
>>              <sysproperty key="test.recorder.run.webapps" 
>> value="${playback.webapps}"/>
>> -            <sysproperty key="test.recorder.run.results.delete" 
>> value="${results.delete}"/>
>> +            <sysproperty key="test.recorder.run.results.delete" 
>> value="${_results.delete}"/>
>>              <sysproperty key="netuidrt.logdir" 
>> path="${build.dir}/testRecorder"/>
>>              <sysproperty key="log4j.configuration" 
>> value="file:${log4j.config}"/>
>>  
>> @@ -259,13 +257,6 @@
>>      <target name="playback"          description="Plays back a list 
>> of pre-recorded tests, set the 'playback.list' property to specify a 
>> list of tests.">
>>  
>> -        <fail unless="testRecorder.config.name" message="No test 
>> recorder config name (property: 'testRecorder.config.name') specified"/>
>> -        <echo>testRecorder.config.name: 
>> ${testRecorder.config.name}</echo>
>> -        <property name="_config.jar" 
>> location="${_testRecorder.config.dir}/${testRecorder.config.name}.jar"/>
>> -        <available property="config.jar.available" 
>> file="${_config.jar}"/>
>> -        <fail unless="config.jar.available" message="Can't find a 
>> test recorder config JAR at ${_config.jar} to copy"/>
>> -        <echo>_config.jar: ${_config.jar}</echo>
>> -
>>          <antcall target="playback.tests">
>>              <param name="formatter.type" value="plain"/>
>>              <param name="formatter.usefile" value="false"/>
>> Index: 
>> netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/shared/Constants.java 
>>
>> ===================================================================
>> --- 
>> netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/shared/Constants.java    
>> (revision 47607)
>> +++ 
>> netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/shared/Constants.java    
>> (working copy)
>> @@ -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
>> Index: 
>> netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/shared/Logger.java 
>>
>> ===================================================================
>> --- 
>> netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/shared/Logger.java    
>> (revision 47607)
>> +++ 
>> netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/shared/Logger.java    
>> (working copy)
>> @@ -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();
>>      }
>> +
>>  }
>> Index: 
>> netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/ResponseWrapper.java 
>>
>> ===================================================================
>> --- 
>> netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/ResponseWrapper.java    
>> (revision 47607)
>> +++ 
>> netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/ResponseWrapper.java    
>> (working copy)
>> @@ -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;
>>  
>> @@ -100,6 +100,29 @@
>>          }
>>      }
>>  
>> +    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
>>      int getStatusCode() {
>>          return statusCode;
>> @@ -124,6 +147,7 @@
>>          return outputString;
>>      }
>>  
>> +
>>      /**
>>       * Internal class that implements a ServletOutputStream.  This 
>> is used to
>>       * return our output stream to the JSP world.
>> Index: 
>> netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/DefaultFilterData.java 
>>
>> ===================================================================
>> --- 
>> netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/DefaultFilterData.java    
>> (revision 47607)
>> +++ 
>> netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/DefaultFilterData.java    
>> (working copy)
>> @@ -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 ) {
>> Index: 
>> netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/TestRecorderFilter.java 
>>
>> ===================================================================
>> --- 
>> netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/TestRecorderFilter.java    
>> (revision 47607)
>> +++ 
>> netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/TestRecorderFilter.java    
>> (working copy)
>> @@ -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 + ")" );
>>                      }
>
>

Re: Netui check-in request

Posted by Eddie O'Neil <ek...@bea.com>.
Patrick--

   These are good bug fixes; I believe that I've changed the 
testRecorder.xml file last week in a way that you'll need to sync and 
work those changes into testRecorderCore.xml.  Then, re-spin your diff 
and someone will get it in.

   Also, one of the other changes below removes the error checking for 
the TR's config.jar from the "playback" target.  It'd be good to also 
remove that from "run.suite" and move the error checking code into 
"playback.tests" which is called by both of these other target.

Thanks for the patch!

Eddie



Patrick Osborne wrote:
> 
> Hi All,
> 
> I have a couple of modifications to the Test Recorder.
> 
> Fixes:
> * 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.
> * Some simple cleanup to netui\test\ant\testRecorder.xml
> 
> Thanks,
> Patrick.
> 
> 
> ------------------------------------------------------------------------
> 
> Index: netui/test/ant/testRecorder.xml
> ===================================================================
> --- netui/test/ant/testRecorder.xml	(revision 47607)
> +++ netui/test/ant/testRecorder.xml	(working copy)
> @@ -201,12 +201,10 @@
>              </or>
>          </condition>
>  
> -        <echo>config.jar: ${_config.jar}</echo>
>          <echo>log4j.config: ${log4j.config}</echo>
>          <echo>playback list: ${_list}</echo>
>          <echo>playback categories: ${_categories}</echo>
>          <echo>playback webapps: ${playback.webapps}</echo>
> -        <echo>playback config jar: ${_config.jar}</echo>
>          <echo>test.recorder.classpath: ${test.recorder.classpath}</echo>
>  
>          <junit dir="${netui.ant.dir}" fork="true" errorproperty="playback.drt.error" failureproperty="playback.drt.failure" 
> @@ -221,7 +219,7 @@
>              <sysproperty key="test.recorder.run.tests" value="${_list}"/>
>              <sysproperty key="test.recorder.run.categories" value="${_categories}"/>
>              <sysproperty key="test.recorder.run.webapps" value="${playback.webapps}"/>
> -            <sysproperty key="test.recorder.run.results.delete" value="${results.delete}"/>
> +            <sysproperty key="test.recorder.run.results.delete" value="${_results.delete}"/>
>              <sysproperty key="netuidrt.logdir" path="${build.dir}/testRecorder"/>
>              <sysproperty key="log4j.configuration" value="file:${log4j.config}"/>
>  
> @@ -259,13 +257,6 @@
>      <target name="playback" 
>          description="Plays back a list of pre-recorded tests, set the 'playback.list' property to specify a list of tests.">
>  
> -        <fail unless="testRecorder.config.name" message="No test recorder config name (property: 'testRecorder.config.name') specified"/>
> -        <echo>testRecorder.config.name: ${testRecorder.config.name}</echo>
> -        <property name="_config.jar" location="${_testRecorder.config.dir}/${testRecorder.config.name}.jar"/>
> -        <available property="config.jar.available" file="${_config.jar}"/>
> -        <fail unless="config.jar.available" message="Can't find a test recorder config JAR at ${_config.jar} to copy"/>
> -        <echo>_config.jar: ${_config.jar}</echo>
> -
>          <antcall target="playback.tests">
>              <param name="formatter.type" value="plain"/>
>              <param name="formatter.usefile" value="false"/>
> Index: netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/shared/Constants.java
> ===================================================================
> --- netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/shared/Constants.java	(revision 47607)
> +++ netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/shared/Constants.java	(working copy)
> @@ -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
> Index: netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/shared/Logger.java
> ===================================================================
> --- netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/shared/Logger.java	(revision 47607)
> +++ netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/shared/Logger.java	(working copy)
> @@ -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();
>      }
> +
>  }
> Index: netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/ResponseWrapper.java
> ===================================================================
> --- netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/ResponseWrapper.java	(revision 47607)
> +++ netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/ResponseWrapper.java	(working copy)
> @@ -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;
>  
> @@ -100,6 +100,29 @@
>          }
>      }
>  
> +    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
>      int getStatusCode() {
>          return statusCode;
> @@ -124,6 +147,7 @@
>          return outputString;
>      }
>  
> +
>      /**
>       * Internal class that implements a ServletOutputStream.  This is used to
>       * return our output stream to the JSP world.
> Index: netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/DefaultFilterData.java
> ===================================================================
> --- netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/DefaultFilterData.java	(revision 47607)
> +++ netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/DefaultFilterData.java	(working copy)
> @@ -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 ) {
> Index: netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/TestRecorderFilter.java
> ===================================================================
> --- netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/TestRecorderFilter.java	(revision 47607)
> +++ netui/test/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/TestRecorderFilter.java	(working copy)
> @@ -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 + ")" );
>                      }