Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[13.1.X] Oracle test: Use fake/random DB name #41635

Merged
merged 1 commit into from
May 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 20 additions & 19 deletions OnlineDB/Oracle/test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,33 @@
using namespace oracle::occi;
using namespace std;

int main(int argc, char *argv[]){
int main(int argc, char* argv[]) {
const char* fake_db = "cms-fake-unknown-db-server-1234567890";
char* p = std::getenv("CMSTEST_FAKE_ORACLE_DBNAME");
fake_db = p ? p : fake_db;
int errCode = 0;
if (argc==2){errCode = stoi(argv[1]);}
if (errCode==24960){
cout <<"Tesing: 'ORA-24960: the attribute OCI_ATTR_USERNAME is greater than the maximum allowable length of 255'"<<endl;
if (argc == 2) {
errCode = stoi(argv[1]);
}
else if (errCode==12154){
cout <<"Tesing: 'ORA-12154: TNS:could not resolve the connect identifier specified'"<<endl;
if (errCode == 24960) {
cout << "Tesing: 'ORA-24960: the attribute OCI_ATTR_USERNAME is greater than the maximum allowable length of 255'"
<< endl;
} else if (errCode == 12154) {
cout << "Tesing: 'ORA-12154: TNS:could not resolve the connect identifier specified'" << endl;
} else {
cout << "Testing exception error code:" << errCode << endl;
}
else{
cout<<"Testing exception error code:"<<errCode<<endl;
}
try
{
try {
auto env = Environment::createEnvironment(Environment::OBJECT);
auto conn = env->createConnection("a", "b", "c");
auto conn = env->createConnection("a", "b", fake_db);
env->terminateConnection(conn);
Environment::terminateEnvironment(env);
}catch(oracle::occi::SQLException &e)
{
cout <<"Caught oracle::occi::SQLException exception with error code: "<<e.getErrorCode()<<endl;
cout <<"Exception Message:"<< e.getMessage()<<endl;
if (e.getErrorCode()==errCode){
} catch (oracle::occi::SQLException& e) {
cout << "Caught oracle::occi::SQLException exception with error code: " << e.getErrorCode() << endl;
cout << "Exception Message:" << e.getMessage() << endl;
if (e.getErrorCode() == errCode) {
cout << "OK: Expected exception found:" << errCode << endl;
}
else{
} else {
throw;
}
}
Expand Down