monadWS: A Monad-Based Testing Tool for Web Services
College of Computer, Nanjing University of Posts and Telecommunications, Nanjing 210003, China Yingzhou Zhang, Wei Fu, Changhai Nie j g
Email: zhangyz@njupt.edu.cn
monadWS : A Monad-Based Testing Tool for Web Services College of - - PowerPoint PPT Presentation
monadWS : A Monad-Based Testing Tool for Web Services College of Computer, Nanjing University of Posts and Telecommunications, Nanjing 210003, China j g Yingzhou Zhang, Wei Fu, Changhai Nie Email: zhangyz@njupt.edu.cn A Agenda d About
Email: zhangyz@njupt.edu.cn
2
____________________
[1] HSP (Haskell Server Pages): http://code.google.com/p/hsp/ [2] Cl K H h J Q i kCh k li ht i ht t l f d t ti f [2] Claessen K, Hughes J. QuickCheck: a lightweight tool for random testing of Haskell programs. In Proceedings of the Fifth ACM SIGPLAN international Conference
WSDL Specification <types/> <binding/> <service/> <portType/>
O perations XML Schema SoapActions Services
Data Generation Strategy
URL address
Gen Monads
test cases (XML files) <<Client>> <<Client>> SO AP Generator SO AP Caller request soap HTTP wrap response results expeted response soap Q uickCheck Properties
HSP Monads TestM Monads
Test Reports
5
Therefore, a monad can be thought as a strategy for combining computations gy g p into more complex computations.
2011-6-15
7
The input type of a service The input type of a service
such as String, Double …
8
makeTC_getOffesetUTCTime :: Double -> HSP XML makeTC_getOffesetUTCTime d = <soap:Envelope xmlns:soap=soapURI xmlns:xsd=xsdURI> p p p p <soap:Body> <getOffesetUTCTime xmlns=operURL> <hoursOffset> <% show d %> </hoursOffset> </getOffesetUTCTime> </soap:Body> </soap:Envelope> where soapURI ="http://schemas.xmlsoap.org/soap/envelope/" xsdURI = "http://www.w3.org/2001/XMLSchema" // / /
9
makeTC getOffesetUTCTime :: Double -> HSP XML _g makeTC_getOffesetUTCTime d = <soap:Envelope xmlns:soap=soapURI xmlns:xsd=xsdURI> <soap:Body> <getOffesetUTCTime xmlns=operURL> g p <hoursOffset> <% show d %> </hoursOffset> </getOffesetUTCTime> </soap:Body> </soap:Envelope> </soap:Envelope> where soapURI ="http://schemas.xmlsoap.org/soap/envelope/" xsdURI = "http://www.w3.org/2001/XMLSchema"
http://www.Nanonull.com/TimeService/
HSP provides interfaces for other computations through the escapes (with “<%” and “%>”)
10
instance Arbitrary String instance Arbitrary Double … instance Arbitrary String … instance Arbitrary Double …
11
makeTC_getOffesetUTCTime :: Double -> HSP XML
Step 1 generate a test value testTCGen :: IO String Step 1. generate a test value Step 2. generate the final test case with the value test CGe :: O St g testTCGen = do d <- generate (arbitrary :: Gen Double) return $ hsp2str (makeTC getOffesetUTCTime d) p ( _g )
12
makeTC getOffesetUTCTime :: Double -> HSP XML _g testTCGen :: IO String
testTCGen :: IO String testTCGen = do d <- generate (arbitrary :: Gen Double) return $ hsp2str (makeTC getOffesetUTCTime d) return $ hsp2str (makeTC_getOffesetUTCTime d)
testTCGen2 :: IO String testTCGen2 =
testTCGen2 liftM (hsp2str. makeTC_getOffesetUTCTime) $ generate (arbitrary :: Gen Double)
13
instance Arbitrary Double where arbitrary = myDoubleGen arbitrary = myDoubleGen myDoubleGen :: Gen Double myStringGen = suchThat arbitrary guard myStringGen suchThat arbitrary guard where guard a = (a > 0) && (a < 1000) || elem a [-1, 0, 9999]
14
|| [ , , ]
Coalgebraic monad
g for WS computing
Environment monad for t ti i t
testing environment (eg. Schema type information, test cases files)
State monad for testing states (eg. executing time, testing results)
15
CPU Time Results
g Test Cases for TimeService Execution Time of the Execution Time of the SOAP Messages of getOffesetUTCTime in TimeService
Comparison of WSTester with Other Test Tools for Web Services Comparison of WSTester with Other Test Tools for Web Services
18
22
23
24