BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
AthenaOutputStream_test.cxx
Go to the documentation of this file.
1/** @file AthenaOutputStream_test.cxx
2 * @brief unit test for AtRndSvc
3 *
4 * @author Paolo Calafiura <pcalafiura@lbl.gov> -ATLAS Collaboration
5 * $Id: AthenaOutputStream_test.cxx,v 1.1.1.1 2004/09/28 01:51:05 liwd Exp $
6 **/
7
8#include "AthenaKernel/IClassIDSvc.h"
9#include "BesServices/AthenaOutputStream.h"
10#include "GaudiKernel/IAlgManager.h"
11#include "GaudiKernel/IAlgorithm.h"
12#include "GaudiKernel/IDataSelector.h"
13#include "GaudiKernel/ISvcLocator.h"
14#include "GaudiKernel/SmartIF.h"
15#include "StoreGate/StoreGateSvc.h"
16#include "TestTools/initGaudi.h"
17#include "ToyConversion/FooBar.h"
18#include <cassert>
19#include <iostream>
20#include <vector>
21
22using std::cerr;
23using std::cout;
24using std::endl;
25using std::vector;
26using namespace Athena_test;
27
28int main() {
29 cout << "*** AthenaOutputStream_test starts ***" << endl;
30 ISvcLocator* pSvcLoc( 0 );
31 if ( !initGaudi( "AthenaOutputStream_test.txt", pSvcLoc ) )
32 {
33 cerr << "This test can not be run" << endl;
34 return 0;
35 }
36 assert( pSvcLoc );
37
38 // locate necessary stuff
39 const bool CREATEIF( true );
40 IClassIDSvc* pCLIDSvc( 0 );
41 assert( ( pSvcLoc->service( "ClassIDSvc", pCLIDSvc, CREATEIF ) ).isSuccess() );
42 assert( pCLIDSvc );
43
44 StoreGateSvc* pStore( 0 );
45 assert( ( pSvcLoc->service( "StoreGateSvc", pStore, CREATEIF ) ).isSuccess() );
46 assert( pStore );
47
48 SmartIF<IAlgManager> algMan( IID_IAlgManager, pSvcLoc );
49 assert( algMan.isValid() );
50 IAlgorithm* pAlg( 0 );
51 assert( ( algMan->createAlgorithm( "AthenaOutputStream", "AthenaOutputStream", pAlg ) )
52 .isSuccess() );
53
54 assert( ( pAlg->sysInitialize() ).isSuccess() );
55 assert( ( pAlg->initialize() ).isSuccess() );
56
57 assert( ( pStore->record( new Foo(), "uno" ) ).isSuccess() );
58 assert( ( pStore->record( new Foo(), "due" ) ).isSuccess() );
59 assert( ( pStore->record( new Bar(), "uno" ) ).isSuccess() );
60 assert( ( pStore->record( new Bar(), "due" ) ).isSuccess() );
61
62 AthenaOutputStream* pStream( dynamic_cast<AthenaOutputStream*>( pAlg ) );
63 assert( pStream );
64
65 // fill the vector of selected objects
66 pStream->collectAllObjects();
67
68 // cout << pStream->selectedObjects()->end() -
69 // pStream->selectedObjects()->begin() <<endl;
70 // verify that we got the right objects in the list
71 // this of course depends on AthenaOutputStream_test.txt
72 assert( 4 == ( pStream->selectedObjects()->end() - pStream->selectedObjects()->begin() ) );
73
74 pStream->clearSelection();
75 assert( 0 == ( pStream->selectedObjects()->end() - pStream->selectedObjects()->begin() ) );
76
77 // all done
78 cout << "*** AthenaOutputStream_test OK ***" << endl;
79 return 0;
80}