CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/CondTools/DQM/src/TestBase.cc

Go to the documentation of this file.
00001 #include "CondTools/DQM/interface/TestBase.h"
00002 #include "RelationalAccess/IRelationalDomain.h"
00003 #include "RelationalAccess/IConnection.h"
00004 #include "RelationalAccess/ISession.h"
00005 #include "RelationalAccess/RelationalServiceException.h"
00006 #include "CoralKernel/Context.h"
00007 #include<iostream>
00008 
00009 
00010 TestBase::TestBase():
00011   m_connection( 0 ) {
00012   coral::Context& context = coral::Context::instance();
00013   context.loadComponent( "CORAL/RelationalPlugins/oracle" );
00014   coral::IHandle<coral::IRelationalDomain> domain = context.query<coral::IRelationalDomain>( "CORAL/RelationalPlugins/oracle" );    
00015   if ( ! domain.isValid() )
00016     throw std::runtime_error( "Could not load the OracleAccess plugin" );
00017 }
00018 
00019 TestBase::~TestBase() {
00020   if ( m_connection ) delete m_connection;
00021 }
00022 
00023 coral::ISession*
00024 TestBase::connect( const std::string& connectionString,
00025                    const std::string& user,
00026                    const std::string& pass ) {
00027   coral::Context& ctx = coral::Context::instance();
00028   coral::IHandle<coral::IRelationalDomain> iHandle=ctx.query<coral::IRelationalDomain>("CORAL/RelationalPlugins/oracle");
00029   if ( ! iHandle.isValid() ) 
00030     throw std::runtime_error( "Could not load the OracleAccess plugin" );
00031   
00032   std::pair<std::string, std::string> connectionAndSchema = iHandle->decodeUserConnectionString( connectionString );
00033   if ( ! m_connection )
00034     m_connection = iHandle->newConnection( connectionAndSchema.first );
00035 
00036   if ( ! m_connection->isConnected() )
00037     m_connection->connect();
00038 
00039   coral::ISession* session = m_connection->newSession( connectionAndSchema.second );
00040   if ( session ) 
00041     session->startUserSession( user, pass );
00042   
00043   return session;
00044 }
00045 
00046 void
00047 TestBase::setVerbosityLevel( coral::MsgLevel level ) {
00048   coral::MessageStream::setMsgVerbosity(level);
00049 }