You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mk...@apache.org on 2005/06/06 16:47:52 UTC

cvs commit: xml-xalan/test/java/src/org/apache/qetest/trax/dom DOMResultAPITest.java

mkwan       2005/06/06 07:47:52

  Modified:    test/java/src/org/apache/qetest/trax
                        TransformerFactoryAPITest.java
               test/java/src/org/apache/qetest/trax/dom
                        DOMResultAPITest.java
  Log:
  1. API test for TransformerFactory.setFeature()
  2. API test and serialization test for DOMResult.nextSibling
  
  Revision  Changes    Path
  1.13      +54 -5     xml-xalan/test/java/src/org/apache/qetest/trax/TransformerFactoryAPITest.java
  
  Index: TransformerFactoryAPITest.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/test/java/src/org/apache/qetest/trax/TransformerFactoryAPITest.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- TransformerFactoryAPITest.java	3 Jun 2005 16:22:30 -0000	1.12
  +++ TransformerFactoryAPITest.java	6 Jun 2005 14:47:52 -0000	1.13
  @@ -29,12 +29,14 @@
   import java.io.FileOutputStream;
   import java.util.Properties;
   
  +import javax.xml.XMLConstants;
   import javax.xml.parsers.DocumentBuilder;
   import javax.xml.parsers.DocumentBuilderFactory;
   import javax.xml.transform.ErrorListener;
   import javax.xml.transform.Source;
   import javax.xml.transform.Templates;
   import javax.xml.transform.Transformer;
  +import javax.xml.transform.TransformerConfigurationException;
   import javax.xml.transform.TransformerFactory;
   import javax.xml.transform.URIResolver;
   import javax.xml.transform.dom.DOMSource;
  @@ -548,13 +550,13 @@
   
   
       /**
  -     * Coverage tests for getFeature, set/getAttribute API's.
  +     * Coverage tests for set/getFeature, set/getAttribute API's.
        *
        * @return false if we should abort the test; true otherwise
        */
       public boolean testCase7()
       {
  -        reporter.testCaseInit("Coverage tests for getFeature, set/getAttribute API's");
  +        reporter.testCaseInit("Coverage tests for set/getFeature, set/getAttribute API's");
           // This test case should be JAXP-generic, and must not rely on Xalan-J 2.x functionality
           reporter.logInfoMsg("Note: only simple validation: most are negative tests");
           TransformerFactory factory = null;
  @@ -623,7 +625,54 @@
               reporter.logThrowable(reporter.ERRORMSG, t, "getFeature/Attribute()2 tests threw");
           }
   
  -
  +        try
  +        {
  +            reporter.logStatusMsg("Calling: factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING)");
  +            factory = TransformerFactory.newInstance();
  +            try
  +            {
  +                // All implementations are required to support the XMLConstants.FEATURE_SECURE_PROCESSING feature
  +                factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
  +                boolean b = factory.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING);
  +                reporter.check(b, true, "factory.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING)");
  +                factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, false);
  +                b = factory.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING);
  +                reporter.check(b, false, "factory.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING)");
  +                
  +            }
  +            catch (TransformerConfigurationException tce)
  +            {
  +                reporter.checkFail("set/getFeature(XMLConstants.FEATURE_SECURE_PROCESSING) tests threw: " + tce.toString());
  +                reporter.logThrowable(reporter.ERRORMSG, tce, "set/getFeature(XMLConstants.FEATURE_SECURE_PROCESSING) tests threw");
  +            }
  +            
  +            try
  +            {
  +                factory.setFeature(BOGUS_NAME, true);
  +                reporter.checkFail("factory.setFeature(BOGUS_NAME) did not throw expected exception");
  +                
  +            }
  +            catch (TransformerConfigurationException tce)
  +            {
  +                reporter.checkPass("factory.setFeature(BOGUS_NAME) threw expected TransformerConfigurationException");
  +            }
  +            
  +            try
  +            {
  +                factory.setFeature(null, true);
  +                reporter.checkFail("factory.setFeature(null, true) did not throw expected exception");
  +            }
  +            catch (NullPointerException npe)
  +	    {
  +	        reporter.checkPass("factory.setFeature(null, true) threw expected NullPointerException");
  +            }
  +                
  +        }
  +        catch (Throwable t)
  +        {
  +            reporter.checkFail("set/getFeature() tests threw: " + t.toString());
  +            reporter.logThrowable(reporter.ERRORMSG, t, "set/getFeature() tests threw");
  +        }
   
           reporter.testCaseClose();
           return true;
  
  
  
  1.13      +59 -2     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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- DOMResultAPITest.java	3 Jun 2005 16:22:31 -0000	1.12
  +++ DOMResultAPITest.java	6 Jun 2005 14:47:52 -0000	1.13
  @@ -42,6 +42,8 @@
   import org.apache.qetest.OutputNameManager;
   import org.apache.qetest.QetestUtils;
   import org.apache.qetest.xsl.XSLTestfileInfo;
  +import org.w3c.dom.Document;
  +import org.w3c.dom.Element;
   import org.w3c.dom.Node;
   import org.xml.sax.InputSource;
   
  @@ -174,6 +176,24 @@
               
               wackyDOM.setSystemId("another-system-id");
               reporter.checkObject(wackyDOM.getSystemId(), "another-system-id", "set/getSystemId API coverage");
  +            
  +            // Test the DOMResult(Node node, Node nextSibling) constructor
  +            Document doc = docBuilder.newDocument();
  +            Element a = doc.createElementNS("", "a");
  +            Element b = doc.createElementNS("", "b");
  +            Element c = doc.createElementNS("", "c");
  +            doc.appendChild(a);
  +            a.appendChild(b);
  +            a.appendChild(c);
  +            DOMResult nodeNextSiblingDOM = new DOMResult(a, c);
  +            reporter.checkObject(nodeNextSiblingDOM.getNode(), a, "DOMResult(node, nextSibling) has Node: " + nodeNextSiblingDOM.getNode());
  +            reporter.checkObject(nodeNextSiblingDOM.getNextSibling(), c, "DOMResult(node, nextSibling) has nextSibling: " + nodeNextSiblingDOM.getNextSibling());
  +        
  +            // Test the DOMResult(Node node, Node nextSibling, String systemId) constructor
  +	    DOMResult nodeNextSiblingIdDOM = new DOMResult(a, b, "this-is-system-id");
  +	    reporter.checkObject(nodeNextSiblingIdDOM.getNode(), a, "DOMResult(node, nextSibling, systemId) has Node: " + nodeNextSiblingIdDOM.getNode());
  +            reporter.checkObject(nodeNextSiblingIdDOM.getNextSibling(), b, "DOMResult(node, nextSibling, systemId) has nextSibling: " + nodeNextSiblingIdDOM.getNextSibling());
  +            reporter.check(nodeNextSiblingIdDOM.getSystemId(), "this-is-system-id", "DOMResult(node, nextSibling, systemId) has SystemId: " + nodeNextSiblingIdDOM.getSystemId());
           }
           catch (Throwable t)
           {
  @@ -322,6 +342,43 @@
                                     "Problem with re-using results(2)");
           }
   
  +        try
  +        {
  +            // The gold file when transforming with a DOMResult created by
  +            // the DOMResult(Node node, Node nextSibling) constructor.
  +            String goldFileName2 = goldDir 
  +                              + File.separator 
  +                              + TRAX_DOM_SUBDIR
  +                              + File.separator
  +                              + "DOMTest2.out";
  +            
  +            DOMSource xmlSource = new DOMSource(xmlNode);
  +	    DOMSource xslSource = new DOMSource(xslNode);
  +            templates = factory.newTemplates(xslSource);
  +            
  +            // Create a DOMResult using the DOMResult(Node node, Node nextSibling) constructor
  +            Document doc = docBuilder.newDocument();
  +            Element a = doc.createElementNS("", "a");
  +            Element b = doc.createElementNS("", "b");
  +            Element c = doc.createElementNS("", "c");
  +            doc.appendChild(a);
  +            a.appendChild(b);
  +            a.appendChild(c);
  +            DOMResult result = new DOMResult(a, c);
  +            
  +            transformer = templates.newTransformer();
  +            transformer.setErrorListener(new DefaultErrorHandler());
  +            transformer.transform(xmlSource, result);
  +            Node resultNode = result.getNode();
  +            serializeDOMAndCheck(resultNode, goldFileName2, "transform into DOMResult with nextSibling");            
  +        }
  +        catch (Throwable t)
  +        {
  +            reporter.checkFail("Problem with DOMResult with nextSibling");
  +            reporter.logThrowable(reporter.ERRORMSG, t,
  +                                  "Problem with DOMResult with nextSibling");        
  +        }
  +
           reporter.testCaseClose();
           return true;
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org