本文整理汇总了C++中Messenger::deleteResource方法的典型用法代码示例。如果您正苦于以下问题:C++ Messenger::deleteResource方法的具体用法?C++ Messenger::deleteResource怎么用?C++ Messenger::deleteResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Messenger
的用法示例。
在下文中一共展示了Messenger::deleteResource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: customCatalogTests
static void customCatalogTests(Node& node, TestRunner& tr)
{
resetTestEnvironment(node);
Messenger* messenger = node.getMessenger();
// generate the ware URLs that will be used throughout the test.
Url waresUrl;
waresUrl.format(
"%s/api/3.0/catalog/wares?nodeuser=%" PRIu64,
messenger->getSelfUrl(true).c_str(), TEST_USER_ID);
Url waresNonDefaultListUrl;
waresNonDefaultListUrl.format(
"%s/api/3.0/catalog/wares?nodeuser=%" PRIu64 "&id=%s&default=false",
messenger->getSelfUrl(true).c_str(), TEST_USER_ID, TEST_WARE_ID_2);
Url wareUrl;
wareUrl.format(
"%s/api/3.0/catalog/wares/%s?nodeuser=%" PRIu64,
messenger->getSelfUrl(true).c_str(), TEST_WARE_ID_2, TEST_USER_ID);
// generate the files URL that will be used to prime the medialibrary
Url filesUrl;
filesUrl.format("%s/api/3.2/medialibrary/files?nodeuser=%" PRIu64,
messenger->getSelfUrl(true).c_str(), TEST_USER_ID);
Url removeUrl;
removeUrl.format(
"%s/api/3.2/medialibrary/files/%s?nodeuser=%" PRIu64,
messenger->getSelfUrl(true).c_str(), TEST_FILE_ID_2, TEST_USER_ID);
// Create basic and detailed test ware with id=2
Ware basicWare2;
Ware detailedWare2;
{
basicWare2["id"] = TEST_WARE_ID_2;
basicWare2["description"] =
"This ware was added by test-services-customcatalog";
detailedWare2 = basicWare2.clone();
detailedWare2["mediaId"] = 2;
detailedWare2["fileInfos"]->setType(Array);
FileInfo fi = detailedWare2["fileInfos"]->append();
fi["id"] = TEST_FILE_ID_2;
fi["mediaId"] = 2;
File file((sTestDataDir + TEST_FILENAME_2).c_str());
fi["extension"] = file->getExtension() + 1;
fi["contentType"] = "audio/mpeg";
fi["contentSize"] = TEST_CONTENT_SIZE_2;
fi["size"] = (uint64_t)file->getLength();
fi["path"] = file->getAbsolutePath();
detailedWare2["payees"]->setType(Array);
Payee p1 = detailedWare2["payees"]->append();
Payee p2 = detailedWare2["payees"]->append();
p1["id"] = 900;
p1["amountType"] = PAYEE_AMOUNT_TYPE_FLATFEE;
p1["amount"] = "0.10";
p1["description"] = "This payee is for media ID 2";
p2["id"] = 900;
p2["amountType"] = PAYEE_AMOUNT_TYPE_PTOTAL;
p2["percentage"] = "0.10";
p2["description"] = "This payee is for media ID 2";
}
// remove any previous files from the media library
messenger->deleteResource(&removeUrl, NULL, node.getDefaultUserId());
// pass even if there is an exception - this is meant to just clear any
// previous entries in the medialibrary database if they existed.
Exception::clear();
tr.group("customcatalog");
tr.test("add file to medialibrary (valid)");
{
DynamicObject in;
DynamicObject out;
// create a FileInfo object
string normalizedPath;
File::normalizePath(
(sTestDataDir + TEST_FILENAME_2).c_str(), normalizedPath);
out["path"] = normalizedPath.c_str();
out["mediaId"] = 2;
// prepare event waiter
EventWaiter ew(node.getEventController());
ew.start("bitmunk.medialibrary.File.updated");
ew.start("bitmunk.medialibrary.File.exception");
// add the file to the media library
assertNoException(
messenger->post(&filesUrl, &out, &in, node.getDefaultUserId()));
// wait for file ID set event
assert(ew.waitForEvent(5*1000));
// ensure it has an exception
Event e = ew.popEvent();
//dumpDynamicObject(e);
//.........这里部分代码省略.........
示例2: interactiveCustomCatalogTests
static void interactiveCustomCatalogTests(Node& node, TestRunner& tr)
{
Messenger* messenger = node.getMessenger();
tr.group("customcatalog+listing updater");
// generate the ware URLs that will be used throughout the test.
Url waresUrl;
waresUrl.format("%s/api/3.0/catalog/wares?nodeuser=%" PRIu64,
messenger->getSelfUrl(true).c_str(), TEST_USER_ID);
Url wareUrl;
wareUrl.format("%s/api/3.0/catalog/wares/%s?nodeuser=%" PRIu64,
messenger->getSelfUrl(true).c_str(), TEST_WARE_ID_2, TEST_USER_ID);
// generate the files URL that will be used to prime the medialibrary
Url filesUrl;
filesUrl.format("%s/api/3.2/medialibrary/files?nodeuser=%" PRIu64,
messenger->getSelfUrl(true).c_str(), TEST_USER_ID);
Url removeUrl;
removeUrl.format(
"%s/api/3.2/medialibrary/files/%s?nodeuser=%" PRIu64,
messenger->getSelfUrl(true).c_str(), TEST_FILE_ID_2, TEST_USER_ID);
// remove any previous files from the media library
messenger->deleteResource(&removeUrl, NULL, node.getDefaultUserId());
// pass even if there is an exception - this is meant to just clear any
// previous entries in the medialibrary database if they existed.
Exception::clear();
tr.test("add file to medialibrary (valid)");
{
DynamicObject in;
DynamicObject out;
// create a FileInfo object
string normalizedPath;
File::normalizePath(
(sTestDataDir + TEST_FILENAME_2).c_str(), normalizedPath);
out["path"] = normalizedPath.c_str();
out["mediaId"] = 2;
// prepare event waiter
EventWaiter ew(node.getEventController());
ew.start("bitmunk.medialibrary.File.updated");
ew.start("bitmunk.medialibrary.File.exception");
// add the file to the media library
assertNoException(
messenger->post(&filesUrl, &out, &in, node.getDefaultUserId()));
// wait for file ID set event
assert(ew.waitForEvent(5*1000));
// ensure it has an exception
Event e = ew.popEvent();
//dumpDynamicObject(e);
if(e["details"]->hasMember("exception"))
{
ExceptionRef ex = Exception::convertToException(
e["details"]["exception"]);
Exception::set(ex);
}
}
tr.passIfNoException();
tr.test("add ware without payee-scheme (valid)");
{
DynamicObject in;
DynamicObject out;
// create the outgoing ware object
FileInfo fi;
fi["id"] = TEST_FILE_ID_2;
out["id"] = TEST_WARE_ID_2;
out["mediaId"] = 2;
out["description"] = "This ware was added by test-services-customcatalog";
out["fileInfo"] = fi;
out["payees"]->setType(Array);
Payee p1 = out["payees"]->append();
Payee p2 = out["payees"]->append();
p1["id"] = 900;
p1["amountType"] = PAYEE_AMOUNT_TYPE_FLATFEE;
p1["amount"] = "0.10";
p1["description"] = "This payee is for media ID 2";
p2["id"] = 900;
p2["amountType"] = PAYEE_AMOUNT_TYPE_PTOTAL;
p2["percentage"] = "0.10";
p2["description"] = "This payee is for media ID 2";
// add the ware to the custom catalog
messenger->post(&waresUrl, &out, &in, node.getDefaultUserId());
}
tr.passIfNoException();
printf("\nWaiting for server info to update...\n");
Thread::sleep(2*1000);
//.........这里部分代码省略.........