CMS 3D CMS Logo

TestBase.cc
Go to the documentation of this file.
2 #include "RelationalAccess/IRelationalDomain.h"
3 #include "RelationalAccess/IConnection.h"
4 #include "RelationalAccess/ISession.h"
5 #include "RelationalAccess/RelationalServiceException.h"
6 #include "CoralKernel/Context.h"
7 #include <iostream>
8 
9 TestBase::TestBase() : m_connection(nullptr) {
10  coral::Context& context = coral::Context::instance();
11  context.loadComponent("CORAL/RelationalPlugins/oracle");
12  coral::IHandle<coral::IRelationalDomain> domain =
13  context.query<coral::IRelationalDomain>("CORAL/RelationalPlugins/oracle");
14  if (!domain.isValid())
15  throw std::runtime_error("Could not load the OracleAccess plugin");
16 }
17 
19  if (m_connection)
20  delete m_connection;
21 }
22 
24  const std::string& user,
25  const std::string& pass) {
26  coral::Context& ctx = coral::Context::instance();
27  coral::IHandle<coral::IRelationalDomain> iHandle =
28  ctx.query<coral::IRelationalDomain>("CORAL/RelationalPlugins/oracle");
29  if (!iHandle.isValid())
30  throw std::runtime_error("Could not load the OracleAccess plugin");
31 
32  std::pair<std::string, std::string> connectionAndSchema = iHandle->decodeUserConnectionString(connectionString);
33  if (!m_connection)
34  m_connection = iHandle->newConnection(connectionAndSchema.first);
35 
36  if (!m_connection->isConnected())
37  m_connection->connect();
38 
39  coral::ISession* session = m_connection->newSession(connectionAndSchema.second);
40  if (session)
41  session->startUserSession(user, pass);
42 
43  return session;
44 }
45 
46 void TestBase::setVerbosityLevel(coral::MsgLevel level) { coral::MessageStream::setMsgVerbosity(level); }
static PFTauRenderPlugin instance
void setVerbosityLevel(coral::MsgLevel level)
Definition: TestBase.cc:46
virtual ~TestBase()
Definition: TestBase.cc:18
coral::IConnection * m_connection
Definition: TestBase.h:32
TestBase()
Definition: TestBase.cc:9
coral::ISession * connect(const std::string &connectionString, const std::string &user, const std::string &password)
Definition: TestBase.cc:23