Hard refactoring. CodecEngine is associated to a unique stack.
[anna.git] / example / diameter / launcher / testing / TestStep.hpp
index e4574c1..9b69579 100644 (file)
@@ -17,6 +17,7 @@
 // Project
 #include <anna/core/DataBlock.hpp>
 #include <anna/xml/Node.hpp>
+#include <anna/diameter/codec/Message.hpp>
 
 // Process
 #include <TestCondition.hpp>
@@ -62,7 +63,7 @@ class TestStep {
     struct Type { enum _v { Unconfigured, Timeout, Sendxml2e, Sendxml2c, Delay, Wait, Cmd }; };
     static const char* asText(const Type::_v type) throw();
 
-    TestStep(TestCase *testCase) { initialize(testCase); }
+    TestStep(TestCase *testCase) : a_message(true), a_messageCodec(NULL) { initialize(testCase); }
     virtual ~TestStep() {;}
 
     // setter & getters
@@ -74,14 +75,19 @@ class TestStep {
     void complete() throw();
     void reset() throw();
     void next() throw();
-    virtual anna::xml::Node* asXML(anna::xml::Node* parent) const throw();
-    std::string asXMLString() const throw();
+    virtual anna::xml::Node* asXML(anna::xml::Node* parent) throw();
+    std::string asXMLString() throw();
 
   protected:
     TestCase *a_testCase;
     bool a_completed;
     Type::_v a_type;
 
+    // Message (not for all step types)
+    anna::DataBlock a_message;
+    anna::diameter::codec::Message *a_messageCodec; // used as helper and for traffic logs
+    bool decodeMessage() throw();
+
     virtual bool do_execute() throw() = 0; // returns true if next step must be executed
     virtual void do_complete() throw() = 0; // end of transaction (delay/timeout expired, wait condition fulfilled, sending done)
                                             // In all cases, the next step will be executed except 'timeout' which is asynchronous
@@ -106,7 +112,7 @@ class TestStepTimeout : public TestStep {
     bool do_execute() throw();
     void do_complete() throw(); // timeout reached, test case failed
     void do_reset() throw();
-    anna::xml::Node* asXML(anna::xml::Node* parent) const throw();
+    anna::xml::Node* asXML(anna::xml::Node* parent) throw();
 };
 
 
@@ -119,16 +125,15 @@ class TestStepSendxml : public TestStep {
     // Step number reference ('wait for request' step)
     int a_waitForRequestStepNumber;
 
-    // Message
-    anna::DataBlock a_message;
-    anna::diameter::codec::Message *a_messageCodec; // used as helper and for traffic logs
-
     // Expired ?
     bool a_expired; // a_endTimestamp will be the expiration reception timestamp
 
   public:
-    TestStepSendxml(TestCase *testCase) : TestStep(testCase), a_message(true), a_messageCodec(NULL), a_expired(false), a_realmNode(NULL), a_waitForRequestStepNumber(-1) {;}
-    ~TestStepSendxml();
+    TestStepSendxml(TestCase *testCase) : TestStep(testCase),
+      a_expired(false),
+      a_realmNode(NULL),
+      a_waitForRequestStepNumber(-1) {;}
+    ~TestStepSendxml() {;}
 
     // setter & getters
     void setRealmNode(RealmNode *realm) throw() { a_realmNode = realm; }
@@ -142,7 +147,7 @@ class TestStepSendxml : public TestStep {
     bool do_execute() throw();
     void do_complete() throw() {;}
     void do_reset() throw();
-    anna::xml::Node* asXML(anna::xml::Node* parent) const throw();
+    anna::xml::Node* asXML(anna::xml::Node* parent) throw();
 };
 
 class TestStepSendxml2e : public TestStepSendxml {
@@ -171,26 +176,29 @@ class TestStepDelay : public TestStep {
     bool do_execute() throw();
     void do_complete() throw(); // delay reached
     void do_reset() throw();
-    anna::xml::Node* asXML(anna::xml::Node* parent) const throw();
+    anna::xml::Node* asXML(anna::xml::Node* parent) throw();
 };
 
 
 class TestStepWait : public TestStep {
 
     TestCondition a_condition;
-    anna::DataBlock a_message; // message which complies with condition
-    anna::diameter::codec::Message *a_messageCodec; // used as helper and for traffic logs
     anna::diameter::comm::ClientSession *a_clientSession;
     anna::diameter::comm::ServerSession *a_serverSession;
 
   public:
-    TestStepWait(TestCase *testCase) : TestStep(testCase), a_message(true), a_messageCodec(NULL) { a_type = Type::Wait; a_clientSession = NULL; a_serverSession = NULL; }
-    ~TestStepWait();
+    TestStepWait(TestCase *testCase) : TestStep(testCase) {
+      a_type = Type::Wait;
+      a_clientSession = NULL;
+      a_serverSession = NULL;
+    }
+    ~TestStepWait() {;}
 
     // setter & getters
     void 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();
     void setCondition(bool fromEntity, const std::string &regexp) throw();
 
     void setClientSession(anna::diameter::comm::ClientSession *cs) throw() { a_clientSession = cs; }
@@ -208,7 +216,7 @@ class TestStepWait : public TestStep {
     bool do_execute() throw(); // this will be executed when test case starts (at least we could measure the time until condition is fulfilled)
     void do_complete() throw(); // condition fulfilled
     void do_reset() throw();
-    anna::xml::Node* asXML(anna::xml::Node* parent) const throw();
+    anna::xml::Node* asXML(anna::xml::Node* parent) throw();
 };
 
 
@@ -248,7 +256,7 @@ class TestStepCmd : public TestStep {
     bool do_execute() throw();
     void do_complete() throw();
     void do_reset() throw();
-    anna::xml::Node* asXML(anna::xml::Node* parent) const throw();
+    anna::xml::Node* asXML(anna::xml::Node* parent) throw();
 };