Fixes and improvs. Basic DRA feature.
[anna.git] / example / diameter / launcher / testing / TestManager.cpp
index ca45e9c..97a0d4f 100644 (file)
@@ -232,6 +232,7 @@ bool TestManager::tick() throw() {
     return false;
   }
 
+  // Synchronous sendings per tick:
   int count = a_synchronousAmount;
   while (count > 0) {
     if (!nextTestCase()) return false; // stop the clock
@@ -271,21 +272,29 @@ bool TestManager::nextTestCase() throw() {
       }
     }
 
-    // Hard reset, because normally a cycle takes more time that a single test case lifetime. We can consider that never
-    //  going to break a in-progress test case due to cycle repeat
+    // Soft reset to initialize already finished (in previous cycle) test cases:
     a_currentTestIt->second->reset(false);
 
     // Process test case:
     LOGDEBUG(anna::Logger::debug(anna::functions::asString("Processing test case id = %llu, currently '%s' state", a_currentTestIt->first, TestCase::asText(a_currentTestIt->second->getState())), ANNA_FILE_LOCATION));
     if (a_currentTestIt->second->getState() != TestCase::State::InProgress) {
       a_currentTestIt->second->process();
-      return true;
+      return true; // is not probably to reach still In-Progress test cases from previous cycles due to the whole
+                   //  time for complete the test cases pool regarding the single test case lifetime. You shouldn't
+                   //  forget to programm a test case timeout with a reasonable value
     }
   }
 }
 
-TestCase *TestManager::getTestCaseFromSessionId(const anna::DataBlock &message, std::string &sessionId) throw(anna::RuntimeException) {
-  sessionId = anna::diameter::helpers::base::functions::getSessionId(message);
+TestCase *TestManager::getTestCaseFromSessionId(const anna::DataBlock &message, std::string &sessionId) throw() {
+  try {
+    sessionId = anna::diameter::helpers::base::functions::getSessionId(message);
+  }
+  catch (anna::RuntimeException &ex) {
+    //ex.trace();
+    LOGWARNING(anna::Logger::warning("Cannot get the Session-Id from received DataBlock in order to identify the Test Case", ANNA_FILE_LOCATION));
+    return NULL;
+  }
   std::map<std::string /* session id's */, TestCase*>::const_iterator sessionIdIt = a_sessionIdTestCaseMap.find(sessionId);
   if (sessionIdIt != a_sessionIdTestCaseMap.end())
     return sessionIdIt->second;