Esempio n. 1
0
/*  Description: Create a mamaPublisher and get its transport
 *
 *  Expected Result: MAMA_STATUS_OK
 */
TEST_F (MamaPublisherTestC, GetTransport)
{
    mamaPublisher    publisher = NULL;
    mamaTransport    tport     = NULL;
    const char*      symbol    = "SYM";
    const char*      source    = "SRC";
   
    ASSERT_EQ (MAMA_STATUS_OK,
               mamaTransport_allocate (&tport));

    ASSERT_EQ (MAMA_STATUS_OK,
               mamaTransport_create (tport, getTransport(), mBridge));

    ASSERT_EQ (MAMA_STATUS_OK,
               mamaPublisher_create (&publisher, tport, symbol, source, NULL));

    ASSERT_EQ(tport, mamaPublisherImpl_getTransportImpl (publisher));

    ASSERT_EQ(tport, mamaPublisherImpl_getTransportImpl (publisher));

    ASSERT_EQ (MAMA_STATUS_OK,
               mamaPublisher_destroy (publisher));

    ASSERT_EQ (MAMA_STATUS_OK,
               mamaTransport_destroy (tport));

    ASSERT_EQ (0, pubOnCreateCount);
    ASSERT_EQ (0, pubOnErrorCount);
    ASSERT_EQ (0, pubOnDestroyCount);
}
Esempio n. 2
0
static void initializeMama ()
{
    mama_status status = MAMA_STATUS_OK;

    status = mama_loadBridge (&gPubBridge, gPubMiddleware);
    if (MAMA_STATUS_OK != status)
    {
        mama_log (MAMA_LOG_LEVEL_ERROR, 
                  "Could not load middleware bridge. Exiting.");
        exit (1);
    }

    status = mama_open ();
    if (MAMA_STATUS_OK != status)
    {
        mama_log (MAMA_LOG_LEVEL_ERROR,
                  "Failed to Open MAMA. Exiting");
        exit (1);
    }

    mama_getDefaultEventQueue (gPubBridge, &gPubDefaultQueue);

    mamaTransport_allocate (&gPubTransport);
    status = mamaTransport_create (gPubTransport,
                                   gPubTransportName,
                                   gPubBridge);
    if (MAMA_STATUS_OK != status)
    {
        mama_log (MAMA_LOG_LEVEL_ERROR,
                  "Failed to create transport. Exiting");
        exit (1);
    }

}
Esempio n. 3
0
/*  Description: Create a mamaPublisher then destroy it.  
 *
 *  Expected Result: MAMA_STATUS_OK
 */
