summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-03-06 09:23:27 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-03-06 09:23:27 +0000
commita84a0e4d169efbc78b169aea3ab422182f156a41 (patch)
treea253d521d452a35ba51b5cd1300e1d482c3291c2 /sca-cpp/trunk
parentf59b38e4887e7ea04cc82bd4ca41ec2766a4ea6b (diff)
Minor code cleanup, refactored some ATOM data conversion functions, simplified client test cases.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@919720 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk')
-rw-r--r--sca-cpp/trunk/modules/atom/atom-test.cpp8
-rw-r--r--sca-cpp/trunk/modules/atom/atom.hpp14
-rw-r--r--sca-cpp/trunk/modules/http/curl.hpp2
-rw-r--r--sca-cpp/trunk/modules/java/client-test.cpp9
-rw-r--r--sca-cpp/trunk/modules/python/client-test.cpp9
-rw-r--r--sca-cpp/trunk/modules/server/client-test.cpp9
-rw-r--r--sca-cpp/trunk/modules/server/client-test.hpp14
-rw-r--r--sca-cpp/trunk/modules/server/mod-eval.hpp4
-rw-r--r--sca-cpp/trunk/modules/wsgi/client-test.cpp10
9 files changed, 28 insertions, 51 deletions
diff --git a/sca-cpp/trunk/modules/atom/atom-test.cpp b/sca-cpp/trunk/modules/atom/atom-test.cpp
index 560c383a23..316e8b44db 100644
--- a/sca-cpp/trunk/modules/atom/atom-test.cpp
+++ b/sca-cpp/trunk/modules/atom/atom-test.cpp
@@ -80,13 +80,13 @@ bool testEntry() {
assert(str(os) == itemEntry);
}
{
- const list<value> a = content(readEntry(mklist(itemEntry)));
+ const list<value> a = content(readATOMEntry(mklist(itemEntry)));
ostringstream os;
writeATOMEntry<ostream*>(writer, &os, a);
assert(str(os) == itemEntry);
}
{
- const list<value> a = content(readEntry(mklist(incompleteEntry)));
+ const list<value> a = content(readATOMEntry(mklist(incompleteEntry)));
ostringstream os;
writeATOMEntry<ostream*>(writer, &os, a);
assert(str(os) == completedEntry);
@@ -133,7 +133,7 @@ bool testFeed() {
assert(str(os) == emptyFeed);
}
{
- const list<value> a = content(readFeed(mklist(emptyFeed)));
+ const list<value> a = content(readATOMFeed(mklist(emptyFeed)));
ostringstream os;
writeATOMFeed<ostream*>(writer, &os, a);
assert(str(os) == emptyFeed);
@@ -169,7 +169,7 @@ bool testFeed() {
assert(str(os) == itemFeed);
}
{
- const list<value> a = content(readFeed(mklist(itemFeed)));
+ const list<value> a = content(readATOMFeed(mklist(itemFeed)));
ostringstream os;
writeATOMFeed<ostream*>(writer, &os, a);
assert(str(os) == itemFeed);
diff --git a/sca-cpp/trunk/modules/atom/atom.hpp b/sca-cpp/trunk/modules/atom/atom.hpp
index 4dbf7c7728..fadb482e0d 100644
--- a/sca-cpp/trunk/modules/atom/atom.hpp
+++ b/sca-cpp/trunk/modules/atom/atom.hpp
@@ -38,7 +38,7 @@ namespace atom {
/**
* Convert a list of elements to a list of values representing an ATOM entry.
*/
-const list<value> entryValues(const list<value>& e) {
+const list<value> entryElementsToValues(const list<value>& e) {
const list<value> lt = filter<value>(selector(mklist<value>(element, "title")), e);
const value t = isNil(lt)? value(emptyString) : elementValue(car(lt));
const list<value> li = filter<value>(selector(mklist<value>(element, "id")), e);
@@ -50,20 +50,20 @@ const list<value> entryValues(const list<value>& e) {
/**
* Convert a list of elements to a list of values representing ATOM entries.
*/
-const list<value> entriesValues(const list<value>& e) {
+const list<value> entriesElementsToValues(const list<value>& e) {
if (isNil(e))
return e;
- return cons<value>(entryValues(car(e)), entriesValues(cdr(e)));
+ return cons<value>(entryElementsToValues(car(e)), entriesElementsToValues(cdr(e)));
}
/**
* Convert a list of strings to a list of values representing an ATOM entry.
*/
-const failable<list<value> > readEntry(const list<string>& ilist) {
+const failable<list<value> > readATOMEntry(const list<string>& ilist) {
const list<value> e = readXML(ilist);
if (isNil(e))
return mkfailure<list<value> >("Empty entry");
- return entryValues(car(e));
+ return entryElementsToValues(car(e));
}
/**
@@ -77,7 +77,7 @@ const value entryValue(const list<value>& e) {
/**
* Convert a list of strings to a list of values representing an ATOM feed.
*/
-const failable<list<value> > readFeed(const list<string>& ilist) {
+const failable<list<value> > readATOMFeed(const list<string>& ilist) {
const list<value> f = readXML(ilist);
if (isNil(f))
return mkfailure<list<value> >("Empty feed");
@@ -86,7 +86,7 @@ const failable<list<value> > readFeed(const list<string>& ilist) {
const list<value> e = filter<value>(selector(mklist<value>(element, "entry")), car(f));
if (isNil(e))
return mklist<value>(elementValue(car(t)), elementValue(car(i)));
- return cons<value>(elementValue(car(t)), cons(elementValue(car(i)), entriesValues(e)));
+ return cons<value>(elementValue(car(t)), cons(elementValue(car(i)), entriesElementsToValues(e)));
}
/**
diff --git a/sca-cpp/trunk/modules/http/curl.hpp b/sca-cpp/trunk/modules/http/curl.hpp
index f2c9458f42..ec152dd8f0 100644
--- a/sca-cpp/trunk/modules/http/curl.hpp
+++ b/sca-cpp/trunk/modules/http/curl.hpp
@@ -303,7 +303,7 @@ const failable<value> get(const string& url, const CURLSession& ch) {
const string ct(content(contentType(car(content(res)))));
if (ct == "application/atom+xml;type=entry") {
- const value val(atom::entryValue(content(atom::readEntry(ls))));
+ const value val(atom::entryValue(content(atom::readATOMEntry(ls))));
debug(val, "http::get::result");
return val;
}
diff --git a/sca-cpp/trunk/modules/java/client-test.cpp b/sca-cpp/trunk/modules/java/client-test.cpp
index d4a4d65ab4..d06c57721e 100644
--- a/sca-cpp/trunk/modules/java/client-test.cpp
+++ b/sca-cpp/trunk/modules/java/client-test.cpp
@@ -27,16 +27,9 @@
#include "string.hpp"
#include "../server/client-test.hpp"
-namespace tuscany {
-namespace server {
-
-string testURI = "http://localhost:8090/java";
-
-}
-}
-
int main() {
tuscany::cout << "Testing..." << tuscany::endl;
+ tuscany::server::testURI = "http://localhost:8090/java";
tuscany::server::testServer();
diff --git a/sca-cpp/trunk/modules/python/client-test.cpp b/sca-cpp/trunk/modules/python/client-test.cpp
index b070f6a798..21fda53e05 100644
--- a/sca-cpp/trunk/modules/python/client-test.cpp
+++ b/sca-cpp/trunk/modules/python/client-test.cpp
@@ -27,16 +27,9 @@
#include "string.hpp"
#include "../server/client-test.hpp"
-namespace tuscany {
-namespace server {
-
-string testURI = "http://localhost:8090/python";
-
-}
-}
-
int main() {
tuscany::cout << "Testing..." << tuscany::endl;
+ tuscany::server::testURI = "http://localhost:8090/python";
tuscany::server::testServer();
diff --git a/sca-cpp/trunk/modules/server/client-test.cpp b/sca-cpp/trunk/modules/server/client-test.cpp
index 3bc8aa7d10..5de7ab6e7b 100644
--- a/sca-cpp/trunk/modules/server/client-test.cpp
+++ b/sca-cpp/trunk/modules/server/client-test.cpp
@@ -27,16 +27,9 @@
#include "string.hpp"
#include "client-test.hpp"
-namespace tuscany {
-namespace server {
-
-string testURI = "http://localhost:8090/test";
-
-}
-}
-
int main() {
tuscany::cout << "Testing..." << tuscany::endl;
+ tuscany::server::testURI = "http://localhost:8090/test";
tuscany::server::testServer();
diff --git a/sca-cpp/trunk/modules/server/client-test.hpp b/sca-cpp/trunk/modules/server/client-test.hpp
index 651a9016b2..91dfe89499 100644
--- a/sca-cpp/trunk/modules/server/client-test.hpp
+++ b/sca-cpp/trunk/modules/server/client-test.hpp
@@ -36,7 +36,8 @@
namespace tuscany {
namespace server {
-extern string testURI;
+string testURI = "http://localhost:8090/test";
+bool testBlobs = true;
ostream* curlWriter(const string& s, ostream* os) {
(*os) << s;
@@ -50,7 +51,7 @@ const bool testGet() {
ostringstream os;
const failable<list<ostream*> > r = http::get<ostream*>(curlWriter, &os, "http://localhost:8090", ch);
assert(hasContent(r));
- assert(contains(str(os), "HTTP/1.1 200 OK"));
+ assert(contains(str(os), "HTTP/1.1 200 OK") || contains(str(os), "HTTP/1.0 200 OK"));
assert(contains(str(os), "It works"));
}
{
@@ -121,8 +122,11 @@ const bool testEvalPerf() {
http::CURLSession ch;
const lambda<bool()> el = evalLoop(testURI, ch);
cout << "JSON-RPC eval echo test " << time(el, 5, 200) << " ms" << endl;
- const lambda<bool()> bel = blobEvalLoop(testURI, ch);
- cout << "JSON-RPC eval blob test " << time(bel, 5, 200) << " ms" << endl;
+
+ if (testBlobs) {
+ const lambda<bool()> bel = blobEvalLoop(testURI, ch);
+ cout << "JSON-RPC eval blob test " << time(bel, 5, 200) << " ms" << endl;
+ }
return true;
}
@@ -176,7 +180,7 @@ const bool testPostPerf() {
const lambda<bool()> pl = postLoop(testURI, val, ch);
cout << "ATOMPub POST small test " << time(pl, 5, 200) << " ms" << endl;
}
- {
+ if (testBlobs) {
const list<value> i = list<value>()
+ (list<value>() + "name" + string("Apple"))
+ (list<value>() + "blob1" + blob)
diff --git a/sca-cpp/trunk/modules/server/mod-eval.hpp b/sca-cpp/trunk/modules/server/mod-eval.hpp
index f319942f8d..a5efc775fc 100644
--- a/sca-cpp/trunk/modules/server/mod-eval.hpp
+++ b/sca-cpp/trunk/modules/server/mod-eval.hpp
@@ -166,7 +166,7 @@ const failable<int> post(request_rec* r, const lambda<value(const list<value>&)>
return rc;
const list<string> ls = httpd::read(r);
debug(ls, "modeval::post::input");
- const value entry = atom::entryValue(content(atom::readEntry(ls)));
+ const value entry = atom::entryValue(content(atom::readATOMEntry(ls)));
// Evaluate the POST expression
const failable<value> val = failableResult(impl(cons<value>("post", mklist<value>(cddr(path), entry))));
@@ -201,7 +201,7 @@ const failable<int> put(request_rec* r, const lambda<value(const list<value>&)>&
return rc;
const list<string> ls = httpd::read(r);
debug(ls, "modeval::put::input");
- const value entry = atom::entryValue(content(atom::readEntry(ls)));
+ const value entry = atom::entryValue(content(atom::readATOMEntry(ls)));
// Evaluate the PUT expression and update the corresponding resource
const failable<value> val = failableResult(impl(cons<value>("put", mklist<value>(cddr(path), entry))));
diff --git a/sca-cpp/trunk/modules/wsgi/client-test.cpp b/sca-cpp/trunk/modules/wsgi/client-test.cpp
index 325223d9ee..60241991a5 100644
--- a/sca-cpp/trunk/modules/wsgi/client-test.cpp
+++ b/sca-cpp/trunk/modules/wsgi/client-test.cpp
@@ -27,16 +27,10 @@
#include "string.hpp"
#include "../server/client-test.hpp"
-namespace tuscany {
-namespace server {
-
-string testURI = "http://localhost:8090/wsgi";
-
-}
-}
-
int main() {
tuscany::cout << "Testing..." << tuscany::endl;
+ tuscany::server::testURI = "http://localhost:8090/wsgi";
+ tuscany::server::testBlobs = false;
tuscany::server::testServer();