CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
11  m_connection( 0 ) {
12  coral::Context& context = coral::Context::instance();
13  context.loadComponent( "CORAL/RelationalPlugins/oracle" );
14  coral::IHandle<coral::IRelationalDomain> domain = context.query<coral::IRelationalDomain>( "CORAL/RelationalPlugins/oracle" );
15  if ( ! domain.isValid() )
16  throw std::runtime_error( "Could not load the OracleAccess plugin" );
17 }
18 
20  if ( m_connection ) delete m_connection;
21 }
22 
23 coral::ISession*
24 TestBase::connect( const std::string& connectionString,
25  const std::string& user,
26  const std::string& pass ) {
27  coral::Context& ctx = coral::Context::instance();
28  coral::IHandle<coral::IRelationalDomain> iHandle=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
47 TestBase::setVerbosityLevel( coral::MsgLevel level ) {
48  coral::MessageStream::setMsgVerbosity(level);
49 }
static PFTauRenderPlugin instance
void setVerbosityLevel(coral::MsgLevel level)
Definition: TestBase.cc:47
virtual ~TestBase()
Definition: TestBase.cc:19
coral::IConnection * m_connection
Definition: TestBase.h:33
TestBase()
Definition: TestBase.cc:10
tuple level
Definition: testEve_cfg.py:34
coral::ISession * connect(const std::string &connectionString, const std::string &user, const std::string &password)
Definition: TestBase.cc:24