curcuru     02/02/12 11:53:21

  Modified:    test/java/src/org/apache/qetest/xsl ErrorHandlerTestlet.java
  Log:
  Attempt to separate errors during stylesheet build and actual transform;
  note that this is not complete, although it is a useful testlet to
  run transforms with an error listener present
  
  Revision  Changes    Path
  1.2       +56 -4     
xml-xalan/test/java/src/org/apache/qetest/xsl/ErrorHandlerTestlet.java
  
  Index: ErrorHandlerTestlet.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/test/java/src/org/apache/qetest/xsl/ErrorHandlerTestlet.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ErrorHandlerTestlet.java  18 Dec 2001 23:07:30 -0000      1.1
  +++ ErrorHandlerTestlet.java  12 Feb 2002 19:53:21 -0000      1.2
  @@ -91,10 +91,13 @@
    * this testlet is effectively only applicable with 
    * TransformWrappers that wrap JAXP-compatible implementations.
    *
  + * Attempts to separate validation between stylesheet parse/build 
  + * errors and transform errors.
  + *
    * //@todo better doc on our algorithim
    *
    * @author [EMAIL PROTECTED]
  - * @version $Id: ErrorHandlerTestlet.java,v 1.1 2001/12/18 23:07:30 curcuru Exp $
  + * @version $Id: ErrorHandlerTestlet.java,v 1.2 2002/02/12 19:53:21 curcuru Exp $
    */
   public class ErrorHandlerTestlet extends StylesheetTestlet
   {
  @@ -115,6 +118,55 @@
       }
   
   
  +    /**
  +     * Our testing state: during stylesheet build or transform.
  +     */
  +    protected boolean duringXSLBuild = true;
  +
  +
  +    /** 
  +     * Worker method to actually perform the transform: overridden.  
  +     *
  +     * Explicitly builds a stylesheet first, then does transform.  
  +     * With duringXSLBuild state above, we can then validate 
  +     * when exceptions/errors are thrown.
  +     * Note: Does not properly handle embedded tests yet!
  +     *
  +     * @param datalet to test with
  +     * @param transformWrapper to have perform the transform
  +     * @throws allows any underlying exception to be thrown
  +     */
  +    protected void testDatalet(StylesheetDatalet datalet, TransformWrapper 
transformWrapper)
  +            throws Exception
  +    {
  +        //@todo Should we log a custom logElement here instead?
  +        logger.logMsg(Logger.TRACEMSG, "executing with: inputName=" + 
datalet.inputName
  +                      + " xmlName=" + datalet.xmlName + " outputName=" + 
datalet.outputName
  +                      + " goldName=" + datalet.goldName + " flavor="  + 
datalet.flavor);
  +
  +        // Simply have the wrapper do all the transforming
  +        //  or processing for us - we handle either normal .xsl 
  +        //  stylesheet tests or just .xml embedded tests
  +        long retVal = 0L;
  +        if (null == datalet.inputName)
  +        {
  +            // presume it's an embedded test
  +            //@todo make this handle duringXSLBuild state!
  +            long [] times = transformWrapper.transformEmbedded(datalet.xmlName, 
datalet.outputName);
  +            retVal = times[TransformWrapper.IDX_OVERALL];
  +        }
  +        else
  +        {
  +            // presume it's a normal stylesheet test
  +            // First build the stylesheet
  +            duringXSLBuild = true;
  +            long[] times = transformWrapper.buildStylesheet(datalet.inputName);
  +            duringXSLBuild = false;
  +            times = transformWrapper.transformWithStylesheet(datalet.xmlName, 
datalet.outputName);
  +        }
  +    }
  +
  +
       /** 
        * Worker method to get a TransformWrapper: overridden.  
        *
  @@ -140,7 +192,7 @@
           catch (Throwable t)
           {
               logger.logThrowable(Logger.ERRORMSG, t, getDescription() + " 
newWrapper/newProcessor threw");
  -            logger.checkErr(getDescription() + " newWrapper/newProcessor threw: " + 
t.toString());
  +            logger.checkErr(getCheckDescription(datalet) + " 
newWrapper/newProcessor threw: " + t.toString());
               return null;
           }
       }
  @@ -171,7 +223,7 @@
               Object[] ctorArgs = new Object[1];
               ctorArgs[0] = (Object) logger;
               LoggingHandler handler = (LoggingHandler) ctor.newInstance(ctorArgs);
  -            if ((handler instanceof LoggingErrorListener) && 
  +            if ((handler instanceof LoggingErrorListener) || 
                   (handler instanceof LoggingSAXErrorHandler))
               {
                   // Mimic DefaultErrorHandler behavior
  @@ -182,7 +234,7 @@
           catch (Throwable t)
           {
               logger.logThrowable(Logger.ERRORMSG, t, getDescription() + " 
newWrapper/newProcessor threw");
  -            logger.checkErr(getDescription() + " newWrapper/newProcessor threw: " + 
t.toString());
  +            logger.checkErr(getCheckDescription(datalet) + " 
newWrapper/newProcessor threw: " + t.toString());
               return null;
           }
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to