Fix bug while getting step number.
[anna.git] / example / diameter / launcher / testing / TestStep.cpp
index 75ede74..018dfcd 100644 (file)
@@ -231,21 +231,21 @@ bool TestStep::execute() throw() {
     if (a_executed) return false; // avoid repeating (this implies amount consumption)
   }
 
-  LOGDEBUG(anna::Logger::debug(anna::functions::asString("EXECUTING %s (step number %d) for Test Case %llu (%p) (%p)", asText(a_type), a_number, a_testCase->getId(), (TestCaseStep*)this, this), ANNA_FILE_LOCATION));
+  LOGDEBUG(anna::Logger::debug(anna::functions::asString("EXECUTING %s (step number %d) for Test Case %llu (%p)", asText(a_type), a_number, a_testCase->getId(), this), ANNA_FILE_LOCATION));
   setBeginTimestamp(anna::functions::millisecond());
   a_executed = true;
   return do_execute();
 }
 
 void TestStep::complete() throw() {
-  LOGDEBUG(anna::Logger::debug(anna::functions::asString("COMPLETE %s (step number %d) for Test Case %llu (%p) (%p)", asText(a_type), a_number, a_testCase->getId(), (TestCaseStep*)this, this), ANNA_FILE_LOCATION));
+  LOGDEBUG(anna::Logger::debug(anna::functions::asString("COMPLETE %s (step number %d) for Test Case %llu (%p)", asText(a_type), a_number, a_testCase->getId(), this), ANNA_FILE_LOCATION));
   a_completed = true;
   setEndTimestamp(anna::functions::millisecond());
   do_complete();
 }
 
 void TestStep::reset() throw() {
-  LOGDEBUG(anna::Logger::debug(anna::functions::asString("RESET %s (step number %d) for Test Case %llu (%p) (%p)", asText(a_type), a_number, a_testCase->getId(), (TestCaseStep*)this, this), ANNA_FILE_LOCATION));
+  LOGDEBUG(anna::Logger::debug(anna::functions::asString("RESET %s (step number %d) for Test Case %llu (%p)", asText(a_type), a_number, a_testCase->getId(), this), ANNA_FILE_LOCATION));
   // type and testCase kept
   a_completed = false;
   a_executed = false;
@@ -300,8 +300,6 @@ void TestStepTimeout::do_complete() throw() {
 }
 
 void TestStepTimeout::do_reset() throw() {
-  LOGDEBUG(anna::Logger::debug(anna::functions::asString("REXXXXXET %s for Test Case %llu (%p) (%p) (a_timer %p)", asText(a_type), a_testCase->getId(), (TestCaseStep*)this, this, a_timer), ANNA_FILE_LOCATION));
-
   try {
     TestManager::instantiate().cancelTimer(a_timer);
   }
@@ -362,10 +360,12 @@ bool TestStepSendxml::do_execute() throw() {
     // Update sequence for answers:
     if (a_waitForRequestStepNumber != -1) { // is an answer: try to copy sequence information; alert about Session-Id discrepance
       // Request which was received:
-      tsw = (const TestStepWait*)(a_testCase->getStep(a_waitForRequestStepNumber));
+      tsw = static_cast<const TestStepWait*>(a_testCase->getStep(a_waitForRequestStepNumber));
+
       const anna::DataBlock &request = tsw->getMsgDataBlock();
       anna::diameter::HopByHop hbh = anna::diameter::codec::functions::getHopByHop(request);
       anna::diameter::EndToEnd ete = anna::diameter::codec::functions::getEndToEnd(request);
+
       // Update sequence:
       anna::diameter::codec::functions::setHopByHop(a_message, hbh);
       anna::diameter::codec::functions::setEndToEnd(a_message, ete);
@@ -373,6 +373,7 @@ bool TestStepSendxml::do_execute() throw() {
       // Check Session-Id for warning ...
       std::string sessionIdAnswer = anna::diameter::helpers::base::functions::getSessionId(a_message);
       std::string sessionIdRequest = anna::diameter::helpers::base::functions::getSessionId(request);
+
       if (sessionIdRequest != sessionIdAnswer) {
         s_warn = anna::functions::asString("Sending an answer which Session-Id (%s) is different than supposed corresponding request (%s)", sessionIdAnswer.c_str(), sessionIdRequest.c_str());
         LOGWARNING(anna::Logger::warning(s_warn, ANNA_FILE_LOCATION));
@@ -569,6 +570,8 @@ throw() {
 
   if (msg != "") result->createAttribute("MatchedMessage", msg);
   if (xmlmsg != "") result->createAttribute("MatchedXMLMessage", xmlmsg);
+  if (a_clientSession) result->createAttribute("ClientSessionOrigin", anna::functions::asString("%p", a_clientSession));
+  if (a_serverSession) result->createAttribute("ServerSessionOrigin", anna::functions::asString("%p", a_serverSession));
 
   return result;
 }