summaryrefslogtreecommitdiffstats
path: root/cpp/sca/test
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2009-10-18 22:25:08 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2009-10-18 22:25:08 +0000
commitf87b9f1e48df02c26e0bbe3f8f1664c2b0862e52 (patch)
tree4d0ee23a5b5c7878b5b4f2131bc17f9765b93313 /cpp/sca/test
parent6dd3610df5854ef9af7e5e2907b2f4065d69075d (diff)
Some fixes to the JSON and httpd support. Added support for Atom. Adjusted store test.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@826545 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/sca/test')
-rw-r--r--cpp/sca/test/store-script/htdocs/store.html21
-rw-r--r--cpp/sca/test/store-script/htdocs/store.js2
-rw-r--r--cpp/sca/test/store-script/store-script-test.cpp34
-rw-r--r--cpp/sca/test/store-script/store.scm14
4 files changed, 51 insertions, 20 deletions
diff --git a/cpp/sca/test/store-script/htdocs/store.html b/cpp/sca/test/store-script/htdocs/store.html
index 42f58ab40c..4a2c65d07c 100644
--- a/cpp/sca/test/store-script/htdocs/store.html
+++ b/cpp/sca/test/store-script/htdocs/store.html
@@ -31,7 +31,7 @@
//var shoppingCart = new tuscany.sca.Reference("shoppingCart");
//@Reference
- //var shoppingTotal = new tuscany.sca.Reference("shoppingTotal");
+ var shoppingTotal = new tuscany.sca.Reference("shoppingTotal");
var catalogItems;
@@ -42,13 +42,16 @@
}
var catalog = "";
- for (var i=0; i<items.length; i++) {
- var item = items[i].name + ' - ' + items[i].price;
- catalog += '<input name="items" type="checkbox" value="' +
- item + '">' + item + ' <br>';
- }
- document.getElementById('catalog').innerHTML=catalog;
- catalogItems = items;
+ for (var i=0; i<items.length; i++) {
+ var item = items[i].name + ' - ' + items[i].price;
+ catalog += '<input name="items" type="checkbox" value="' +
+ item + '">' + item + ' <br>';
+ }
+ document.getElementById('catalog').innerHTML=catalog;
+ catalogItems = items;
+
+ // TEMP
+ shoppingTotal.getTotal(shoppingTotal_getTotalResponse);
}
function shoppingCart_getResponse(feed) {
@@ -65,7 +68,7 @@
if (entries.length != 0) {
try {
- //shoppingTotal.getTotal(shoppingTotal_getTotalResponse);
+ shoppingTotal.getTotal(shoppingTotal_getTotalResponse);
}
catch(e){
alert(e);
diff --git a/cpp/sca/test/store-script/htdocs/store.js b/cpp/sca/test/store-script/htdocs/store.js
index 47af7c01f7..526d36790a 100644
--- a/cpp/sca/test/store-script/htdocs/store.js
+++ b/cpp/sca/test/store-script/htdocs/store.js
@@ -652,7 +652,7 @@ tuscany.sca.Property = function (name) {
tuscany.sca.referenceMap = new Object();
tuscany.sca.referenceMap.catalog = new JSONRpcClient("/Catalog").Service;
//tuscany.sca.referenceMap.shoppingCart = new AtomClient("/ShoppingCart/Cart");
-//tuscany.sca.referenceMap.shoppingTotal = new JSONRpcClient("/ShoppingCart/Total").Service;
+tuscany.sca.referenceMap.shoppingTotal = new JSONRpcClient("/ShoppingCart/Total").Service;
tuscany.sca.Reference = function (name) {
return tuscany.sca.referenceMap[name];
}
diff --git a/cpp/sca/test/store-script/store-script-test.cpp b/cpp/sca/test/store-script/store-script-test.cpp
index 95e7ba0929..8eac2f7b8b 100644
--- a/cpp/sca/test/store-script/store-script-test.cpp
+++ b/cpp/sca/test/store-script/store-script-test.cpp
@@ -52,19 +52,35 @@ const tuscany::value evalLoop(std::istream& is, const tuscany::value& req, tusca
}
bool testEval() {
- std::ifstream is("store.scm", std::ios_base::in);
- std::ostringstream os;
+ {
+ std::ifstream is("store.scm", std::ios_base::in);
+ std::ostringstream os;
+
+ tuscany::setupEvalOut(os);
+ tuscany::Env globalEnv = tuscany::setupEnvironment();
+
+ const tuscany::value req(tuscany::mklist<tuscany::value>("storeui_service", std::string("getcatalog")));
+ const tuscany::value res = evalLoop(is, req, globalEnv);
+
+ std::ostringstream rs;
+ rs << res;
+ assert(contains(rs.str(), "List::(List::(List::(Symbol::name, (String::\"apple\", ())), (List::(Symbol::currency, (String::\"USD\", ())), (List::(Symbol::symbol, (String::\"$\", ())), (List::(Symbol::price, (Number::2.99, ())), ())))), (List::(List::(Symbol::name, (String::\"orange\", ())), (List::(Symbol::currency, (String::\"USD\", ())), (List::(Symbol::symbol, (String::\"$\", ())), (List::(Symbol::price, (Number::3.55, ())), ())))), (List::(List::(Symbol::name, (String::\"pear\", ())), (List::(Symbol::currency, (String::\"USD\", ())), (List::(Symbol::symbol, (String::\"$\", ())), (List::(Symbol::price, (Number::1.55, ())), ())))), ())))"));
+ }
- tuscany::setupEvalOut(os);
- tuscany::Env globalEnv = tuscany::setupEnvironment();
+ {
+ std::ifstream is("store.scm", std::ios_base::in);
+ std::ostringstream os;
- const tuscany::value req(tuscany::makeList<tuscany::value>("storeui_service", std::string("getcatalog")));
- const tuscany::value res = evalLoop(is, req, globalEnv);
+ tuscany::setupEvalOut(os);
+ tuscany::Env globalEnv = tuscany::setupEnvironment();
- std::ostringstream rs;
- rs << res;
- assert(contains(rs.str(), "List::(List::(List::(Symbol::name, (String::\"apple\", ())), (List::(Symbol::currency, (String::\"USD\", ())), (List::(Symbol::symbol, (String::\"$\", ())), (List::(Symbol::price, (Number::2.99, ())), ())))), (List::(List::(Symbol::name, (String::\"orange\", ())), (List::(Symbol::currency, (String::\"USD\", ())), (List::(Symbol::symbol, (String::\"$\", ())), (List::(Symbol::price, (Number::3.55, ())), ())))), (List::(List::(Symbol::name, (String::\"pear\", ())), (List::(Symbol::currency, (String::\"USD\", ())), (List::(Symbol::symbol, (String::\"$\", ())), (List::(Symbol::price, (Number::1.55, ())), ())))), ())))"));
+ const tuscany::value req(tuscany::mklist<tuscany::value>("storeui_service", std::string("gettotal")));
+ const tuscany::value res = evalLoop(is, req, globalEnv);
+ std::ostringstream rs;
+ rs << res;
+ assert(contains(rs.str(), "Number::10"));
+ }
return true;
}
diff --git a/cpp/sca/test/store-script/store.scm b/cpp/sca/test/store-script/store.scm
index 5bda81ca69..323a2ca304 100644
--- a/cpp/sca/test/store-script/store.scm
+++ b/cpp/sca/test/store-script/store.scm
@@ -54,10 +54,15 @@
content
)
+(define (cart_gettotal)
+ 10.0
+)
+
(define (cart_impl op args)
(cond
((equal? op "post") (apply cart_post args))
((equal? op "getall") (apply cart_getall args))
+ ((equal? op "gettotal") (apply cart_gettotal args))
)
)
@@ -75,11 +80,16 @@
(catalog "get")
)
+(define (storeui_gettotal cart)
+ (cart "gettotal")
+)
+
(define (storeui_impl cart catalog op args)
(cond
((equal? op "post") (apply storeui_post (cons cart args)))
((equal? op "getall") (apply storeui_getcart (cons cart args)))
((equal? op "getcatalog") (apply storeui_getcatalog (cons catalog args)))
+ ((equal? op "gettotal") (apply storeui_gettotal (cons cart args)))
)
)
@@ -96,9 +106,11 @@
(define apple (car catalog))
(define full (storeui_service "post" empty apple))
(display (storeui_service "getall" full))
+(display (storeui_service "gettotal"))
(; "Store UI JSON-RPC interop test case")
-(define (system.listMethods) (list "Service.get"))
+(define (system.listMethods) (list "Service.get" "Service.getTotal"))
(define (Service.get) (storeui_service "getcatalog"))
+(define (Service.getTotal) (storeui_service "gettotal"))