Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:23:16

0001 #include <iostream>
0002 #include <string>
0003 #include <sstream>
0004 
0005 #include "occi.h"
0006 
0007 using namespace oracle::occi;
0008 using namespace std;
0009 
0010 int main(int argc, char* argv[]) {
0011   const char* fake_db = "cms-fake-unknown-db-server-1234567890";
0012   char* p = std::getenv("CMSTEST_FAKE_ORACLE_DBNAME");
0013   fake_db = p ? p : fake_db;
0014   int errCode = 0;
0015   if (argc == 2) {
0016     errCode = stoi(argv[1]);
0017   }
0018   if (errCode == 24960) {
0019     cout << "Tesing: 'ORA-24960: the attribute  OCI_ATTR_USERNAME is greater than the maximum allowable length of 255'"
0020          << endl;
0021   } else if (errCode == 12154) {
0022     cout << "Tesing: 'ORA-12154: TNS:could not resolve the connect identifier specified'" << endl;
0023   } else {
0024     cout << "Testing exception error code:" << errCode << endl;
0025   }
0026   try {
0027     auto env = Environment::createEnvironment(Environment::OBJECT);
0028     auto conn = env->createConnection("a", "b", fake_db);
0029     env->terminateConnection(conn);
0030     Environment::terminateEnvironment(env);
0031   } catch (oracle::occi::SQLException& e) {
0032     cout << "Caught oracle::occi::SQLException exception with error code: " << e.getErrorCode() << endl;
0033     cout << "Exception Message:" << e.getMessage() << endl;
0034     if (e.getErrorCode() == errCode) {
0035       cout << "OK: Expected exception found:" << errCode << endl;
0036     } else {
0037       throw;
0038     }
0039   }
0040   return 0;
0041 }