Fixes and improvs. Basic DRA feature.
[anna.git] / example / diameter / launcher / testing / TestStep.cpp
index c4ec2e5..e53ae9a 100644 (file)
@@ -161,15 +161,19 @@ anna::xml::Node* TestStepSendxml::asXML(anna::xml::Node* parent) const
 throw() {
   anna::xml::Node* result = TestStep::asXML(parent);
   //parent->createChild("TestStepSendxml");
+  std::string msg = "", xmlmsg = "";
 
   // Message
-  std::string msg = "", xmlmsg = "";
-  if (a_message.isEmpty()) {
-    msg = "<empty>";
+  if (TestManager::instantiate().getDumpHex()) {
+    if (a_message.isEmpty()) {
+      msg = "<empty>";
+    }
+    else {
+      msg = "\n"; msg += a_message.asString(); msg += "\n";
+    }
   }
-  else {
-    msg = "\n"; msg += a_message.asString(); msg += "\n";
-    // Helper
+
+  if (!a_message.isEmpty()) {
     try {
       Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
       static anna::diameter::codec::Message codecMsg(my_app.getCodecEngine());
@@ -181,9 +185,11 @@ throw() {
     }
   }
 
-  result->createAttribute("Message", msg);
+  if (msg != "") result->createAttribute("Message", msg);
   if (xmlmsg != "") result->createAttribute("XMLMessage", xmlmsg);
   result->createAttribute("Expired", (a_expired ? "yes":"no"));
+  if (a_waitForRequestStepNumber != -1)
+    result->createAttribute("WaitForRequestStepNumber", a_waitForRequestStepNumber);
 
   return result;
 }
@@ -334,25 +340,36 @@ anna::xml::Node* TestStepWait::asXML(anna::xml::Node* parent) const
 throw() {
   anna::xml::Node* result = TestStep::asXML(parent);
   //parent->createChild("TestStepWait");
+  std::string msg = "", xmlmsg = "";
 
   // Condition
   a_condition.asXML(result);
 
+  // Message
+  if (TestManager::instantiate().getDumpHex()) {
+    if (a_message.isEmpty()) {
+      msg = "<empty>";
+    }
+    else {
+      msg = "\n"; msg += a_message.asString(); msg += "\n";
+    }
+  }
+
   if (!a_message.isEmpty()) {
-    // Message
-    result->createAttribute("MatchedMessage", a_message.asString());
-    // Helper
     try {
       Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
       static anna::diameter::codec::Message codecMsg(my_app.getCodecEngine());
       codecMsg.decode(a_message);
-      result->createAttribute("MatchedXMLMessage", codecMsg.asXMLString());
+      xmlmsg = "\n"; xmlmsg += codecMsg.asXMLString(); xmlmsg += "\n";
     }
     catch (anna::RuntimeException &ex) {
       ex.trace();
     }
   }
 
+  if (msg != "") result->createAttribute("MatchedMessage", msg);
+  if (xmlmsg != "") result->createAttribute("XMLMessage", xmlmsg);
+
   return result;
 }