summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/components/cache/client-test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sca-cpp/trunk/components/cache/client-test.cpp')
-rw-r--r--sca-cpp/trunk/components/cache/client-test.cpp83
1 files changed, 37 insertions, 46 deletions
diff --git a/sca-cpp/trunk/components/cache/client-test.cpp b/sca-cpp/trunk/components/cache/client-test.cpp
index 63d1691f8b..5e9be6c14a 100644
--- a/sca-cpp/trunk/components/cache/client-test.cpp
+++ b/sca-cpp/trunk/components/cache/client-test.cpp
@@ -42,15 +42,15 @@ const string memocacheuri("http://localhost:8090/memocache");
const string partition1uri("http://localhost:8090/partitioner/a");
const string partition2uri("http://localhost:8090/partitioner/b");
-bool testCache(const string& uri) {
- http::CURLSession cs("", "", "", "", 0);
-
- const list<value> i = list<value>() + "content" + (list<value>() + "item"
- + (list<value>() + "name" + string("Apple"))
- + (list<value>() + "price" + string("$2.99")));
- const list<value> a = list<value>() + (list<value>() + "entry"
- + (list<value>() + "title" + string("item"))
- + (list<value>() + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"))
+const bool testCache(const string& uri) {
+ const http::CURLSession cs("", "", "", "", 0);
+
+ const list<value> i = nilListValue + "content" + (nilListValue + "item"
+ + (nilListValue + "name" + string("Apple"))
+ + (nilListValue + "price" + string("$2.99")));
+ const list<value> a = nilListValue + (nilListValue + "entry"
+ + (nilListValue + "title" + string("item"))
+ + (nilListValue + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"))
+ i);
const failable<value> id = http::post(a, uri, cs);
@@ -63,18 +63,18 @@ bool testCache(const string& uri) {
assert(content(val) == a);
}
- const list<value> j = list<value>() + "content" + (list<value>() + "item"
- + (list<value>() + "name" + string("Apple"))
- + (list<value>() + "price" + string("$3.55")));
- const list<value> b = list<value>() + (list<value>() + "entry"
- + (list<value>() + "title" + string("item"))
- + (list<value>() + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"))
+ const list<value> j = nilListValue + "content" + (nilListValue + "item"
+ + (nilListValue + "name" + string("Apple"))
+ + (nilListValue + "price" + string("$3.55")));
+ const list<value> b = nilListValue + (nilListValue + "entry"
+ + (nilListValue + "title" + string("item"))
+ + (nilListValue + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"))
+ j);
{
const failable<value> r = http::put(b, uri + p, cs);
assert(hasContent(r));
- assert(content(r) == value(true));
+ assert(content(r) == trueValue);
}
{
const failable<value> val = http::get(uri + p, cs);
@@ -84,7 +84,7 @@ bool testCache(const string& uri) {
{
const failable<value> r = http::del(uri + p, cs);
assert(hasContent(r));
- assert(content(r) == value(true));
+ assert(content(r) == trueValue);
}
{
const failable<value> val = http::get(uri + p, cs);
@@ -94,16 +94,16 @@ bool testCache(const string& uri) {
return true;
}
-bool testMemcache() {
+const bool testMemcache() {
return testCache(memcacheuri);
}
-bool testDatacache() {
+const bool testDatacache() {
return testCache(datacacheuri);
}
-bool testMemocache() {
- http::CURLSession cs("", "", "", "", 0);
+const bool testMemocache() {
+ const http::CURLSession cs("", "", "", "", 0);
const failable<value> res = http::evalExpr(mklist<value>(string("add"), 33, 22), memocacheuri, cs);
assert(hasContent(res));
@@ -116,8 +116,8 @@ bool testMemocache() {
return true;
}
-bool testPartitioner() {
- http::CURLSession cs("", "", "", "", 0);
+const bool testPartitioner() {
+ const http::CURLSession cs("", "", "", "", 0);
const failable<value> res1 = http::get(partition1uri, cs);
assert(hasContent(res1));
@@ -130,35 +130,26 @@ bool testPartitioner() {
return true;
}
-struct getLoop {
- const string path;
- const value entry;
- http::CURLSession& cs;
- getLoop(const string& path, const value& entry, http::CURLSession& cs) : path(path), entry(entry), cs(cs) {
- }
- const bool operator()() const {
- const failable<value> val = http::get(memcacheuri + path, cs);
- assert(hasContent(val));
- assert(content(val) == entry);
- return true;
- }
-};
-
-bool testGetPerf() {
- const list<value> i = list<value>() + "content" + (list<value>() + "item"
- + (list<value>() + "name" + string("Apple"))
- + (list<value>() + "price" + string("$4.55")));
- const list<value> a = list<value>() + (list<value>() + "entry"
- + (list<value>() + "title" + string("item"))
- + (list<value>() + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"))
+const bool testGetPerf() {
+ const list<value> i = nilListValue + "content" + (nilListValue + "item"
+ + (nilListValue + "name" + string("Apple"))
+ + (nilListValue + "price" + string("$4.55")));
+ const list<value> a = nilListValue + (nilListValue + "entry"
+ + (nilListValue + "title" + string("item"))
+ + (nilListValue + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"))
+ i);
- http::CURLSession cs("", "", "", "", 0);
+ const http::CURLSession cs("", "", "", "", 0);
const failable<value> id = http::post(a, memcacheuri, cs);
assert(hasContent(id));
const string p = path(content(id));
- const lambda<bool()> gl = getLoop(p, a, cs);
+ const blambda gl = [p, a, cs]() -> const bool {
+ const failable<value> val = http::get(memcacheuri + p, cs);
+ assert(hasContent(val));
+ assert(content(val) == a);
+ return true;
+ };
cout << "Cache get test " << time(gl, 5, 200) << " ms" << endl;
return true;