summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/test
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-01-11 08:29:17 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-01-11 08:29:17 +0000
commit8015f0d53da53876b65fdcdc712f1dc92835a9b1 (patch)
tree4cffc808317d16435c19289bd2a14d88a357f088 /sca-cpp/trunk/test
parent11c57b87a39a30904cdf24ef81c770e8f17096a1 (diff)
Minor fixes to server and python evaluator to get python store working. Some changes to python and scheme store test cases to simplify them a bit and make them consistent. Enabled a few more server test combinations.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@897785 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--sca-cpp/trunk/test/store-python/Makefile.am2
-rw-r--r--sca-cpp/trunk/test/store-python/currency-converter.py10
-rw-r--r--sca-cpp/trunk/test/store-python/fruits-catalog.py10
-rw-r--r--sca-cpp/trunk/test/store-python/htdocs/store.html4
-rwxr-xr-xsca-cpp/trunk/test/store-python/server-test (renamed from sca-cpp/trunk/test/store-python/store-composite-test)0
-rw-r--r--sca-cpp/trunk/test/store-python/shopping-cart.py88
-rw-r--r--sca-cpp/trunk/test/store-python/store.py7
-rw-r--r--sca-cpp/trunk/test/store-scheme/Makefile.am10
-rw-r--r--sca-cpp/trunk/test/store-scheme/fruits-catalog.scm3
-rw-r--r--sca-cpp/trunk/test/store-scheme/htdocs/store.html4
-rw-r--r--sca-cpp/trunk/test/store-scheme/script-test.cpp (renamed from sca-cpp/trunk/test/store-scheme/store-script-test.cpp)6
-rw-r--r--sca-cpp/trunk/test/store-scheme/script-test.scm (renamed from sca-cpp/trunk/test/store-scheme/store-script-test.scm)26
-rwxr-xr-xsca-cpp/trunk/test/store-scheme/server-test (renamed from sca-cpp/trunk/test/store-scheme/store-composite-test)0
-rw-r--r--sca-cpp/trunk/test/store-scheme/shopping-cart.scm3
-rw-r--r--sca-cpp/trunk/test/store-scheme/store.scm4
15 files changed, 64 insertions, 113 deletions
diff --git a/sca-cpp/trunk/test/store-python/Makefile.am b/sca-cpp/trunk/test/store-python/Makefile.am
index daefd9a405..345e58d544 100644
--- a/sca-cpp/trunk/test/store-python/Makefile.am
+++ b/sca-cpp/trunk/test/store-python/Makefile.am
@@ -15,5 +15,5 @@
# specific language governing permissions and limitations
# under the License.
-TESTS = store-composite-test
+TESTS = server-test
diff --git a/sca-cpp/trunk/test/store-python/currency-converter.py b/sca-cpp/trunk/test/store-python/currency-converter.py
index 1ee39b63f3..61d3ae42ac 100644
--- a/sca-cpp/trunk/test/store-python/currency-converter.py
+++ b/sca-cpp/trunk/test/store-python/currency-converter.py
@@ -1,14 +1,12 @@
# Currency converter implementation
def convert(fr, to, amount):
- if (to == "EUR")
+ if to == "EUR":
return amount * 0.70
- else
- return amount
+ return amount
def symbol(currency):
- if (currency == "EUR")
+ if currency == "EUR":
return "E"
- else
- return "$"
+ return "$"
diff --git a/sca-cpp/trunk/test/store-python/fruits-catalog.py b/sca-cpp/trunk/test/store-python/fruits-catalog.py
index 5fcb9216c2..ea71e93b22 100644
--- a/sca-cpp/trunk/test/store-python/fruits-catalog.py
+++ b/sca-cpp/trunk/test/store-python/fruits-catalog.py
@@ -3,17 +3,15 @@
def get(converter):
def convert(price):
return converter("convert", "USD", "USD", price)
- code = "USD")
+ code = "USD"
symbol = converter("symbol", code)
return (
(("'javaClass", "services.Item"), ("'name", "Apple"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price", convert(2.99))),
(("'javaClass", "services.Item"), ("'name", "Orange"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price", convert(3.55))),
- (("'javaClass", "services.Item"), ("'name", "Pear"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price" convert(1.55)))
+ (("'javaClass", "services.Item"), ("'name", "Pear"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price", convert(1.55)))
)
# TODO remove these JSON-RPC specific functions
-def system.listMethods(converter):
- return ("Service.get")
-
-Service.get = get
+def listMethods(converter):
+ return ("Service.get",)
diff --git a/sca-cpp/trunk/test/store-python/htdocs/store.html b/sca-cpp/trunk/test/store-python/htdocs/store.html
index f8c6027abe..21eabca7a7 100644
--- a/sca-cpp/trunk/test/store-python/htdocs/store.html
+++ b/sca-cpp/trunk/test/store-python/htdocs/store.html
@@ -51,7 +51,7 @@
catalogItems = items;
// TEMP
- shoppingTotal.getTotal(shoppingTotal_getTotalResponse);
+ shoppingTotal.gettotal(shoppingTotal_getTotalResponse);
}
function shoppingCart_getResponse(feed) {
@@ -68,7 +68,7 @@
if (entries.length != 0) {
try {
- shoppingTotal.getTotal(shoppingTotal_getTotalResponse);
+ shoppingTotal.gettotal(shoppingTotal_getTotalResponse);
}
catch(e){
alert(e);
diff --git a/sca-cpp/trunk/test/store-python/store-composite-test b/sca-cpp/trunk/test/store-python/server-test
index b41c4e5393..b41c4e5393 100755
--- a/sca-cpp/trunk/test/store-python/store-composite-test
+++ b/sca-cpp/trunk/test/store-python/server-test
diff --git a/sca-cpp/trunk/test/store-python/shopping-cart.py b/sca-cpp/trunk/test/store-python/shopping-cart.py
index cc89bb6c99..317038d93f 100644
--- a/sca-cpp/trunk/test/store-python/shopping-cart.py
+++ b/sca-cpp/trunk/test/store-python/shopping-cart.py
@@ -1,77 +1,65 @@
# Shopping cart implementation
+import uuid
+import sys
cartId = "1234"
-#TODO finish conversion from scheme to python
-
# Get the shopping cart from the cache
# Return an empty cart if not found
-(define (getcart id cache)
- (define cart (cache "get" id))
- (if (nul cart)
- (list)
- cart)
-)
+def getcart(id, cache):
+ cart = cache("get", id)
+ if cart is None:
+ return ()
+ return cart
# Post a new item to the cart, create a new cart if necessary
-(define (post item cache)
- (define id (uuid))
- (define newItem (list (car item) id (caddr item)))
- (define cart (cons newItem (getcart cartId cache)))
- (cache "put" cartId cart)
- id
-)
+def post(item, cache):
+ id = str(uuid.uuid1())
+ cart = ((item[0], id, item[2]),) + getcart(cartId, cache)
+ cache("put", cartId, cart)
+ return id
# Return the content of the cart
-(define (getall cache)
- (cons "Your Cart" (cons cartId (getcart cartId cache)))
-)
+def getall(cache):
+ return ("Your Cart", cartId) + getcart(cartId, cache)
# Find an item in the cart
-(define (find id cart)
- (if (nul cart)
- (cons "Item" (list "0" (list)))
- (if (= id (cadr (car cart)))
- (car cart)
- (find id (cdr cart))))
-)
+def find(id, cart):
+ if cart == ():
+ return ("Item", "0", ())
+ elif id == cart[0][1]:
+ return cart[0]
+ else:
+ return find(id, cart[1:])
# Get an item from the cart
-(define (get id cache)
- (find id (getcart cartId cache))
-)
+def get(id, cache):
+ return find(id, getcart(cartId, cache))
# Delete the whole cart
-(define (deleteall cache)
- (cache "delete" cartId)
-)
+def deleteall(cache):
+ return cache("delete", cartId)
# Delete an item from the cart
-(define (delete id cache)
- true
-)
+def delete(id, cache):
+ return true
# Return the price of an item
-(define (price item)
- (cadr (assoc 'price (caddr item)))
-)
+def price(item):
+ return float(filter(lambda x: x[0] == "'price", item[2])[0][1])
# Sum the prices of a list of items
-(define (sum items)
- (if (nul items)
- 0
- (+ (price (car items)) (sum (cdr items))))
-)
+def sum(items):
+ if items == ():
+ return 0
+ return price(items[0]) + sum(items[1:])
# Return the total price of the items in the cart
-(define (gettotal cache)
- (define cart (getcart cartId cache))
- (sum cart)
-)
+def gettotal(cache):
+ cart = getcart(cartId, cache)
+ return sum(cart)
# TODO remove these JSON-RPC specific functions
-def system.listMethods(cache):
- return ("Service.getTotal")
-
-Service.getTotal = gettotal
+def listMethods(cache):
+ return ("Service.gettotal",)
diff --git a/sca-cpp/trunk/test/store-python/store.py b/sca-cpp/trunk/test/store-python/store.py
index 942544a3b2..54fd315fea 100644
--- a/sca-cpp/trunk/test/store-python/store.py
+++ b/sca-cpp/trunk/test/store-python/store.py
@@ -22,9 +22,6 @@ def delete(id, catalog, shoppingCart, shoppingTotal):
return shoppingCart("delete", id)
# TODO remove these JSON-RPC specific functions
-def system.listMethods(catalog, shoppingCart, shoppingTotal):
- return ("Service.get", "Service.getTotal")
-
-Service.getCatalog = getcatalog
-Service.getTotal = gettotal
+def listMethods(catalog, shoppingCart, shoppingTotal):
+ return ("Service.get", "Service.gettotal")
diff --git a/sca-cpp/trunk/test/store-scheme/Makefile.am b/sca-cpp/trunk/test/store-scheme/Makefile.am
index fc6a1f88fb..19b2640f3b 100644
--- a/sca-cpp/trunk/test/store-scheme/Makefile.am
+++ b/sca-cpp/trunk/test/store-scheme/Makefile.am
@@ -15,12 +15,12 @@
# specific language governing permissions and limitations
# under the License.
-noinst_PROGRAMS = store-script-test
+noinst_PROGRAMS = script-test
INCLUDES = -I. -I$(top_builddir)/kernel -I${LIBXML2_INCLUDE} -I${APR_INCLUDE} -I${JS_INCLUDE}
-store_script_test_SOURCES = store-script-test.cpp
-store_script_test_LDADD = -L${LIBXML2_LIB} -lxml2 -L${APR_LIB} -lapr-1 -laprutil-1 -L${JS_LIB} -lmozjs
-
-TESTS = store-script-test store-composite-test
+script_test_SOURCES = script-test.cpp
+script_test_LDADD = -L${LIBXML2_LIB} -lxml2 -L${APR_LIB} -lapr-1 -laprutil-1 -L${JS_LIB} -lmozjs
+
+TESTS = script-test server-test
diff --git a/sca-cpp/trunk/test/store-scheme/fruits-catalog.scm b/sca-cpp/trunk/test/store-scheme/fruits-catalog.scm
index 18128f0137..173bcbe9c0 100644
--- a/sca-cpp/trunk/test/store-scheme/fruits-catalog.scm
+++ b/sca-cpp/trunk/test/store-scheme/fruits-catalog.scm
@@ -12,6 +12,5 @@
)
; TODO remove these JSON-RPC specific functions
-(define (system.listMethods converter) (list "Service.get"))
-(define Service.get get)
+(define (listMethods converter) (list "Service.get"))
diff --git a/sca-cpp/trunk/test/store-scheme/htdocs/store.html b/sca-cpp/trunk/test/store-scheme/htdocs/store.html
index f8c6027abe..21eabca7a7 100644
--- a/sca-cpp/trunk/test/store-scheme/htdocs/store.html
+++ b/sca-cpp/trunk/test/store-scheme/htdocs/store.html
@@ -51,7 +51,7 @@
catalogItems = items;
// TEMP
- shoppingTotal.getTotal(shoppingTotal_getTotalResponse);
+ shoppingTotal.gettotal(shoppingTotal_getTotalResponse);
}
function shoppingCart_getResponse(feed) {
@@ -68,7 +68,7 @@
if (entries.length != 0) {
try {
- shoppingTotal.getTotal(shoppingTotal_getTotalResponse);
+ shoppingTotal.gettotal(shoppingTotal_getTotalResponse);
}
catch(e){
alert(e);
diff --git a/sca-cpp/trunk/test/store-scheme/store-script-test.cpp b/sca-cpp/trunk/test/store-scheme/script-test.cpp
index fe2a64e57f..c8eecb65c3 100644
--- a/sca-cpp/trunk/test/store-scheme/store-script-test.cpp
+++ b/sca-cpp/trunk/test/store-scheme/script-test.cpp
@@ -39,7 +39,7 @@ using namespace tuscany;
bool testScript() {
gc_scoped_pool pool;
- ifstream is("store-script-test.scm");
+ ifstream is("script-test.scm");
ostringstream os;
scheme::evalDriverRun(is, os);
assert(contains(str(os), "(\"Sample Feed\" \""));
@@ -52,7 +52,7 @@ bool testScript() {
bool testEval() {
{
gc_scoped_pool pool;
- ifstream is("store-script-test.scm");
+ ifstream is("script-test.scm");
ostringstream os;
scheme::setupDisplay(os);
scheme::Env globalEnv = scheme::setupEnvironment();
@@ -66,7 +66,7 @@ bool testEval() {
{
gc_scoped_pool pool;
- ifstream is("store-script-test.scm");
+ ifstream is("script-test.scm");
ostringstream os;
scheme::setupDisplay(os);
diff --git a/sca-cpp/trunk/test/store-scheme/store-script-test.scm b/sca-cpp/trunk/test/store-scheme/script-test.scm
index 30c10d8184..711656019a 100644
--- a/sca-cpp/trunk/test/store-scheme/store-script-test.scm
+++ b/sca-cpp/trunk/test/store-scheme/script-test.scm
@@ -121,29 +121,3 @@
(display (storeui_service "getall" added2))
(display (storeui_service "gettotal"))
-; Store UI JSON-RPC interop test case
-
-(define (system.listMethods) (list "Service.get" "Service.getTotal"))
-
-(define (Service.get) (storeui_service "getcatalog"))
-
-(define (.get) (storeui_service "getcatalog"))
-
-(define (Service.getTotal) (storeui_service "gettotal"))
-
-; Store UI ATOMPub interop test case
-
-(define (getall) (storeui_service "getall" added2))
-
-(define (get id) (storeui_service "getentry" id))
-
-(define (post entry)
- (display entry)
- (uuid)
-)
-
-(define (delete id)
- (display id)
- true
-)
-
diff --git a/sca-cpp/trunk/test/store-scheme/store-composite-test b/sca-cpp/trunk/test/store-scheme/server-test
index b41c4e5393..b41c4e5393 100755
--- a/sca-cpp/trunk/test/store-scheme/store-composite-test
+++ b/sca-cpp/trunk/test/store-scheme/server-test
diff --git a/sca-cpp/trunk/test/store-scheme/shopping-cart.scm b/sca-cpp/trunk/test/store-scheme/shopping-cart.scm
index 60981411c7..77a98c9fd7 100644
--- a/sca-cpp/trunk/test/store-scheme/shopping-cart.scm
+++ b/sca-cpp/trunk/test/store-scheme/shopping-cart.scm
@@ -68,6 +68,5 @@
)
; TODO remove these JSON-RPC specific functions
-(define (system.listMethods cache) (list "Service.getTotal"))
-(define Service.getTotal gettotal)
+(define (listMethods cache) (list "Service.gettotal"))
diff --git a/sca-cpp/trunk/test/store-scheme/store.scm b/sca-cpp/trunk/test/store-scheme/store.scm
index e325a65d74..0091af542d 100644
--- a/sca-cpp/trunk/test/store-scheme/store.scm
+++ b/sca-cpp/trunk/test/store-scheme/store.scm
@@ -29,7 +29,5 @@
)
; TODO remove these JSON-RPC specific functions
-(define (system.listMethods catalog shoppingCart shoppingTotal) (list "Service.get" "Service.getTotal"))
-(define Service.getCatalog getcatalog)
-(define Service.getTotal gettotal)
+(define (listMethods catalog shoppingCart shoppingTotal) (list "Service.getcatalog" "Service.gettotal"))