// // See the file LICENSE for redistribution information. // // Copyright (c) 2002,2009 Oracle. All rights reserved. // // // DB XML includes (external) #include "dbxml/DbXml.hpp" // System includes #include #include #include // XQilla includes #include // Xerces includes #include #include #include // test code includes #include "TestEnvironment.hpp" #include "../util/TestLogging.hpp" using namespace DbXml; using namespace DbXmlTest; using namespace std; // function prototypes (so that main() appears first...) void usage(const string &progname, int exitCode); int main(int argc, char **argv) { bool validation(false); // true iff docs are to be validated bool secureMode(false); // true iff manaager is created in secure mode bool transacted(false); // true iff a transacted environment is used bool nodeLevelStorage(false); // node level storage (whole docs otherwise) bool indexNodes(false); // use the DBXML_INDEX_NODES flag bool verifyLog(false); // true iff log file is to be verified bool debug(false); // true iff all dbxml debugging is on string logDir("./"); // path to dir to contain log file string dataDirectory; // path to dir containing unit test data string path2DbEnv; // path to DB XML env (must exist) string testid; // arbitrary id for test (used for file names) string container; // open this container or create one vector unknownArgs; // args passed on to test objects int err(1); for(int i=1; i(unknownArgs)); ENV_MSG(log, "Successful completion of test"); err = 0; } catch(XERCES_CPP_NAMESPACE_QUALIFIER DOMException &e) { INFO_MSG(log, "Caught Xerces DOM Exception: %1") << XMLChToUTF8(e.msg).str(); } catch(XERCES_CPP_NAMESPACE_QUALIFIER XMLException &e) { INFO_MSG(log, "Caught Xerces Exception: %1") << XMLChToUTF8(e.getMessage()).str(); } catch(XQException &e) { INFO_MSG(log, "Caught XQilla Exception: %1") << XMLChToUTF8(e.getError()).str(); } catch(XmlException &e) { INFO_MSG(log, "Caught DB XML Exception: %1: %2") << e.getExceptionCode() << (char*)e.what(); } catch(...) { INFO_MSG(log, "Caught unknown exception"); } if(err) { cout << endl << "Tests did not pass - an exception was caught" << endl; } else { cout << "Completed the test program" << endl; } if(verifyLog) { cout << verifyLogFile(logFile); } else { cout << "Check the log \"" << logFile << "\" for more information, especially error and warning messages" << endl; } return err; } void usage(const string &progname, int exitCode) { string::size_type pos = progname.rfind('/'); if(pos == string::npos) { pos = progname.rfind('\\'); } if(pos == string::npos) { pos = 0; } else { ++pos; } cerr << "Usage: " << progname.substr(pos) << " [OPTIONS] -e|--env path_to_dbenv " << endl; cerr << "Options:" << endl; cerr << "\t-t|--transacted\t\tuse a transacted environment" << endl; cerr << "\t-s|--secure\t\tuse secure mode" << endl; cerr << "\t-a|--validate\t\tuse validation mode" << endl; cerr << "\t-n|--nls\t\tuse node level storage" << endl; cerr << "\t--indexnodes\t\tuse DBXML_INDEX_NODES flag" << endl; cerr << "\t-c|--container ctr\topen the specified container" << endl; cerr << "\t--id id\t\tassign a (test) ID to this invocation" << endl; cerr << "\t-d|--datadir dir\tdirectory containing data files (test input)" << endl; cerr << "\t-l|--logdir\t\tdirectory for the log files [.]" << endl; cerr << "\t-v|--verify\t\tverify the log file for warnings and errors" << endl; cerr << "\t-x|--debug|-?\t\tdebug logging on" << endl; cerr << "\t-h|--help|-?\t\tprint this help" << endl; cerr << endl; cerr << "Additional options may be supported by specific test classes." << endl; cerr << endl; exit(exitCode); }