TEST_F (MamaPublisherTestC, CreateDestroy)
{
    mamaPublisher    publisher = NULL;
    mamaTransport    tport     = NULL;
    const char*      source    = getSource();
   
    pubOnCreateCount = 0;
    pubOnErrorCount = 0;
    pubOnDestroyCount = 0;

    ASSERT_EQ (MAMA_STATUS_OK,
               mamaTransport_allocate (&tport));

    ASSERT_EQ (MAMA_STATUS_OK,
               mamaTransport_create (tport, getTransport(), mBridge));

    ASSERT_EQ (MAMA_STATUS_OK,
               mamaPublisher_create (&publisher, tport, source, NULL, NULL));

    ASSERT_EQ (MAMA_STATUS_OK,
               mamaPublisher_destroy (publisher));

    ASSERT_EQ (MAMA_STATUS_OK,
               mamaTransport_destroy (tport));
}
Esempio n. 4
0
mama_status createTransport (mamaCaptureConfig subCapture,
                             mamaTransport* transport,
                             char* tportName)
{
    mama_status   status =  MAMA_STATUS_OK;
    mamaCapture*  capture = (mamaCapture*)subCapture;

    if (capture == NULL) return MAMA_STATUS_NULL_ARG;


    status = mamaTransport_allocate (transport);
    if (status != MAMA_STATUS_OK)
    {
        mama_log (MAMA_LOG_LEVEL_NORMAL,
                  "Failed to allocate transport STATUS: %d %s\n", status,
                  mamaStatus_stringForStatus (status));
        exit(1);
    }

    status = mamaTransport_setTransportCallback(*transport, transportCb, NULL);

    status = mamaTransport_create (*transport, tportName, capture->myBridge);

    if (status != MAMA_STATUS_OK)
    {
        mama_log (MAMA_LOG_LEVEL_NORMAL,
                  "Failed to create transport STATUS: %d %s\n", status,
                  mamaStatus_stringForStatus (status));
        exit(1);
    }

    /*if we still haven't create a transport for
      dictionary then do so */
    if (capture->myDictTransport == NULL)
    {
        capture->myDictTransport = *transport;

        mamaSource_create             (&capture->myDictSource);
        mamaSource_setTransport       (capture->myDictSource,
                                      capture->myDictTransport);
        mamaSource_setSymbolNamespace (capture->myDictSource,
                                       capture->myDictSourceName);
        if (status != MAMA_STATUS_OK)
        {
            mama_log (MAMA_LOG_LEVEL_NORMAL,
                      "Failed to create data dictionary transport STATUS: %d %s\n",
                      status, mamaStatus_stringForStatus (status));
            exit(1);
        }
    }
    return status;
}
Esempio n. 5
0
static void initializeMama ()
{
    mama_status status;

    status = mama_loadBridge (&gPubBridge, gPubMiddleware);
    status = mama_loadBridge (&gSubBridge, gSubMiddleware);

    mama_open();

    mama_getDefaultEventQueue (gPubBridge, &gPubDefaultQueue);
    mama_getDefaultEventQueue (gSubBridge, &gSubDefaultQueue);

    mamaTransport_allocate (&gSubTransport);
    mamaTransport_create (gSubTransport,
                          gSubTransportName,
                          gSubBridge);

    mamaTransport_allocate (&gPubTransport);
    mamaTransport_create (gPubTransport,
                          gPubTransportName,
                          gPubBridge);

    /*The mamaSource used for all subscription creation*/
    if (MAMA_STATUS_OK!=(status=mamaSource_create (&gSubscriptionSource)))
    {
        fprintf (stderr,
                 "Failed to create subscription mamaSource STATUS: %d %s\n",
                 status, mamaStatus_stringForStatus (status));
        exit(1);
    }

    mamaSource_setId (gSubscriptionSource, "Subscription_Source");
    mamaSource_setTransport (gSubscriptionSource, gSubTransport);
    mamaSource_setSymbolNamespace (gSubscriptionSource, gSubSource);


}
/**********************************************************
 *                    mc_initializeMama                   *
 **********************************************************/
static void mc_initializeMama
(
  mamaBridge       * pBridge,
  const char       * middleware,
  mamaQueue        * pQueue,
  mamaTransport    * pTransport,
  const char       * transportName
)
{
  MAMA_CHECK(mama_loadBridge (pBridge, middleware));
  MAMA_CHECK(mama_open ());
  mama_getDefaultEventQueue (*pBridge, pQueue);
  MAMA_CHECK(mamaTransport_allocate (pTransport));
  MAMA_CHECK(mamaTransport_create (*pTransport, transportName, *pBridge));
}
/*
 * Connect to specified transport using the previously loaded bridge
 */
void connectTransport(const char * transportName)
{
    global.transport = NULL;
    mama_status status;
    if (((status = mamaTransport_allocate(&global.transport)) == MAMA_STATUS_OK) &&
        ((status = mamaTransport_create(global.transport, transportName, global.bridge)) == MAMA_STATUS_OK))
    {
        // normal exit
        return;
    }
    // error exit
    printf("Transport %s connect error: %s\n", transportName, mamaStatus_stringForStatus(status));
    mama_close();
    exit(status);
}
Esempio n. 8
0
/*  Description: Create a mamaPublisher and mamaMsg, send the msg using 
 *               mamaPublisher then destroy both.
 *
 *  Expected Result: MAMA_STATUS_OK
 */
