BOSS 7.0.7
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 <[email protected]> -ATLAS Collaboration
5 * $Id: AthenaOutputStream_test.cxx,v 1.1.1.1 2004/09/28 01:51:05 liwd Exp $
6 **/
7
8#include <cassert>
9#include <iostream>
10#include <vector>
11#include "TestTools/initGaudi.h"
12#include "ToyConversion/FooBar.h"
13#include "GaudiKernel/IAlgorithm.h"
14#include "GaudiKernel/IAlgManager.h"
15#include "GaudiKernel/ISvcLocator.h"
16#include "GaudiKernel/IDataSelector.h"
17#include "GaudiKernel/SmartIF.h"
18#include "AthenaKernel/IClassIDSvc.h"
19#include "BesServices/AthenaOutputStream.h"
20#include "StoreGate/StoreGateSvc.h"
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 cerr << "This test can not be run" << endl;
33 return 0;
34 }
35 assert(pSvcLoc);
36
37 //locate necessary stuff
38 const bool CREATEIF(true);
39 IClassIDSvc* pCLIDSvc(0);
40 assert( (pSvcLoc->service("ClassIDSvc", pCLIDSvc, CREATEIF)).isSuccess() );
41 assert( pCLIDSvc );
42
43 StoreGateSvc* pStore(0);
44 assert( (pSvcLoc->service("StoreGateSvc", pStore, CREATEIF)).isSuccess() );
45 assert( pStore );
46
47 SmartIF<IAlgManager> algMan(IID_IAlgManager, pSvcLoc);
48 assert( algMan.isValid() );
49 IAlgorithm* pAlg(0);
50 assert( (algMan->createAlgorithm( "AthenaOutputStream", "AthenaOutputStream", pAlg)).isSuccess() );
51
52 assert( (pAlg->sysInitialize()).isSuccess() );
53 assert( (pAlg->initialize()).isSuccess() );
54
55 assert( (pStore->record(new Foo(), "uno")).isSuccess());
56 assert( (pStore->record(new Foo(), "due")).isSuccess());
57 assert( (pStore->record(new Bar(), "uno")).isSuccess());
58 assert( (pStore->record(new Bar(), "due")).isSuccess());
59
60 AthenaOutputStream* pStream(dynamic_cast<AthenaOutputStream*>(pAlg));
61 assert( pStream );
62
63 //fill the vector of selected objects
64 pStream->collectAllObjects();
65
66 // cout << pStream->selectedObjects()->end() -
67 // pStream->selectedObjects()->begin() <<endl;
68 // verify that we got the right objects in the list
69 // this of course depends on AthenaOutputStream_test.txt
70 assert( 4 == (pStream->selectedObjects()->end() -
71 pStream->selectedObjects()->begin()) );
72
73 pStream->clearSelection();
74 assert( 0 == (pStream->selectedObjects()->end() -
75 pStream->selectedObjects()->begin()) );
76
77
78 //all done
79 cout << "*** AthenaOutputStream_test OK ***" <<endl;
80 return 0;
81}