grchiu      2003/06/16 14:45:07

  Modified:    test     build.xml
               test/java/src/org/apache/qetest/xsl
                        StylesheetTestletDriver.java
               test/java/src/org/apache/qetest/xslwrapper
                        TraxWrapperUtils.java
  Log:
  Based on original patch by Elson Jiang ([EMAIL PROTECTED]).
  Implemented of conf.trace, accept.trace, alltest.conf.trace, and
  alltest.accept.trace targets to run conformance tests with a trace listener
  installed on the transformer. Also logs trace output.
  
  Revision  Changes    Path
  1.64      +20 -3     xml-xalan/test/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-xalan/test/build.xml,v
  retrieving revision 1.63
  retrieving revision 1.64
  diff -u -r1.63 -r1.64
  --- build.xml 26 May 2003 19:48:28 -0000      1.63
  +++ build.xml 16 Jun 2003 21:45:07 -0000      1.64
  @@ -297,6 +297,11 @@
           </antcall>
       </target>
   
  +    <target name="conf.trace" description="Run TestletDriver over the conf tree">
  +        <property name="conf.trace" value="on"/>
  +        <antcall target="conf"/>
  +    </target>
  +
       <!-- ================================================================== -->
       <!-- Run tests: the normal StylesheetTestletDriver on the accept suite  -->
       <!-- ================================================================== -->
  @@ -316,6 +321,11 @@
           <antcall target="conf.xsltc" />
       </target>
   
  +    <target name="accept.trace" description="Run TestletDriver over the accept 
tree">
  +        <property name="accept.trace" value="on"/>
  +        <antcall target="accept"/>
  +    </target>
  +
       <!-- ================================================================== -->
       <!-- Run tests: the StylesheetErrorTestlet on the conferr suite         -->
       <!-- ================================================================== -->
  @@ -1010,8 +1020,15 @@
           </antcall>
       </target>
   
  +    <target name="alltest.conf.trace">
  +        <property name="conf.trace" value="on"/>
  +        <antcall target="alltest.conf"/>
  +    </target>
   
  -
  +    <target name="alltest.accept.trace">
  +        <property name="accept.trace" value="on"/>
  +        <antcall target="alltest.accept"/>
  +    </target>
   
       <target name="test"
           depends="alltest"
  
  
  
  1.12      +20 -1     
xml-xalan/test/java/src/org/apache/qetest/xsl/StylesheetTestletDriver.java
  
  Index: StylesheetTestletDriver.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/test/java/src/org/apache/qetest/xsl/StylesheetTestletDriver.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- StylesheetTestletDriver.java      31 Jan 2003 15:47:21 -0000      1.11
  +++ StylesheetTestletDriver.java      16 Jun 2003 21:45:07 -0000      1.12
  @@ -71,6 +71,7 @@
   import org.apache.qetest.Logger;
   import org.apache.qetest.QetestUtils;
   import org.apache.qetest.Testlet;
  +import org.apache.qetest.xslwrapper.TransformWrapper;
   import org.apache.qetest.xslwrapper.TransformWrapperFactory;
   
   /**
  @@ -177,6 +178,17 @@
       protected String processor = null;
   
       /**
  +     * Parameter: Is trace mode on?
  +     * <p>Default: null (no trace)
  +     * if on, non-null
  +     * </p>
  +     */
  +    public static final String OPT_TRACE = "trace";
  +
  +    /** Parameter: Are we tracing? */
  +    protected String traceMode = null;
  +
  +    /**
        * Parameter: Name of test (Conf, Accept) as StylesheetTestletDriver
        * can be used for more than one bucket
        * <p>Default: null (use StylesheetTestletDriver)
  @@ -197,6 +209,9 @@
       /** Convenience constant: .out extension for output result file.  */
       public static final String OUT_EXTENSION = ".out";
   
  +    /** Convenience constant: .log extension for log file.  */
  +    public static final String LOG_EXTENSION = ".log";
  +
   
       /** Just initialize test name, comment; numTestCases is not used. */
       public StylesheetTestletDriver()
  @@ -225,6 +240,7 @@
           embedded = testProps.getProperty(OPT_EMBEDDED, embedded);
           processor = testProps.getProperty(OPT_PROCESSOR, processor);        
           testName = testProps.getProperty(OPT_TESTNAME, testName);
  +        traceMode = testProps.getProperty(OPT_TRACE, traceMode);
           // Grab a unique runid for logging out with our tests 
           //  Used in results reporting stylesheets to differentiate 
           //  between different test runs
  @@ -673,6 +689,9 @@
               //  fileCheckers should not store state, so this 
               //  shouldn't affect the testing at all
               d.options.put("fileCheckerImpl", fileChecker);
  +            if (traceMode != null) {
  +                d.options.put(TransformWrapper.SET_PROCESSOR_ATTRIBUTES  + 
"setTraceListener", d.outputName + LOG_EXTENSION);
  +            }
               v.addElement(d);
           }
           return v;
  
  
  
  1.9       +33 -1     
