Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:20

0001 #include "CondTools/RunInfo/interface/TestBase.h"
0002 #include "RelationalAccess/IRelationalDomain.h"
0003 #include "RelationalAccess/IConnection.h"
0004 #include "RelationalAccess/ISession.h"
0005 #include "RelationalAccess/RelationalServiceException.h"
0006 #include "CoralKernel/Context.h"
0007 #include <iostream>
0008 
0009 TestBase::TestBase() : m_connection(nullptr) {
0010   coral::Context& context = coral::Context::instance();
0011   context.loadComponent("CORAL/RelationalPlugins/oracle");
0012   coral::IHandle<coral::IRelationalDomain> domain =
0013       context.query<coral::IRelationalDomain>("CORAL/RelationalPlugins/oracle");
0014   if (!domain.isValid())
0015     throw std::runtime_error("Could not load the OracleAccess plugin");
0016 }
0017 
0018 TestBase::~TestBase() {
0019   if (m_connection)
0020     delete m_connection;
0021 }
0022 
0023 coral::ISession* TestBase::connect(const std::string& connectionString,
0024                                    const std::string& user,
0025                                    const std::string& pass) {
0026   coral::Context& ctx = coral::Context::instance();
0027   coral::IHandle<coral::IRelationalDomain> iHandle =
0028       ctx.query<coral::IRelationalDomain>("CORAL/RelationalPlugins/oracle");
0029   if (!iHandle.isValid()) {
0030     throw std::runtime_error("Could not load the OracleAccess plugin");
0031   }
0032   std::pair<std::string, std::string> connectionAndSchema = iHandle->decodeUserConnectionString(connectionString);
0033   if (!m_connection) {
0034     m_connection = iHandle->newConnection(connectionAndSchema.first);
0035   }
0036   if (!m_connection->isConnected()) {
0037     m_connection->connect();
0038   }
0039   coral::ISession* session = m_connection->newSession(connectionAndSchema.second);
0040   if (session) {
0041     session->startUserSession(user, pass);
0042   }
0043   return session;
0044 }
0045 
0046 void TestBase::setVerbosityLevel(coral::MsgLevel level) { coral::MessageStream::setMsgVerbosity(level); }