Example #1
0
/* Description:      Attempt to create an iterator with a NULL iterator.
 *
 * Expected Result:  MAMA_STATUS_NULL_ARG
 */
TEST_F (MsgNewIteratorTestC, DISABLED_IteratorCreateNullIter)
{
    mama_status status = MAMA_STATUS_OK;
    status = mamaMsgIterator_create (NULL, dict);

    ASSERT_EQ (MAMA_STATUS_NULL_ARG, status);
}
Example #2
0
/* Description:      Attempt to destroy a valid iterator
 *
 * Expected Result:  MAMA_STATUS_OK
 */
TEST_F (MsgNewIteratorTestC, IteratorDestroy)
{
    mama_status status = MAMA_STATUS_OK;
    mamaMsgIterator destroyableIter = NULL;
    status = mamaMsgIterator_create (&destroyableIter, dict);
    ASSERT_EQ (MAMA_STATUS_OK, status);

    status = mamaMsgIterator_destroy (destroyableIter);
    ASSERT_EQ (MAMA_STATUS_OK, status);
}
Example #3
0
/* Description:      Attempt to create an iterator with a NULL dict.
 *
 * Expected Result:  MAMA_STATUS_NULL_ARG
 */
TEST_F (MsgNewIteratorTestC, IteratorCreateNullDict)
{
    mama_status status = MAMA_STATUS_OK;
    mamaMsgIterator createIter = NULL;
    status = mamaMsgIterator_create (&createIter, NULL);

    ASSERT_EQ (MAMA_STATUS_OK, status);

    mamaMsgIterator_destroy (createIter);
}
Example #4
0
void MsgNewIteratorTestC::SetUp(void)
{
    mama_loadBridge (&mBridge, getMiddleware());
    mama_open();

    /* add a fields to the message. */
    mamaMsg_create    (&msg);
    mamaMsg_addU8     (msg, "u8", 101, 8);
    mamaMsg_addString (msg, "string", 102, "This is an iteration test.");
    mamaMsg_addU16    (msg, "u16", 103, 16);
    mamaMsg_addU32    (msg, "u32", 104, 32);
    mamaMsg_addU64    (msg, "u64", 105, 64);

    /* Build the MAMA Dictionary from our test message. */
    mamaDictionary_create (&dict);
    mamaDictionary_buildDictionaryFromMessage (dict, msg);

    /* Create the message iterator */
    mamaMsgIterator_create (&iterator, dict);
    mamaMsgIterator_associate (iterator, msg);
}
Example #5
0
void MsgNewIteratorTestC::SetUp(void)
{
    mama_loadBridge (&mBridge, getMiddleware());
    mama_open();

    /* add a fields to the message. */
    mamaMsg_create    (&msg);
    for (mama_fid_t f = 101; f < 106; f++)
    {
        char buf[64];
        sprintf (buf, "field_%u", f);
        int val = rand();
        mamaMsg_addU64 (msg, buf, f, val);
        values.insert(std::pair<mama_fid_t, uint64_t>(f, val));
    }

    /* Build the MAMA Dictionary from our test message. */
    mamaDictionary_create (&dict);
    mamaDictionary_buildDictionaryFromMessage (dict, msg);

    /* Create the message iterator */
    mamaMsgIterator_create (&iterator, dict);
    mamaMsgIterator_associate (iterator, msg);
}
int main (int argc, const char **argv)
{

	mamaPlaybackFileParser	fileParser		= NULL;
	mamaPlaybackCapture		fileCapture		= NULL;
	char*           		headerString	= NULL;
	mamaMsg        			sourceMsg		= NULL;
	mamaMsg					targetMsg		= NULL;
	mamaMsgField			aField 			= NULL;
	mamaBridge        		gMamaBridge     = NULL;
    mamaMsgIterator 		iterator 		= NULL;
    mamaFieldType 			fieldType		= MAMA_FIELD_TYPE_UNKNOWN;
    parseCommandLine (argc, argv);

     mama_loadBridge (&gMamaBridge, "wmw");
     mama_loadBridge (&gMamaBridge, "avis");
     mama_open ();

    mamaPlaybackFileParser_allocate (&fileParser);
    mamaPlaybackFileParser_openFile(fileParser, (char*)gInputFilename);

    mamaCapture_allocate(&fileCapture);
    mamaCapture_openFile (&fileCapture, gOutputFilename);

    mamaMsgIterator_create(&iterator, NULL);

    mamaMsg_createForPayload(&targetMsg, 'A');

    while (mamaPlaybackFileParser_getNextHeader(fileParser, &headerString))
    {
        if (mamaPlaybackFileParser_getNextMsg (fileParser,
                                                &sourceMsg))
        {
            char 	temp[64];
            char*	start = headerString;
            char*	end = strchr (headerString,':');

            strncpy (temp,start, end-start); temp[end-start]='\0';
            mamaCapture_setFeedSource (&fileCapture, temp);
            end++;
            start=end;
            end = strchr (start,':');
            strncpy (temp,start, end-start);temp[end-start]='\0';
            mamaCapture_setTransportName (&fileCapture, temp);
            end++;
            start=end;
            end = strchr (start,'\0');
            strncpy (temp,start, end-start);temp[end-start]='\0';
            mamaCapture_setSymbol (&fileCapture, temp);

			mamaMsgIterator_associate(iterator, sourceMsg);
			mamaMsg_clear(targetMsg);

			while ((aField = mamaMsgIterator_next(iterator)) != NULL)
			{
				uint16_t        fid             = 0;
				mamaMsgField_getFid(aField, &fid);
				mamaMsgField_getType(aField, &fieldType);
				switch (fieldType)
				{

					case  MAMA_FIELD_TYPE_BOOL:
		               { mama_bool_t result;
		                mamaMsgField_getBool (aField, &result);
						mamaMsg_addBool(targetMsg, NULL, fid, result);
						}break;
					case MAMA_FIELD_TYPE_CHAR:
						{char result;
		                mamaMsgField_getChar (aField, &result);
						mamaMsg_addChar(targetMsg, NULL, fid, result);
						}break;
					case  MAMA_FIELD_TYPE_I8:
		                {mama_i8_t result;
		                mamaMsgField_getI8 (aField, &result);
						mamaMsg_addI8(targetMsg, NULL, fid, result);
						}break;
					case  MAMA_FIELD_TYPE_U8:
		                {mama_u8_t result;
		                mamaMsgField_getU8 (aField, &result);
						mamaMsg_addU8(targetMsg, NULL, fid, result);
						}break;
					case MAMA_FIELD_TYPE_I16:
		                {mama_i16_t result;
		                mamaMsgField_getI16 (aField, &result);
						mamaMsg_addI16(targetMsg, NULL, fid, result);
						}break;
					case MAMA_FIELD_TYPE_U16:
		                {mama_u16_t result;
		                mamaMsgField_getU16 (aField, &result);
						mamaMsg_addU16(targetMsg, NULL, fid, result);
						}break;
					case  MAMA_FIELD_TYPE_I32:
		                {mama_i32_t result;
		                mamaMsgField_getI32 (aField, &result);
						mamaMsg_addI32(targetMsg, NULL, fid, result);
						}break;
					case  MAMA_FIELD_TYPE_U32:
		                {mama_u32_t result;
		                mamaMsgField_getU32 (aField, &result);
						mamaMsg_addU32(targetMsg, NULL, fid, result);
						}break;
					case MAMA_FIELD_TYPE_I64:
		                {mama_i64_t result;
		                mamaMsgField_getI64 (aField, &result);
						mamaMsg_addI64(targetMsg, NULL, fid, result);
						}break;
					case  MAMA_FIELD_TYPE_U64:
		                {mama_u64_t result;
		                mamaMsgField_getU64 (aField, &result);
						mamaMsg_addU64(targetMsg, NULL, fid, result);
						}break;
					case  MAMA_FIELD_TYPE_F32:
		                {mama_f32_t result;
		                mamaMsgField_getF32 (aField, &result);
						mamaMsg_addF32(targetMsg, NULL, fid, result);
						}break;
					case MAMA_FIELD_TYPE_F64:
		                {mama_f64_t result;
		                mamaMsgField_getF64 (aField, &result);
						mamaMsg_addF64(targetMsg, NULL, fid, result);
						}break;
					case MAMA_FIELD_TYPE_STRING:
						{const char* result;
		                mamaMsgField_getString (aField, &result);
						mamaMsg_addString(targetMsg, NULL, fid, result);
						}break;
					case  MAMA_FIELD_TYPE_TIME:
						{
							mamaDateTime result;
							mamaMsgField_getDateTime (aField, result);
							mamaMsg_addDateTime(targetMsg, NULL, fid, result);
						}break;
					case MAMA_FIELD_TYPE_PRICE:
						{
							mamaPrice result;
							mamaMsgField_getPrice(aField, result);
							mamaMsg_addPrice(targetMsg, NULL, fid, result);
						}break;
					default:
						case MAMA_FIELD_TYPE_VECTOR_I8:
						case MAMA_FIELD_TYPE_VECTOR_U8:
						case MAMA_FIELD_TYPE_VECTOR_I16:
						case MAMA_FIELD_TYPE_VECTOR_U16:
						case MAMA_FIELD_TYPE_VECTOR_I32:
						case MAMA_FIELD_TYPE_VECTOR_U32:
						case MAMA_FIELD_TYPE_VECTOR_I64:
						case MAMA_FIELD_TYPE_VECTOR_U64:
						case MAMA_FIELD_TYPE_VECTOR_F32:
						case MAMA_FIELD_TYPE_VECTOR_F64:
						case MAMA_FIELD_TYPE_VECTOR_STRING:
						case MAMA_FIELD_TYPE_VECTOR_MSG:
						case MAMA_FIELD_TYPE_VECTOR_TIME:
						case MAMA_FIELD_TYPE_VECTOR_PRICE:
						case MAMA_FIELD_TYPE_QUANTITY:
						case MAMA_FIELD_TYPE_COLLECTION :
						case MAMA_FIELD_TYPE_UNKNOWN:
						case MAMA_FIELD_TYPE_OPAQUE:
						case MAMA_FIELD_TYPE_MSG:
							break;
				}
			}
            mamaCapture_saveMamaMsg (&fileCapture, &targetMsg);
        }
    }

    mamaMsgIterator_destroy(iterator);
    mamaCapture_closeFile(fileCapture);
    mamaCapture_deallocate (fileCapture);
    mamaPlaybackFileParser_closeFile(fileParser);
    mamaPlaybackFileParser_deallocate (fileParser);
    return (0);
}
Example #7
0
TEST_F (MsgIterateTestC, CreateIterator)
{   
    mama_fid_t      fid         = 0;
    mamaMsgIterator iterator    = NULL;
    mamaMsgField    field       = NULL;
    mamaFieldType   type        = MAMA_FIELD_TYPE_UNKNOWN;    

    /* Create a mama message. */
    mamaMsg msg = NULL;
    mamaMsg_create (&msg);
    
    /* add a fields to the message. */
    mamaMsg_addString (msg, "string", 101, "This is an iteration test.");
    mamaMsg_addU8     (msg, "u8", 102, 8);
    mamaMsg_addU16    (msg, "u16", 103, 16);
    mamaMsg_addU32    (msg, "u32", 104, 32);
    mamaMsg_addU64    (msg, "u64", 105, 64);
   
    /* Create iterator and message field required.*/
    ASSERT_EQ (MAMA_STATUS_OK, 
               mamaMsgIterator_create (&iterator,NULL));
    
    mamaMsgIterator_associate (iterator,msg);
    
    while ((field = mamaMsgIterator_next(iterator)) != NULL)
    {
        /* Operate on contents of each field. */
        mamaMsgField_getFid (field, &fid);
        mamaMsgField_getType (field, &type);
        switch(type)
        {
            case MAMA_FIELD_TYPE_STRING:
            {
                char buffer[MAX_FIELD_STR_LEN];
                ASSERT_EQ (101, fid);
                mamaMsgField_getAsString (field, buffer, MAX_FIELD_STR_LEN);
                ASSERT_STREQ ("This is an iteration test.", buffer);
                break;
            }
            case MAMA_FIELD_TYPE_U8:
            {
                mama_u8_t buffer = 0;
                ASSERT_EQ (102, fid);
                mamaMsgField_getU8 (field, &buffer);
                ASSERT_EQ (8, buffer);
                break;
            }
            case MAMA_FIELD_TYPE_U16:
            {
                mama_u16_t buffer = 0;
                ASSERT_EQ (103, fid);
                mamaMsgField_getU16 (field, &buffer);
                ASSERT_EQ (16, buffer);
                break;
            }
            case MAMA_FIELD_TYPE_U32:
            {
                mama_u32_t buffer = 0;
                ASSERT_EQ (104, fid);
                mamaMsgField_getU32 (field, &buffer);
                ASSERT_EQ (32, buffer);
                break;
            }
            case MAMA_FIELD_TYPE_U64:
            {
                mama_u64_t buffer = 0;
                ASSERT_EQ (105, fid);
                mamaMsgField_getU64 (field, &buffer);
                ASSERT_EQ (64, buffer);
                break;
            }
            default:
                break;
        }
    }

    /* destroy the message. */
    mamaMsg_destroy (msg);
}