LONGBOW_TEST_CASE(Dictionary, component_Codec_Tlv_Upcall_Read_Interest)
{
    TestData *data = longBowTestCase_GetClipBoardData(testCase);

    PARCBuffer *wireFormat = parcBuffer_Wrap(v1_interest_nameA, sizeof(v1_interest_nameA), 0, sizeof(v1_interest_nameA));
    CCNxTlvDictionary *dictionary = ccnxWireFormatMessage_FromInterestPacketType(CCNxTlvDictionary_SchemaVersion_V1, wireFormat);
    parcBuffer_Release(&wireFormat);

    // We have not set the message type or schema
    TransportMessage *tm = transportMessage_CreateFromDictionary(dictionary);
    transportMessage_SetInfo(tm, data->mock->connection, NULL);
    ccnxTlvDictionary_Release(&dictionary);

    // ------
    // Now do the actual test of sending the transport message up the stack

    TransportMessage *test_tm = sendUp(data, tm);

    // It should now be parsed into an Interest
    CCNxTlvDictionary *testdict = transportMessage_GetDictionary(test_tm);
    assertNotNull(testdict, "Failed to get dictionary from the transport message");

    assertTrue(ccnxTlvDictionary_IsInterest(testdict), "Dictionary says it is not an Interest");
    assertTrue(ccnxTlvDictionary_GetSchemaVersion(testdict) == CCNxTlvDictionary_SchemaVersion_V1,
               "Wrong schema, got %d expected %d",
               ccnxTlvDictionary_GetSchemaVersion(testdict), CCNxTlvDictionary_SchemaVersion_V1);

    transportMessage_Destroy(&tm);
}
LONGBOW_TEST_CASE(Global, ccnxWireFormatMessage_FromInterestPacketType)
{
    PARCBuffer *buffer = parcBuffer_Allocate(10);
    CCNxWireFormatMessage *message = ccnxWireFormatMessage_FromInterestPacketType(CCNxTlvDictionary_SchemaVersion_V1, buffer);

    assertTrue(ccnxTlvDictionary_IsInterest((CCNxTlvDictionary *) message), "Wrong message type");

    ccnxWireFormatMessage_Release(&message);
    parcBuffer_Release(&buffer);
}
Ejemplo n.º 3
0
static void
_assertInvariants(const CCNxTlvDictionary *interestDictionary)
{
    assertNotNull(interestDictionary, "Dictionary is null");
    assertTrue((ccnxTlvDictionary_IsInterest(interestDictionary) ||
                ccnxTlvDictionary_IsInterestReturn(interestDictionary)), "Dictionary is not an interest");
    assertTrue(ccnxTlvDictionary_GetSchemaVersion(interestDictionary) == CCNxTlvDictionary_SchemaVersion_V1,
               "Dictionary is wrong schema Interest, got %d expected %d",
               ccnxTlvDictionary_GetSchemaVersion(interestDictionary), CCNxTlvDictionary_SchemaVersion_V1);
}
LONGBOW_TEST_CASE(Global, ccnxWireFormatMessage_GetDictionary)
{
    PARCBuffer *buffer = parcBuffer_Allocate(10);
    CCNxWireFormatMessage *message = ccnxWireFormatMessage_FromInterestPacketType(CCNxTlvDictionary_SchemaVersion_V1, buffer);

    CCNxTlvDictionary *dictionary = ccnxWireFormatMessage_GetDictionary(message);
    assertNotNull(dictionary, "Expected to retrieve the dictionary from the CCNxWireFormatMessage");
    assertTrue(ccnxTlvDictionary_IsInterest(dictionary), "Wrong message type");

    ccnxWireFormatMessage_Release(&message);
    parcBuffer_Release(&buffer);
}
LONGBOW_TEST_CASE(Global, ccnxWireFormatMessage_FromInterestPacketTypeIoVec)
{
    uint8_t data[64];

    uint8_t pad[32];
    CCNxCodecNetworkBufferIoVec *vec = _createNetworkBufferIoVec(512, 32, pad, 64, data);

    CCNxWireFormatMessage *message = ccnxWireFormatMessage_FromInterestPacketTypeIoVec(CCNxTlvDictionary_SchemaVersion_V1, vec);

    assertNotNull(message, "Got null CCNxWireFormatMessage");
    assertTrue(ccnxTlvDictionary_IsInterest(message), "Wrong message type");
    assertTrue(ccnxTlvDictionary_GetSchemaVersion(message) == CCNxTlvDictionary_SchemaVersion_V1,
               "Wrong schema, got %d expected %d",
               ccnxTlvDictionary_GetSchemaVersion(message), CCNxTlvDictionary_SchemaVersion_V1);

    ccnxWireFormatMessage_Release(&message);
    ccnxCodecNetworkBufferIoVec_Release(&vec);
}