00001 /* 00002 * Copyright 1999-2004 The Apache Software Foundation. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #if !defined(HARNESS_HEADER_GUARD_1357924680) 00017 #define HARNESS_HEADER_GUARD_1357924680 00018 00019 00020 00021 #include "xalanc/Harness/XalanHarnessDefinitions.hpp" 00022 00023 00024 00025 #include <cstdio> 00026 00027 00028 00029 #include "xalanc/XalanDOM/XalanDOMString.hpp" 00030 00031 00032 00033 #include "xalanc/Include/XalanMemMgrHelper.hpp" 00034 #include "xalanc/Include/XalanMap.hpp" 00035 00036 00037 00038 #include "xalanc/PlatformSupport/DOMStringHelper.hpp" 00039 00040 00041 00042 XALAN_CPP_NAMESPACE_BEGIN 00043 00044 00045 00046 00047 class XALAN_HARNESS_EXPORT XalanXMLFileReporter 00048 { 00049 00050 public: 00051 00052 typedef XalanMap<XalanDOMString, XalanDOMString> Hashtable; 00053 00054 #if defined(XALAN_STRICT_ANSI_HEADERS) 00055 typedef std::FILE FileHandleType; 00056 #else 00057 typedef FILE FileHandleType; 00058 #endif 00059 00060 public: 00061 00062 00063 // Construct and initialize this reporter with specified filename, if 00064 // the filename is not empty. 00065 XalanXMLFileReporter(MemoryManagerType& theManager, const XalanDOMString& fileName); 00066 00067 // Initialize this XalanXMLFileReporter. Must be called before attempting to log anything. 00068 bool initialize(MemoryManagerType& theManager); 00069 00070 MemoryManagerType& 00071 getMemoryManager() 00072 { 00073 return m_fileName.getMemoryManager(); 00074 } 00075 00076 // Accessor for flushing; is set from properties. 00077 bool getFlushOnCaseClose(); 00078 00079 // Accessor methods for our properties block. 00080 const XalanDOMString& getFileName() const; 00081 00082 // Accessor methods for our properties block. 00083 void setFileName(const XalanDOMString& fileName); 00084 00085 // Accessor methods for our properties block. 00086 void setFileName(const char* fileName, MemoryManagerType& theManager) 00087 { 00088 setFileName(XalanDOMString(fileName, theManager)); 00089 } 00090 00091 // 00092 // Is this Reporter still running OK? 00093 // @returns status - true if an error has occoured, false if it's still working fine 00094 bool checkError(); 00095 00096 00097 // 00098 // Is this Reporter ready to log results? 00099 // @returns status - true if it's ready to report, false otherwise 00100 bool isReady(); 00101 00102 // Flush this reporter - ensure our File is flushed. 00103 void flush(); 00104 00105 00106 // Close this reporter - ensure our File, etc. are closed. 00107 void close(); 00108 00109 //----------------------------------------------------- 00110 //-------- Testfile / Testcase start and stop routines -------- 00111 //----------------------------------------------------- 00112 00117 void logTestFileInit(const XalanDOMString& msg); 00118 00119 void logTestFileInit(const char* msg) 00120 { 00121 logTestFileInit(XalanDOMString(msg, getMemoryManager())); 00122 } 00123 00129 void logTestFileClose(const XalanDOMString& msg, const XalanDOMString& result); 00130 00131 void logTestFileClose(const char* msg, const char* result) 00132 { 00133 logTestFileClose(XalanDOMString(msg, getMemoryManager()), XalanDOMString(result, getMemoryManager())); 00134 } 00135 00136 void logTestCaseInit(const XalanDOMString& msg); 00137 00138 void logTestCaseInit(const char* msg) 00139 { 00140 logTestCaseInit(XalanDOMString(msg, getMemoryManager())); 00141 } 00142 00148 void logTestCaseClose(const XalanDOMString& msg, const XalanDOMString& result); 00149 00150 void logTestCaseClose(const char* msg, const char* result) 00151 { 00152 logTestCaseClose(XalanDOMString(msg , getMemoryManager()), XalanDOMString(result , getMemoryManager())); 00153 } 00154 //----------------------------------------------------- 00155 //-------- Test results reporting and logging routines -------- 00156 //----------------------------------------------------- 00157 00158 00165 void logMessage(int level, const XalanDOMString& msg); 00166 00175 void logStatistic (int level, long lVal, double dVal, const XalanDOMString& msg); 00176 00177 void logStatistic (int level, long lVal, double dVal, const char* msg) 00178 { 00179 logStatistic(level, lVal, dVal, XalanDOMString(msg, getMemoryManager())); 00180 } 00181 00182 // This routine will add an attribute to the attribute list. 00183 void addMetricToAttrs(char* desc, double theMetric, Hashtable& attrs); 00184 00196 void logElementWAttrs(int level, const XalanDOMString& element, Hashtable& attrs, const XalanDOMString& msg); 00197 00198 void logElementWAttrs(int level, const char* element, Hashtable& attrs, const char* msg) 00199 { 00200 logElementWAttrs(level, XalanDOMString(element, getMemoryManager()), attrs, XalanDOMString(msg, getMemoryManager())); 00201 } 00202 00203 void logElement(int level, const XalanDOMString& element, const XalanDOMString& msg); 00204 00205 void logElement(const XalanDOMString& element, const XalanDOMString& msg); 00217 void logArbitraryMessage (int level, const XalanDOMString& msg); 00218 00231 /* 00232 void logHashtable (int level, Hashtable hash, const XalanDOMString& msg); 00233 */ 00234 00240 void logCheckPass(const XalanDOMString& comment); 00241 00247 void logCheckAmbiguous(const XalanDOMString& comment); 00248 00254 void logCheckFail(const XalanDOMString& comment); 00255 00256 void logCheckFail(const XalanDOMString& test, const Hashtable& faildata, const Hashtable& actexp); 00257 00258 void logCheckFail(const XalanDOMString& test, const Hashtable& actexp); 00259 00260 void logErrorResult(const XalanDOMString& test, const XalanDOMString& reason); 00261 00267 void logCheckErr(const XalanDOMString& comment); 00268 00275 XalanDOMString& escapestring(const XalanDOMString& s, XalanDOMString& buffer); 00276 00277 00278 private: 00279 // not implemented 00280 XalanXMLFileReporter(const XalanXMLFileReporter&); 00284 bool startResultsFile(); 00285 00289 bool closeResultsFile(); 00290 00294 bool printToFile(const XalanDOMString& output); 00295 00296 void 00297 initStrings(); 00298 00302 XalanDOMString& 00303 getDateTimeString(XalanDOMString& result); 00304 00306 XalanDOMString OPT_FILENAME; 00307 00309 XalanDOMString ELEM_RESULTSFILE; 00310 XalanDOMString ELEM_TESTFILE; 00311 XalanDOMString ELEM_FILERESULT; 00312 XalanDOMString ELEM_TESTCASE; 00313 XalanDOMString ELEM_CASERESULT; 00314 XalanDOMString ELEM_CHECKRESULT; 00315 XalanDOMString ELEM_STATISTIC; 00316 XalanDOMString ELEM_LONGVAL; 00317 XalanDOMString ELEM_DOUBLEVAL; 00318 XalanDOMString ELEM_MESSAGE; 00319 XalanDOMString ELEM_ARBITRARY; 00320 XalanDOMString ELEM_HASHTABLE; 00321 XalanDOMString ELEM_HASHITEM; 00322 00324 XalanDOMString ATTR_LEVEL; 00325 XalanDOMString ATTR_DESC; 00326 XalanDOMString ATTR_TIME; 00327 XalanDOMString ATTR_RESULT; 00328 XalanDOMString ATTR_KEY; 00329 XalanDOMString ATTR_FILENAME; 00330 XalanDOMString LESS_THAN; 00331 XalanDOMString GREATER_THAN; 00332 XalanDOMString EQUALS_QUOTE; 00333 XalanDOMString SPACE; 00334 XalanDOMString QUOTE; 00335 XalanDOMString QUOTE_SPACE; 00336 XalanDOMString QUOTE_GREATER_THAN; 00337 XalanDOMString QUOTE_SOLIDUS_GREATER_THAN; 00338 XalanDOMString PASS; 00339 XalanDOMString AMBG; 00340 XalanDOMString ERRR; 00341 XalanDOMString FAIL; 00342 XalanDOMString LESS_THAN_SOLIDUS; 00343 XalanDOMString XML_HEADER; 00344 XalanDOMString REASON_EQUALS_QUOTE; 00345 00350 XalanDOMString TESTCASEINIT_HDR; 00351 XalanDOMString TESTCASECLOSE_HDR; 00352 XalanDOMString MESSAGE_HDR; 00353 XalanDOMString STATISTIC_HDR; 00354 XalanDOMString ARBITRARY_HDR; 00355 XalanDOMString HASHTABLE_HDR; 00356 XalanDOMString HASHITEM_HDR; 00357 XalanDOMString CHECKPASS_HDR; 00358 XalanDOMString CHECKAMBG_HDR; 00359 XalanDOMString CHECKERRR_HDR; 00360 XalanDOMString CHECKFAIL_HDR; 00361 XalanDOMString CHECKFAIL_FTR; 00362 00364 bool m_anyOutput; 00365 00367 XalanDOMString m_fileName; 00368 00370 FileHandleType* m_fileHandle; 00371 00373 bool m_ready; 00374 00376 bool m_error; 00377 00379 bool m_flushOnCaseClose; 00380 00381 }; // end of class XalanXMLFileReporter 00382 00383 00384 00385 XALAN_CPP_NAMESPACE_END 00386 00387 00388 00389 #endif
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
Xalan-C++ XSLT Processor Version 1.10 |
|