summaryrefslogtreecommitdiffstats
path: root/cpp/sca/test/store-script/store.scm
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2009-11-16 06:01:41 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2009-11-16 06:01:41 +0000
commit51a97b5d9350b37f95d6f0c00d013b886e64fcd3 (patch)
tree480092faac7c7deb40265fb070d1b4b059638814 /cpp/sca/test/store-script/store.scm
parentada8802640aa232d34b1fe2793b9f52cd62b41f1 (diff)
Added test cases and scripts to test the HTTP binding support. Refactored httpd module and added a wiring httpd module. Implementation of the store demo prepared for ApacheCon.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@880601 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--cpp/sca/test/store-script/store.scm147
1 files changed, 14 insertions, 133 deletions
diff --git a/cpp/sca/test/store-script/store.scm b/cpp/sca/test/store-script/store.scm
index 709fd943f1..2434b18b51 100644
--- a/cpp/sca/test/store-script/store.scm
+++ b/cpp/sca/test/store-script/store.scm
@@ -1,150 +1,31 @@
+; Store implementation
-(; "Currency implementation")
-
-(define (currency_convert from to amount)
- (if (equal? to "EUR") (* amount 0.70) amount)
-)
-
-(define (currency_symbol currency)
- (if (equal? currency "EUR") "E" "$")
-)
-
-(define (currency_impl op args)
- (cond
- ((equal? op "convert") (apply currency_convert args))
- ((equal? op "symbol") (apply currency_symbol args))
- )
-)
-
-(; "Currency composite")
-
-(define (currency_service op . args) (currency_impl op args))
-
-(; "Catalog implementation")
-
-(define (catalog_get converter)
- (define (convert price) (converter "convert" "USD" "USD" price))
-
- (define code "USD")
- (define symbol (converter "symbol" code))
-
- (list
- (list (list 'javaClass "services.Item") (list 'name "Apple") (list 'currency code) (list 'symbol symbol) (list 'price 2.99))
- (list (list 'javaClass "services.Item") (list 'name "Orange") (list 'currency code) (list 'symbol symbol) (list 'price 3.55))
- (list (list 'javaClass "services.Item") (list 'name "Pear") (list 'currency code) (list 'symbol symbol) (list 'price 1.55))
- )
-)
-
-(define (catalog_impl converter op args)
- (cond
- ((equal? op "get") (apply catalog_get (cons converter args)))
- )
-)
-
-(; "Catalog composite")
-
-(define (catalog_service op . args) (catalog_impl currency_service op args))
-
-(; "Cart implementation")
-
-(define (cart_post content item)
- (cons (cons "Item" (list (uuid) item)) content)
-)
-
-(define (cart_getall content)
- (cons "Sample Feed" (cons (uuid) content))
-)
-
-(define (cart_getentry id)
- (define entry (list (list 'name "Apple") (list 'currency "USD") (list 'symbol "$") (list 'price 2.99)))
- (cons "Item" (list id entry))
+(define (post item catalog shoppingCart shoppingTotal)
+ (shoppingCart "post" item)
)
-(define (cart_gettotal)
- 10.0
+(define (getall catalog shoppingCart shoppingTotal)
+ (shoppingCart "getall")
)
-(define (cart_impl op args)
- (cond
- ((equal? op "post") (apply cart_post args))
- ((equal? op "getall") (apply cart_getall args))
- ((equal? op "getentry") (apply cart_getentry args))
- ((equal? op "gettotal") (apply cart_gettotal args))
- )
+(define (get id catalog shoppingCart shoppingTotal)
+ (shoppingCart "get" id)
)
-(; "Store UI implementation")
-
-(define (storeui_post cart content item)
- (cart "post" content item)
-)
-
-(define (storeui_getcart cart content)
- (cart "getall" content)
-)
-
-(define (storeui_getentry cart id)
- (cart "getentry" id)
-)
-
-(define (storeui_getcatalog catalog)
+(define (getcatalog catalog shoppingCart shoppingTotal)
(catalog "get")
)
-(define (storeui_gettotal cart)
- (cart "gettotal")
+(define (gettotal catalog shoppingCart shoppingTotal)
+ (shoppingCart "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 "getentry") (apply storeui_getentry (cons cart args)))
- ((equal? op "getcatalog") (apply storeui_getcatalog (cons catalog args)))
- ((equal? op "gettotal") (apply storeui_gettotal (cons cart args)))
- )
+(define (delete id catalog shoppingCart shoppingTotal)
+ (shoppingCart "delete" id)
)
-(; "Store UI composite")
-
-(define (cart_service op . args) (cart_impl op args))
-
-(define (storeui_service op . args) (storeui_impl cart_service catalog_service op args))
-
-(; "Store UI test case")
-
-(define catalog (storeui_service "getcatalog"))
-(define empty (list))
-(define apple (car catalog))
-(define orange (car (cdr catalog)))
-(define added1 (storeui_service "post" empty apple))
-(define added2 (storeui_service "post" added1 orange))
-(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 . args)
- (display args)
- true
-)
+(define Service.getCatalog getcatalog)
+(define Service.getTotal gettotal)