[PATCH 07/14] UNITTEST: Added some working getSendSubject unit tests


Frank Quinn <fquinn.ni@...>
 

The previous tests pretty much assumed it wasn't implemented in the
bridge. This fix adds some basic testing around this functionality
for self-describing messages.

Signed-off-by: Frank Quinn <fquinn.ni@...>
---
 .../src/gunittest/c/mamamsg/msggeneraltests.cpp    | 10 ++++++---
 .../gunittest/c/payload/payloadgeneraltests.cpp    | 25 ++++++++++++++++++----
 2 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/mama/c_cpp/src/gunittest/c/mamamsg/msggeneraltests.cpp b/mama/c_cpp/src/gunittest/c/mamamsg/msggeneraltests.cpp
index a7bc7a9..408dc02 100644
--- a/mama/c_cpp/src/gunittest/c/mamamsg/msggeneraltests.cpp
+++ b/mama/c_cpp/src/gunittest/c/mamamsg/msggeneraltests.cpp
@@ -531,18 +531,22 @@ TEST_F (MsgGeneralTestsC, DISABLED_msgImplSetDqStrategyContextInValidDq)
 */
 TEST_F (MsgGeneralTestsC, msgGetSendSubjectValid)
 {
-    const char*       subject    = "";
+    const char*       subjectIn  = "subject";
+    const char*       subjectOut = NULL;
     mama_status       status;
   
     //add fields to msg
     mamaMsg_addString (mMsg, "name0", 101, "test0");
     mamaMsg_addString (mMsg, "name1", 102, "test1");
-   
-    status = mamaMsg_getSendSubject(mMsg, &subject);
+
+    mamaMsgImpl_setBridgeImpl (mMsg, mMiddlewareBridge);
+    mamaMsgImpl_setSubscInfo (mMsg, NULL, NULL, subjectIn, 1);
+    status = mamaMsg_getSendSubject(mMsg, &subjectOut);
 
     CHECK_NON_IMPLEMENTED_OPTIONAL(status);
 
     ASSERT_EQ (status, MAMA_STATUS_OK);
+    EXPECT_STREQ(subjectIn, subjectOut);
 }
 
 TEST_F (MsgGeneralTestsC, msgGetSendSubjectInValidMsg)
diff --git a/mama/c_cpp/src/gunittest/c/payload/payloadgeneraltests.cpp b/mama/c_cpp/src/gunittest/c/payload/payloadgeneraltests.cpp
index bf67cb0..199e2ad 100644
--- a/mama/c_cpp/src/gunittest/c/payload/payloadgeneraltests.cpp
+++ b/mama/c_cpp/src/gunittest/c/payload/payloadgeneraltests.cpp
@@ -40,11 +40,13 @@ protected:
     virtual void TearDown(void);
 
     mamaPayloadBridge   aBridge;
+    mamaBridge          mMiddlewareBridge;
     mama_status         result;
 };
 
 PayloadGeneralTests::PayloadGeneralTests(void)
     : aBridge (NULL)
+    , mMiddlewareBridge (NULL)
     , result (MAMA_STATUS_OK)
 {
 }
@@ -56,6 +58,7 @@ PayloadGeneralTests::~PayloadGeneralTests(void)
 void PayloadGeneralTests::SetUp(void)
 {
     mama_loadPayloadBridge (&aBridge,getPayload());
+    mama_loadBridge (&mMiddlewareBridge, getMiddleware());
 }
 
 void PayloadGeneralTests::TearDown(void)
@@ -534,12 +537,23 @@ TEST_F(PayloadGeneralTests, GetNumberFieldsInValidNumFields)
 TEST_F(PayloadGeneralTests, GetSendSubjectValid)
 {
     msgPayload          testPayload = NULL;
+    const char*         subjectOut  = NULL;
+    const char*         subjectIn   = "testsubj";
+    msgBridge           bridgeMsg   = NULL;
+    mamaMsg             parentMsg   = NULL;
 
-    result = aBridge->msgPayloadCreate(&testPayload);
+    //result = aBridge->msgPayloadCreate(&testPayload);
+    mamaMsg_createForPayloadBridge(&parentMsg, aBridge);
+    mamaMsgImpl_getPayload(parentMsg, &testPayload);
     EXPECT_EQ (MAMA_STATUS_OK, result);
 
-    result = aBridge->msgPayloadGetSendSubject(testPayload, NULL);
-    EXPECT_EQ (MAMA_STATUS_NOT_IMPLEMENTED, result);
+    mamaMsgImpl_setBridgeImpl (parentMsg, mMiddlewareBridge);
+    mamaMsgImpl_setSubscInfo (parentMsg, NULL, NULL, subjectIn, 1);
+
+    result = aBridge->msgPayloadGetSendSubject(testPayload, &subjectOut);
+    CHECK_NON_IMPLEMENTED_OPTIONAL(result);
+
+    EXPECT_EQ (MAMA_STATUS_OK, result);
 }
 
 
@@ -562,7 +576,10 @@ TEST_F(PayloadGeneralTests, GetSendSubjectInValidSubject)
     EXPECT_EQ (MAMA_STATUS_OK, result);
 
     result = aBridge->msgPayloadGetSendSubject(testPayload, NULL);
-    EXPECT_EQ (MAMA_STATUS_NOT_IMPLEMENTED, result);
+
+    CHECK_NON_IMPLEMENTED_OPTIONAL(result);
+
+    EXPECT_EQ (MAMA_STATUS_NULL_ARG, result);
 }
 
 TEST_F(PayloadGeneralTests, ToStringValid)
--
2.4.3