LONGBOW_TEST_CASE(Global, ccnxTlvCodecName_Encode)
{
    uint8_t truthBytes[] = { 0x10, 0x20, 0x00, 0x0E, 0x00, CCNxNameLabelType_NAME, 0x00, 0x0A, 'b', 'r', 'a', 'n', 'd', 'y', 'w', 'i', 'n', 'e' };
    PARCBuffer *truth = parcBuffer_Wrap(truthBytes, sizeof(truthBytes), 0, sizeof(truthBytes));

    CCNxCodecTlvEncoder *encoder = ccnxCodecTlvEncoder_Create();
    ccnxCodecTlvEncoder_Initialize(encoder);

    PARCBuffer *buffer = parcBuffer_WrapCString("brandywine");
    CCNxNameSegment *segment = ccnxNameSegment_CreateTypeValue(CCNxNameLabelType_NAME, buffer);

    CCNxName *name = ccnxName_Append(ccnxName_Create(), segment);
    ccnxNameSegment_Release(&segment);
    parcBuffer_Release(&buffer);

    ccnxCodecSchemaV1NameCodec_Encode(encoder, 0x1020, name);

    ccnxCodecTlvEncoder_Finalize(encoder);
    PARCBuffer *test = ccnxCodecTlvEncoder_CreateBuffer(encoder);

    if (!parcBuffer_Equals(truth, test)) {
        printf("Buffers do not match\n");
        printf("Excpected:\n");
        parcBuffer_Display(truth, 3);
        printf("Got:\n");
        parcBuffer_Display(test, 3);
        assertTrue(parcBuffer_Equals(truth, test), "Buffers do not match");
    }

    ccnxName_Release(&name);
    parcBuffer_Release(&test);
    ccnxCodecTlvEncoder_Destroy(&encoder);
    parcBuffer_Release(&truth);
}
Пример #2
0
void
parcJSONValue_Display(const PARCJSONValue *value, int indentation)
{
    parcDisplayIndented_PrintLine(indentation, "PARCJSONValue@%p {", value);
    if (value != NULL) {
        parcDisplayIndented_PrintLine(indentation + 1, ".type=%d", value->type);

        switch (value->type) {
            case PARCJSONValueType_Boolean:
                _displayBoolean(value, indentation + 1);
                break;
            case PARCJSONValueType_String:
                parcBuffer_Display(value->value.string, indentation + 1);
                break;
            case PARCJSONValueType_Number:
                _displayNumber(value, indentation + 1);
                break;
            case PARCJSONValueType_Array:
                parcJSONArray_Display(value->value.array, indentation + 1);
                break;
            case PARCJSONValueType_JSON:
                parcJSON_Display(value->value.object, indentation + 1);
                break;
            case PARCJSONValueType_Null:
                parcDisplayIndented_PrintLine(indentation + 1, ".value=null");
                break;
            default:
                trapIllegalValue(value->type, "Unknown PARCJSONValue type %d", value->type);
        }
    }
    parcDisplayIndented_PrintLine(indentation, "}");
}
LONGBOW_TEST_CASE(Local, _athenaLRUContentStore_ProcessMessage_StatHits)
{
    AthenaLRUContentStore *impl = _createLRUContentStore();

    CCNxName *name = ccnxName_CreateFromURI(CCNxNameAthena_ContentStore "/stat/hits");
    CCNxInterest *interest = ccnxInterest_CreateSimple(name);
    ccnxName_Release(&name);

    CCNxMetaMessage *message = ccnxMetaMessage_CreateFromInterest(interest);
    ccnxInterest_Release(&interest);

    CCNxMetaMessage *response = _athenaLRUContentStore_ProcessMessage(impl, message);

    assertNotNull(response, "Expected a response to ProcessMessage()");
    assertTrue(ccnxMetaMessage_IsContentObject(response), "Expected a content object");

    CCNxContentObject *content = ccnxMetaMessage_GetContentObject(response);

    PARCBuffer *payload = ccnxContentObject_GetPayload(content);
    parcBuffer_Display(payload, 0);

    ccnxMetaMessage_Release(&message);
    ccnxMetaMessage_Release(&response);
    _athenaLRUContentStore_Release((AthenaContentStoreImplementation *) &impl);
}
Пример #4
0
void
ccnxNameSegment_Display(const CCNxNameSegment *segment, int indentation)
{
    parcDisplayIndented_PrintLine(indentation, "CCNxNameSegment@%p {", segment);
    parcDisplayIndented_PrintLine(indentation + 1, "type=%d", segment->type);
    parcBuffer_Display(segment->value, indentation + 1);
    parcDisplayIndented_PrintLine(indentation, "}");
}
Пример #5
0
static void
dump(PARCSortedList *i)
{
    PARCIterator *iterator = parcSortedList_CreateIterator(i);
    while (parcIterator_HasNext(iterator)) {
        PARCBuffer *buffer = parcIterator_Next(iterator);
        parcBuffer_Display(buffer, 0);
    }

    parcIterator_Release(&iterator);
}