curcuru     01/02/14 13:55:32

  Modified:    test/java/src/org/apache/qetest/xsl
                        XSLDirectoryIterator.java
  Log:
  Fix problem with calling checkExpectedException() with URL-ized names;
  Fix checkExpectedException() to do indexOf for passing instead of 
startsWith() -
  note I'm still not entirely happy with how this works, but it's better than 
before
  
  Revision  Changes    Path
  1.7       +27 -21    
xml-xalan/test/java/src/org/apache/qetest/xsl/XSLDirectoryIterator.java
  
  Index: XSLDirectoryIterator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/test/java/src/org/apache/qetest/xsl/XSLDirectoryIterator.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XSLDirectoryIterator.java 2001/02/01 16:51:19     1.6
  +++ XSLDirectoryIterator.java 2001/02/14 21:55:31     1.7
  @@ -99,7 +99,7 @@
    * </ul>
    * @todo improve file discovery - file execution paradigm
    * @author Shane Curcuru
  - * @version $Id: XSLDirectoryIterator.java,v 1.6 2001/02/01 16:51:19 curcuru 
Exp $
  + * @version $Id: XSLDirectoryIterator.java,v 1.7 2001/02/14 21:55:31 curcuru 
Exp $
    */
   public class XSLDirectoryIterator extends XSLProcessorTestBase
   {
  @@ -1105,6 +1105,8 @@
       {
   
           long fileTime = ProcessorWrapper.ERROR;
  +        String xmlURI = XMLName;    // default to what user gave us
  +        String xslURI = XSLName;
   
           try
           {
  @@ -1120,19 +1122,13 @@
               // Force filerefs to be URI's if needed
               if (useURI)
               {
  -
  -                // Use this static convenience method; returns a URL; 
convert to String via toExternalForm()
  -                XMLName = filenameToURL(XMLName);
  -                XSLName = filenameToURL(XSLName);
  -
  -                // HACK (end)- replicate this code locally, since we may 
test Xalan2 which doesn't have this!
  +                xmlURI = filenameToURL(XMLName);
  +                xslURI = filenameToURL(XSLName);
                   // Note: Currently 28-Jun-00, the output of files is handled 
differently, so 
                   //  we do NOT want to convert those.  Subject to change, 
however.
  -                reporter.logTraceMsg("processSingleFile() useURI: "
  -                                     + XSLName);
               }
   
  -            fileTime = processorW.processToFile(XMLName, XSLName, OutName);
  +            fileTime = processorW.processToFile(xmlURI, xslURI, OutName);
   
               if (fileTime != ProcessorWrapper.ERROR)
               {
  @@ -1140,14 +1136,14 @@
   
                   dirFilesProcessed++;
   
  -                reporter.logTraceMsg("processSingleFile(" + XSLName
  +                reporter.logTraceMsg("processSingleFile(" + xslURI
                                        + ") no exceptions; time " + fileTime);
               }
               else
               {
   
                   // Do not increment performance counters if there's an error
  -                reporter.logWarningMsg("processSingleFile(" + XSLName
  +                reporter.logWarningMsg("processSingleFile(" + xslURI
                                          + ") returned ERROR code!");
               }
   
  @@ -1158,11 +1154,10 @@
           // Catch any Throwable, check if they're expected, and restart
           catch (Throwable t)
           {
  -            reporter.logStatusMsg("processSingleFile(" + XSLName
  -                                  + ") threw: " + t.toString());
               reporter.logThrowable(reporter.WARNINGMSG, t, 
  -                                  "processSingleFile(" + XSLName + ") 
threw");
  +                                  "processSingleFile(" + xslURI + ") threw");
   
  +            // Here, use the original, non-URI'd name
               int retVal = checkExpectedException(t, XSLName, OutName);
   
               createNewProcessor();
  @@ -1294,16 +1289,27 @@
                   if (idx <= 0)
                       continue;  // not on this line, keep going
   
  -                // The expected exception.getMessage is the rest of the 
line, trimmed
  -                //   Note that there's actually a " -->" at the end of the 
line probably,
  -                //   but we'll ignore that by using .startsWith()
  +                // The expected exception.getMessage is the rest of the 
line...
                   String expExc =
                       inbuf.substring((idx + EXPECTED_EXCEPTION.length()),
  -                                    inbuf.length()).trim();
  +                                    inbuf.length());
   
  -                if (expExc.startsWith(ee.toString()))
  +                // Hack off the end of the line if it's the " -->" comment 
end
  +                //  (which it should be: we need to make this a standard)
  +                int endComment = expExc.indexOf("-->");
  +                expExc = expExc.substring(0, endComment).trim();
  +
  +                // They pass if the expected appears whole anywhere 
  +                //  in the actual exception .toString: this takes 
  +                //  care of the case where sometimes you might get 
  +                //  wrapped in a TransformerConfigurationException,
  +                //  and sometimes in a TransformerException
  +                // Note this could also give false pass results 
  +                //  if you have a very short string that could be 
  +                //  found anywhere... oops!
  +                if (ee.toString().indexOf(expExc) > -1)
                   {
  -                    gotExpected = true;  // equal, they pass
  +                    gotExpected = true;  // match partially, they pass
   
                       break;
                   }
  
  
  

Reply via email to