curcuru     00/11/29 07:21:52

  Modified:    test/java/src/org/apache/qetest/trax/dom
                        DOMResultAPITest.java DOMSourceAPITest.java
  Log:
  Added new DOM functionality tests
  
  Revision  Changes    Path
  1.2       +176 -13   
xml-xalan/test/java/src/org/apache/qetest/trax/dom/DOMResultAPITest.java
  
  Index: DOMResultAPITest.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/test/java/src/org/apache/qetest/trax/dom/DOMResultAPITest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DOMResultAPITest.java     2000/11/16 02:46:46     1.1
  +++ DOMResultAPITest.java     2000/11/29 15:21:46     1.2
  @@ -80,6 +80,7 @@
   
   // java classes
   import java.io.File;
  +import java.io.FileOutputStream;
   import java.util.Properties;
   
   //-------------------------------------------------------------------------
  @@ -87,7 +88,7 @@
   /**
    * API Coverage test for the DOMResult class of TRAX.
    * @author [EMAIL PROTECTED]
  - * @version $Id: DOMResultAPITest.java,v 1.1 2000/11/16 02:46:46 curcuru Exp 
$
  + * @version $Id: DOMResultAPITest.java,v 1.2 2000/11/29 15:21:46 curcuru Exp 
$
    */
   public class DOMResultAPITest extends XSLProcessorTestBase
   {
  @@ -104,6 +105,11 @@
        */
       protected XSLTestfileInfo testFileInfo = new XSLTestfileInfo();
   
  +    /** 
  +     * Information about an xsl/xml file pair for transforming with 
import/include.  
  +     */
  +    protected XSLTestfileInfo impInclFileInfo = new XSLTestfileInfo();
  +
       /** Subdirectory under test\tests\api for our xsl/xml files.  */
       public static final String TRAX_DOM_SUBDIR = "trax" + File.separator + 
"dom";
   
  @@ -145,6 +151,10 @@
           testFileInfo.inputName = testBasePath + "DOMTest.xsl";
           testFileInfo.xmlName = testBasePath + "DOMTest.xml";
           testFileInfo.goldName = goldBasePath + "DOMTest.out";
  +
  +        impInclFileInfo.inputName = testBasePath + "DOMImpIncl.xsl";
  +        impInclFileInfo.xmlName = testBasePath + "DOMImpIncl.xml";
  +        impInclFileInfo.goldName = testBasePath + "DOMImpIncl.out";
           try
           {
               TransformerFactory tf = TransformerFactory.newInstance();
  @@ -216,6 +226,7 @@
   
       /**
        * Basic functionality of DOMResults.
  +     * Test 'blank' Result; reuse Results; swap Nodes; etc.
        *
        * @return false if we should abort the test; true otherwise
        */
  @@ -223,43 +234,195 @@
       {
           reporter.testCaseInit("Basic functionality of DOMResults");
   
  +        DocumentBuilder docBuilder = null;
           TransformerFactory factory = null;
           Templates templates = null;
           Transformer transformer = null;
           Node xmlNode = null;
           Node xslNode = null;
  +        Node xslImpInclNode = null;
  +        Node xmlImpInclNode = null;
           try
           {
               factory = TransformerFactory.newInstance();
               DocumentBuilderFactory dfactory = 
DocumentBuilderFactory.newInstance();
               dfactory.setNamespaceAware(true);
  -            DocumentBuilder docBuilder = dfactory.newDocumentBuilder();
  +            docBuilder = dfactory.newDocumentBuilder();
               reporter.logTraceMsg("parsing xml, xsl files");
               xslNode = docBuilder.parse(new 
InputSource(testFileInfo.inputName));
               xmlNode = docBuilder.parse(new 
InputSource(testFileInfo.xmlName));
  -            
  +            xslImpInclNode = docBuilder.parse(new 
InputSource(impInclFileInfo.inputName));
  +            xmlImpInclNode = docBuilder.parse(new 
InputSource(impInclFileInfo.xmlName));
  +        }
  +        catch (Throwable t)
  +        {
  +            reporter.checkFail("Problem creating factory; can't continue 
testcase");
  +            reporter.logThrowable(reporter.ERRORMSG, t,
  +                                  "Problem creating factory; can't continue 
testcase");
  +            reporter.testCaseClose();
  +            return true;
  +        }
  +        try
  +        {
               // Try to get templates, transformer from node
  -            DOMSource xslDOM = new DOMSource(xslNode);
  -            templates = factory.newTemplates(xslDOM);
  -            DOMSource xmlDOM = new DOMSource(xmlNode);
  +            DOMSource xslSource = new DOMSource(xslNode);
  +            templates = factory.newTemplates(xslSource);
  +            DOMSource xmlSource = new DOMSource(xmlNode);
               
  -            DOMResult blankDOM = new DOMResult();
  +            // Transforming into a DOMResult with a node is already 
  +            //  well covered in DOMSourceAPITest and elsewhere
  +            // Verify a 'blank' Result object gets filled up properly
  +            DOMResult blankResult = new DOMResult();
               transformer = templates.newTransformer();
  -            transformer.transform(xmlDOM, blankDOM);
  -            reporter.logTraceMsg("blankDOM is now: " + blankDOM);
  -            reporter.checkAmbiguous("More tests to be added!");            
  +            transformer.transform(xmlSource, blankResult);
  +            reporter.logTraceMsg("blankResult is now: " + blankResult);
  +            Node blankNode = blankResult.getNode();
  +            if (blankNode != null)
  +            {
  +                serializeDOMAndCheck(blankNode, testFileInfo.goldName, 
"transform into blank DOMResult");
  +            }
  +            else
  +            {
  +                reporter.checkFail("transform into 'blank' DOMResult");
  +            }
  +        }
  +        catch (Throwable t)
  +        {
  +            reporter.checkFail("Problem with blank results");
  +            reporter.logThrowable(reporter.ERRORMSG, t,
  +                                  "Problem with blank results");
  +        }
  +        try
  +        {
  +            DOMSource xmlSource = new DOMSource(xmlNode);
  +            DOMSource xslSource = new DOMSource(xslNode);
  +            templates = factory.newTemplates(xslSource);
               
  +            // Reuse the same result for multiple transforms
  +            DOMResult reuseResult = new DOMResult(docBuilder.newDocument());
  +            transformer = templates.newTransformer();
  +            transformer.transform(xmlSource, reuseResult);
  +            Node reuseNode = reuseResult.getNode();
  +            serializeDOMAndCheck(reuseNode, testFileInfo.goldName, 
"transform into reuseable1 DOMResult");
  +            
  +            // Get a new transformer just to avoid extra complexity
  +            reporter.logTraceMsg("About to re-use DOMResult from previous 
transform as-is");
  +            transformer = templates.newTransformer();
  +            transformer.transform(xmlSource, reuseResult); // SPR SCUU4RJKG4 
throws DOM006
  +            reuseNode = reuseResult.getNode();
  +            serializeDOMAndCheck(reuseNode, testFileInfo.goldName, 
"transform into reused1 DOMResult");
  +
  +            // Reuse again, with the same transformer
  +            transformer.transform(xmlSource, reuseResult);
  +            reuseNode = reuseResult.getNode();
  +            serializeDOMAndCheck(reuseNode, testFileInfo.goldName, 
"transform into reused1 DOMResult again");
           }
           catch (Throwable t)
           {
  -            reporter.checkFail("Problem creating factory; can't continue 
testcase");
  +            reporter.checkFail("Problem with re-using results(1)");
               reporter.logThrowable(reporter.ERRORMSG, t,
  -                                  "Problem creating factory; can't continue 
testcase");
  -            return true;
  +                                  "Problem with re-using results(1)");
           }
  +        try
  +        {
  +            DOMSource xmlSource = new DOMSource(xmlNode);
  +            DOMSource xslSource = new DOMSource(xslNode);
  +            templates = factory.newTemplates(xslSource);
  +            
  +            // Reuse the same result for multiple transforms, after 
resetting node
  +            DOMResult reuseResult = new DOMResult(docBuilder.newDocument());
  +            transformer = templates.newTransformer();
  +            transformer.transform(xmlSource, reuseResult);
  +            Node reuseNode = reuseResult.getNode();
  +            serializeDOMAndCheck(reuseNode, testFileInfo.goldName, 
"transform into reuseable2 DOMResult");
  +            
  +            // Get a new transformer just to avoid extra complexity
  +            reporter.logTraceMsg("About to re-use DOMResult from previous 
transform after setNode()");
  +            transformer = templates.newTransformer();
  +            reuseResult.setNode(docBuilder.newDocument());
  +            transformer.transform(xmlSource, reuseResult);
  +            reuseNode = reuseResult.getNode();
  +            serializeDOMAndCheck(reuseNode, testFileInfo.goldName, 
"transform into reused2 DOMResult");
  +
  +            // Reuse again, with the same transformer
  +            reuseResult.setNode(docBuilder.newDocument());
  +            transformer.transform(xmlSource, reuseResult);
  +            reuseNode = reuseResult.getNode();
  +            serializeDOMAndCheck(reuseNode, testFileInfo.goldName, 
"transform into reused2 DOMResult again");
  +        }
  +        catch (Throwable t)
  +        {
  +            reporter.checkFail("Problem with re-using results(2)");
  +            reporter.logThrowable(reporter.ERRORMSG, t,
  +                                  "Problem with re-using results(2)");
  +        }
   
           reporter.testCaseClose();
           return true;
  +    }
  +
  +
  +    /**
  +     * Worker method to serialize DOM and fileChecker.check().  
  +     * @return true if pass, false otherwise
  +     */
  +    public boolean serializeDOMAndCheck(Node dom, String goldFileName, 
String comment)
  +    {
  +        if ((dom == null) || (goldFileName == null))
  +        {
  +            reporter.logWarningMsg("serializeDOMAndCheck of null dom or 
goldFileName!");
  +            return false;
  +        }
  +        try
  +        {
  +            TransformerFactory factory = TransformerFactory.newInstance();
  +            if (factory.getFeature(StreamResult.FEATURE))
  +            {
  +                // Use identity transformer to serialize
  +                Transformer identityTransformer = factory.newTransformer();
  +                StreamResult streamResult = new StreamResult(new 
FileOutputStream(outNames.nextName()));
  +                DOMSource nodeSource = new DOMSource(dom);
  +                reporter.logTraceMsg("serializeDOMAndCheck() into " + 
outNames.currentName());
  +                identityTransformer.transform(nodeSource, streamResult);
  +                fileChecker.check(reporter, 
  +                                  new File(outNames.currentName()), 
  +                                  new File(goldFileName), 
  +                                  comment + " into " + 
outNames.currentName());
  +                return true;    // Note: should check return from 
fileChecker.check!
  +            }
  +            else
  +            {   // We should try another method to serialize the data
  +                reporter.logWarningMsg("getFeature(StreamResult.FEATURE), 
can't validate serialized data");
  +                return false;
  +            }
  +            
  +        }
  +        catch (Throwable t)
  +        {
  +            reporter.checkFail("serializeDOMAndCheckFile threw: " + 
t.toString());
  +            reporter.logThrowable(reporter.ERRORMSG, t, 
"serializeDOMAndCheckFile threw:");
  +            return false;
  +        }
  +    }
  +
  +
  +    /**
  +     * Worker method to translate String to URI.  
  +     * Note: Xerces and Crimson appear to handle some URI references 
  +     * differently - this method needs further work once we figure out 
  +     * exactly what kind of format each parser wants (esp. considering 
  +     * relative vs. absolute references).
  +     * @param String path\filename of test file
  +     * @return URL to pass to SystemId
  +     */
  +    public String filenameToURI(String filename)
  +    {
  +        File f = new File(filename);
  +        String tmp = f.getAbsolutePath();
  +         if (File.separatorChar == '\\') {
  +             tmp = tmp.replace('\\', '/');
  +         }
  +        return "file:///" + tmp;
       }
   
   
  
  
  
  1.3       +209 -10   
xml-xalan/test/java/src/org/apache/qetest/trax/dom/DOMSourceAPITest.java
  
  Index: DOMSourceAPITest.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/test/java/src/org/apache/qetest/trax/dom/DOMSourceAPITest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DOMSourceAPITest.java     2000/11/16 15:24:11     1.2
  +++ DOMSourceAPITest.java     2000/11/29 15:21:47     1.3
  @@ -88,7 +88,7 @@
   /**
    * API Coverage test for the DOMSource class of TRAX.
    * @author [EMAIL PROTECTED]
  - * @version $Id: DOMSourceAPITest.java,v 1.2 2000/11/16 15:24:11 curcuru Exp 
$
  + * @version $Id: DOMSourceAPITest.java,v 1.3 2000/11/29 15:21:47 curcuru Exp 
$
    */
   public class DOMSourceAPITest extends XSLProcessorTestBase
   {
  @@ -105,6 +105,11 @@
        */
       protected XSLTestfileInfo testFileInfo = new XSLTestfileInfo();
   
  +    /** 
  +     * Information about an xsl/xml file pair for transforming with 
import/include.  
  +     */
  +    protected XSLTestfileInfo impInclFileInfo = new XSLTestfileInfo();
  +
       /** Subdirectory under test\tests\api for our xsl/xml files.  */
       public static final String TRAX_DOM_SUBDIR = "trax" + File.separator + 
"dom";
   
  @@ -146,6 +151,11 @@
           testFileInfo.inputName = testBasePath + "DOMTest.xsl";
           testFileInfo.xmlName = testBasePath + "DOMTest.xml";
           testFileInfo.goldName = goldBasePath + "DOMTest.out";
  +
  +        impInclFileInfo.inputName = testBasePath + "DOMImpIncl.xsl";
  +        impInclFileInfo.xmlName = testBasePath + "DOMImpIncl.xml";
  +        impInclFileInfo.goldName = goldBasePath + "DOMImpIncl.out";
  +
           try
           {
               TransformerFactory tf = TransformerFactory.newInstance();
  @@ -217,6 +227,7 @@
   
       /**
        * Basic functionality of DOMSources.
  +     * Use them in simple transforms, with/without systemId set.
        *
        * @return false if we should abort the test; true otherwise
        */
  @@ -230,6 +241,8 @@
           DocumentBuilder docBuilder = null;
           Node xmlNode = null;
           Node xslNode = null;
  +        Node xslImpInclNode = null;
  +        Node xmlImpInclNode = null;
           try
           {
               // Startup a factory, create some nodes/DOMs
  @@ -240,6 +253,8 @@
               reporter.logTraceMsg("parsing xml, xsl files");
               xslNode = docBuilder.parse(new 
InputSource(testFileInfo.inputName));
               xmlNode = docBuilder.parse(new 
InputSource(testFileInfo.xmlName));
  +            xslImpInclNode = docBuilder.parse(new 
InputSource(impInclFileInfo.inputName));
  +            xmlImpInclNode = docBuilder.parse(new 
InputSource(impInclFileInfo.xmlName));
           }
           catch (Throwable t)
           {
  @@ -251,7 +266,7 @@
               // A blank DOM as an input stylesheet - what should happen?
               DOMSource blankXSLDOM = new DOMSource();
               reporter.logTraceMsg("About to newTemplates(blankXSLDOM)");
  -            Templates blankTemplates = factory.newTemplates(blankXSLDOM); // 
SPR SCUU4R5JYZ throws npe
  +            Templates blankTemplates = factory.newTemplates(blankXSLDOM); // 
SPR SCUU4R5JYZ throws npe; 0b29CVS now returns null
               reporter.check((blankTemplates != null), true, 
"factory.newTemplates(blankXSLDOM) is non-null");
               reporter.checkObject(blankXSLDOM.getNode(), null, "blankXSLDOM 
is still empty");
           }
  @@ -308,28 +323,175 @@
           }
           catch (Throwable t)
           {
  -            reporter.checkFail("Problem with tests(1)");
  -            reporter.logThrowable(reporter.ERRORMSG, t, "Problem with 
tests(1)");
  +            reporter.checkFail("Problem with transform(doms 1)");
  +            reporter.logThrowable(reporter.ERRORMSG, t, "Problem with 
transform(doms 1)");
           }
           try
           {
               // A blank DOM as an output of the transform - should 
               //  auto-create a source Document
               DOMSource xmlDOM = new DOMSource(xmlNode);
  -            DOMResult emptyResult = new DOMResult();
  +            Node outNode = docBuilder.newDocument();
  +            DOMResult outResult = new DOMResult(outNode);
               reporter.logTraceMsg("About to transform(xmlDOM, emptyResult)");
  +            transformerXSL.transform(xmlDOM, outResult);
  +            outNode = outResult.getNode();
  +            reporter.check((outNode != null), true, "transform(xmlDOM, 
outResult) has non-null node");
  +            serializeDOMAndCheck(outNode, testFileInfo.goldName, 
"transform(xmlDOM, outResult)");
  +        }
  +        catch (Throwable t)
  +        {
  +            reporter.checkFail("Problem with transform(doms 2)");
  +            reporter.logThrowable(reporter.ERRORMSG, t, "Problem with 
transform(doms 2)");
  +        }
  +
  +        try
  +        {
  +            // Setting SystemId with imports/inclues
  +            DOMSource xslDOM = new DOMSource(xslImpInclNode);
  +            xslDOM.setSystemId(filenameToURI(impInclFileInfo.inputName));
  +            transformerXSL = factory.newTransformer(xslDOM);
  +            DOMSource xmlDOM = new DOMSource(xmlImpInclNode);
  +            // Do we really need to set SystemId on both XML and XSL?
  +            xmlDOM.setSystemId(filenameToURI(impInclFileInfo.xmlName));
  +            DOMResult emptyResult = new DOMResult();
  +            reporter.logTraceMsg("About to transformXSLImpIncl(xmlDOM, 
emptyResult)");
               transformerXSL.transform(xmlDOM, emptyResult);
               Node outNode = emptyResult.getNode();
  -            reporter.check((outNode != null), true, "transform(xmlDOM, 
emptyResult) has non-null node");
  -            serializeDOMAndCheck(outNode, testFileInfo.goldName, 
"transform(xmlDOM, emptyResult)");
  +            reporter.check((outNode != null), true, 
"transformXSLImpIncl(xmlDOM, emptyResult) has non-null node");
  +            serializeDOMAndCheck(outNode, impInclFileInfo.goldName, 
"transformXSLImpIncl(xmlDOM, emptyResult)");
  +        }
  +        catch (Throwable t)
  +        {
  +            reporter.checkFail("Problem with SystemId");
  +            reporter.logThrowable(reporter.ERRORMSG, t, "Problem with 
SystemId");
  +        }
  +        try
  +        {
  +            // Do a transform without systemId set
  +            // Note: is affected by user.dir property; if we're 
  +            //  already in the correct place, this won't be different
  +            // But: most people will run from xml-xalan\test, so this should 
fail
  +            try
  +            {
  +                reporter.logStatusMsg("System.getProperty(user.dir) = " + 
System.getProperty("user.dir"));
  +            }
  +            catch (SecurityException e) // in case of Applet context
  +            {
  +                reporter.logTraceMsg("System.getProperty(user.dir) threw 
SecurityException");
  +            }
  +            DOMSource xslDOM = new DOMSource(xslImpInclNode);
  +            transformerXSL = factory.newTransformer(xslDOM);
  +            DOMSource xmlDOM = new DOMSource(xmlImpInclNode);
  +            DOMResult emptyResult = new DOMResult();
  +            reporter.logStatusMsg("About to transform without systemID; 
probably throws exception");
  +            transformerXSL.transform(xmlDOM, emptyResult);
  +            reporter.checkFail("The above transform should probably have 
thrown an exception");
  +        }
  +        catch (Throwable t)
  +        {
  +            reporter.checkPass("Transforming with include/import and wrong 
SystemId throws exception");
  +            reporter.logThrowable(reporter.ERRORMSG, t, "Transforming with 
include/import and wrong SystemId");
  +        }
  +
  +        reporter.testCaseClose();
  +        return true;
  +    }
  +
  +
  +    /**
  +     * More advanced functionality of DOMSources.
  +     * Re-using DOMSource objects for multiple transforms; setNode and 
reuse; etc.
  +     *
  +     * @return false if we should abort the test; true otherwise
  +     */
  +    public boolean testCase3()
  +    {
  +        reporter.testCaseInit("More advanced functionality of DOMSources");
  +
  +        TransformerFactory factory = null;
  +        DocumentBuilder docBuilder = null;
  +        Node xmlNode = null;
  +        Node xslNode = null;
  +        Node xslImpInclNode = null;
  +        Node xmlImpInclNode = null;
  +
  +        try
  +        {
  +            // Startup a factory, create some nodes/DOMs
  +            factory = TransformerFactory.newInstance();
  +            DocumentBuilderFactory dfactory = 
DocumentBuilderFactory.newInstance();
  +            dfactory.setNamespaceAware(true);
  +            docBuilder = dfactory.newDocumentBuilder();
  +            reporter.logTraceMsg("parsing xml, xsl files");
  +            xslNode = docBuilder.parse(new 
InputSource(testFileInfo.inputName));
  +            xmlNode = docBuilder.parse(new 
InputSource(testFileInfo.xmlName));
  +            xslImpInclNode = docBuilder.parse(new 
InputSource(impInclFileInfo.inputName));
  +            xmlImpInclNode = docBuilder.parse(new 
InputSource(impInclFileInfo.xmlName));
  +        }
  +        catch (Throwable t)
  +        {
  +            reporter.checkErr("Problem with factory; testcase may not work");
  +            reporter.logThrowable(reporter.ERRORMSG, t, "Problem with 
factory; testcase may not work");
  +        }
  +        try
  +        {
  +            // Re-use DOMSource for stylesheet
  +            DOMSource xmlSource1 = new DOMSource(xmlNode);
  +            DOMResult result1 = new DOMResult(docBuilder.newDocument());
  +            DOMSource xslSource = new DOMSource(xslNode);
  +            Transformer transformer1 = factory.newTransformer(xslSource);
  +            transformer1.transform(xmlSource1, result1);
  +            Node node1 = result1.getNode();
  +            serializeDOMAndCheck(node1, testFileInfo.goldName, "transform 
first time xslSource worked");
  +            // Use same Source for the stylesheet
  +            DOMSource xmlSource2 = new DOMSource(xmlNode);
  +            DOMResult result2 = new DOMResult(docBuilder.newDocument());
  +            Transformer transformer2 = factory.newTransformer(xslSource);
  +            transformer2.transform(xmlSource2, result2);
  +            Node node2 = result2.getNode();
  +            serializeDOMAndCheck(node2, testFileInfo.goldName, "transform 
second time xslSource worked");
  +
  +            // Re-use DOMSource for XML doc; with the same stylesheet
  +            DOMResult result3 = new DOMResult(docBuilder.newDocument());
  +            Transformer transformer3 = factory.newTransformer(xslSource);
  +            transformer3.transform(xmlSource2, result3);
  +            Node node3 = result3.getNode();
  +            serializeDOMAndCheck(node3, testFileInfo.goldName, "transform 
reusing both xsl/xml Sources");
           }
           catch (Throwable t)
           {
  -            reporter.checkFail("Problem with tests(2)");
  -            reporter.logThrowable(reporter.ERRORMSG, t, "Problem with 
tests(2)");
  +            reporter.checkFail("Problem with reuse xslSource");
  +            reporter.logThrowable(reporter.ERRORMSG, t, "Problem reuse 
xslSource");
           }
   
  -        reporter.checkAmbiguous("@todo setSystemId functionality");
  +        try
  +        {
  +            // Re-use DOMSource after setNode to different one
  +            DOMSource xmlSource = new DOMSource(xmlNode);
  +            DOMSource xslSource = new DOMSource(xslNode);
  +            Transformer transformer1 = factory.newTransformer(xslSource);
  +            DOMResult result1 = new DOMResult(docBuilder.newDocument());
  +            transformer1.transform(xmlSource, result1);
  +            Node node1 = result1.getNode();
  +            serializeDOMAndCheck(node1, testFileInfo.goldName, "transform 
with original Sources");
  +
  +            // Use same Sources, but change Nodes for xml,xsl
  +            xmlSource.setNode(xmlImpInclNode);
  +            xmlSource.setSystemId(filenameToURI(impInclFileInfo.xmlName));
  +            xslSource.setNode(xslImpInclNode);
  +            xslSource.setSystemId(filenameToURI(impInclFileInfo.inputName));
  +            Transformer transformer2 = factory.newTransformer(xslSource);
  +            DOMResult result2 = new DOMResult(docBuilder.newDocument());
  +            transformer2.transform(xmlSource, result2);
  +            Node node2 = result2.getNode();
  +            serializeDOMAndCheck(node2, impInclFileInfo.goldName, "transform 
after xml/xslSource.setNode, setSystemId");
  +        }
  +        catch (Throwable t)
  +        {
  +            reporter.checkFail("Problem with reuse after setNode");
  +            reporter.logThrowable(reporter.ERRORMSG, t, "Problem with reuse 
after setNode");
  +        }
   
           reporter.testCaseClose();
           return true;
  @@ -378,6 +540,43 @@
               return false;
           }
       }
  +
  +
  +    /**
  +     * Worker method to create factory objects.  
  +     * Changes caller's copy of passed arguments; passes-through
  +     * any underlying exceptions; dfactory.setNamespaceAware(true)
  +     */
  +    public void createFactoryAndDocBuilder(TransformerFactory f, 
DocumentBuilder d)
  +        throws Exception
  +    {
  +        f = TransformerFactory.newInstance();
  +        DocumentBuilderFactory dfactory = 
DocumentBuilderFactory.newInstance();
  +        dfactory.setNamespaceAware(true);
  +        d = dfactory.newDocumentBuilder();
  +    }
  +
  +
  +    /**
  +     * Worker method to translate String to URI.  
  +     * Note: Xerces and Crimson appear to handle some URI references 
  +     * differently - this method needs further work once we figure out 
  +     * exactly what kind of format each parser wants (esp. considering 
  +     * relative vs. absolute references).
  +     * @param String path\filename of test file
  +     * @return URL to pass to SystemId
  +     */
  +    public String filenameToURI(String filename)
  +    {
  +        File f = new File(filename);
  +        String tmp = f.getAbsolutePath();
  +         if (File.separatorChar == '\\') {
  +             tmp = tmp.replace('\\', '/');
  +         }
  +        return "file:///" + tmp;
  +    }
  +
  +
       /**
        * Convenience method to print out usage information - update if needed. 
 
        * @return String denoting usage of this test class
  
  
  

Reply via email to