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); }
LONGBOW_TEST_CASE(Global, ccnxWireFormatMessage_WriteToFile) { const char string[] = "Hello dev null\n"; PARCBuffer *buffer = parcBuffer_Wrap((void *) string, sizeof(string), 0, sizeof(string)); CCNxWireFormatMessage *message = ccnxWireFormatMessage_FromInterestPacketType(CCNxTlvDictionary_SchemaVersion_V1, buffer); ccnxWireFormatMessage_WriteToFile(message, "/dev/null"); ccnxWireFormatMessage_Release(&message); parcBuffer_Release(&buffer); }
LONGBOW_TEST_CASE(Global, ccnxWireFormatMessage_GetWireFormatBuffer) { PARCBuffer *buffer = parcBuffer_Allocate(1); CCNxWireFormatMessage *message = ccnxWireFormatMessage_FromInterestPacketType(CCNxTlvDictionary_SchemaVersion_V1, buffer); PARCBuffer *test = ccnxWireFormatMessage_GetWireFormatBuffer(message); assertTrue(test == buffer, "Retrieved unexpected buffer: got %p expected %p", (void *) test, (void *) buffer); ccnxWireFormatMessage_Release(&message); parcBuffer_Release(&buffer); }
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_AcquireRelease) { PARCBuffer *buffer = parcBuffer_Allocate(10); CCNxWireFormatMessage *message = ccnxWireFormatMessage_FromInterestPacketType(CCNxTlvDictionary_SchemaVersion_V1, buffer); CCNxWireFormatMessage *ref = ccnxWireFormatMessage_Acquire(message); assertNotNull(ref, "Expected a non-NULL reference to be acquired"); ccnxWireFormatMessage_Release(&message); assertNotNull(ref, "Expected a non-NULL reference to be acquired"); assertNull(message, "Expeced original message to be NULL"); ccnxWireFormatMessage_Release(&ref); parcBuffer_Release(&buffer); }