/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Control/BesServices/BesServices-00-00-11/test/AthenaOutputStream_test.cxx

Go to the documentation of this file.
00001 
00008 #include <cassert>
00009 #include <iostream>
00010 #include <vector>
00011 #include "TestTools/initGaudi.h"
00012 #include "ToyConversion/FooBar.h"
00013 #include "GaudiKernel/IAlgorithm.h"
00014 #include "GaudiKernel/IAlgManager.h"
00015 #include "GaudiKernel/ISvcLocator.h"
00016 #include "GaudiKernel/IDataSelector.h"
00017 #include "GaudiKernel/SmartIF.h"
00018 #include "AthenaKernel/IClassIDSvc.h"
00019 #include "BesServices/AthenaOutputStream.h"
00020 #include "StoreGate/StoreGateSvc.h"
00021 
00022 using std::cerr;
00023 using std::cout;
00024 using std::endl;
00025 using std::vector;
00026 using namespace Athena_test;
00027 
00028 int main() {
00029   cout << "*** AthenaOutputStream_test starts ***" <<endl;
00030   ISvcLocator* pSvcLoc(0);
00031   if (!initGaudi("AthenaOutputStream_test.txt", pSvcLoc)) {
00032     cerr << "This test can not be run" << endl;
00033     return 0;
00034   }  
00035   assert(pSvcLoc);
00036 
00037   //locate necessary stuff
00038   const bool CREATEIF(true);
00039   IClassIDSvc* pCLIDSvc(0);
00040   assert( (pSvcLoc->service("ClassIDSvc", pCLIDSvc, CREATEIF)).isSuccess() );
00041   assert( pCLIDSvc );
00042 
00043   StoreGateSvc* pStore(0);
00044   assert( (pSvcLoc->service("StoreGateSvc", pStore, CREATEIF)).isSuccess() );
00045   assert( pStore );
00046 
00047   SmartIF<IAlgManager> algMan(IID_IAlgManager, pSvcLoc);
00048   assert( algMan.isValid() );
00049   IAlgorithm* pAlg(0);
00050   assert( (algMan->createAlgorithm( "AthenaOutputStream", "AthenaOutputStream", pAlg)).isSuccess() );
00051 
00052   assert( (pAlg->sysInitialize()).isSuccess() );
00053   assert( (pAlg->initialize()).isSuccess() );
00054 
00055   assert( (pStore->record(new Foo(), "uno")).isSuccess());
00056   assert( (pStore->record(new Foo(), "due")).isSuccess());
00057   assert( (pStore->record(new Bar(), "uno")).isSuccess());
00058   assert( (pStore->record(new Bar(), "due")).isSuccess());
00059   
00060   AthenaOutputStream* pStream(dynamic_cast<AthenaOutputStream*>(pAlg));
00061   assert( pStream );
00062 
00063   //fill the vector of selected objects
00064   pStream->collectAllObjects();
00065 
00066   //  cout << pStream->selectedObjects()->end() - 
00067   //    pStream->selectedObjects()->begin() <<endl;
00068   // verify that we got the right objects in the list
00069   //  this of course depends on AthenaOutputStream_test.txt
00070   assert( 4 == (pStream->selectedObjects()->end() - 
00071                 pStream->selectedObjects()->begin()) );
00072   
00073   pStream->clearSelection();
00074   assert( 0 == (pStream->selectedObjects()->end() - 
00075                 pStream->selectedObjects()->begin()) );
00076 
00077 
00078   //all done
00079   cout << "*** AthenaOutputStream_test OK ***" <<endl;
00080   return 0;
00081 }

Generated on Tue Nov 29 22:57:58 2016 for BOSS_7.0.2 by  doxygen 1.4.7