LONGBOW_TEST_CASE(Global, getMatchByName) { AthenaLRUContentStoreConfig config; config.capacityInMB = 10; AthenaContentStore *store = athenaContentStore_Create(&AthenaContentStore_LRUImplementation, &config); char *lci = "lci:/cakes/and/pies"; PARCClock *clock = parcClock_Wallclock(); CCNxName *truthName = ccnxName_CreateFromURI(lci); CCNxContentObject *truthObject = ccnxContentObject_CreateWithDataPayload(truthName, NULL); ccnxContentObject_SetExpiryTime(truthObject, parcClock_GetTime(clock) + 100); ccnxName_Release(&truthName); athenaContentStore_PutContentObject(store, truthObject); CCNxName *testName = ccnxName_CreateFromURI(lci); CCNxInterest *interest = ccnxInterest_CreateSimple(testName); ccnxName_Release(&testName); //athena_EncodeMessage(interest); CCNxContentObject *testObject = athenaContentStore_GetMatch(store, interest); ccnxInterest_Release(&interest); // TODO: match on other than name! assertTrue(ccnxContentObject_Equals(truthObject, testObject), "Expected to get the same ContentObject back"); assertTrue(truthObject == testObject, "Expected the same pointer back"); athenaContentStore_Release(&store); ccnxContentObject_Release(&truthObject); parcClock_Release(&clock); }
LONGBOW_TEST_CASE(Global, removeMatch) { AthenaLRUContentStoreConfig config; config.capacityInMB = 10; AthenaContentStore *store = athenaContentStore_Create(&AthenaContentStore_LRUImplementation, &config); PARCClock *clock = parcClock_Wallclock(); char *lci = "lci:/cakes/and/pies"; CCNxName *origName = ccnxName_CreateFromURI(lci); CCNxContentObject *contentObject = ccnxContentObject_CreateWithDataPayload(origName, NULL); ccnxContentObject_SetExpiryTime(contentObject, parcClock_GetTime(clock) + 100); ccnxName_Release(&origName); athenaContentStore_PutContentObject(store, contentObject); ccnxContentObject_Release(&contentObject); CCNxName *testName = ccnxName_CreateFromURI(lci); bool status = athenaContentStore_RemoveMatch(store, testName, NULL, NULL); // TODO: match on other than name! assertTrue(status, "Expected to remove the contentobject we had"); ccnxName_Release(&testName); parcClock_Release(&clock); athenaContentStore_Release(&store); }
static void _athenaDestroy(Athena **athena) { ccnxName_Release(&((*athena)->athenaName)); athenaTransportLinkAdapter_Destroy(&((*athena)->athenaTransportLinkAdapter)); athenaContentStore_Release(&((*athena)->athenaContentStore)); athenaPIT_Release(&((*athena)->athenaPIT)); athenaFIB_Release(&((*athena)->athenaFIB)); parcLog_Release(&((*athena)->log)); }
LONGBOW_TEST_CASE(Global, createRelease) { AthenaLRUContentStoreConfig config; config.capacityInMB = 10; AthenaContentStore *store = athenaContentStore_Create(&AthenaContentStore_LRUImplementation, &config); athenaContentStore_Release(&store); }
LONGBOW_TEST_CASE(EmptyImplementation, booleanApiFunctions) { AthenaContentStore *store = athenaContentStore_Create(&EmptyContentStoreImplementation, NULL); CCNxContentObject *contentObject = _createContentObject("lci:/dogs/are/better/than/cats", 10, NULL); CCNxName *name = ccnxName_CreateFromURI("lci:/pie/is/always/good"); CCNxInterest *interest = ccnxInterest_CreateSimple(name); //athena_EncodeMessage(interest); AthenaContentStore *ref = athenaContentStore_Acquire(store); athenaContentStore_Release(&ref); assertFalse(athenaContentStore_PutContentObject(store, contentObject), "Expected false from PutContentObject"); assertFalse(athenaContentStore_GetMatch(store, interest), "Expected false from GetMatch"); assertFalse(athenaContentStore_SetCapacity(store, 1), "Expected false from SetCapacity"); assertFalse(athenaContentStore_RemoveMatch(store, name, NULL, NULL), "Expected false from RemoveMatch"); ccnxName_Release(&name); ccnxInterest_Release(&interest); ccnxContentObject_Release(&contentObject); athenaContentStore_Release(&store); }
LONGBOW_TEST_CASE(EmptyImplementation, apiFunctions) { AthenaContentStore *store = athenaContentStore_Create(&EmptyContentStoreImplementation, NULL); CCNxName *name = ccnxName_CreateFromURI("lci:/pie/is/always/good"); CCNxInterest *interest = ccnxInterest_CreateSimple(name); athena_EncodeMessage(interest); assertNull(athenaContentStore_ProcessMessage(store, interest), "Expected a NULL response."); ccnxName_Release(&name); ccnxInterest_Release(&interest); athenaContentStore_Release(&store); }
LONGBOW_TEST_CASE(Global, setGetCapacity) { AthenaLRUContentStoreConfig config; config.capacityInMB = 10; AthenaContentStore *store = athenaContentStore_Create(&AthenaContentStore_LRUImplementation, &config); size_t capacity = athenaContentStore_GetCapacity(store); assertTrue(capacity = config.capacityInMB, "Expected the same capacity as we specified at init"); size_t newCapacity = 20; athenaContentStore_SetCapacity(store, newCapacity); assertTrue(newCapacity == athenaContentStore_GetCapacity(store), "Expected to see the new capacity"); athenaContentStore_Release(&store); }
LONGBOW_TEST_CASE(Global, putContent) { AthenaLRUContentStoreConfig config; config.capacityInMB = 10; AthenaContentStore *store = athenaContentStore_Create(&AthenaContentStore_LRUImplementation, &config); PARCBuffer *payload = parcBuffer_WrapCString("this is a payload"); CCNxContentObject *contentObject = _createContentObject("lci:/cakes/and/pies", 0, payload); parcBuffer_Release(&payload); ccnxContentObject_SetExpiryTime(contentObject, 100); athenaContentStore_PutContentObject(store, contentObject); athenaContentStore_Release(&store); ccnxContentObject_Release(&contentObject); }
LONGBOW_TEST_CASE(Global, processMessage) { AthenaLRUContentStoreConfig config; config.capacityInMB = 10; AthenaContentStore *store = athenaContentStore_Create(&AthenaContentStore_LRUImplementation, &config); CCNxName *name = ccnxName_CreateFromURI(CCNxNameAthena_ContentStore "/stat/size"); CCNxInterest *interest = ccnxInterest_CreateSimple(name); CCNxMetaMessage *message = ccnxMetaMessage_CreateFromInterest(interest); athena_EncodeMessage(message); CCNxMetaMessage *result = athenaContentStore_ProcessMessage(store, message); assertNotNull(result, "Expected a response from the store"); ccnxMetaMessage_Release(&result); ccnxMetaMessage_Release(&message); ccnxInterest_Release(&interest); ccnxName_Release(&name); athenaContentStore_Release(&store); }
static void _emptyImplTeardown(AthenaContentStore *store) { athenaContentStore_Release(&store); }