TEST_F (MamaPublisherTestC, Send)
{
    mamaPublisher    publisher = NULL;
    mamaTransport    tport     = NULL;
    const char*      symbol    = getSymbol();
    const char*      source    = getSource();
    mamaMsg          msg       = NULL;

    pubOnCreateCount = 0;
    pubOnErrorCount = 0;
    pubOnDestroyCount = 0;

    ASSERT_EQ (MAMA_STATUS_OK, mama_open());

    ASSERT_EQ (MAMA_STATUS_OK,
               mamaMsg_create (&msg));

    ASSERT_EQ (MAMA_STATUS_OK,
               mamaMsg_addString (msg, symbol, 101, source));

    ASSERT_EQ (MAMA_STATUS_OK,
               mamaTransport_allocate (&tport));

    ASSERT_EQ (MAMA_STATUS_OK,
               mamaTransport_create (tport, getTransport(), mBridge));

    ASSERT_EQ (MAMA_STATUS_OK,
               mamaPublisher_create (&publisher, tport, symbol, source, NULL));

    ASSERT_EQ (MAMA_STATUS_OK,
               mamaPublisher_send (publisher, msg));

    ASSERT_EQ (MAMA_STATUS_OK,
               mamaPublisher_destroy (publisher));

    ASSERT_EQ (MAMA_STATUS_OK,
               mamaTransport_destroy (tport));

    ASSERT_EQ (MAMA_STATUS_OK, mama_close());

    ASSERT_EQ (0, pubOnCreateCount);
    ASSERT_EQ (0, pubOnErrorCount);
    ASSERT_EQ (0, pubOnDestroyCount);
}
Esempio n. 9
0
void initializeMama (void)
{
    mama_status status;

    status = mama_loadBridge (&gMamaBridge, gMiddleware);
    if (status != MAMA_STATUS_OK)
    {
        printf ("Error loading bridge: %s\n",
                mamaStatus_stringForStatus (status));
        exit (status);
    }

    status = mama_open ();

    if (status != MAMA_STATUS_OK)
    {
        printf ("Error initializing mama: %s\n",
                mamaStatus_stringForStatus (status));
        exit (status);
    }

    mama_getDefaultEventQueue (gMamaBridge, &gMamaDefaultQueue);

    status = mamaTransport_allocate (&gTransport);

    if (status != MAMA_STATUS_OK)
    {
        printf ("Error allocating transport: %s\n",
                mamaStatus_stringForStatus (status));
        exit (status);
    }

    status = mamaTransport_create (gTransport, gTransportName, gMamaBridge);

    if (status != MAMA_STATUS_OK)
    {
        printf ("Error creating transport: %s\n",
                mamaStatus_stringForStatus (status));
        exit (status);
    }

}
Esempio n. 10
0
/*  Description: Create a mamaPublisher with event callbacks and mamaMsg, send the msg using 
 *               mamaPublisher then destroy both. A non-entitled source is used to generate
 *               publisher error events. But the callbacks are not set, so no callbacks 
 *               should be received.
 *
 *  Expected Result: MAMA_STATUS_OK
 */
