#include <anna/diameter.comm/ServerSession.hpp>
#include <anna/diameter.comm/Server.hpp>
#include <anna/core/tracing/Logger.hpp>
-#include <anna/diameter/codec/Message.hpp>
#include <anna/diameter/codec/functions.hpp>
#include <anna/diameter/helpers/base/functions.hpp>
#include <MyDiameterEntity.hpp>
#include <MyLocalServer.hpp>
#include <TestStep.hpp>
-#include <Launcher.hpp>
#include <TestCase.hpp>
#include <TestManager.hpp>
#include <TestTimer.hpp>
+#include <Launcher.hpp>
namespace {
// TODO: mutex the step while setting data here !!
}
- bool decodeMessage(const anna::DataBlock &message, anna::diameter::codec::Message *messageCodec) throw() {
+ bool decodeMessage(const anna::DataBlock &message, anna::diameter::codec::Message &messageCodec) throw() {
if (message.isEmpty())
return false;
bool result = true;
try {
- if (!messageCodec) {
- Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
- messageCodec = new anna::diameter::codec::Message(my_app.getCodecEngine());
- }
-
- messageCodec->decode(message);
+ messageCodec.decode(message);
}
catch (anna::RuntimeException &ex) {
ex.trace();
return result;
}
-
}
a_number = testCase->steps() + 1; // testCase is not NULL
}
+bool TestStep::decodeMessage() throw() {
+ if (a_messageCodec) return true;
+ a_messageCodec = new anna::diameter::codec::Message;
+ if (::decodeMessage(a_message, *a_messageCodec)) return true;
+
+ delete a_messageCodec;
+ a_messageCodec = NULL;
+ return false;
+}
+
const char* TestStep::asText(const Type::_v type)
throw() {
static const char* text [] = { "Unconfigured", "Timeout", "Sendxml2e", "Sendxml2c", "Delay", "Wait", "Cmd" };
return text [type];
}
-anna::xml::Node* TestStep::asXML(anna::xml::Node* parent) const
+anna::xml::Node* TestStep::asXML(anna::xml::Node* parent)
throw() {
anna::xml::Node* result = parent->createChild("TestStep");
return result;
}
-std::string TestStep::asXMLString() const throw() {
+std::string TestStep::asXMLString() throw() {
anna::xml::Node root("root");
return anna::xml::Compiler().apply(asXML(&root));
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// TestStepTimeout
////////////////////////////////////////////////////////////////////////////////////////////////////////
-anna::xml::Node* TestStepTimeout::asXML(anna::xml::Node* parent) const
+anna::xml::Node* TestStepTimeout::asXML(anna::xml::Node* parent)
throw() {
anna::xml::Node* result = TestStep::asXML(parent); // end timestamp will be 0 if test finished OK
//parent->createChild("TestStepTimeout");
////////////////////////////////////////////////////////////////////////////////////////////////////////
// TestStepSendxml
////////////////////////////////////////////////////////////////////////////////////////////////////////
-TestStepSendxml::~TestStepSendxml() {
- delete a_messageCodec;
- a_messageCodec = NULL;
-}
-
-anna::xml::Node* TestStepSendxml::asXML(anna::xml::Node* parent) const
+anna::xml::Node* TestStepSendxml::asXML(anna::xml::Node* parent)
throw() {
anna::xml::Node* result = TestStep::asXML(parent);
//parent->createChild("TestStepSendxml");
}
}
- if (decodeMessage(a_message, a_messageCodec)) {
+ if (decodeMessage()) {
xmlmsg = "\n";
xmlmsg += a_messageCodec->asXMLString();
xmlmsg += "\n";
// Detailed log:
if(a_realmNode->logEnabled()) {
- if (!a_messageCodec)
- decodeMessage(a_message, a_messageCodec);
-
- if (a_messageCodec) {
+ if (decodeMessage()) {
std::string detail = usedClientSession ? usedClientSession->asString() : "<null client session>"; // shouldn't happen
a_realmNode->writeLogFile(*a_messageCodec, (success ? "sent2e" : "send2eError"), detail);
}
// Detailed log:
if(a_realmNode->logEnabled()) {
- if (!a_messageCodec)
- decodeMessage(a_message, a_messageCodec);
-
- if (a_messageCodec) {
+ if (decodeMessage()) {
std::string detail = usedServerSession ? usedServerSession->asString() : "<null server session>"; // shouldn't happen
a_realmNode->writeLogFile(*a_messageCodec, (success ? "sent2c" : "send2cError"), detail);
}
void TestStepSendxml::do_reset() throw() {
a_expired = false;
//a_message.clear();
+ //a_messageAlreadyDecoded = false;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// TestStepDelay
////////////////////////////////////////////////////////////////////////////////////////////////////////
-anna::xml::Node* TestStepDelay::asXML(anna::xml::Node* parent) const
+anna::xml::Node* TestStepDelay::asXML(anna::xml::Node* parent)
throw() {
anna::xml::Node* result = TestStep::asXML(parent);
//parent->createChild("TestStepDelay");
////////////////////////////////////////////////////////////////////////////////////////////////////////
// TestStepWait
////////////////////////////////////////////////////////////////////////////////////////////////////////
-TestStepWait::~TestStepWait() {
- delete a_messageCodec;
- a_messageCodec = NULL;
-}
-
void TestStepWait::setCondition(bool fromEntity,
- const std::string &code, const std::string &bitR, const std::string &resultCode, const std::string &sessionId,
- const std::string &hopByHop, const std::string &msisdn, const std::string &imsi, const std::string &serviceContextId) throw() {
+ const std::string &code, const std::string &bitR, const std::string &hopByHop, const std::string &applicationId,
+ const std::string &sessionId, const std::string &resultCode,
+ const std::string &msisdn, const std::string &imsi, const std::string &serviceContextId) throw() {
a_condition.setReceivedFromEntity(fromEntity);
a_condition.setCode(code);
a_condition.setRegexp(regexp);
}
-anna::xml::Node* TestStepWait::asXML(anna::xml::Node* parent) const
+anna::xml::Node* TestStepWait::asXML(anna::xml::Node* parent)
throw() {
anna::xml::Node* result = TestStep::asXML(parent);
//parent->createChild("TestStepWait");
}
}
- if (decodeMessage(a_message, a_messageCodec)) {
+ if (decodeMessage()) {
xmlmsg = "\n";
xmlmsg += a_messageCodec->asXMLString();
xmlmsg += "\n";
////////////////////////////////////////////////////////////////////////////////////////////////////////
// TestStepCmd
////////////////////////////////////////////////////////////////////////////////////////////////////////
-anna::xml::Node* TestStepCmd::asXML(anna::xml::Node* parent) const
+anna::xml::Node* TestStepCmd::asXML(anna::xml::Node* parent)
throw() {
anna::xml::Node* result = TestStep::asXML(parent);
//parent->createChild("TestStepCmd");