xml-xalan/test/java/src/org/apache/qetest/xslwrapper/TraxWrapperUtils.java
  
  Index: TraxWrapperUtils.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/test/java/src/org/apache/qetest/xslwrapper/TraxWrapperUtils.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- TraxWrapperUtils.java     31 Jan 2003 15:47:24 -0000      1.8
  +++ TraxWrapperUtils.java     16 Jun 2003 21:45:07 -0000      1.9
  @@ -56,6 +56,9 @@
    */
   package org.apache.qetest.xslwrapper;
   
  +import java.io.FileNotFoundException;
  +import java.io.FileOutputStream;
  +import java.io.PrintWriter;
   import java.lang.reflect.Field;
   import java.util.Enumeration;
   import java.util.Hashtable;
  @@ -66,6 +69,10 @@
   import javax.xml.transform.TransformerFactory;
   import javax.xml.transform.URIResolver;
   
  +import org.apache.xalan.trace.PrintTraceListener;
  +import org.apache.xalan.trace.TraceManager;
  +import org.apache.xalan.transformer.TransformerImpl;
  +
   /**
    * Cheap-o utilities for Trax*Wrapper implementations.
    *
  @@ -201,6 +208,9 @@
       /** Token specifying a call to setErrorListener.  */
       public static String SET_ERROR_LISTENER = "setErrorListener";
   
  +    /** Token specifying a call to setup a trace listener.  */
  +    public static String SET_TRACE_LISTENER = "setTraceListener";
  +
       /**
        * Apply specific Attributes to a TransformerFactory OR call 
        * specific setFoo() API's on a TransformerFactory.  
  @@ -236,6 +246,10 @@
           {
               factory.setErrorListener((ErrorListener)value);
           }
  +        else if (SET_TRACE_LISTENER.equals(key))
  +        {
  +            // no-op
  +        }
           else
           {
               // General case; just call setAttribute
  @@ -277,6 +291,24 @@
           else if (SET_ERROR_LISTENER.equals(key))
           {
               transformer.setErrorListener((ErrorListener)value);
  +        }
  +        else if (SET_TRACE_LISTENER.equals(key) && transformer instanceof 
TransformerImpl)
  +        {
  +            TraceManager traceManager = 
((TransformerImpl)transformer).getTraceManager();
  +            try {
  +                FileOutputStream writeStream = new FileOutputStream((String)value);
  +                PrintWriter printWriter = new PrintWriter(writeStream, true);
  +                PrintTraceListener traceListener = new 
PrintTraceListener(printWriter);
  +                traceListener.m_traceElements = true;
  +                traceListener.m_traceGeneration = true;
  +                traceListener.m_traceSelection = true;
  +                traceListener.m_traceTemplates = true;
  +                traceManager.addTraceListener(traceListener);        
  +            } catch (FileNotFoundException fnfe) {
  +                System.out.println("File not found: " + fnfe);
  +            } catch (Exception e) {
  +                System.out.println("Exception: " + e);
  +            }
           }
           else
           {
  
  
  

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

Reply via email to