Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

MsgServiceValidate.cxx

Go to the documentation of this file.
00001 
00002 // $Id: MsgServiceValidate.cxx,v 1.2 2006/10/28 05:07:14 gmieg Exp $
00003 //
00004 // testMsgService
00005 //
00006 // Test the methods provided by the message service
00007 //
00009 #include "MessageService/test/MsgServiceValidate.h"
00010 #include <cstdlib>
00011 #include <iostream>
00012 #include "MessageService/MsgService.h"
00013 #include "MessageService/test/MsgFormatValidate.h"
00014 #include "MessageService/test/MsgOStreamServiceValidate.h"
00015 #include "MessageService/test/MsgStreamValidate.h"
00016 
00017 CVSID("$Id: MsgServiceValidate.cxx,v 1.2 2006/10/28 05:07:14 gmieg Exp $");
00018 
00019 //......................................................................
00020 
00021 MsgServiceValidate::MsgServiceValidate() {}
00022 
00023 //......................................................................
00024 
00025 MsgServiceValidate::~MsgServiceValidate() {}
00026 
00027 //......................................................................
00028 
00029 bool MsgServiceValidate::TestMsgServiceConstructor() 
00030 {
00031   MsgService* m1;
00032   MsgService* m2;
00033 
00034   m1 = MsgService::Instance();
00035   m2 = MsgService::Instance();
00036 
00037   // MsgService is a singleton so these must be the same
00038   if (m1==m2) return true;
00039 
00040   return false;
00041 }
00042 
00043 //......................................................................
00044 
00045 bool MsgServiceValidate::TestMsgService() 
00046 {
00047   MsgService* ms;
00048   MsgStream* s1;
00049   MsgStream* s2;
00050 
00051   // Check that the service creates streams properly
00052   ms = MsgService::Instance();
00053   s1 = ms->GetStream("St1");  
00054   if (s1==0) {
00055     cout << "testMsgService:: St1 returns zero!\n";
00056     return false;
00057   }
00058   s2 = ms->GetStream("St2");  
00059   if (s2==0) {
00060     cout << "testMsgService:: St2 returns zero!\n";
00061     return false;
00062   }
00063 
00064   // Check the default settings
00065   try {
00066     MSG("AAA",Msg::kVerbose) << "Verbose message to stream AAA\n";
00067     MSG("AAA",Msg::kDebug)   << "Debug message to stream AAA\n";
00068     MSG("AAA",Msg::kInfo)    << "Info message to stream AAA\n";
00069     MSG("AAA",Msg::kWarning) << "Warning message to stream AAA\n";
00070     MSG("AAA",Msg::kError)   << "Error message to stream AAA\n ";
00071     MSG("AAA",Msg::kFatal)   << "Fatal message to stream AAA\n";
00072   }
00073   catch(MSGException) {
00074     cerr << endl << endl;
00075     cerr << "***************** MSGException *****************" << endl;
00076     cerr << "*** MSGException caught (MsgServiceValidate) ***" << endl;
00077     cerr << "***************** MSGException *****************" << endl;
00078     cerr << endl;
00079     MSG("AAA",Msg::kError)   << "Fatal message to stream AAA\n";
00080   }
00081 
00082   // Check the handling of concatenated streams
00083   ms->AddCatStream("cat1.txt", "C11", Msg::kInfo);
00084   ms->AddCatStream("cat1.txt", "C12", Msg::kInfo);
00085 
00086   ms->AddCatStream("cat2.txt", "C21", Msg::kInfo);
00087   ms->AddCatStream("cat2.txt", "C22", Msg::kInfo);
00088 
00089   MSG("St1", Msg::kInfo) << "An Info message to St1\n";
00090   MSG("St2", Msg::kInfo) << "An Info message to St2\n";
00091   MSG("C11", Msg::kInfo) << "An Info message to C11 about cat1\n";
00092   MSG("C12", Msg::kInfo) << "An Info message to C12 about cat1\n";
00093   MSG("C21", Msg::kInfo) << "An Info message to C21 about cat2\n";
00094   MSG("C22", Msg::kInfo) << "An Info message to C22 about cat2\n";
00095 
00096   // Dump information about the message service itself
00097   MSG("Msg",Msg::kInfo) << (*ms);
00098 
00099   // Print message service usage statistics
00100   ms->PrintStatistics();
00101   
00102   return true;
00103 }
00104 
00105 //......................................................................
00106 
00107 bool MsgServiceValidate::RunAllTests()
00108 {
00109   bool passed = true;
00110   MsgFormatValidate mfv;
00111   MsgOStreamServiceValidate mossv;
00112   MsgStreamValidate msv;
00113 
00114   passed &= mfv.RunAllTests();
00115   passed &= mossv.RunAllTests();
00116   passed &= msv.RunAllTests();
00117 
00118   passed &= this->TestMsgServiceConstructor();
00119   passed &= this->TestMsgService();
00120   
00121   return passed;
00122 }

Generated on Mon Feb 15 11:07:01 2010 for loon by  doxygen 1.3.9.1