diff options
Diffstat (limited to 'sca-cpp/trunk/test/store-script')
-rw-r--r-- | sca-cpp/trunk/test/store-script/htdocs/store.html | 2 | ||||
-rw-r--r-- | sca-cpp/trunk/test/store-script/htdocs/store.js | 6 | ||||
-rw-r--r-- | sca-cpp/trunk/test/store-script/shopping-cart.scm | 24 | ||||
-rwxr-xr-x | sca-cpp/trunk/test/store-script/store-composite-test | 42 | ||||
-rw-r--r-- | sca-cpp/trunk/test/store-script/store.composite | 27 |
5 files changed, 33 insertions, 68 deletions
diff --git a/sca-cpp/trunk/test/store-script/htdocs/store.html b/sca-cpp/trunk/test/store-script/htdocs/store.html index 0378b454cc..f8c6027abe 100644 --- a/sca-cpp/trunk/test/store-script/htdocs/store.html +++ b/sca-cpp/trunk/test/store-script/htdocs/store.html @@ -162,7 +162,7 @@ <br>
<input type="button" onClick="checkoutCart()" value="Checkout">
<input type="button" onClick="deleteCart()" value="Empty">
- <a href="../ShoppingCart/">(feed)</a>
+ <a href="../shoppingCart/">(feed)</a>
</form>
</div>
</body>
diff --git a/sca-cpp/trunk/test/store-script/htdocs/store.js b/sca-cpp/trunk/test/store-script/htdocs/store.js index 9cb09f4b78..9cd8eb526d 100644 --- a/sca-cpp/trunk/test/store-script/htdocs/store.js +++ b/sca-cpp/trunk/test/store-script/htdocs/store.js @@ -650,9 +650,9 @@ 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"); -tuscany.sca.referenceMap.shoppingTotal = new JSONRpcClient("/Total").Service; +tuscany.sca.referenceMap.catalog = new JSONRpcClient("/catalog").Service; +tuscany.sca.referenceMap.shoppingCart = new AtomClient("/shoppingCart"); +tuscany.sca.referenceMap.shoppingTotal = new JSONRpcClient("/total").Service; tuscany.sca.Reference = function (name) { return tuscany.sca.referenceMap[name]; } diff --git a/sca-cpp/trunk/test/store-script/shopping-cart.scm b/sca-cpp/trunk/test/store-script/shopping-cart.scm index 01ca62df40..b7672345d7 100644 --- a/sca-cpp/trunk/test/store-script/shopping-cart.scm +++ b/sca-cpp/trunk/test/store-script/shopping-cart.scm @@ -14,21 +14,29 @@ ; Post a new item to the cart, create a new cart if necessary (define (post item cache) (define id (uuid)) - (define cart (cons item (getcart cartId cache))) + (define newItem (list (car item) id (caddr item))) + (define cart (cons newItem (getcart cartId cache))) (cache "put" cartId cart) id ) ; Return the content of the cart (define (getall cache) - (define cart (getcart cartId cache)) - (cons "Your Cart" (cons cartId cart)) + (cons "Your Cart" (cons 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)))) ) ; Get an item from the cart (define (get id cache) - (define entry (list (list 'name "Apple") (list 'currencyCode "USD") (list 'currencySymbol "$") (list 'price 2.99))) - (cons "Item" (list id entry)) + (find id (getcart cartId cache)) ) ; Delete the cart @@ -38,12 +46,14 @@ ; Return the price of an item (define (price item) - (car (cdr (car (cdr (cdr (cdr (cdr (car (cdr (cdr item)))))))))) + (cadr (assoc 'price (caddr item))) ) ; Sum the prices of a list of items (define (sum items) - (if (nul items) 0 (+ (price (car items)) (sum (cdr items)))) + (if (nul items) + 0 + (+ (price (car items)) (sum (cdr items)))) ) ; Return the total price of the items in the cart diff --git a/sca-cpp/trunk/test/store-script/store-composite-test b/sca-cpp/trunk/test/store-script/store-composite-test index 43923fca36..b41c4e5393 100755 --- a/sca-cpp/trunk/test/store-script/store-composite-test +++ b/sca-cpp/trunk/test/store-script/store-composite-test @@ -24,43 +24,7 @@ echo "Testing..." ../../modules/server/server-conf tmp cat >>tmp/conf/httpd.conf <<EOF -<Location /Catalog> -SetHandler mod_tuscany_eval -SCAContribution `pwd`/ -SCAComposite store.composite -SCAComponent Catalog -</Location> - -<Location /Total> -SetHandler mod_tuscany_eval -SCAContribution `pwd`/ -SCAComposite store.composite -SCAComponent ShoppingCart -</Location> - -<Location /ShoppingCart> -SetHandler mod_tuscany_eval -SCAContribution `pwd`/ -SCAComposite store.composite -SCAComponent ShoppingCart -</Location> - -<Location /CurrencyConverter> -SetHandler mod_tuscany_eval -SCAContribution `pwd`/ -SCAComposite store.composite -SCAComponent CurrencyConverter -</Location> - -<Location /Cache> -SetHandler mod_tuscany_eval -SCAContribution `pwd`/ -SCAComposite store.composite -SCAComponent Cache -</Location> - -<Location /references> -SetHandler mod_tuscany_wiring +<Location /> SCAContribution `pwd`/ SCAComposite store.composite </Location> @@ -70,7 +34,7 @@ apachectl -k start -d `pwd`/tmp mc="memcached -l 127.0.0.1 -m 4 -p 11211" $mc & -sleep 1 +sleep 2 # Test HTTP GET curl http://localhost:8090/store.html 2>/dev/null >tmp/store.html @@ -80,7 +44,7 @@ rc=$? # Cleanup apachectl -k stop -d `pwd`/tmp kill `ps -f | grep -v grep | grep "$mc" | awk '{ print $2 }'` -sleep 1 +sleep 2 if [ "$rc" = "0" ]; then echo "OK" fi diff --git a/sca-cpp/trunk/test/store-script/store.composite b/sca-cpp/trunk/test/store-script/store.composite index 2cfadf3f71..cc00ae2d65 100644 --- a/sca-cpp/trunk/test/store-script/store.composite +++ b/sca-cpp/trunk/test/store-script/store.composite @@ -25,26 +25,19 @@ <component name="Store"> <!-- <t:implementation.widget location="store.html"/> --> <t:implementation.scheme uri="store.scm"/> - <service name="Widget"> <t:binding.http uri="store"/> </service> - <reference name="catalog" target="Catalog"> - <t:binding.jsonrpc uri="Catalog"/> - </reference> - <reference name="shoppingCart" target="ShoppingCart/Cart"> - <t:binding.atom/> - </reference> - <reference name="shoppingTotal" target="ShoppingCart/Total"> - <t:binding.jsonrpc/> - </reference> + <reference name="catalog" target="Catalog"/> + <reference name="shoppingCart" target="ShoppingCart/Cart"/> + <reference name="shoppingTotal" target="ShoppingCart/Total"/> </component> <component name="Catalog"> <t:implementation.scheme uri="fruits-catalog.scm"/> <property name="currencyCode">USD</property> <service name="Catalog"> - <t:binding.jsonrpc uri="Catalog"/> + <t:binding.jsonrpc uri="catalog"/> </service> <reference name="currencyConverter" target="CurrencyConverter"/> </component> @@ -52,27 +45,25 @@ <component name="ShoppingCart"> <t:implementation.scheme uri="shopping-cart.scm"/> <service name="ShoppingCart"> - <t:binding.atom uri="ShoppingCart"/> + <t:binding.atom uri="shoppingCart"/> </service> <service name="Total"> - <t:binding.jsonrpc uri="Total"/> + <t:binding.jsonrpc uri="total"/> </service> - <reference name="cache" target="Cache"> - <t:binding.atom/> - </reference> + <reference name="cache" target="Cache"/> </component> <component name="CurrencyConverter"> <t:implementation.scheme uri="currency-converter.scm"/> <service name="CurrencyConverter"> - <t:binding.jsonrpc uri="CurrencyConverter"/> + <t:binding.jsonrpc uri="currencyConverter"/> </service> </component> <component name="Cache"> <t:implementation.cpp uri="../../components/cache/.libs/libmcache"/> <service name="Cache"> - <t:binding.atom uri="Cache"/> + <t:binding.atom uri="cache"/> </service> </component> |