TEST_F (MamaPublisherTestC, EventSendWithCallbacksNoCallbacks)
{
    mamaPublisher    publisher = NULL;
    mamaTransport    tport     = NULL;
    const char*      symbol    = getSymbol();
    const char*      source    = getBadSource();
    mamaMsg          msg       = NULL;
    mamaQueue        queue     = NULL;
    mamaPublisherCallbacks* cb = NULL;
    int              i         = 0;
    int              numErrors = 10;

    pubOnCreateCount = 0;
    pubOnErrorCount = 0;
    pubOnDestroyCount = 0;

    mamaPublisherCallbacks_allocate(&cb);
    cb->onError = NULL;
    cb->onCreate = NULL;
    cb->onDestroy = NULL;

    ASSERT_EQ (MAMA_STATUS_OK, mama_open());

    ASSERT_EQ (MAMA_STATUS_OK,
               mamaMsg_create (&msg));

    ASSERT_EQ (MAMA_STATUS_OK,
               mamaMsg_addString (msg, symbol, 101, source));

    ASSERT_EQ (MAMA_STATUS_OK,
               mama_getDefaultEventQueue (mBridge, &queue));
 
    ASSERT_EQ (MAMA_STATUS_OK,
               mamaTransport_allocate (&tport));

    ASSERT_EQ (MAMA_STATUS_OK,
               mamaTransport_create (tport, getTransport(), mBridge));

    ASSERT_EQ (MAMA_STATUS_OK,
		mamaTransport_setTransportTopicCallback (tport, (mamaTransportTopicCB) transportTopicCb, NULL));

    ASSERT_EQ (MAMA_STATUS_OK,
               mamaPublisher_createWithCallbacks (&publisher, tport, queue, symbol, source, NULL, cb, NULL));

    for (i = 0; i < numErrors; i++)
    {
        ASSERT_EQ (MAMA_STATUS_OK,
                   mamaPublisher_send (publisher, msg));
    }

    ASSERT_EQ (MAMA_STATUS_OK,
               mamaPublisher_destroy (publisher));

    ASSERT_EQ (MAMA_STATUS_OK,
               mamaTransport_destroy (tport));

    ASSERT_EQ (MAMA_STATUS_OK, mama_close());

    ASSERT_EQ (0, pubOnCreateCount);
    ASSERT_EQ (0, pubOnErrorCount);
    ASSERT_EQ (0, pubOnDestroyCount);

    mamaPublisherCallbacks_deallocate(cb);
}
Esempio n. 11
0
static mama_status initializeMama (mamaCaptureConfig subCapture)
{
    mamaCapture * capture = (mamaCapture*)subCapture;
    mama_status status = MAMA_STATUS_OK;

    status = mama_loadBridge (&capture->myBridge, capture->myMiddleware);

    if (MAMA_STATUS_OK!=status)
    {
        mama_log (MAMA_LOG_LEVEL_NORMAL,"Could not open MAMA %s bridge.",
                                         capture->myMiddleware);
        exit (1);
    }

    status = mama_open ();
    if (status != MAMA_STATUS_OK)
    {
        mama_log (MAMA_LOG_LEVEL_NORMAL,
                  "Failed to initialize MAMA STATUS: %d (%s)\n", status,
                  mamaStatus_stringForStatus (status));
        exit(1);
    }

    mama_getDefaultEventQueue (capture->myBridge, &capture->myDefaultQueue);

    status = mamaCapture_allocate(&capture->myCapture);
    if (status != MAMA_STATUS_OK)
    {
        mama_log (MAMA_LOG_LEVEL_NORMAL,
                  "Failed to create capture STATUS: %d %s\n", status,
                  mamaStatus_stringForStatus (status));
        exit(1);

    }
    if (capture->myDictTport != NULL)
    {
        mama_log (MAMA_LOG_LEVEL_FINE,
                  "Creating data dictionary transport using name: %s\n",
                  capture->myDictTport);
        if (strlen(capture->myDictTport)==0) capture->myDictTport = NULL;

        status = mamaTransport_allocate (&capture->myDictTransport);
        status = mamaTransport_create (capture->myDictTransport,
                                       capture->myDictTport,
                                       capture->myBridge);
        mamaSource_create             (&capture->myDictSource);
        mamaSource_setTransport       (capture->myDictSource,
                                      capture->myDictTransport);
        mamaSource_setSymbolNamespace (capture->myDictSource,
                                       capture->myDictSourceName);
        if (status != MAMA_STATUS_OK)
        {
            mama_log (MAMA_LOG_LEVEL_NORMAL,
                      "Failed to create data dictionary transport STATUS: %d %s\n",
                      status, mamaStatus_stringForStatus (status));
            exit(1);
        }
    }

    return MAMA_STATUS_OK;
}