• No results found

monadws: A Monad-Based Testing Tool for Web Services

N/A
N/A
Protected

Academic year: 2021

Share "monadws: A Monad-Based Testing Tool for Web Services"

Copied!
25
0
0

Loading.... (view fulltext now)

Full text

(1)

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

(2)

A

d

Ab

t

dWS

Agenda

About monadWS

Monads Techniques

q

The monads in monadWS

HSP

d

HSP monad

Gen monad

TestM monad

Tool Snapshots

Tool Snapshots

Conclusion

2
(3)

About

monadWS

• An automatic WS testing tool based on monads techniques

About

monadWS

An automatic WS testing tool based on monads techniques

monadWS

adopts

• HSP monad

[1]

for describing WS test cases

• Gen monad

[2]

for generating test data automatically,

and

and

TestM

monad

for building the whole WS testing.

____________________

[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 on Functional Programming, New York, 2005: 268~279.

(4)

It f

k

W SDL Specificat ion <type s/> <bi n di n g/> <s e rvi ce/> <portType/>

Its framework

O pe rati on s XML S ch e m a S oapActi on s S e rvi ce s Data G e ne r ation Str ate gy URL addre s s

Gen

Monads

te s t cas e s (XML fi l e s ) <<Client >> <<Client >> S O AP Ge n e rator S O AP C al l e r re qu e s t s oap HTTP wrap re s pon s e re s u l ts e xpe te d re s pon s e s oap Q u i ck C h e ck Prope rti e s

HSP

Monads

TestM

Monads

Test Re ports
(5)

A

d

Ab

t

dWS

Agenda

About monadWS

Monads Techniques

q

The monads in monadWS

HSP

d

HSP monad

Gen monad

TestM monad

Tool Snapshots

Tool Snapshots

Conclusion

(6)

Monads Intro

Monads Intro.

• A general functional notation

A general functional notation

 

f : a -> b

• Its monadic version of this notion

 

f: a -> M b

• Operations on monad M

return :: a > M a

 

return :: a -> M a

 

bind :: M a -> (a -> M b) -> M b

Therefore, a monad can be thought as a strategygy for combining computations g p into more complex computations.

(7)

A

d

Ab

t

dWS

Agenda

About monadWS

Monads Techniques

q

The monads in monadWS

HSP

d

HSP monad

Gen monad

TestM monad

Tool Snapshots

Tool Snapshots

Conclusion

(8)

HSP Monad: represent TC

HSP Monad: represent TC

represents a WS test case as a SOAP message

can encapsulate any side effects, and lets all XML

expressions be computed safely

makeTC serv :: InputType

->

HSP

XML

expressions be computed safely

makeTC_serv :: InputType

>

HSP

XML

The input type of a service The input type of a service operation (say serv),

such as String, Double …

(9)

HSP Monad: represent TC

HSP Monad: represent TC

makeTC serv :: InputType

->

HSP

XML

For example:

makeTC_serv :: InputType

>

HSP

XML

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" // / / operURL = "http://www.Nanonull.com/TimeService/"

(10)

HSP Monad: represent TC

HSP Monad: represent TC

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" operURL = "http://www.Nanonull.com/TimeService/" operURL http://www.Nanonull.com/TimeService/

HSP provides interfaces for other computations through the escapes (with “<%” and “%>”)

(11)

Gen Monad: generate data

Gen Monad: generate data

automatically generates data for simple types

(such as Double, Int, String and so on)

class

Arbitrary a

where

arbitrary :: Gen a

y

instance Arbitrary String instance Arbitrary Double …

(12)

Gen Monad: generate data

Gen Monad: generate data

class

Arbitrary a

where

arbitrary :: Gen a

makeTC_getOffesetUTCTime :: Double -> HSP XML

arbitrary :: Gen a

general testing method:

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 )

(13)

Gen Monad: generate data

Gen Monad: generate data

makeTC getOffesetUTCTime :: Double -> HSP XML_g

testTCGen :: IO String

general testing method:

testTCGen :: IO String testTCGen = do

d <- generate (arbitrary :: Gen Double)

return $ hsp2str (makeTC getOffesetUTCTime d)

return $ hsp2str (makeTC_getOffesetUTCTime d)

monadic method by

liftM

:

on-the-fly generate

testTCGen2 :: IO String

testTCGen2 =

y

y g

testTCGen2

liftM

(hsp2str. makeTC_getOffesetUTCTime) $

generate (arbitrary :: Gen Double)

(14)

Gen Monad: generate data

Gen Monad: generate data

We can easily change the generation strategy

through the instances of Arbitrary class.

class

Arbitrary a

where

arbitrary :: Gen a

y

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

(15)

TestM Monad:

t

ti

d

TestM Monad:

testing as a monad

type TestM

a

processes WS testing as the following

TestM

monad:

Coalgebraic

monad

yp

= CoAlgMonadT

(EnvT TestEnv

g for WS computing

Environment monad for

t ti

i

t

(StateT TestState

HSP

)) a

testing environment

(eg.

Schema type information,

test cases files

)

)) a

State monad for testing states

(16)

CPU Time Results of Autogeneration g Test Cases for TimeService

Execution Time of the Execution Time of the SOAP Messages of

getOffesetUTCTime in TimeService

(17)

Comparison of WSTester with Other Test Tools for Web Services Comparison of WSTester with Other Test Tools for Web Services

(18)

A

d

Ab

t

dWS

Agenda

About monadWS

Monads Techniques

q

The monads in monadWS

HSP

d

HSP monad

Gen monad

TestM monad

Tool Snapshots

Tool Snapshots

Conclusion

18
(19)

S

h t

f

t

l

dWS

(20)
(21)
(22)

A

d

Ab

t

dWS

Agenda

About monadWS

Monads Techniques

q

The monads in monadWS

HSP

d

HSP monad

Gen monad

TestM monad

Tool Snapshots

Tool Snapshots

Conclusion

22
(23)

C

l

i

b i fl i t

d

d b

d t ti

Conclusion

briefly introduce our monad-based testing

tool,

monadWS

To automatically test web services.

dWS

d

l t d t h l

monadWS can use monads related to help

WS test case representation,

test data autogeneration, and

(24)

C

l

i

dWS

d

l t d t h l

Conclusion

monadWS can use monads related to help

WS test case representation,

test data autogeneration, and

test auto-execution

test auto-execution.

Future work

More comparisons with existing tools

Use more data-generation strategy

g

gy

Apply to WS composition (with BPEL)

(25)

References

Related documents

In solving these problems, Company ‘A’ started developing a culture which supports and promotes knowledge sharing through its integration of HRM practices into the knowledge

Hash based message authentication code using cryptographic hash functionsuch as SHA-1 in combination with secret key.It provides the integrity of information

The aim of the research was to evaluate the organisation and delivery of nursing care and the effective use of staff skills/resources on acute wards within Bolton Hospitals

Nowadays, major research is focused on sustainable energy solution with major emphasis on energy efficiency and use of renewable energy resources. Increasing

In this context, this paper aims to analyse the impact of the Tsunami on infrastructure facilities in Sri Lanka and how the post- Tsunami reconstruction process has affected

Most of the medium and small-scale contractors and even large-scale contractors do not have sufficient working capital to finance construction projects. The paid up capital of