pauldick 01/07/13 13:48:40 Modified: c/Tests/Harness FileUtility.cpp FileUtility.hpp Harness.dsp HarnessInit.hpp Log: Many changes. New comparision methods, consolidated where all includes happen Revision Changes Path 1.10 +152 -53 xml-xalan/c/Tests/Harness/FileUtility.cpp Index: FileUtility.cpp =================================================================== RCS file: /home/cvs/xml-xalan/c/Tests/Harness/FileUtility.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- FileUtility.cpp 2001/07/11 20:23:40 1.9 +++ FileUtility.cpp 2001/07/13 20:48:33 1.10 @@ -30,25 +30,12 @@ #include <crtdbg.h> #endif -//#include <Include/PlatformDefinitions.hpp> +// XERCES HEADERS... +// Are included by HarnessInit.hpp -#include <framework/URLInputSource.hpp> -#include <util/PlatformUtils.hpp> -#include <util/XercesDefs.hpp> - -#include <XalanDOM/XalanNode.hpp> -#include <XalanDOM/XalanDocument.hpp> -#include <XalanDOM/XalanElement.hpp> -#include <XalanDOM/XalanNodeList.hpp> - -#include <XalanSourceTree/FormatterToSourceTree.hpp> - -#include <PlatformSupport/DoubleSupport.hpp> -#include <PlatformSupport/DirectoryEnumerator.hpp> -#include <PlatformSupport/DOMStringHelper.hpp> -#include <PlatformSupport/XalanUnicode.hpp> -#include <PlatformSupport/XalanOutputStreamPrintWriter.hpp> -#include <PlatformSupport/XalanStdOutputStream.hpp> +// XALAN HEADERS... +// Are included by FileUtility.hpp + #include "FileUtility.hpp" bool diffElement(const XalanNode& gold, const XalanNode& doc, const XalanDOMString& fileName); @@ -213,10 +200,11 @@ } -/* This routine get Xerces Version number. +// This routine gets Xerces Version number. It's used to put the Xerces Version +// into the output xml results file as an attribute of 'PerfData' element. // Inputs: None // -*/ + XalanDOMString FileUtility::getXercesVersion() { @@ -224,6 +212,124 @@ } +/* This routine creates a FormatterToXML FormatterListener. This is used to format +// the output DOM so a comparision can be done with the expected GOLD file. +// Inputs: None +// +*/ + + +FormatterListener* +FileUtility::getXMLFormatter(bool shouldWriteXMLHeader, + bool stripCData, + bool escapeCData, + PrintWriter& resultWriter, + int indentAmount, + const XalanDOMString& mimeEncoding, + const StylesheetRoot* stylesheet) +{ + FormatterListener* formatter = 0; + + XalanDOMString version; + bool outputIndent= 0; + XalanDOMString mediatype; + XalanDOMString doctypeSystem; + XalanDOMString doctypePublic; + XalanDOMString standalone; + + if (stylesheet != 0) + { + version = stylesheet->m_version; + + mediatype = stylesheet->m_mediatype; + doctypeSystem = stylesheet->getOutputDoctypeSystem(); + doctypePublic = stylesheet->getOutputDoctypePublic(); + standalone = stylesheet->m_standalone; + outputIndent = stylesheet->m_indentResult; + } + + FormatterToXML* const fToXML = + new FormatterToXML( + resultWriter, + version, + outputIndent, + indentAmount, + mimeEncoding, + mediatype, + doctypeSystem, + doctypePublic, + true, // xmlDecl + standalone); + +// fToXML->setShouldWriteXMLHeader(shouldWriteXMLHeader); +// fToXML->setStripCData(stripCData); +// fToXML->setEscapeCData(escapeCData); + + formatter = fToXML; + return formatter; +} + +/* This routine compares the results of a transform with the gold file. +// It in turn call the domCompare routine to do the actual comparision. +// Inputs: +// gold - Dom tree for the expected results +// doc - Dom tree created during transformation +// filename - Current filename +// +// Returns: +// Void +// +*/ +void +FileUtility::compareResults(const XalanDOMString& theOutputFile, + const XalanCompiledStylesheet* compiledSS, + XalanSourceTreeDocument* dom, + XalanDOMString fileName, + const XSLTInputSource& goldInputSource) +{ + const XalanDOMString mimeEncoding("whatever"); + XalanFileOutputStream myOutput(theOutputFile); + XalanOutputStreamPrintWriter myResultWriter(myOutput); + FormatterListener* theFormatter = getXMLFormatter(true,true,true, + myResultWriter,0, + mimeEncoding, + compiledSS->getStylesheetRoot()); + + FormatterTreeWalker theTreeWalker(*theFormatter); + theTreeWalker.traverse(dom); + delete theFormatter; + + + XalanSourceTreeDOMSupport domSupport; + XalanSourceTreeParserLiaison parserLiaison(domSupport); + domSupport.setParserLiaison(&parserLiaison); + + XalanDocument* goldDom = parserLiaison.parseXMLStream(goldInputSource); + if ( domCompare(*goldDom, *dom, fileName) ) + { + cout << endl << "Passed: " << c_str(TranscodeToLocalCodePage(fileName)); + } + +} + +void +FileUtility::compareSerializedResults(const XSLTInputSource& transformResult, + const XSLTInputSource& goldInputSource, + XalanDOMString fileName, const char* testCase) +{ + XalanSourceTreeDOMSupport domSupport; + XalanSourceTreeParserLiaison parserLiaison(domSupport); + domSupport.setParserLiaison(&parserLiaison); + + XalanDocument* goldDom = parserLiaison.parseXMLStream(goldInputSource); + XalanDocument* transformDom = parserLiaison.parseXMLStream(transformResult); + if ( domCompare(*goldDom, *transformDom, fileName) ) + { + cout << endl << "Passed: " << testCase; + } + +} + /* This routine performs a DOM Comparision. // Inputs: // gold - Dom tree for the expected results @@ -247,17 +353,6 @@ const XalanDOMString& goldNodeValue = gold.getNodeValue(); - //const XalanDOMString& docNsUri = doc.getNamespaceURI(); - //const XalanDOMString& goldNsUri = gold.getNamespaceURI(); - - //const XalanDOMString& docPrefix = doc.getPrefix(); - //const XalanDOMString& goldPrefix = gold.getPrefix(); - - //const XalanDOMString& docLName = doc.getLocalName(); - //const XalanDOMString& goldLName = gold.getLocalName(); - - - if (goldNodeType != docNodeType) { reportDOMError(fileName, docNodeName, "Error: NodeType mismatch. Expected: "); @@ -288,9 +383,31 @@ { reportDOMError(fileName, docNodeName, "Error: Text node mismatch. Expected: "); cout << c_str(TranscodeToLocalCodePage(goldNodeValue)); + cout << c_str(TranscodeToLocalCodePage(docNodeValue)); return false; } + // Need to process textnode siblings. Note that text nodes do not have child nodes. + const XalanNode *goldNextNode; + const XalanNode *domNextNode; + goldNextNode = gold.getNextSibling(); + domNextNode = doc.getNextSibling(); + + if (0 != goldNextNode) + { + if (0 != domNextNode) + { + if ( ! domCompare(*goldNextNode, *domNextNode, fileName) ) + return false; + } + else + { + reportDOMError(fileName, docNodeName, "Error: Element missing SiblingNode. Expected: "); + cout << c_str(TranscodeToLocalCodePage(goldNextNode->getNodeName())); + return false; + } + } + break; } case XalanNode::CDATA_SECTION_NODE: @@ -482,9 +599,9 @@ /* This routine compares two attribute nodes. // Inputs: -// gold - Dom tree for the expected results -// doc - Dom tree created during transformation -// filename - Current filenam +// gAttr - attribute from Gold dom tree +// dAttr - attribute from Dom tree created during transformation +// fileName - Current filenam // // Returns: // True or False @@ -494,11 +611,10 @@ bool FileUtility::diffATTR(const XalanNode* gAttr, const XalanNode* dAttr, const XalanDOMString& fileName) { - const XalanDOMString& goldAttrName = gAttr->getNodeName(); const XalanDOMString& docAttrName = dAttr->getNodeName(); - #if !defined(NDEBUG) && defined(_MSC_VER) + const XalanDOMString& goldAttrName = gAttr->getNodeName(); cout << " Attribute is: " << c_str(TranscodeToLocalCodePage(goldAttrName)) << endl; #endif @@ -528,23 +644,6 @@ return false; } -/* I think that these are not necessary. I assume that they will be caught earlier when - checking for named attributes. - - if (goldAttrPrefix != docAttrPrefix) - { - reportDOMError(fileName, "Error: Attribute Namespace Prefix mismatch. Expected: ",errAttrName); - cout << c_str(TranscodeToLocalCodePage(goldAttrPrefix)); - return false; - } - - if (goldAttrLName != docAttrLName) - { - reportDOMError(fileName, "Error: Attribute LocalName mismatch. Expected: ",errAttrName); - cout << c_str(TranscodeToLocalCodePage(goldAttrLName)); - return false; - } -*/ return true; } 1.8 +57 -10 xml-xalan/c/Tests/Harness/FileUtility.hpp Index: FileUtility.hpp =================================================================== RCS file: /home/cvs/xml-xalan/c/Tests/Harness/FileUtility.hpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- FileUtility.hpp 2001/07/11 17:47:01 1.7 +++ FileUtility.hpp 2001/07/13 20:48:34 1.8 @@ -59,7 +59,6 @@ #if !defined(FILEUTILITY_HEADER_GUARD_1357924680) #define FILEUTILITY_HEADER_GUARD_1357924680 - #include<string> #include<stdio.h> #include <time.h> @@ -69,21 +68,35 @@ #else #include <iostream> #endif + +// XERCES HEADERS ... +// Are included in HarnessInit.hpp + +// XALAN HEADERS... +#include <PlatformSupport/XalanOutputStreamPrintWriter.hpp> +#include <PlatformSupport/XalanFileOutputStream.hpp> +#include <PlatformSupport/DirectoryEnumerator.hpp> + +#include <XPath/XObjectFactoryDefault.hpp> +#include <XPath/XPathFactoryDefault.hpp> + +#include <XMLSupport/FormatterToXML.hpp> +#include <XMLSupport/FormatterTreeWalker.hpp> -#include <util/XercesDefs.hpp> -#include <XSLT/XSLTInputSource.hpp> #include <XalanSourceTree/XalanSourceTreeDOMSupport.hpp> #include <XalanSourceTree/XalanSourceTreeParserLiaison.hpp> #include <XalanSourceTree/XalanSourceTreeDocument.hpp> -using namespace std; +#include <XalanTransformer/XalanCompiledStylesheetDefault.hpp> +#include <XalanTransformer/XalanTransformer.hpp> +using namespace std; /** * Utility call that extracts test file names from testsuite. * @author Paul [EMAIL PROTECTED] - * @version $Id: FileUtility.hpp,v 1.7 2001/07/11 17:47:01 pauldick Exp $ + * @version $Id: FileUtility.hpp,v 1.8 2001/07/13 20:48:34 pauldick Exp $ */ #if defined HARNESS_EXPORTS @@ -92,7 +105,7 @@ #define HARNESS_API __declspec(dllimport) #endif -// Misc typedefs and const definitions +// Misc typedefs and Global variables. // These structures hold vectors of directory names and file names. #if defined(XALAN_NO_NAMESPACES) typedef vector<XalanDOMString> FileNameVectorType; @@ -100,10 +113,11 @@ typedef std::vector<XalanDOMString> FileNameVectorType; #endif - const XalanDOMString processorType(XALAN_STATIC_UCODE_STRING("XalanC")); - const XalanDOMString XSLSuffix(XALAN_STATIC_UCODE_STRING(".xsl")); - const XalanDOMString XMLSuffix(XALAN_STATIC_UCODE_STRING(".xml")); - const XalanDOMString pathSep(XALAN_STATIC_UCODE_STRING("\\")); +// Basic Global variables used by many tests. +const XalanDOMString processorType(XALAN_STATIC_UCODE_STRING("XalanC")); +const XalanDOMString XSLSuffix(XALAN_STATIC_UCODE_STRING(".xsl")); +const XalanDOMString XMLSuffix(XALAN_STATIC_UCODE_STRING(".xml")); +const XalanDOMString pathSep(XALAN_STATIC_UCODE_STRING("\\")); // This class is exported from the Harness.dll class HARNESS_API FileUtility @@ -165,6 +179,39 @@ * @returns a XalanDOMString. */ XalanDOMString FileUtility::getXercesVersion(); + + /** + * Utility method used to compare the results. It inturn + * call domCompare. + * @returns Void. + */ + void + FileUtility::compareResults(const XalanDOMString& theOutputFile, + const XalanCompiledStylesheet* compiledSS, + XalanSourceTreeDocument* dom, + XalanDOMString fileName, + const XSLTInputSource& goldInputSource); + /** + * Simplified version of above. + */ + void + FileUtility::compareSerializedResults(const XSLTInputSource& transformResult, + const XSLTInputSource& goldInputSource, + XalanDOMString fileName, const char* testCase); + /** + * Utility method used to create a FormatterToXML FormatterListener. + * This is required to DOM comparisions. + * @returns a pointer to a FormatterListener. + */ + FormatterListener* + FileUtility::getXMLFormatter(bool shouldWriteXMLHeader, + bool stripCData, + bool escapeCData, + PrintWriter& resultWriter, + int indentAmount, + const XalanDOMString& mimeEncoding, + const StylesheetRoot* stylesheet); + /** * Utility methods used to perform a DOM Compare 1.10 +2 -2 xml-xalan/c/Tests/Harness/Harness.dsp Index: Harness.dsp =================================================================== RCS file: /home/cvs/xml-xalan/c/Tests/Harness/Harness.dsp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- Harness.dsp 2001/05/17 18:31:55 1.9 +++ Harness.dsp 2001/07/13 20:48:34 1.10 @@ -54,7 +54,7 @@ # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 ..\..\..\..\xml-xerces\c\Build\Win32\VC6\Release\xerces-c_1.lib ..\..\Build\Win32\VC6\Release\PlatformSupport.lib ..\..\Build\Win32\VC6\Release\XalanDOM.lib /nologo /dll /pdb:none /machine:I386 +# ADD LINK32 ..\..\..\..\xml-xerces\c\Build\Win32\VC6\Release\xerces-c_1.lib ..\..\Build\Win32\VC6\Release\PlatformSupport.lib ..\..\Build\Win32\VC6\Release\XalanDOM.lib ..\..\Build\Win32\VC6\Release\XMLSupport.lib ..\..\Build\Win32\VC6\Release\XSLT.lib ..\..\Build\Win32\VC6\Release\XalanSourceTree.lib ..\..\Build\Win32\VC6\Release\DOMSupport.lib /nologo /dll /pdb:none /machine:I386 # SUBTRACT LINK32 /debug !ELSEIF "$(CFG)" == "Harness - Win32 Debug" @@ -81,7 +81,7 @@ # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 ..\..\..\..\xml-xerces\c\Build\Win32\VC6\Debug\xerces-c_1D.lib ..\..\Build\Win32\VC6\Debug\PlatformSupportD.lib ..\..\Build\Win32\VC6\Debug\XalanDOMD.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 ..\..\..\..\xml-xerces\c\Build\Win32\VC6\Debug\xerces-c_1D.lib ..\..\Build\Win32\VC6\Debug\PlatformSupportD.lib ..\..\Build\Win32\VC6\Debug\XalanDOMD.lib ..\..\Build\Win32\VC6\Debug\XMLSupportD.lib ..\..\Build\Win32\VC6\Debug\XalanSourceTreeD.lib ..\..\Build\Win32\VC6\Debug\XSLTD.lib ..\..\Build\Win32\VC6\Debug\DOMSupportD.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # SUBTRACT LINK32 /incremental:no !ELSEIF "$(CFG)" == "Harness - Win32 Release with symbols" 1.2 +6 -3 xml-xalan/c/Tests/Harness/HarnessInit.hpp Index: HarnessInit.hpp =================================================================== RCS file: /home/cvs/xml-xalan/c/Tests/Harness/HarnessInit.hpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- HarnessInit.hpp 2001/05/15 16:12:39 1.1 +++ HarnessInit.hpp 2001/07/13 20:48:35 1.2 @@ -64,17 +64,20 @@ #include<stdio.h> #include <time.h> +// Base header file. Must be first... +// Not sure what this is refering to, but it was in front of the PlatformDefinitions include?? +// XERCES HEADERS... +#include <Include/PlatformDefinitions.hpp> +#include <util/XercesDefs.hpp> #include <util/PlatformUtils.hpp> -#include <FileUtility.hpp> using namespace std; - /** * Utility call that extracts test file names from testsuite. * @author Paul [EMAIL PROTECTED] - * @version $Id: HarnessInit.hpp,v 1.1 2001/05/15 16:12:39 pauldick Exp $ + * @version $Id: HarnessInit.hpp,v 1.2 2001/07/13 20:48:35 pauldick Exp $ */ // This is all commented out because these are inline methods, there is no // .cpp file associated. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]