140
Virtualization with IBM Rational Integration Tester

2012 10 23_2649_rational_integration_tester_vi

Embed Size (px)

Citation preview

Page 1: 2012 10 23_2649_rational_integration_tester_vi

VirtualizationwithIBMRationalIntegrationTester

Page 2: 2012 10 23_2649_rational_integration_tester_vi

Note

Beforeusingthisinformationandtheproductitsupports,readtheinformationin“Notices”onpage137.

©CopyrightIBMCorporation2001,2012.

Page 3: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page1of138©IBMCorporation2001,2012

1  INTRODUCTION ............................................................................................................................. 4 

2  USING VIRTUALIZED APPLICATIONS FOR TESTING ........................................................................... 5 

2.1  INTRODUCTION ....................................................................................................................... 5 

2.2  THE OLD WORLD ................................................................................................................... 6 

2.3  THE NEW WORLD ................................................................................................................... 6 

2.4  WHEN TO USE VIE .................................................................................................................. 6 

2.5  USING VIE STRATEGICALLY .................................................................................................... 6 

2.6  SOLVING PROBLEMS WITH VIE ................................................................................................ 7 

2.7  VIRTUAL APPLICATIONS – SIMPLE TO COMPLEX ........................................................................ 7 

3  VIE ARCHITECTURE AND SETUP .................................................................................................... 9 

3.1  OVERVIEW ............................................................................................................................. 9 

3.2  DOMAINS AND ENVIRONMENTS .............................................................................................. 10 

4  RATIONAL INTEGRATION TESTER PROJECT SETUP ........................................................................ 12 

4.1  THE INITIAL SCREEN ............................................................................................................. 12 

4.2  CREATING A NEW PROJECT ................................................................................................... 13 

4.3  EXERCISE: CREATING THE TRAINING PROJECT ........................................................................ 14 

4.4  RATIONAL INTEGRATION TESTER LAYOUT ............................................................................... 18 

4.5  RATIONAL INTEGRATION TESTER PERSPECTIVES .................................................................... 19 

5  MODELING THE SYSTEM .............................................................................................................. 20 

5.1  PERSPECTIVE OVERVIEW ...................................................................................................... 20 

5.2  WORKING IN MULTIPLE ENVIRONMENTS ................................................................................. 20 

5.3  LOGICAL VIEW ...................................................................................................................... 21 

5.4  EXERCISE: SETTING UP THE LOGICAL VIEW FOR A SIMPLE SYSTEM .......................................... 23 

5.5  PHYSICAL VIEW .................................................................................................................... 25 

5.6  EXERCISE: SETTING UP PHYSICAL VIEW FOR A SIMPLE SYSTEM ............................................... 26 

5.7  ENVIRONMENTS ................................................................................................................... 26 

5.8  EXERCISE: CREATING AN ENVIRONMENT ................................................................................ 26 

5.9  EXERCISE: SCHEMA LIBRARY ................................................................................................ 27 

5.10  EXERCISE: THE MESSAGE EXCHANGE PATTERN (MEP) ....................................................... 29 

6  THE DEMONSTRATION ENVIRONMENT ........................................................................................... 31 

6.1  MANAGING FLIGHT BOOKINGS ............................................................................................... 31 

6.2  FINDING AND BOOKING HOTELS ............................................................................................. 32 

6.3  FLIGHT ADMINISTRATION ....................................................................................................... 32 

7  USING SYSTEM DATA TO BUILD A SYSTEM MODEL ........................................................................ 34 

Page 4: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page2of138©IBMCorporation2001,2012

7.1  OVERVIEW ........................................................................................................................... 34 

7.2  SYNCHRONISATION OVERVIEW .............................................................................................. 34 

7.3  BUILDING A MODEL FROM RECORDED EVENTS ........................................................................ 35 

7.4  RECORDING MQ MESSAGES ................................................................................................. 35 

7.5  EXERCISE: SETTING UP THE TRANSPORTS .............................................................................. 36 

7.6  EXERCISE: ADDING THE FLIGHT BOOKING MESSAGE SCHEMAS ................................................ 41 

8  RECORDING EVENTS ................................................................................................................... 42 

8.1  THE RECORDING STUDIO ...................................................................................................... 42 

8.2  EXERCISE: RECORDING EVENTS FROM A TRANSPORT ............................................................. 43 

8.3  EXERCISE: BUILDING OPERATIONS FROM RECORDED EVENTS ................................................. 45 

8.4  EXERCISE: COMPLETING THE SYSTEM MODEL ........................................................................ 51 

8.5  EXERCISE: RECORDING EVENTS FROM AN OPERATION ............................................................ 52 

9  CREATING AND EXECUTING A BASIC STUB ................................................................................... 55 

9.1  EXERCISE: MAKING A SIMPLE STUB FROM RECORDED MESSAGES .............................................. 55 

9.2  EXERCISE: EXECUTING A STUB FROM RATIONAL INTEGRATION TESTER ..................................... 58 

9.3  EXERCISE: MODIFYING THE STUB ON THE FLY ......................................................................... 59 

10  PUBLISHING AND DEPLOYING STUBS ........................................................................................ 61 

10.1  EXERCISE: USING RTCP ................................................................................................... 61 

10.2  EXERCISE: PUBLISHING A STUB .......................................................................................... 62 

10.3  EXERCISE: DEPLOYING A STUB ........................................................................................... 63 

11  SYNCHRONIZATION .................................................................................................................. 65 

11.1  A SECOND TEST SYSTEM – HOTELFINDER ........................................................................... 65 

11.2  SYNCHRONIZATION ............................................................................................................ 65 

11.3  EXERCISE: SYNCHRONIZING WITH THE HOTELFINDER WSDL ............................................... 65 

12  CREATING A STUB FROM MEP ................................................................................................. 71 

12.1  THE STUB EDITOR ............................................................................................................. 71 

12.2  TRANSITIONS .................................................................................................................... 71 

12.3  EXERCISE: CREATING A STUB FROM THE MEP ..................................................................... 72 

12.4  USING THE HTTP PROXY .................................................................................................. 73 

12.5  EXERCISE: HTTP STUB EXECUTION ................................................................................... 75 

12.6  EXERCISE: HANDLING NEW REQUEST OPTIONS .................................................................... 76 

13  STORING AND MANIPULATING DATA ......................................................................................... 79 

13.1  TAGS AND THE TAG DATA STORE ....................................................................................... 79 

13.2  CREATING TAGS ............................................................................................................... 80 

Page 5: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page3of138©IBMCorporation2001,2012

13.3  USING TAGS ..................................................................................................................... 82 

13.4  EXERCISE: CREATING AND USING A TAG .............................................................................. 82 

13.5  GUARDS ........................................................................................................................... 83 

13.6  EXERCISE: USING GUARDS ................................................................................................ 83 

14  DATA DRIVEN STUBS ............................................................................................................... 85 

14.1  DATA SOURCES ................................................................................................................ 85 

14.2  EXERCISE: CREATING PARAMETERIZED STUBS FROM RECORDED MESSAGES ........................ 85 

14.3  EXERCISE: CREATING A DATA SOURCE WITHOUT RECORDED MESSAGES ................................ 89 

14.4  EXERCISE: DATA DRIVING WITH REPEATING ELEMENTS ........................................................ 92 

14.5  EXERCISE: INPUT TAGS ..................................................................................................... 95 

15  DATABASE STUBS ................................................................................................................... 97 

15.1  INTRODUCTION .................................................................................................................. 97 

15.2  THE RIT JDBC DRIVER ..................................................................................................... 97 

15.3  EXERCISE: RECORDING SQL ............................................................................................. 99 

15.4  EXERCISE: CREATING AND EXECUTING A DATABASE STUB ................................................... 101 

15.5  EXERCISE: MODIFYING THE SIMULATION DATABASE ............................................................ 104 

16  ALTERNATIVE MESSAGE FORMATS ......................................................................................... 106 

16.1  EXERCISE: COBOL COPYBOOK MESSAGES ...................................................................... 106 

17  DATA MASKING ..................................................................................................................... 109 

17.1  EXERCISE: FIXED VALUE SUBSTITUTION ............................................................................ 109 

17.2  EXERCISE: DATA SOURCE SUBSTITUTION ......................................................................... 111 

17.3  EXERCISE: AUTOMATIC VALUE CREATION ......................................................................... 112 

18  DATA MODEL STUBS ............................................................................................................. 114 

18.1  EXERCISE: RECORDING A WEB SERVICE WITHOUT A WSDL ............................................... 114 

18.2  CREATING A DATA MODEL STUB AND ASSOCIATED OPERATIONS ......................................... 116 

18.3  EDITING THE DATA MODEL STUB ...................................................................................... 126 

19  STATE AND SESSIONS ............................................................................................................ 129 

19.1  EXERCISE: TRACKING USER SESSIONS ............................................................................. 129 

20  BEHAVIOURS ......................................................................................................................... 132 

20.1  EXERCISE: THE TIMER BEHAVIOUR ................................................................................... 132 

21  LEGAL NOTICES .................................................................................................................... 137 

Page 6: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page4of138©IBMCorporation2001,2012

1 Introduction

ThisdocumentservesasatrainingmanualtohelpfamiliarizetheuserwiththevirtualizationfunctionalitypresentinIBM®Rational®IntegrationTester.Thetrainingexercisesmakeuseofavarietyoftechnologies,includingIBMWebSphere®ApplicationServer,WebSphereMQ,IBMDB2®,andwebservices.Itisassumedthatthereaderhasafairunderstandingofthesesystems.

ThemainobjectivesofthistrainingcoursearetopresentthevariousfunctionalitiesoftheVirtualIntegrationEnvironment(VIE)andhowbesttousethemintestingMessageOrientedMiddleware(MOM)applications.Inthiscoursewewill:

WalkyouthroughtheinstallationofthedifferentcomponentsofVIEonyourPC PresentthevariousperspectivesinthedesigncomponentofVIE,RationalIntegrationTester,

describinghowandwhentheyareused DemonstratehowVIEcanfacilitatevirtualizationofservicesinamessageorientedmiddleware

architecturebyo Recordingmessagesorsynchronizingwiththesystemtoprovideamodelofthesystem.o Providingagraphicalinterfaceforthedisplayandcreationofmessageso Creatingvirtualizedservicesformessagebasedsystemsanddatabasesfromrecorded

events.o Allowingtherunningofvirtualizedservicestoberepeatedoverandoverwithlittle

manualintervention Demonstratehowtovirtualizedatabaseconnectionswithinthesystemundertest Createandutilizedatamodelsbetweenasetofvirtualservices,allowingdatatobepersisted

andmodifiedacrossservices,andbetweenexecutionsofthoseservices. PublishvirtualservicestotheRationalTestControlPanel(RTCP),allowingthemtobedeployed

andmanagedfromacentralrepository.

Page 7: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page5of138©IBMCorporation2001,2012

2 Using Virtualized Applications for Testing

2.1 Introduction

WhenweneedtotestasetofserviceswithinaService‐OrientedArchitecture(SOA),wemayfindthatsomecomponentsofthesystemareunavailable.Thismaybeforanumberofreasons.Itmaybethataparticularserviceisstillunderdevelopment,andcannotbeaccessedyet.Perhapsdevelopmenthasnotevenstartedyet.Inothercases,servicesmaybeinusebyothers,andcannotbeshared–ormaybeexpensivetouse.Openingupaccesstootherservicesmightexposeprivatedatatotesters,andsothoseservicesarenotavailabletothetestteam.

Alternatively,servicesmaybeavailable,buttheymightnotberespondinginthewaythatisnecessarytocarryoutagivensetoftests–forexample,usersmaywanttocheckthatthesystemrespondsappropriatelytoerrorconditions.Bystubbingaparticularservicetogeneratetheseerrors,atestercanhavefullcontrolovertheoperationofthesystem,allowingthemtotestconditionsthatmaynotexistwithinthelivesystem.

Whateverthereason,whileconductingSOAtesting,itislikelythatatesterwillhavetheneedforthesystemtooperateinwaysthatmaynotbecurrentlyavailable.Thismaycausedelays,duetodependenciesonthecomponentsinquestion.

VIEisasetofintegratedtoolsthatallowyoutostuboutdependencieswithinatestenvironment,allowingtestingtocontinuewithoutworryingaboutanymissingcomponents,ormodifyingexistingcomponentstoactdifferently.Yourstartingpointmaybeaclientapplicationthatcommunicateswithaservicethroughthenetwork,usingoneofthecommunicationmethods(ortransports)supportedbyVIE.ThisclientapplicationmaypresentaGUItoauser,oritmaysimplybeanotherservicewithinyourarchitecture.

However,forwhateverreason,thisserviceisunavailable.Inordertocarryoutourtesting,wewillneedtoprovideavirtualreplacementfortheservice.UsingVIE,wecancreatethisreplacement–avirtualservicethatreactstothesamenetworktraffic,onyourexistingtestinfrastructure.

YoumayalreadybefamiliarwiththeconceptofaVirtualMachine(VM).VirtualizationasimplementedwithVIEshouldbethoughtofasmoregranularthanVMs.VIEcanvirtualizeanapplicationordatabase(orjustpartofthatapplicationordatabase),whereasVMsaredesignedtovirtualizeanentiremachine.VMsalsorequirelicensesfortheirapplicationsandaregenerallystillmaintainedoutsideofthetestteam.VMsarelessflexiblefortestingpurposeswhereasavirtualizedapplicationinVIEcan

Page 8: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page6of138©IBMCorporation2001,2012

easilybemanipulatedtofityourtestingpurposes.Forexample,youmaywantyourvirtualapplicationtosendinerroneousdatafornegativetestingofyoursystem.

2.2 TheOldWorld

Stubbingoutcomponentsofasystemallowsustotestthatsystemwithoutwaitingforcomponentstobecomeavailable.However,testershavetraditionallybeenreliantondeveloperstocreatethesestubs.

Thesestubswereusuallynotuser‐friendly.Therewouldbelittlechancethatatestercouldpickthemupandre‐usethem.Additionally,maintenancewouldnormallybehandledbythedevelopers.Thisapproachhadlittleon‐goingvalueandpoorreturnoninvestment.VIEhasbeencreatedtochangethis.

2.3 TheNewWorld

VIEmovestestersintoanewworldwheretheybuildandmaintaintheirownstubs.Infact,testerscangoevenfurther–stubsbecomevirtualapplications.VIEdoesnotrequireanycoding;virtualapplicationsareeasilymaintainedanduniversallyunderstood,ensuringmaximumre‐use.

2.4 WhentouseVIE

Thechancesarehighthatyouareworkinginacomplex,changeableenvironment.Functional(andnon‐functional)requirementschangequicklyandtestenvironmentsandapplicationsareinhighdemandfromotherteams.ThishighpressureenvironmentputlotsofstrainontestteamsandisthereasonthatVIEexists.VIEhelpsin3keyareas:

1. Ithelpsyoutocontinuetestingwhenenvironmentsarenotavailable

2. Itallowsyoutotestearlierandmoreoften,reducingthecostofdefects

3. ItallowsyoutoforcebehaviorintheSUTbybeingincontroloftheservices(ormorespecifically,theresponsesfromthoseservices).

Withthese3thingsinmindwecanbegintothinkaboutthesituationsthatVIEmightbeapplied.

2.5 UsingVIEStrategically

VIEisdesignedtobeappliedinalltestphasesfromUnitTestingtoUAT.Hereisagoldenrule:weshouldalwaystestascompletelyaspossible.WeknowthatwhenweareUnitTestingindividualoperationsorservicesthatwemaynotalwayshavetheinterfacingcomponentsavailabletotestagainst.Sowevirtualizetheseinterfacingcomponentstoallowustorunourunittests.

AswemovethroughthetestphasesfromUnitTestingtoIntegrationTestingandonwards,weintroducemore“real”componentsintothesystem.Theintroductionoftheserealcomponentshasbeende‐riskedthroughvirtualization.TheseinterfaceshavebeenaccuratelymodeledbyVIEandtestedagainst.ThisistheconceptofIncrementalIntegrationTestingandithelpstovisualizethis:

Page 9: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page7of138©IBMCorporation2001,2012

Initially,webuildasystemusingthefirstcomponentsthatareavailable.Anyothercomponentsthatarerequiredarevirtualized.Wethenintroducenewcomponentsintothesysteminaprioritized,controlledfashion,replacingthevirtualcomponentsaswego.Duringthisstage,wecanperformincrementalintegrationtesting.Eventually,wewillreachastagewhenallactualcomponentsareavailablefortest.Wewillthenbeabletocarryoutfullendtoendtestswithveryfewsurprises,aswehavebeengraduallybuildingtowardsthisstagethroughouttheentiretestprocess.

2.6 SolvingProblemswithVIE

Yourtestingprojectmaybeheavilyreliantonintegrationwith3rdparties.Thiscanbeimmenselyfrustratingandcostly.VIEcanvirtualize3rdpartyinterfacestoallowyoutotestonyourowntermsaccordingtoyourschedule

Integrationdependenciesarenotyetreadytoparticipateintesting.Paralleldevelopmentmeansthatsomeprojectsmaynotbereadytobeginintegrationtestingwhenyourprojectisready.VIEallowsyoutovirtualizeinterfaces(evenbeforetheyhavebeenbuilt)andcontinuetesting

Runningtraininginstancesofapplicationswithoutaccesstolargeinfrastructure.Fortrainingpurposes,youmaynotrequireaccesstoproductionsizedversionoftheapplication.Youmayalsonotrequireaccesstoanydownstreamapplications.VIEcanvirtualizeandsimplifyinterfaces,ensuringthattrainingexercisesdonotimpacttheproductionsystems

Testingadatabasedependentapplicationwithscrubbedandisolateddata.VIEcansimulatedatabasestoo.Ofcourse,thismeansthatyouwillhavefullcontrolofallofthedatatobeusedintesting

Providingatestsystemwhereotherwisetherearenone.Itmaybetooexpensivetobuildthattestenvironment.Itmaytaketoolongtobuildit.Itmaybethatthetestenvironmentisbeingusedbysomeoneelseforthedurationofyourproject.VIEstandsintovirtualizeapplications.

2.7 VirtualApplications–SimpletoComplex

Virtualapplicationscanbeassimpleorascomplexasrequired.VIEprovidesyouwiththetoolstomodelyourapplicationtothelevelyourequire.

Page 10: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page8of138©IBMCorporation2001,2012

Aswemovethroughthistrainingcourse,wewilllookathowwecancreateeachofthesetypesofstub,startingfromsimplehardcodedstubs,movingtowardsmorecomplexstubsthattrackdatamodelsandbehaviors.

Page 11: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page9of138©IBMCorporation2001,2012

3 VIE Architecture and Setup

3.1 Overview

InordertointroduceVIE,weneedtotakealookatthedifferentcomponentsthatyoumayusewhileworkingwithit.ThesetoolsareRationalIntegrationTester(RIT),RationalTestControlPanel(RTCP),andtheAgents.Theywillbeusedinthethreestagesofastub’slifecycle–development,publication,anddeployment.

RationalIntegrationTesteristhemaintoolthatwewilluseforthecreationofvirtualservices.Itmayalsobeusedforlimiteddeploymentofservices.Itallowsustocreateamodelofthesystemundertest,recordeventsfromthesystem,aswellastocreateandexecutestubs.

TheRationalTestControlPanelisaseparatetoolthatwillallowustomanagevirtualserviceswithinyourenvironment.Generally,afterthedevelopmentofastub,itmaybepublishedfromRationalIntegrationTestertoRTCP.Thestubisthenstoredwithinarepositoryontheserver.Fromthisrepository,eachvirtualservicemaybereconfigured,deployedandmanaged.Theserverisalsousedtomanageanyagentswithintheenvironment.

Agentscanrunonanumberofcomputers,providingtheabilitytohandledifferenttasksfortheVIEsystem.Someagentswillactasproxies,redirectingdifferenteventssothattheymayberecordedwithinRationalIntegrationTester,orhandledbyavirtualimplementation.Otheragentsactashostsforvirtualservices,allowingthemtobedeployedtodifferentlocationswithinthenetwork.Bothtypesofagentswillberegisteredwiththeserver,andwilltakeinstructionsfromit.Theywillalsoreportloggingdatabacktotheserver.

Page 12: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page10of138©IBMCorporation2001,2012

Optionally,aprojectdatabasemaybeusedtorecordlogginginformationfromanyvirtualservicesthatareinplaceforlaterreview.ThisisnotnecessaryforservicesrunfromRationalIntegrationTester,butadatabaseisrequiredtoreviewinteractionswithastubifithasbeendeployedfromRTCP.TheprojectdatabasecanbesetupasaMySQL,MSSQLorOracledatabase.

Dependingonthetaskathand(recording,virtualization,orboth),thecommunicationsbetweenthesecomponentswillbeslightlydifferent.Wewilllookathowthesecomponentsfittogetherineachsituationasweencounterthem.

3.2 DomainsandEnvironments

StubscreatedinVIEwillbeorganizedintoastructureusingtwoproperties:domainsandenvironments.

AdomainrepresentsalogicalgroupingofrelatedsystemsthatarepartofarealbusinessprojectanditisthebasicunitofmanagementwithinVIE.ItmaybeservedbyoneormoreRationalIntegrationTesterorVIEprojects,dependingonhowlargeorsmallthedomainis,andhowmanyRationalIntegrationTester/VIEusersareworkingonit.

Itisusualforaserviceorotherendpointtoappearinmorethanonedomainbecauseitisreusedbydifferentbusinessprojectsindifferentcontexts.Thus,adomainisusedasameanstogroupandmanageassetsinRTCP.Forexample,uniquebusinessgroupswithinanorganizationmaywanttomanagestubsindependentlyfromeachother.

WhilebeingdevelopedandexecutedinsideRationalIntegrationTester,eachstubusesthedomainoftheRationalIntegrationTesterproject.WhentheyarepublishedontoRTCP,theymaybepublishedintothatdomain,oranotherdomain.ThisallowsustocontrolstubswithinagivendomainthroughRTCP;wecanalsocontrolanyproxiesoragentswithinthesystemsothattheyacceptinstructionsonlyfromstubsrunninginparticulardomains.

AfterstubshavebeenpublishedtoRTCP,theymaybestartedandstoppedthroughtheRTCPinterface,andtheroutingofmessages(tostubsorlivesystems)canbecontrolledatdomainlevel.

Eachdomaincancontainoneormoreenvironments.InRationalIntegrationTesterandVIE,anenvironmentenablesuserstodefineboththeinfrastructureusedbyanymessagingtransports,aswellasagroupofvariables(calledtags)thatmaybeusedbyanytestsorstubsrunningwithinthatenvironment.

Typically,environmentsareusedtocreateconfigurationsfordifferentpartsofasoftwareproductdevelopmentworkflow,forexample,development,qualityassurance,useracceptancetesting,andsoon.

EnvironmentsarenotcreateddirectlywithinRTCP.Instead,theyarecreatedautomaticallywhenstubsarepublishedfromRationalIntegrationTester(becausestubsarepublishedintoanenvironmentwithinadomain)orwhenaproxyoragentregisterswithRTCPspecifyinganenvironmentname.

Page 13: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page11of138©IBMCorporation2001,2012

Environmentswithineachdomainareindependentfromthoseinotherdomains–soifwehaveaPerformanceenvironmentinonedomain,itdoesnotneedtoexistinallotherdomains.Similarly,ifusersinsideonedomaincallatestenvironmentIntegrationTesting,itdoesnotmeanthatallotherdomainsneedtousethesamenamingscheme.

WhenstubsarepublishedintoRTCP,theymaybepublishedintooneormoreenvironments.SowithinaShippingdomain,wemighthaveanAddresslookupstubthatisonlyusedwithinadevelopmentenvironment,whileaDispatchOrderstubmayexistwithinmultipleenvironmentswithinthatdomain.

Page 14: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page12of138©IBMCorporation2001,2012

4 Rational Integration Tester Project Setup

4.1 TheInitialScreen

Onceconfigurationofoursystemiscomplete,we’rereadytolaunchRationalIntegrationTesterandcreateanewproject.LaunchingRationalIntegrationTesterwillbringupthefollowingscreen:

IfyouarerunningRationalIntegrationTesteronyourlocalmachine,youwillneedtomakesureyouhavealicenseatthisstage–cloudinstancesshouldalreadyhavealicenseinstalledforyou.Formoreinformationonlicensing,pleaseaskyourtrainer,orviewsection2.2oftherit_ins.pdfinstallationguide.

Oncelicensingissortedout,youhaveseveraloptions.Fromtoptobottom:

NewProject–allowsyoutocreateaproject.

CloneProject–createsacopyofanyRationalIntegrationTesterproject.

FetchProjectfromSourceControl–Checkoutaprojectfromasourcecontrolsystem,andopenit.NotethatyouwillneedtoconfigureRationalIntegrationTestertocommunicatewithyoursourcecontrolsystembeforedoingthis.Seetherit_scm_ref.pdfpluginguideformoreinformation.

OpenLink–followsalinktakenfromtheTestLabtonavigatetotheresultsofatestortestsuite.

Page 15: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page13of138©IBMCorporation2001,2012

Openanexistingproject–opensanexistingproject,eitherfromthelistofrecentprojectsshownbyRationalIntegrationTester,orbybrowsingtoa.ghpfile.

4.2 CreatingaNewProject

Creatinganewprojectgoesthrough4stages.Theseare:

1. Settingtheprojectnameandlocation

2. Connectingtoexternalservers

3. Settingupuser‐basedpermissions

4. Settingupchangemanagementintegration

Onlythefirststepiscompulsory;theothersareoptional,butcanbeeditedlaterfromwithintheproject.Ifyouneedtoeditanyofthesesettingsaftertheprojecthasbeencreated,youcandoitthroughtheProjectSettingsdialog(foundintheProjectmenuofRationalIntegrationTester).

Thatsaid,fillingouttheserversettingslistedinthesecondstageoftheprojectcreationprocesswillnormallybeveryuseful,andwewillbesupplyingthatinformationfortheexamplesusedinthiscourse.

Thefirstofthesesettingsisforaprojectdatabase,whichwewillbeusingduringthistrainingcourse.Theprojectdatabaseprovidestheabilitytorecordandviewhistoricaltestresults–withoutthis,youwillonlybeabletoviewresultsfromthecurrentsession.Italsoprovidestheabilitytorecordloggingdatafromanystubsthatyouuse.ScriptsareprovidedwithRationalIntegrationTestertohelpyousetupandconfigureaprojectdatabase,whichmaybeaMySQL,MSSQL,orOracledatabase.Onceitissetup,thedatabasemaybesharedacrossmultipleusersandmultipleprojects.

TheotherserversettingsavailableareforRTCPandtheResultsServer(legacyusersonly).RTCPprovidestheabilitytomanageanyproxiesandagentsusedbythesoftware;thesecapabilitiescanbeusedwhilerecordingandstubbing.TheResultsServersettingisusedtocreatelinkstothereportsheldontheserver,whichshouldalsobeconnectedtoyourprojectdatabase;thisfunctionalityisnowprovidedbyRTCP,sotheResultsServerisnolongerrequired,andwillnotbeusedinthisproject.

Asweonlyhaveasingleuserforourexampleproject,wewillnotconfigureuser‐basedpermissionsforourproject.Itwillbeusefulinotherprojectswhereitisnecessarytorestrictaccesstoaprojecttocertainindividuals,ortoallowdifferentaccesslevelstotheprojectfordifferentusers.Inparticular,itwillbehelpfulforprojectsthatimplementdatamasking–permissionswillallowoneusertosetupmasksovercertainmessagefields,sothatotheruserscannotviewthecontentsofthosefields.Wewilldiscussthisfurtherinthesectionondatamasking.

Finally,wecanconfigureaconnectiontochangemanagementtoolssuchasJIRA,HP’sQualityCenter,oranyOpenServicesforLifecycleCollaboration(OSLC)compliantchangemanagementsystem,suchasRationalTeamConcert.Thisallowsustolinkdirectlyintothesetools,andraisedefectsdirectlyfromatestortestsuite.

Attheendofthewizard,anewprojectfolderwillbecreatedwithinyourfilesystem.Thisfolderwillholdallresources–amodelofthesystemundertest,alongwithanytests,stubsorotherresourcescreatedfortheproject.Datafilesusedbyyourprojectcanalsobestoredhere–thiscanhelpyoumakeyourprojectmoreportablebyincludingeverythinginoneplace.Alternatively,youmightwantto

Page 16: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page14of138©IBMCorporation2001,2012

includethosedatafilesinanotherlocation–RationalIntegrationTesterwillbeabletorefertothemeitherway.

4.3 Exercise:CreatingtheTrainingproject

Wewillnowcreateabrandnewproject,whichwewillcontinuetouseforthedurationofthiscourse:

1. LaunchRationalIntegrationTesterbydouble‐clickingtheIBMRationalIntegrationTestershortcutonyourdesktop.

2. RationalIntegrationTesterwilllaunch,displayingtheinitialscreen.CreateanewprojectbyselectingNewProjectandclickingOK.

3. Wecannowgiveourprojectaname,usingtheProjectNamefield.We’llcallourproject

WWTravel Virtualization.

Page 17: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page15of138©IBMCorporation2001,2012

4. Ifdesired,modifytheOwnerandCommentsfields(thesearesavedwiththeprojectandcanbe

modifiedlater).

5. IntheDirectoryfield,enterthefullpathtothedirectorywheretheprojectshouldbecreated,orclickBrowsetolocatethedirectory.TheselecteddirectorycannotcontainanexistingRationalIntegrationTesterproject.

6. Whenyouaresatisfiedwiththeprojectdetails,clickNext.Iftheselecteddirectorydoesnotexist,youwillbepromptedtoletRationalIntegrationTestercreateit,oryoucangobackandselectadifferentdirectory.

7. ThewizardwillnowdisplaytheServerSettingsdialog.Atthetopofthisdialog,thereisaResultsDatabasesection,wherewecanprovideconnectiondetailsfortheprojectdatabase,whichisusedtostoreallofthetestdatacollectedbyRationalIntegrationTester.AvaliddatabaseandworkingconnectionarerequiredtostoreorviewanyhistoricalresultsinRationalIntegrationTester.

8. RationalIntegrationTesterwillrememberthedatabasedetailsthatwereusedpreviously;ifyouareusingacloudinstance,thismeansthatyoushouldalreadyhavedetailsenteredforyou.Otherwise,youwillneedtoentertheDatabaseURL,UserName,andPassword.Ifyouneedtore‐enterthem,thesettingsforthedatabasesonthecloudinstancesareshownbelow.Otherwise,askyourtrainer.

Page 18: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page16of138©IBMCorporation2001,2012

Settings Value

DatabaseURL jdbc:mysql://localhost:3306/projectdb 

UserName root 

Password root 

9. ClickonTestConnection.Awindowshouldpopupstatingthattheconnectionwassuccessful.

10. Belowthedatabasesettings,wecanconnecttotheResultsServerandRTCP.WewillnotbeusingtheResultsServer,butRTCPwillbeneededlateron.Thedefaultsettinghereshouldbesufficient:

Settings Value

RTCPURL http://localhost:7819/RTCP 

Domain Booking System 

Page 19: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page17of138©IBMCorporation2001,2012

11. Whenyouaresatisfiedwiththedetailsenteredonthisscreen,clickFinish.Ifuser‐basedpermissionsorconnectionstochangemanagementtoolswererequired,youwouldneedtochooseNext,andthensetthemuponthefollowingscreens.

12. ThenewprojectwillbeopenedinRationalIntegrationTester.Bydefault,itwilldisplaytheLogicalViewintheArchitectureSchoolperspective.

Page 20: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page18of138©IBMCorporation2001,2012

4.4 RationalIntegrationTesterlayout

ThemainwindowofRationalIntegrationTesterisaworkbenchthatcontainsseveraldockablewindows.Thesewindowsareorganizedinalogicalway,providinganintuitive,easy‐to‐usecentralworkspace.

Informationaboutyourcurrentprojectcanbefoundinthetitlebarandstatusbar.Atthetopofthescreen,thetitlebarindicatesthenameofthecurrentproject,alongwiththecurrentenvironment.Atthebottomofthescreen,thestatusbarindicatesthenameofthecurrenttestcycle,thecurrentuser,andthememoryusage.Forthepurposesofthismanual,wewillnotneedtobeconcernedwiththeinformationinthestatusbar,thoughyoumayfinditusefultokeepaneyeonthetitlebartocheckwhichenvironmentiscurrentlyactive.

Page 21: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page19of138©IBMCorporation2001,2012

4.5 RationalIntegrationTesterPerspectives

InthecenterofthescreenisthemainworkbenchofRationalIntegrationTester,showingthecurrent

perspectiveview.Theworkbenchcanbeviewedfromoneofsixperspectives ,selectedfromthePerspectivestoolbar:

Perspective Icon Description

ArchitectureSchool

definesthearchitectureofthesystemundertest,includingservicecomponentsaswellaslogicalandphysicalresources

RequirementsLibrary

createsrequirementsthatwillhelpotheruserstocreatetestsandtestdatamorequicklyandmoreaccurately

RecordingStudio

monitorssystemsandprocessestorecordeventsthatarecapturedbyRationalIntegrationTester

TestFactory

creationoftests,testsuites,stubsandtestdatasets

TestLab

executesresourcesthatarecreatedintheTestFactory

ResultsGallery

containshistoricaltestdataandletsusersviewvariousreportsforanystoredtestrun,includingperformance,errors,andcoveragedata

Theinitiallayoutoftheworkbenchforeachperspectiveispre‐determined,anditcanberestoredatanytimebyselectingWindow>ResetCurrentPerspectivefromthemainmenu.Manyaspectsoftheworkspacecanbecustomized.Eachwindowcanberesizedwithintheworkbenchbyclickinganddraggingonitsborders;itcanbeclosedviathe buttoninthetoprighthandcornerandcanbesettoautomaticallyhidewhennotinusewith ortoremainconstantlyvisiblewith .

Page 22: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page20of138©IBMCorporation2001,2012

5 Modeling the System

5.1 PerspectiveOverview

TheArchitectureSchoolperspectiveisthedefaultperspectiveloadedwhenRationalIntegrationTesterisstarted.Thisperspectiveisusedformodelingthesysteminasimple,graphicalfashion.Thismodelissplitintoseveralparts.Asthemodelissplitintoseveralparts,theArchitectureSchoolperspectiveisalsosplitintoseveraldifferentviews.Inadditiontotheseviews,wealsouseanEnvironmenttobinddifferentpartsofthemodeltogether.

Theviewsarepresentedalongthebottomofthescreen:

LogicalView

PhysicalView

Synchronisation

SchemaLibrary

DataModels

RuleCache

Forthemoment,we’regoingtolookatanexampleofasimplesystem,whichwillmakeuseofthefirsttwoviews,alongwithEnvironments,whichareusedtotietheLogicalandPhysicalviewstogether.We’llthenmovetotheSchemaLibrarytosetupmessageformats.

5.2 WorkinginMultipleEnvironments

Aswemovethroughthelifecycleofaproject,testingmaybecarriedoutovermultipleenvironments.Forexample,wemighthaveadevelopmentenvironment,usingdevelopmentdata,anditsowninfrastructure.Aswemoveintoaformaltestphase,wemightstarttousedifferentinfrastructurecomponents,ordifferentdata.Finally,inproduction,acompletelynewsetofinfrastructurecomponentswillbeused,andreal‐worlddatawillbeinuse.

Thisisonlyasimpleexample,butitservestoillustratetheproblem:ifwe’renotcareful,wecouldcreatetestsorstubsthatwillneedtoberebuiltaswemovefromenvironmenttoenvironment,orevenworse,resourcesthatarenotportableatall.Fortunately,RationalIntegrationTesterprovidesasolutiontothis,bypartitioningthemodelofthesystemundertest.Inordertomoveourresourcesacrossdifferentenvironments,wewillsetuptheinfrastructureofoursysteminthreesections:LogicalView,PhysicalView,andtheEnvironment.

Page 23: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page21of138©IBMCorporation2001,2012

TheLogicalViewprovidesuswithanabstractviewofthesystemundertest,butdoesnottieustousinganyparticularinfrastructure.Asanexample,itwillstatethatadatabaseisrequiredbyoursystem,butitwillnotstateanymorethanthat–thedatabaseURL,connectiondetails,andeventhetypeofdatabaseproviderarenotspecifiedatthisstage.

ThePhysicalViewthendefinesalloftheimplementationoptions–so,forourexample,wemayhave3separatedatabasesusedacrossalldifferentenvironments.All3databaseswouldbelistedinthePhysicalView.

Finally,theEnvironmentbindsthelogicalandphysicalresourcestogether.Atanystage,RationalIntegrationTestercancheckwhichenvironmentisbeingused,andifareferenceisfoundtoalogicalinfrastructureelement,itwillusetheenvironmenttofindthecorrectphysicalcomponent.So,tofinishoffourexample,ifweneedtoaccessadatabasewithinatestorastub,RationalIntegrationTesterwilllookuptheenvironmenttodeterminewhichofthe3databasesshouldbeaccessed.Ifwethenmovetoanotherenvironment,RationalIntegrationTesterwillperformthelookupagain,andselecttheappropriatedatabase.

Ofcourse,thisappliestoanyinfrastructure–notjustdatabases,butalsowebservers,Emailservers,JavaMessageService(JMS),oranyproprietarytechnologies.

5.3 LogicalView

TheLogicalViewprovidesanabstractmodelofthesystemthatweareinteractingwith.We’regoingtobuildasimplemodelheretodemonstratehowthisworks.Thismodelwillbemadeupofseveraldifferentelements:

Thefirstobjectwe’llneedtocreateisaServiceComponent.ServiceComponentsactascontainersforallotherelementswithintheLogicalView,andmaycontainotherServiceComponentstobuildupmorecomplexstructures.

Inmostcases,we’llwanttodefineOperationswithinaServiceComponent.Operationsdefinethefunctionalityofthesystem.Wewillbeabletocreateresourcesbasedupontheinformationprovidedwithineachoperation.

Page 24: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page22of138©IBMCorporation2001,2012

Inordertocommunicatewiththeoperationsavailablewithinthesystem,we’llalsoneedasetofInfrastructureComponents.Thesearenamedcomponentsthatcanbeboundtophysicalresources.RememberingthatLogicalViewdoesnotcontainanyconcretedetailsofthesecomponents,theywillservetotellusthatthereisaJMSserver,database,webserver,etc.,whilethePhysicalViewandEnvironmentwillprovidemoreexactinformationlateron.

Alloftheseelements–servicecomponents,operations,andinfrastructurecomponents‐maybecreatedbypressingCtrl+Ntocreateanewcomponent,rightclickingandusingthecontextmenu,orfromthetoolbaratthetopoftheLogicalView.Inaddition,youcanuseCtrl+Ftofindresourcesaftertheyhavebeencreated.

Finally,wewilluseDependenciestolinkoperationstoeachother,ortoinfrastructurecomponents.Outgoingdependenciesaredisplayedinlavender,andincomingdependenciesaredisplayedingreen.Dependenciesareonlydisplayedforitemsinthediagramthatareselected.Intheexamplediagramabove,thisletsusknowthat:

Operation1hasadependencyonOperation2,meaningthatOperation1maycalluponOperation2(thoughitmightnotdosoinallcircumstances).

Operation2hasadependencyontheHTTP Connection.ThiswillnormallymeanthateitherwerequirethisHTTPconnectiontoactasthetransportfortheoperation,orthattheoperationmayneedtomakeuseoftheHTTPconnectionitselfafterithasreceivedamessage.

Tocreateadependency,wecaneitherdrawitusingtheAddaDependency buttoninthetoolbar,orifwearesettingupaninfrastructurecomponentasthetransport,wecandothisbyopeninguptheoperation’spropertiesbydoubleclickingonit,andeditingthetransportinformationwithintheMessageExchangePatterntabofthepropertieswindowthatappears.

Page 25: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page23of138©IBMCorporation2001,2012

Thetoolbarcontainsanumberofotherusefultools,attherighthandside:

AddanExternalResource:createsanewExternalResource,orSynchronizationSource,withintheLogicalView,andoptionallysynchronizeswithit.Wewilldiscusssynchronizationindetaillateron.

AddaDependency:allowsyoutodrawadependencybetweentwooperations,orfromanoperationtoaninfrastructurecomponent.

EditFilters:filtersdeterminewhichdependencieswillbeshownintheLogicalView.Theymaybenecessaryinlarger,morecomplexsystems.

Selectionmode:putsthecursorintoselectionmode,whereyoucanselectandeditelementsofthemodel.Thisisthedefaultcursormode.

Zoomin:zoomsintothediagram.ThiscanalsobedonewithCtrl+MouseWheelUp.

Zoomout:zoomsoutofthediagram.ThiscanalsobedonewithCtrl+MouseWheelDown.

Zoomarea:zoomstofitanarea,drawnwiththemouse,ontothescreen.

ResetZoom:setsthezoombacktothedefaultlevel.

Fittocontents:zoomsthescreentofiteverythingcontainedintheLogicalView.

Panmode:usesthecursortopanaroundthescreen.

Layoutallnodes:automaticallyrearrangesallelementscontainedintheLogicalView,sothatnothingisobscured.

Grid:switchesthegridonoroff.Thedefaultsettingisoff.

Wewillnowusetheelementsdescribedabovetostartbuildingamodelofanexamplesystem.Thissystemwillcontainasinglewebservice.Wecanusethissameprocesstobuildamodelofanyserviceorientedarchitecture.Lateron,wewilllookatmoreefficientmethodstobuildthemodel,thoughasthesearenotavailableinallenvironments,we’lllookatbuildingeverythingbyhandforthisfirstexample.

5.4 Exercise:SettinguptheLogicalViewforaSimpleSystem

1. Beforestarting,we’llneedtomakesurethatthewebservicewe’remodelingisactive.OntheWindowsdesktop,doubleclicktheAddNumbersServer.jartoexecuteit.Youshouldseethefollowingwindowappear:

Page 26: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page24of138©IBMCorporation2001,2012

2. PresstheStartServicebutton.TheAddNumbersServerwindowshouldupdatesothatthe

StartServicebuttonisnolongervalid:

3. Minimizethiswindow(donotcloseit),andreturntoRationalIntegrationTester.

4. FromtheArchitectureSchoolperspective,makesurethatyouareinLogicalViewusingthe

tabatthebottomofthescreen.

5. Themiddleofthescreenwillbeblank,asthereiscurrentlynothinginourmodel.Toaddthefirstcomponentofasystem,rightclickandselectNew>General>ServiceComponent.Whenaskedforaname,callitAddNumbers.Itshouldthenappearinyourworkspace:

6. SelectAddNumbersbyclickingonit.Theoutlineshouldchangetoorange,toindicatethe

selection.

7. RightclickontheAddNumberscomponent,andselectNew>General>Operation.CalltheoperationAddition.Yourservicecomponentshouldnowlooklikethefollowing:

Page 27: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page25of138©IBMCorporation2001,2012

8. Similarly,addaninfrastructurecomponentcalledAddNumbersPort,byrightclickingandselectingNew>Web>HTTPConnection

9. Thelogicaldescriptionofourbasicsystemisnearlycomplete.WejustneedtodefinethetransportinformationfortheAdditionoperationbytyingittotheAddNumbersPort.DoubleclickontheAdditionoperation,andtakealookattheMessageExchangePatterntab.

10. LookfortheTransportproperty,andpresstheBrowse…buttonnexttoittoselectatransport.

11. Inthedialogthatappears,selecttheAddNumbersPortwecreatedearlier.PressOKtoreturntothepropertiesoftheAdditionoperation.

12. TheBindingsectionofthedialogwillnowhavebeenupdatedtopointtowardstheAddNumbersPort.AsetofHTTPsettingswillalsobeavailablenowthatwehavespecifiedaHTTPtransport.We’llcomebacktothesesettingslater–fornow,pressOKtoclosethepropertiesdialog.

13. Youshouldnowbeabletoseethedependencybetweentheoperationandtheinfrastructurecomponent.SelecttheAdditionoperationbyclickingonit,andyoushouldseeapurplearrowgoingfromtheoperationtoAddNumbersPort.ThisindicatesthattheAdditionoperationisdependentonAddNumbersPort.

14. Trynavigatingaroundthelogicalviewusingthefollowingcontrols:

o Tonavigatearoundthelogicalviewyoucanusethehorizontalandverticalscrollbars,orpressthePanbutton andleftclickonthescreentodragitaround.

o Toadjustthezoomlevelyoucanuseeitherthezoombuttons orholddowntheCtrlkeyandusethemousewheel.

o Tomoveanyoftheservicesorcomponentsaround,ensuretheSelectCursorbutton isselected,andleftclickontheserviceorcomponentyouwishtomove,anddragittothedesiredlocation.

o Ifyoueverwanttoresetthelayoutoftheservicesandcomponents,thentheLayoutAllNodesbutton willorganizethemintoanefficientlayout.

o Tosetthezoomlevelsothattheentirediagramfitsinsidethescreen,usetheFittoContentsbutton .

5.5 PhysicalView

Onitsown,thelogicalviewthatwe’vecreatedisnotenoughtofullydescribeoursystem.Asmentionedpreviously,itdoesn’tcontaininformationabouttheaddressoftheserverwe’retalkingto,

Page 28: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page26of138©IBMCorporation2001,2012

oranyconnectionsettingsthatmayberequired.We’regoingtospecifythisinformationseparately,inthePhysicalView.

Thisviewdisplaysavailablephysicalresourcesandtheirlocationwithintheenterprise.EachresourcelistedwithinthePhysicalViewrepresentsasingleconfigurationofaninfrastructurecomponentdescribedintheLogicalView.

Resourcesinthisviewareorganizedbysubnetandhost.Ifaresourceisnotassociatedwithasubnetorhost,itwillbedisplayedunderUnconnectedResources.We’regoingtocreatethephysicalresourcefortheAddNumberswebservice–asimplewebserver.

5.6 Exercise:SettingupPhysicalViewforaSimpleSystem

1. SwitchtoPhysicalViewusingthe tabatthebottomofthescreen.

2. We’regoingtoaddanewresourcehere.Alongthetopoftheperspective,you’llseeatoolbarcontainingoptionsforaddingnewresourcesfromdifferentcategories

3. ChoosetheWebcategory,andthenchoosetheWebServer option.

4. TheNewWebServerdialogwillappear.SettheHostsettingtolocalhostusingPort8088.

5. PressTestTransporttomakesurethatyouareabletoconnectproperlytothewebservice.Onceyouaresatisfiedthatitisworkingproperly,pressOKtoclosethedialogandsavethenewresource.

5.7 Environments

Oncewehavethelogicaldata,whichgivesusanabstractmodelofwhatinfrastructureisrequiredbyoursystem,andthephysicaldata,whichspecifiesthedifferentconfigurationsavailableforeachinfrastructurecomponent,wethenneedtomatchtheseup.Rememberingthatthiscouldchangebetweendifferentstagesofthelifecycleoftheproject,wecanuseasetofenvironmentstocoordinatethisprocess.

Anewprojectstartswithoutanenvironment,sowe’llcreateaninitialenvironmentinthisexercise.Otherenvironmentscouldbecreatedsubsequentlyasrequired.Thesewillallowustokeepusingthesametestresources,simplybyswitchingtonewenvironmentsastheybecomeavailable.

Environmentsdonothavetheirownview;instead,thereareanumberofoptionsintheProjectmenuwhichallowustoaccessandeditanenvironment:CreateNewEnvironment ,EditEnvironments,andSwitchtoEnvironment .IfyouareusingthedefaultsettingswithinRationalIntegration

Tester,theTitleBarwillalsoshowthenameofthecurrentenvironment.

5.8 Exercise:CreatinganEnvironment

1. SelectProject>CreateNewEnvironment

2. Givetheenvironmentaname–forexample,Local(mostoftheenvironmentwe’reworkingwithinthistrainingcoursewillbeonthelocalhost).

Page 29: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page27of138©IBMCorporation2001,2012

3. TheEnvironmentswindowwillappear.Onthelefthandside,youcanselecttheenvironmenttoedit.Ontherighthandside,youcanseehowthisenvironmentisconfigured.

4. Ontherighthandside,youshouldbelookingatthePropertiestab,whichwillbeemptyatthemoment.Thepropertiesofanenvironmentareexpressedastags,whichwillbecoveredlaterinthecourse.Forthemoment,we’renotgoingtoneedtosetupanypropertiesourselves.

5. SwitchtotheBindingstab.YoushouldseetheAddNumbersPortlistedhere.NotethatthephysicalconnectionforitiscurrentlylistedasUNBOUND.

6. ClickontheUNBOUNDsetting,andadropdownboxshouldappear,containingtheoptiontobindtheAddNumbersPorttotheHTTPClientatlocalhost.SelectthenewphysicalresourcetotellRationalIntegrationTesterthatanymessagessenttotheAddNumbersPortwillbesenttolocalhost.

7. PressOKtosaveyourchangesandexitthedialog.Youshouldseethattheenvironmentnameis

nowdisplayedintheTitleBar.

Onceanenvironmenthasbeencreated,wecanalsoviewandeditenvironmentaldatadirectlyfromtheLogicalView.Todothis,youcanrightclickonaninfrastructurecomponentinLogicalView,andselecteitherPhysicalResource,whichwillshowtherelatedphysicalresourceinthecurrentenvironment,orselectSetBindingIn...,whichwillallowyoutosetthebindinginanyenvironment.Thisinformationcanalsobeseenbyopeningtheinfrastructurecomponentbydoubleclickingonit,andgoingtotheBindingstab.

5.9 Exercise:SchemaLibrary

Wenowhavemostoftheinformationwewouldneedtocreateatestorstubforthissamplewebservice.However,we’restillmissinginformationabouttheformatofthemessagesgoingtoandfromthewebservice.MostofthisinformationcanbeprovidedthroughtheSchemaLibrary.

1. SwitchtotheSchemaLibraryusingthe tabatthebottomofthescreen.

Page 30: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page28of138©IBMCorporation2001,2012

2. Atthetopoftheperspective,thereisatoolbarcontainingbuttonsforimportingdifferenttypes

ofmessageschemas. PresstheWSDL button.TheNewWSDLwindowwillappear.

3. PressChange…toenterthelocationofourschemadefinition.TheSelectLocationdialogboxwillappear.

4. SelecttheURLtab,andenterthefollowingURL: http://localhost:8088/addNumbers?wsdl–notethattheURLiscase‐sensitive.PressOKtoclosetheSelectLocationdialog,andagaintoclosetheNewWSDLdialog.

5. YoucanalsoviewtheschemainformationusedbytheaddNumbersservicebygoingtothesameURLwithyourwebbrowser.

6. Oncetheschemashavebeenimported,youcanthenviewtheminRationalIntegrationTester.SelectWSDLsonthefarleftofthescreen.YouwillthenbeabletoseetheaddNumbersWSDLdisplayedonthelefthandside.SelectthisWSDL;thedetailsoftheschemashouldthenbeshownontherighthandside.TheSourcetabwillgivethesameschemainformationwesawinourwebbrowser.

Note:IfyouhavemistypedthenameoftheWSDL,youshouldreceiveawarning,andtherighthandsideofthescreenwillnotshowthemessageschemas.Ifyouendupinthissituation,youcanfixitinthefollowingmanner:

AmendthelocationoftheWSDLbyusingtheChange…buttonnexttotheWSDLLocationatthetopofthescreen.Followingthat,presstheRebuild buttontorebuildtheschemadata.

Page 31: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page29of138©IBMCorporation2001,2012

7. GototheConfigtabtovieweachindividualmessagetype.YoucanselecteachmessagetypeusingtheOperationdropdownjustunderthetabsalongthetopofthescreen.Usethistoviewthethreemessagetypes:addition__INPUT__addition,addition__OUTPUT__additionResponse,andaddition__FAULT__AdditionException.

5.10 Exercise:TheMessageExchangePattern(MEP)

Thefinalstageofbuildingoursystemmodelistostatehowtheoperationswillmakeuseofthemessageschemasthathavebeenprovided.WewilldothisbybuildinguptheMessageExchangePattern,orMEP,foreachoperation.TheMEPcontainsinformationabouttheinputandoutputschemasfortheoperation,whetherthemessagingpatternisRequest/ReplyorPublish/Subscribe,andhowthemessageswillbesent.InordertocreateadependencyintheLogicalView,wehavealreadysetupthetransport,statinghowmessageswillbesenttoandfromourservice.Tocompletethemodelofthesystemundertest,westillneedtosettherestofthepropertiesoftheMEP.

Aswewillseelateron,settinguptheMEPcorrectlynowwillallowRationalIntegrationTestertoaidusinautomaticallycreatingresourcesforeachoperation.

1. ReturntotheLogicalView.

2. DoubleclickontheAdditionoperationtoeditit.

3. OntheMessageExchangePatterntab,makesurethatthePatternissettoRequest/Reply.

4. Wenowneedtoselectthemessageformatsfortherequestandthereply.OntheRequestline,presstheBrowse…buttontoselectamessageformat.

5. TheSelectSchemadialogwillappear.ItisformattedinmuchthesamewayastheSchemaLibrary.Findandselecttheaddition__INPUT__additionschema,thenpressFinish.

6. DothesamefortheReplymessage,selectingtheaddition__OUTPUT__additionResponseschema.

7. YouwillalsoseetabstowardsthebottomofthescreenforHTTPPropertiesandHTTPHeaders.UndertheHTTPPropertiestab,settheResourceNameto/addNumbers.

Page 32: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page30of138©IBMCorporation2001,2012

8. PressOKtoclosetheAdditionoperation.

Wenowhavealltheinformationwemightneedtoworkwithaverysimplewebservice.Formorecomplexsystems,itwouldbepreferabletoanalyzethesystemtoderivesomeorallofthisinformationautomatically.Wecandothisintwoways,dependingonthetechnologiesinvolved–bysynchronizingwiththesystem,orbybuildingamodelofthesystemfromrecordedevents.

Page 33: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page31of138©IBMCorporation2001,2012

6 The Demonstration Environment

Obviously,thereisonlysomuchwecandowithasimpledemoenvironmentlikeaddNumbers.TheRationalIntegrationTestertrainingcoursesuseamorecomplexexample,theWorldwideTravelsystem.Yourinstructormaychoosetousesomeorallofthesesectionsduringyourtrainingcourse.

Sobeforewecangoanyfurther,weneedtoknowhowthisexamplesystemundertestfitstogether.Therearethreemainsectionstothesystemthatwe’llbedealingwith:aflightbookingsystem,ahotelbookingsystem,andaflightadministrationsystem.

Allthreepartsofthesystemarepresentedtotheuserthroughtheirwebbrowser;theinterfaceisgeneratedbyaTomcatwebserver,whichconnectstotherelevantpartsofthesystemasrequired.Inthebackground,thefollowingsoftwarehasbeendeployed:

Tomcat7.0.26

IBMWebSphereApplicationServer8.

IBMWebSphereMQ7.

IBMDB29.7ExpressEdition.

6.1 ManagingFlightBookings

TheWorldwideTravelsystemletsusersbookaflightonthefictionalairline,Worldwide.Bookingscanalsobemanagedthroughtheinterface,allowinguserstofind,update,anddeleteexistingbookings.

Theimplementationforthisissplitintotwoparts–thesetofservicesformakingbookings,andthesetofservicesformanagingbookings.

Whenausermakesabooking,TomcatpublishesamessageontoaMQqueue,whichisthenretrievedbytheMakeBookingservicerunninginWebSphereApplicationServer.Thislooksatthecreditcardtype,andpostsamessageontoaqueueforthatcardtype(Global,Multinational,orWorldwide).Aserviceforthatcardtype,alsorunningonWebSphereApplicationServer,willthenpickupthemessage,andprocessit.Inordertoprocessthebooking,theserviceneedstoknowwhatreservationnumbersexist,createanewreservationnumber,andrecorditforfuturereference.AllofthisisdonebyreferringtoaDB2databasewhichisusedtoholdbookinginformation.ThereservationnumberisthenpassedbacktoMakeBooking,toTomcat,andthentheuser.

Page 34: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page32of138©IBMCorporation2001,2012

Whenauserwantstomanageabooking,TomcatwillbeinteractingwithasetofwebservicesimplementedbyWebSphereApplicationServer.Theseserviceswillallowtheusertologintothebookingsystem,searchexistingbookings,updatebookings,ordeletethem.Searching,updating,anddeletingwillaccessthesamedatabasethatwasusedpreviouslyformakingbookings.

6.2 FindingandBookingHotels

Followingaflightbooking,ausermayrequireahotelinthatdestination.TheHotelFinderwebserviceallowstheusertolookupalistofhotelsthatareavailableinaparticularcitybetweenagivenpairofdates.Tomcatcanthenprovidethislisttotheuser.TheHotelFinderwebserviceishostedbyTomcatitself,ratherthanrunningonWebSphereApplicationServer.

6.3 FlightAdministration

Onthedayofaflight,usersfromtheairlinewillneedtocheckinpassengers.Theadministrationservicesallowtheusertofirstsearchthroughalistofflights,selectaflight,andthenselectparticularbookingonthatflight.ThisisalldonebyTomcat,directlyaccessingtheDB2databaseusedwhencreatingandmanagingbookings.

Whenapassengerischeckedin,theairlineuserwillneedtochecktheirpassport,andupdaterecordsaccordingly.Todothisonceabookinghasbeenselected,amessageispostedtoanMQqueueinCOBOLCopybookformat.Itispickedupbytheflightconfirmationservice(runningasitsownprocess),whichthenpostsareplyback,alsoinCopybookformat.Tomcatthenusestheinformationinthisreplymessagetoupdatethedatabase.

Page 35: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page33of138©IBMCorporation2001,2012

Page 36: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page34of138©IBMCorporation2001,2012

7 Using System Data to Build a System Model

7.1 Overview

Obviously,ifwewantedtobuildalargersystemsuchasWorldwideTravelwithinRationalIntegrationTesterbyhand,aswedidforaddNumbers,itwouldtakesometime.Instead,dependingonthetechnologiesinusewithinthesystemundertest,therearetwomethodsofautomaticallygeneratingasystemmodel.Wecaneithersynchronizeoursystemmodelwiththesystemundertest,orwemayrecordeventswithinthesystem,andusetheserecordedeventstobuildasystemmodel.

7.2 SynchronisationOverview

Thesimpleroptionwhenbuildingamodelofthesystemundertestissynchronisation.Thisprocessanalysestheservicesandinfrastructureprovidedbythesystem,andreplicatesthatwithintheArchitectureSchool.Thiswillsetupthelogicalandphysicalviews,anenvironment,andanymessageschemasusedbythevariousservicesinthesystem.

Inordertodothis,RationalIntegrationTesterrequiresavalidsynchronisationsourcetoexistwithinthesystemundertest,sothatitcanrequestinformationonthesystem.Supportedsynchronisationsourcesinclude:

WSDL

webMethodsIntegrationServer

TIBCOBusinessWorksProject/DesignTimeLibrary

SAPSystem

OracleSCADomain

Addinganyofthesetoyourprojectwillgiveyoutheoptiontosynchronisewiththedataheldbythatexternalresource.Tostartthesynchronizationprocess,youcanaddanyoneoftheseinfrastructurecomponentstotheLogicalViewofArchitectureSchool,orbyswitchingtoSynchronisationviewandaddingitthere.Eitherway,theprocessofaddingasynchronizationsourcewillprovidetheoptionofsynchronising.Multiplesynchronisationsourcesmaybeaddedtotheprojectifrequired.

Post‐synchronisation,thesystemundertestmaychange;asthiswillberecordedwithinthesynchronisationsource,itispossibleforRationalIntegrationTestertoupdatetheprojecttoreflectthesechanges.TodothiswithintheSynchronisationview,firstpressCheckSynchronisation –thiswillcomparethesystemmodelwithintheRationalIntegrationTesterprojectagainstanysynchronisationsources,anddisplayanydifferencesbetweenthese.Followingonfromthat,youcanpresstheSynchronise button,whichwillthenupdatetheRationalIntegrationTesterprojecttoresolvethesedifferences.

Page 37: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page35of138©IBMCorporation2001,2012

7.3 BuildingaModelfromRecordedEvents

Asyoucansee,whileRationalIntegrationTestersupportsanumberofsynchronizationsources,notallofthesewillexistineverysystem.Ifasystemdoesnothaveanyofthesynchronizationsourcesmentionedabove,thenthereisnothingtorefertowhenbuildingamodelofasystemundertest–forexample,aJMS‐basedsystemmaybeabletoprovideinformationontheavailablequeuesandtopics,butitwillnotprovideanyinformationontheoperationsthataccessthoseresources,thedependenciesbetweenoperations,orthemessageschemasbeingused.Inthiscase,wemaybeabletobuildamodelofthesystemfromrecordeddata.

Thisisexactlythesortofsituationwe’reinwithasystembasedaroundMQandWebSphereApplicationServer.Wedon’thaveasinglesourceofdatathatwillprovideuswithinformationaboutthesystem.Instead,we’llrecorddatafromthetransporttobuildthesystem.Forthemoment,we’llsetupthetransport,andimportthenecessarymessageschemas.WhenwemovetotheRecordingStudioperspective,we’llrecordasetofevents,andusethisinformationtocreateasetofoperations.

7.4 RecordingMQMessages

ThereareseveraldifferentwaystorecordmessagesovertheMQtransport–eachhastheirownadvantagesanddisadvantages.Thechoicesareasfollows:

QueueBrowsing

ProxyQueues

MirrorQueues

DynamicMirrorQueues

QueueAliasing

Yourchoicewilldependonseveralfactors.Somemethods,suchastheuseofproxyqueues,requirechangestothesystemundertest.Othersareinvisibletothesystemundertest,butrequireaccesstotheMQserverinordertomakemodifications.Otherfactorswillincludedeterminingifthesystemundercanbestoppedtemporarily,toensurethatnomessagesaremissed,andconnectionscanbesetupappropriately;andfinally,theamountofeffortrequiredonthepartoftheuser,andtheimpactontheperformanceoftheMQserver.Formoreinformationontheprosandconsofeachmethod,pleaserefertotheRecordingSettingssectionofthedocumentrit_wmq_ref.pdf.Inourexample,wewillbeusingdynamicmirrorqueues,asthisrequiresnomodificationtothesystemundertest,andrequiresaverysmallamountofsetuponthepartoftheuser

Regardlessofthemethodthatyouhavechosen,therecordingsetupshouldlookquitesimilartothefollowing:

Page 38: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page36of138©IBMCorporation2001,2012

Theclientapplicationwillcommunicateviarequestandreplyqueueswithagivenservice.RationalIntegrationTesterwillreadtherequestandresponsemessagesbeingpostedtothequeueswithinthequeuemanager.Whilethequeuemanagermayactslightlydifferentlytoitsusualbehavior–forexample,bycopyingeachmessagetoamirrorqueue–themessagesthemselveswillbeuntouched,andtheactionsofthesystemundertestshouldalsobeunchanged.

Notethatwemaychoosetorecordjustagivenservice,ifwehaveanoperationdefinition(andsoknowwhichqueuestomonitor),orwemayrecordallqueueswithinthequeuemanagerbyrecordingtheMQtransport.

7.5 Exercise:SettinguptheTransports

Inordertorecordinformationaboutthesystem,wefirstneedtoprovidesomebasicinformationabouttheinfrastructureofthatsystem.We’llbuildthisintheArchitectureSchool,inthesamewaythatwebuilttheaddNumberssystempreviously.Itwillbeverysimpleatthisstage–justaservicecomponentandafewinfrastructurecomponents.We’llthenimportsomemessageschemasthatwecanusewithinouroperationslateron.

1. ReturntotheLogicalViewofArchitectureSchool,andcreateanewServiceComponent.CallthenewservicecomponentWWTravel.

2. RightclickontheWWTravelservicecomponent,andselectNew>IBM>IBMWebSphereMQQueueManager.CallitWWTravel_MQ.

3. Asbefore,we’llneedtoaddaphysicalinfrastructurecomponent.WecoulddothisbygoingtothePhysicalViewandcreatingonethere,butwe’lltakeadifferentapproachthistime,whichwillallowustocreatetheenvironmentalbindingatthesametime.RightclickontheWWTravel_MQinfrastructurecomponent,thenchooseSetBindingIn>Local>CreateNewIBMWebSphereQueueManager.

Page 39: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page37of138©IBMCorporation2001,2012

4. Aswe’reusinganMQserveronthelocalmachine,enterlocalhostasthehost.Theportshouldbe1414.

5. WethenneedtosetuptheChannelandQueueManager.SettheChanneltowwtravelwebappandtheQueueManagertoQM_wwtravelThesettingsforthetransportshouldbeasfollows:

6. PressTestTransporttomakesureeverythingissetupcorrectlysofar.AfterRational

IntegrationTesterhasreportedthatithassuccessfullyconnectedtotheMQserver,whichmaytakeamoment,switchtotheRecordingtab.

Page 40: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page38of138©IBMCorporation2001,2012

7. UnderQueueRecording,settheRecordingModetoDynamicMirrorQueues.Allother

settingsherecanbeleftattheirdefaults.

8. Finally,switchtotheAdvancedtab.Here,setthenumberofQMConnectionsto5.Thiswillallowustomanagemoreconnectionswiththequeuemanager,incasewemaybeworkingonmultipletasksatthesametime(e.g.,recordingandstubbing).

Page 41: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page39of138©IBMCorporation2001,2012

9. PressOKtoclosethepropertiesfortheMQQueueManager.

10. AsourserviceswillberunningontheWebsphereApplicationServer,we’llwanttomodelthat,too.AlsowithintheWWTravelservicecomponent,addaNew>IBM>IBMWebsphereApplicationServer,andcallitWWTravel_WAS.

11. AswiththeMQQueueManager,rightclickonWWTravel_WAS,andselectSetBindingIn>Local>CreateNewIBMWebSphereApplicationServer.

12. EnterlocalhostastheHostname,and2809fortheBootstrapPort.PressOKtoclosethepropertiesoftheWebSphereApplicationServer.

Page 42: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page40of138©IBMCorporation2001,2012

13. Finally,we’lladdthebookingdatabasethatwillbeusedbyseveraloftheservicesinoursystem.AgainwithintheWWTravelservicecomponent,rightclickandselectNew>General>DatabaseServer.CallitWWTravel_DB.

14. Again,rightclickonthedatabase,andselectSetBindingIn>Local>CreateNewDatabase.

15. Wecannowenterthephysicalpropertiesforourdatabase.First,we’llneedtoselecttheDriver–inthiscase,we’reusingaDB2database,soselecttheIBM DB2 (Universal)driver.

16. Asfortheothersettings,theMaximumNumberofConnectionsshouldbesetto1,theDatabaseURLshouldbejdbc:db2://localhost:50001/WWTRAVEL,theUserNametraveluser,andthePasswordPi‐Ev‐G7,asseenbelow:

17. PressTestConnectiontomakesurethatthedatabaseconnectionisupandrunning,thenpress

OKtoclosethedialogbox.

18. YourLogicalViewshouldnowshowtheWWTravelservicecomponentlikeso(inadditiontotheAddNumbersservicecomponentcreatedearlier):

19. Finally,openuptheEnvironmentEditorusingProject>EditEnvironments,andverifythatall

ofthelogicalandphysicalcomponentshavebeenboundcorrectly.

Page 43: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page41of138©IBMCorporation2001,2012

WehavenowmodeledthebasicinfrastructureoftheWorldwideTravelsystem.Fromthispoint,wecouldmovedirectlytorecordingeventsfromthesystem,andmodelingtheoperationsfromthat.We’llmakethisabiteasierbyimportingsomemessageschemasbeforewebeginrecording.

7.6 Exercise:AddingtheFlightBookingMessageSchemas

1. ReturntotheSchemaLibrary.Here,weneedtoaddthreenewXMLschemas,sopresstheXSDs

buttononthelefthandsideofthescreen toshowanyavailableXSDs–noneshouldbeshownatthemoment.

2. WecouldusetheXSD buttonintheSchemaLibrarytoolbartoaddnewXSDstotheproject,aswedidwiththeaddNumbersWSDL.However,aswe’vegotagroupoffiles,we’lljustdraganddropthemintotheschemalibrary.FindtheXSD Schemasfolderonyourdesktop,anddraganddropitintothecenterpaneloftheSchemaLibrary.

3. RationalIntegrationTestershouldnowshowthreenewXSDs–BookFlightRequest,BookFlightResponse,andPayment.

4. Youcanselecteachofthese,andviewtheassociatedmessageschemasontherighthandsideof

thescreen.

Page 44: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page42of138©IBMCorporation2001,2012

8 Recording Events

8.1 TheRecordingStudio

RationalIntegrationTesterandtheagentsprovideuswiththecapabilitytorecordevents(messagesordatabaseinteractions)fromthesystemundertest.TheRecordingStudioallowsustocontrolwhatpartsofthesystemwewishtorecord,whetheritmightbespecificpartsofthesysteminfrastructure,orspecificservicesusingthatinfrastructure.WedothisbysettingupEventMonitorsthatspecifywhatwewishtorecord.

Oncewehavedecidedwhattorecord,wecanthenbeginrecording.Aseventsarerecorded,theyaredisplayedwithintheEventsView.Ifdesired,EventMonitorscanbeaddedorremovedaswerecord.WecanalsofilterwhateventsareshownintheEventsViewbyselectingdifferentmonitorswithintheEventMonitorspanel.Aseventsofinterestarerecorded,wecanviewmoredetailsfortheseeventsbyselectingthemwithintheEventsView–furtherdetailswillthenappearintheEventDetailspanelbelow.

Itisimportanttonotethatrecordingtheseeventsdoesnotinterferewiththeoperationofthesystemundertest.Eventswillstillbedealtwithinthesamewaythattheyusuallywouldbe–theonlydifferenceisthatthoseeventswillbeaccessiblethroughRationalIntegrationTester.

Page 45: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page43of138©IBMCorporation2001,2012

Followingrecording,eventsmaybere‐usedinavarietyofways.Thesimplestthingwecandoisexporttherecordedeventstodisk,sothattheymaybeimportedbackintotheRecordingStudioatanotherpointintime.Otherwise,eventscanbeusedtobuild:

Operations

Triggers

Requirements

DataSets

Tests

Stubs

Ifwedonothaveacompletemodelofthesystemundertest,theneventsrecordedfromthetransportswithinthesystemmaybeusedasabasisforbuildingnewoperationswithinoursystemmodel.

Eventsmaybere‐usedintheformofTriggers;atriggerallowsustostimulatethesystemundertestdirectlyfromRationalIntegrationTester.Wecanthenrecordwhathappensinresponse–notethatthiswillnotnecessarilybethesameaswhathappenedwhenweoriginallycreatedthetrigger,andwewillnotbeperforminganyvalidationonanyeventsrecordedinresponsetothetrigger.ThismeansthatwecansendeventstothesystemwithoutgoingthroughtheGUIlayer(oranyotherlayerofthesystemthatwemightprefertobypass),allowingustounderstandhowthesystemreactstovariousinputs.

Inothercases,wemaywishtosaveamessageforlateron,withoutspecifyinghowitwillbeused.ItmaybesavedintheformofaRequirement,givingusanexamplemessagethatwecanviewintheRequirementsLibrary.Thoserequirementsmaylaterbeimportedintootherresources.

Wecanalsouserecordedgroupsofeventstocreatetestsorstubs.Thedatawithintheeventsmaybehard‐codedintothetestorstub;itmayalsobeenteredintoadatasetsuchasaCSVfile,oradatamodel,whichmapstherelationshipsbetweenthedatainthesystem.

8.2 Exercise:RecordingEventsfromaTransport

WewillnowcaptureeventsfortheMQQueueManagertransport.

1. Beforewegetstarted,wewillneedtoinitializeafewcomponentsofthesystem,suchastheGUIlayer,tomakesurethattheyarerunning.Todothis,usetheStart WWTravel.batshortcutonyourdesktop.

2. Oncethishascompleted(itwillonlytakeafewseconds),returntoRationalIntegrationTester,andgototheLogicalViewofArchitectureSchool.

3. MakesureyouareintheLocalenvironment(asshownintheRationalIntegrationTestertitlebar).

4. SelecttheWWTravel_MQinfrastructurecomponent.

5. RightclickontheWWTravel_MQcomponent,andselectRecord.TheperspectivewillchangetotheRecordingStudio,andtheWWTravel_MQtransportshouldbelistedintheEventMonitors.

6. ClicktheStartRecordingbuttonintheEventsViewtoolbar tostartrecordingevents.

Page 46: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page44of138©IBMCorporation2001,2012

7. Inabrowserwindow,opentheWorldwideTravelbookingsite.Foracloudimage,thiswillbelistedinthebookmarksmenuofyourwebbrowser;otherwise,askyourtrainer.

8. Clickonthe“StanstedtoBarcelona”BookNowbutton.Here,youwillhavetheopportunityto

bookaflightandahotel.Forthemoment,we’llonlyworryaboutflights,soskipthehoteldataatthetopoftheform,andjustenterpassengerandpaymentdetailsforaflight.MakesurethatyouselectMultinationalasthecreditcard–theotherdetailsdonotmatter,aslongastheyarefilledin.

9. ClickProceedwhenfinishedandyoushouldseeaconfirmationpagewithareservationnumber.

Page 47: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page45of138©IBMCorporation2001,2012

10. ReturntoRationalIntegrationTesterandyoushouldseethat4eventshavebeenrecordedin

theEventsView.

11. ClickonthefirstmessageintheEventsView.Youshouldthenseethemessagedetailsappearinthepanelbelow,showingthemessagethatwasinitiallysentbyTomcat.

12. Westillneedinformationonhowthesystemdealswithrequestsforothercreditcardtypes,asthesewillbepostedtodifferentqueues,soreturntoyourwebbrowser,andmakebookingsforGlobalandWorldwidecreditcards.TheseshouldalsoberecordedinRationalIntegrationTester,givingyouatotalof12recordedevents.

8.3 Exercise:BuildingOperationsfromRecordedEvents

Nowthatwehaverecordedsomeevents,wecanusetheseforanumberofdifferentpurposes.Thefirstthingwe’lldoistocompletethemodelofthesystem.

1. Takealookatyoursetofrecordedmessages,inparticularthedescriptionfields.Thereshouldbe12messages,andthedescriptionswilllistthequeuesthatwereusedwhilerecording.Thisshouldincludewwtravel.booking,wwtravel.payment.multinational,wwtravel.payment.global,wwtravel.payment.worldwide,alongwiththeirrespectivereplyqueues.Ifyouaremissinganyofthedifferentcreditcardqueues,gobackandrecordabookingusingthatparticulartypeofcard.

2. PausetherecordingbypressingthePause button.

3. Selectall12messages,beforepressingtheSave button.

Page 48: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page46of138©IBMCorporation2001,2012

4. TheRecordedEventswizardwillappear,allowingustochoosewhatwewilldowiththe

selectedevents.Tobuildamodelofthesystemundertest,weneedtocreatesomeoperations,soselectthatoption,thenpressNext.

5. RationalIntegrationTesterwillnowdisplaythe12recordedmessages,attemptingtoseparate

themintodistinctoperations.Itshouldlooksomethinglikethefollowing:

Page 49: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page47of138©IBMCorporation2001,2012

6. Astheoperationnamesaregeneratedfromthequeuenamesused,wemightliketochange

themtosomethingmoreuseful.Selectthefirstmessagebelongingtotheoperationthatiscurrentlynamedwwtravel.booking – wwtravel.booking.reply.

7. Youwillnowbeabletoenteranewnamebelow,soenterMakeBooking,andpressRename.Youwillbeaskedifyouwanttoapplythischangetoallothermessagesthatwereassociatedwiththesameoperation–answerYes.YoushouldthenseetheOperationcolumnupdateaccordingly.

Page 50: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page48of138©IBMCorporation2001,2012

8. Next,wewilladdthemessageschemasforMakeBooking.Todothis,selectoneoftherequestmessagesforMakeBookingonthelefthandsideofthedialog(itwillcontainallofthedatayouenteredintothewebformearlier).Ontherighthandside,selectthesecondlineofthemessage,beginningtext (String).

9. TheAddSchemabuttonshouldnowbeactive.Pressit,andtheSelectSchemadialogwill

appear.Onthelefthandside,selectXSDs,thentheBookFlightRequestXSD.PressFinishtoapplytheschematothismessage.Youshouldthenseethenamespaceupdatewithinallfieldsofthemessage:

Page 51: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page49of138©IBMCorporation2001,2012

10. NowselectaresponsemessageforMakeBooking,andfollowthesameprocedure,usingtheBookFlightResponseXSD.

11. We’llneedtogothroughthesameprocessfortheotheroperationsinoursystem.Selectthetwomessagesthatareassociatedwiththewwtravel.payment.multinationalqueue,givethemanoperationnameofProcessMultinational,andpressRename.

12. WealsoneedtosetupmessageschemasforProcessMultinational,butthiswillbealittlebitsimplerthanforMakeBooking.Ifyoutakealookattheresponsemessage,you’llseethatitonlyincludesasingletextfield,sowewon’tneedtoapplyaschemathere.SelecttherequestmessagefortheProcessMultinationaloperation,andapplythePaymentXSDastheschema.

13. YoucansetupthelasttwooperationsforGlobalandWorldwidecardsinexactlythesameway–callthemProcessGlobalandProcessWorldwide;youcanusethesamemessageschemasasforProcessMultinational.Onceyou’redone,thedialogshouldlooklikethefollowing:

14. PressNext.Youwillthenbeabletoselectwhereinthemodelofthesystemtheseoperations

shouldbecreated.Bydefault,WWTravelshouldbelistedastheparentservicecomponentforalloftheoperationswe’recreating,asitistheparentservicecomponentfortheinfrastructurewerecordedearlier.Asthisissuitable,pressNext.

Page 52: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page50of138©IBMCorporation2001,2012

15. You’llnowseeasummary,lettingyouknowthatRationalIntegrationTesterwillbecreating4

operationsforyou.MakesurethatOpenresourceafterfinishisunchecked,thenpressFinishtocreateall4operations.YoucannowswitchbacktotheArchitectureSchooltoseewhathasbeencreated.

16. IntheLogicalView,youcannowdoubleclickoneachoperationtoviewitsproperties.Dothis

foroneoftheoperationsyoucreated,andviewtheMessageExchangePatterntab.Thisshouldshowyouthemessageschemasyousetearlierforrequestandreplymessages;itshould

Page 53: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page51of138©IBMCorporation2001,2012

alsoshowyouthetransportinformationusedbythatoperation,includingthenamesofthequeuesthatituses.

8.4 Exercise:CompletingtheSystemModel

1. WithintheLogicalViewofArchitectureSchool,wenowneedtoaddsomeextradependencyinformationtogiveourselvesacompletesystemmodel.Firstly,theMakeBookingoperationshouldhaveadependencyoneachofthecreditcardprocessingoperations.Forexample,toadd

adependencyfromMakeBookingtoProcessMultinational,selecttheAddDependency buttonfromthetoolbar,clickontheMakeBookingoperation,andthenontheProcessMultinationaloperation.

2. FollowthesameprocesstocreatedependenciesfromMakeBookingtoProcessWorldwideandProcessGlobal.

3. Next,eachofthecreditcardprocessingoperationshavedependenciesontheWWTraveldatabase.AddadependencyfromProcessMultinationaltotheWWTravel_DBcomponentinthesameway,andthendothesameforProcessGlobalandProcessWorldwide.

4. Last,alloftheoperationsarerunningonourWebSphereApplicationServer,soaddadependencyfromeachoperationtotheWWTravel_WAScomponent.

5. Notethatdependenciesonlyappearforitemsyouhaveselected.However,youmightnoticethatifyouselectMakeBooking,forexample,alotofdependencieswillbedisplayed,makingthediagramdifficulttoread.Thisisbecausedefaultsettingswilldisplaythedependenciesallthewaythrough–ifyoujustwanttoseeasinglelevelofdependencies,youcangotoProject>Preferences,andintheGeneralpanel,setMaxdependenciesshownto1,thenpressOK.Thediagramshouldthenbecomeeasiertoread.

Page 54: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page52of138©IBMCorporation2001,2012

8.5 Exercise:RecordingEventsfromanOperation

Nowthatwehaveamodelofthesystem,wecanchoosetorecordeventsforparticularoperations,ratherthanrecordingeverythinginthesystem.Aswenowhavemultiplesourcesofevents,wecanalsochoosetofiltereventsbysource.

Wewillcapturebookingeventsagain,butthistimewewillberecordingeventsbasedonoperationsratherthantransports.Wewillseehowwecanfiltertheseevents.Later,wewillseehowwecanre‐usetheseeventstobuildotherresourceswithinRationalIntegrationTester.

1. ReturntotheRecordingStudioperspective,andfindtheEventMonitorspanel.ThisshouldcurrentlyshowthatwearemonitoringtheWWTravel_MQtransport.We’llstopmonitoringthisforthemoment,soselectit,andpresstheDeleteEventMonitor buttontoremovetheeventmonitor.

2. We’llalsocleartheeventswerecordedinthepreviousexercise.Todothis,presstheClearAllEvents buttonintheEventsViewtoolbar.

3. PresstheAddEventMonitor button;thiswillallowustoselectanoperationtorecord.ChoosetheMakeBookingoperationwecreatedinthepreviousexercise.

4. Youwillnowbegiventheoptiontochoosetorecordanyofthedependenciesofthe

MakeBookingoperationatthesametime.YoushouldseethattheWWTravel_MQtransportisavailable,asaretheotherthreeoperations.ThisisbecausethedefaultbehaviouristoshowonlyitemsthatMakeBookinghasadirectdependencyon(theWWTravel_WAScomponentisnotshown,asRationalIntegrationTestercannotrecorddirectlyfromtheWebSphereApplicationServer).SwitchtheradiobuttonatthetopofthedialogfromDirectOnlytoIndirectOnly,andyoushouldseetheWWTravel_DBcomponentbecomeavailable,whiletheotherdependenciesarehidden;MakeBookingonlyhasadependencyonWWTravel_DBthroughtheotheroperationsintheproject,ratherthanhavingadirectconnectiontoit.Finally,switchtoBoth,andyoushouldseeallrecordablecomponentsthatMakeBookinghasadependencyupon.

5. SelecttheProcessMultinational,ProcessWorldwide,andProcessGlobaloperations.NotethatiftherewereotheroperationshaddependenciesontheMakeBookingoperation,wecouldselectthoseontheParentReferencestab;asnothingdependsonMakeBookinginoursystem,thiswillnotbenecessary.PressOKtocontinue.

Page 55: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page53of138©IBMCorporation2001,2012

6. All4operationscreatedinthepreviousexerciseshouldnowbelistedintheEventMonitors

panel.Ifanyofthemarenotlisted,returntostep2,andaddanymissingoperations.

7. PresstheStartRecording button.

8. Switchtoyourwebbrowserandsubmitanotherbookingrequest,usingaMultinationalcreditcard.

9. ReturntoRationalIntegrationTester,whereyoushouldsee4eventsrecordedintheEventsView–2eachforMakeBookingandProcessMultinational.

10. YoucanfilterrecordedeventstoshowonlythoseeventsthatwererecordedforagiveneventmonitorbyselectingtheeventmonitorintheEventMonitorspanel.Forexample,clickontheMakeBookingeventmonitor.YoushouldnowseejusttheMakeBookingevents,withtheeventsrecordedforProcessMultinationalfilteredout.

11. Clickintheemptyspacebelowthelistofeventmonitorstoclearthefilter–youshouldseeall4eventsagain.

12. Record2newbookings,againusingtheGlobalandWorldwideoptions.Youshouldnowhave12messagesintotal.

Page 56: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page54of138©IBMCorporation2001,2012

13. Again,you’llbeabletofilterbysource.Notethatyoucanselectmultipleeventmonitorsatthe

sametimewhenfiltering,toshowmessagesfrommultipleoperations.

Page 57: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page55of138©IBMCorporation2001,2012

9 Creating and Executing a Basic Stub

We’renowreadytocreateourfirstvirtualizedservice.Forthemoment,wejustwanttocreatethesimplestsortofstubpossible–onethatalwaysreturnsthesameresponse.Itwon’tdoanycalculations,makeanydecisions,orlookupanydata.Wewilllookatstubsthatcarryoutmorecomplexoperationslateron.

Tothisend,wewilltakeapairofmessagesrecordedforMakeBooking,andcreateasimplestub.Thisstubwillalwaysreturnthesamereservationnumber,nomatterwhattherequest.

Inordertodothis,we’llusetheSaveRecordedMessageswizardagain.We’llalsoseethestubeditorforthefirsttime–forthemoment,we’llsimplyeditthemessagefilteringtotellthestubtorespondtoanymessagewiththesamestructure,withoutworryingtoomuchaboutthecontentsofthefields.We’llbereturningtothestubeditorlateron,andlookingatitinmoredepth.

We’llthenexecuteastubfromRationalIntegrationTester,usingtheTestLabperspective.Finally,we’llmakeaminormodificationtothemessagethatthestubwillsend,andseehowRationalIntegrationTesterwillautomaticallyreplaceastubthatiscurrentlyexecuting.

9.1 Exercise:Makingasimplestubfromrecordedmessages

1. ClickonMakeBookingintheEventMonitorstofilteroutanymessagesfromothersources.

2. SelectarequestmessageandthecorrespondingreplymessageintheEventsView.

3. PresstheSavebutton.Thistime,wewillnotbecreatinganyoperations–instead,wewillcreateastub,soselectstubsonthefirstpageofthewizard,andpressNext.

4. Onthesecondpageofthewizard,wehavetheoptionofcreatingseveraldifferenttypesofstub.Asthisfirststubwillbeprettysimple,we’llchoosetoStoredataashardcodedvalues.PressNextonceyou’vedonethis.

5. Thenextpageofthewizardsimplyasksforverificationthatalleventshavebeensortedbythecorrectoperation.AswehavealreadyfilteredmessagesbytheMakeBookingoperation,thisshouldshowtwomessagesfromthatoperation.Ifso,pressNext.

6. Onthefollowingpage,themessageshavebeengroupedintotransactions.Asthereisonlyasinglepairofmessagesforthemoment,theseshouldbothbelistedasasingletransaction.

Page 58: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page56of138©IBMCorporation2001,2012

7. Onthefinalpage,youwillbeabletospecifyanameforthestub.SetthistoSimpleBookingStub,

andmakesurethatOpenresourceafterfinishischecked.

8. PressFinishtocreatethestub.RationalIntegrationTestershouldthenswitchtotheTestFactoryperspective.

9. Wecannowtakealookatthestubwe’vecreated.IntheTransitionssection,wehavealistoftheeventsthatthestubwillrespondto.ThestubwehavecreatedonlyknowshowtorespondtoeventsforMakeBooking.

10. Belowthis,wecanseethemessageswerecordedpreviously,intheInputandOutputtabs.

11. Bydefault,thestubwillattempttofilteroutanythingthatdoesn’texactlymatchthedefaultmessagethatwereceived.Inthosecases,itwillnotsendaresponsemessage.Forourexample,we’dliketorespondtoanythingthatmatchesthesamemessagestructure;itmayormaynothavethesamevalueswithinthemessagefields.Thiswillmakeourstubabitmoreversatile.Togetstarted,switchtotheInputtab,andtakealookatthemessagebody.Youwillseethateachfieldhasasmallfiltericonnexttoit:

Page 59: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page57of138©IBMCorporation2001,2012

12. Wewanttoswitchoffanyfilteringthatischeckingforanexactfieldmatch.TheDoesExist

filterswon’tmatter,aslongasthebasicmessagestructureisthesame.Todoswitchofffilteringfortheexactmatches,selectallofthefieldswithinthemessage(youmayneedtoscrolldowntodothis).Witheverythingselected,rightclickandchooseContents>FieldActions>Filter>Equality.Thiswilltoggletheequalitychecksoff,andthemessagebodyshouldthenappearwithfewerfiltericons,likeso:

13. SwitchtotheOutputtab,andtakenoteofthereservationnumberthatwillbesentbythestub.

Youshouldseethisagaininthefollowingexercise.

14. Saveyourstub–it’snowreadytobeexecuted.

Page 60: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page58of138©IBMCorporation2001,2012

9.2 Exercise:ExecutingastubfromRationalIntegrationTester

1. Beforewestartusingourstub,let’sswitchofftheserviceinWebSphereApplicationServer,sowe’recertainthatitisnotprocessinganymessages,butinsteadleavingthemforthestub.Todothis,openupyourwebbrowser,andfollowthelinkinyourbookmarkstotheWebsphereIntegratedSolutionsConsole.Whenaskedforlogindetails,leavethemblank,andpresstheLogInbutton.

2. InthelefthandpaneselectApplications>ApplicationTypes>WebsphereEnterpriseApplications.

3. Thelistofapplicationsthatwe’reusingwithinWebSphereApplicationServerwillthenappearontherighthandside.Checktheboxforcom.wwtravel.booking.app–thishandlesbookingrequestsforus.

4. Abovethelistofapplications,thereisaStopbutton.Youcannowpressthistostopthebookingapplication–notethatthiswilltakeamoment.Youshouldthenseethattheapplicationhasstoppedsuccessfully.

5. ReturntoRationalIntegrationTester,andswitchtotheTestLabperspective.

6. You’llstillseeyourstubinthetreeonthelefthandsideofthescreen.Runthestub,eitherbydoubleclickingonit,orbyselectingitandpressingtheRunbutton.

7. ThestubwillthenappearintheTaskMonitor.Someinitialdetailswillappeardownbelow,intheConsole.Thiswillbeupdatedlateron,asthestubreceivesincomingmessages,andrespondstothem.

8. Asitstands,thestubwillnowwaituntilitreceivessomeinput,solet’sprovidesomethingforittoworkwith.Returntoyourwebbrowser,andmakeanewbooking.

9. IntheTestLabofRationalIntegrationTester,takealookattheconsoleoutputforyourstub.Youshouldnowseethatthestubhasreceivedamessage,andsentareply.

Page 61: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page59of138©IBMCorporation2001,2012

10. Ifyoumakeanotherbookinginyourwebbrowser,youshouldseethatyouarereceivingthe

samebookingnumbereverytime.Asweturnedoffthefilteringofmessageswithinthestub,itshouldn’tmakeanydifferencewhatbookingrequestwesendtothestub;wejustneedtobeusingthesamemessagestructure.

9.3 Exercise:Modifyingthestubonthefly

Astubcanbemodifiedasitisbeingexecuted.Simplymakeyourmodifications,savethestub,andRationalIntegrationTesterwillautomaticallyshutdowntheoldversionofthestub,andstartupthenewversion.Asasimpleexample,we’llnowupdateourstubtosendadifferentreservationnumbertotheuser.

1. WithinRationalIntegrationTester,returntotheTestFactoryperspective.

2. EdittheSimpleBookingStub,andgototheOutputtab.

3. Changethereservationnumbertosomethingdifferent–forexample,A01234.

4. Savethestub.RationalIntegrationTesterwilloffertoupdatetherunningstub.ChooseYes.

5. SwitchtotheTestLabperspective.

6. YoushouldseeintheTaskMonitorthatthestubhasautomaticallybeenstopped,andstartedagain:

7. Makeanotherbookinginyourwebbrowser–itshouldnowgiveyouthenewreservation

numberyouhaveentered.

Page 62: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page60of138©IBMCorporation2001,2012

8. Aswe’renowfinishedusingthisstub,we’llswitchbacktothelivesystem.WithintheTestLab

ofRationalIntegrationTester,selectthecurrentlyrunningversionofthestubintheTaskMonitor(itwillbetheonewithaStatusofReady).

9. TheStop buttonintheTaskMonitortoolbarwillnowbeavailable–pressittostopthestub.

10. We’llnowwanttorestartthebookingserviceonWebSphereApplicationServer,soreturntoyourwebbrowser,andgobacktotheconsoleinterface.Ifyouclosedthebrowserpreviously,navigatebacktothelistofapplicationsagain.

11. Selectthecom.wwtravel.booking.appapplicationbycheckingtheboxnexttoitsname,andStartit.Allservicesshouldberunning,asshownbelow:

12. Ifyoumakeanyfurtherbookings,youshouldnownoticethatyouarereceivingnew

reservationnumbersagaineachtimeyoumakearequest.

Page 63: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page61of138©IBMCorporation2001,2012

10 Publishing and Deploying Stubs

Sofar,thestubsthatwe’vecreatedhavebeenlocatedonourpersonalmachines,usingourownlicenseforRationalIntegrationTester.Thishasanumberoflimitations–theownerofthemachineistheonlypersonwithcontroloverthestub,anditcannotbeusedbyotherpeople.Otherteammembersalsohaveverylimitedvisibilityoverwhichstubsarecurrentlyinuse,andwhichstubsarenot.Inaddition,stubsinsideRationalIntegrationTestermayonlyrunforaperiodof5minutesoutsideofascenarioinatestsuite.

Inordertomakeourstubsmoreuseful,we’llpublishthemtoRTCP.Thismakesthestubsavailabletootherteammembers,andalsoprovidesmonitoring,versioning,andothertechnicalcapabilities.

We’llfirstlookathowwecanpublishstubstotheserver,anddeploythosestubs.We’llthenlookathowwecanmakeuseofsomeofthemoreadvancedfeaturesoftheserver,suchasmanagingmultipleversionsofthesamestub,andprovidinginputdatatostubsasrequired.

10.1 Exercise:UsingRTCP

1. Beforewepublishordeployanystubs,let’stakealookattheRTCPinterface.Todothis,openanewtabinyourwebbrowser,andgototheRTCPbookmark.Ifaskedforaloginandpassword,enteradminforboth.

2. Onceyou’reloggedin,you’llbepresentedwith5options–Scheduling,Agents,Results,VIE,

andAdministration.We’llbelookingatsomeoftheseaswegothroughthedifferentpublishinganddeploymentoptionsthatareavailableforthestubsthatwehavecreated.We’llstartbylookingattheAgents,soclickonthatoption.

Page 64: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page62of138©IBMCorporation2001,2012

3. Youshouldnowbeabletoseethedifferenttypesofavailableagentsavailablethroughthisserver.Someofthesewillbeparticulartypesofproxiesthatwe’llbeusinglaterinthecourse,andasingleonewillbelistedasanEngine.Agentsthatareprovidingengines–theremaybemorethanone–allowustodeploystubsontothoseengines,whichwillthenrunthestubsaswewerepreviouslydoingthroughRationalIntegrationTester.ClickonthemagnifyingglassfortheAgentthatisprovidinganEngine.

4. Wecannowseewheretheengineisrunning,alongwithstatusinformation.Currently,this

shouldtellyouthattheengineisnotrunninganystubs.PresstheClosebutton.

5. Forthemoment,thereisnothingelseforustodountilwehavepublishedastubtotheserver,sominimizeyourwebbrowser,andreturntoRationalIntegrationTester.

10.2 Exercise:PublishingaStub

1. Inordertomakeastubavailabletotheserver,weneedtopublishitfromRationalIntegrationTester.Togetourselvesstarted,we’llpublishthestubwecreatedfortheMakeBookingoperation.WithinRationalIntegrationTester,switchtotheTestFactoryperspective.

2. RightclickontheMakeBookingoperation,andselectPublishStubs…Notethatthisprocesswillpublishallstubsthathavebeencreatedfortheoperation.Inourcase,we’veonlycreatedasinglestubsofar.

3. Adialogwillappear,lettingusselectaVersion,Domain,andEnvironmentforthestubs.You

willalsoseetheserver,pointingatthelocalhost–thishasallbeentakenfromourprojectsettings,sowecanleaveitallas‐is.

4. Asthisisourfirstpublication,leavetheVersionas1.0.Youcanmanuallysettheversionofstubsasyoupublishthem.Olderversionsofstubswillremainavailableontheserver,soyoucaneasilybacktracktoaparticularversionofthestubifrequired.

5. TheDomainshouldbesettoBooking System–belowthat,wecanselectwhichoftheenvironmentsusedinourprojectshouldbeused.We’llusetheLocalenvironmentthatwe

Page 65: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page63of138©IBMCorporation2001,2012

createdatthebeginningofthecourse.Ifwehadcreatedmultipleenvironmentswithinourproject,wecouldselectwhichenvironmentsthestubshouldbeavailablein.

6. PressPublish.RationalIntegrationTesterwillthentellyouthatyourstubshavebeenpublishedtotheserver.

10.3 Exercise:Deployingastub

We’llnowcheckthatourstubhasbeensuccessfullypublishedtotheserver,anddeployitontoanagent.

1. Switchbacktoyourwebbrowser,andviewtheRTCPdashboard.Ifwewanttoviewtheavailablestubs,we’llneedtofollowtheVIElinkalongthetopofthedashboard,soclickonthat.

2. Youshouldthenseetheavailabledomainsonthelefthandside.SelecttheBooking Systemdomain,andalistofenvironmentsthatcanprovidestubsforthatdomainwillappear.

3. ChoosetheLocalenvironment,thenpressViewDashboardtoseemoreinformation.

4. Youwillnowseealistofallofthepartsofthesystemthatmayhavestubs–atthemoment,no

stubsshouldberunning,andallrequirementsshouldbesatisfiedbythelivesystem.Youwillalsonoticethateachrowwilleitherhaveagreyplussign,oragreenplussign.Arowwithagreenplussignindicatesthatastubisavailableforthatoperationorcomponent.ClickontheplussignfortheMakeBookingoperation.

Page 66: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page64of138©IBMCorporation2001,2012

5. Adialogwillappear,allowingyoutoselectthestubtorun,andtoprovidesomeconfiguration

options.Forthemoment,we’llkeeptheconfigurationfairlysimple.SelecttheSimpleBookingStub.

6. Youshouldthenseeinformationforeachversionthathasbeenpublished–inourcase,we’relookingatthefirstversionofourstub,sothisisgoingtobeprettysimple.Wewon’tbeworryingaboutmostoftheconfigurationoptionsforthisstub–we’llcoverconfigurationinlaterexamples–butwedoneedtomakesurethatweknowwhereourstubwillberunning.ClickontheAgentslinkinthedialogtocheckthisout.

7. Ifdesired,youcannowselectwhichagentsshouldrunthestub.RTCPwillchooseonebydefault,andsinceweonlyhaveasingleagentinourtrainingenvironment,thiscanbeleftalonefornow.

8. Attheverybottomofthedialog,youcangivethisinstanceofthestubalabeltoidentifyit.EnterFirstRuninhere,andpressStartStub.

9. Thedialogwillclose,andyouwillseethattheMakeBookingoperationisnowsatisfiedbytheSimpleBookingStub.Atfirst,thestatuswillbelistedasDeploying–waitforamoment,andthestatusshouldupdatetoReady.

10. Switchbacktothetabofyourwebbrowserthatcontainsthebookinginterface,andmakeabooking–youshouldreceivetheresponsethatyoucodedintoyourstubearlier.

11. BackintheRTCPinterface,Stopthestub,sothatthelivesystemwillagainbehandlingtherequestmessages.

Page 67: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page65of138©IBMCorporation2001,2012

11 Synchronization

11.1 Asecondtestsystem–HotelFinder

Wewillnowlookasimulatingasecondpartofoursystem,theHotelFindersearchservice.Thisisimplementedasawebservice,sowehavedifferentoptionsforrecordingandsimulatingthisservice.

Intheprovidedinterface,theHotelFinderserviceisprovidedasanoptionforuserswhohavebookedaflight,givingthemtheabilitytobookahotelattheirchosendestination.Theusersuppliesdatesandadestination;thesearchservicethenletsthemknowwhathotelsareavailableinthatlocation,andprovidesthemwiththeabilitytobookoneofthosehotelsforthosedates.Thismaybedoneinparallelwithaflightbooking,orsubsequenttoabooking.

Thefrontend,aswiththeflightbookingservice,hasbeenimplementedasaTomcatwebapplication,whilethebackendisasimplewebservice.Currently,thisservicehasonlybeenimplementedtothepointwhereitcanrespondwithasmallgroupofavailablehotelsforBarcelonaandEdinburgh.WewillusethevirtualizationcapabilitiesofVIEtoextendthis,firstlyeditingthehotelspresentedtotheuserwithinthosecities,andthenseeinghowwecandatadriveastubtoallowustopresentoptionsfromothercities.

11.2 Synchronization

Beforewecanstartsimulatingthisservice,weneedtolookathowwecangetinformationaboutthestructureofthesystemwe’resimulating.Previously,werecordedatransport,andmodeledthesystembasedonthemessagesthatwesaw.WecoulddothisfortheHotelFinderwebserviceaswell–RationalIntegrationTestercanrecordtheHTTPtransport,andthenmodelwebservicesbasedonthatdata.

However,wecanalsousesynchronization,asmentionedpreviously.ThiswillallowustointerrogatetheWSDLprovidedbythewebservice,andautomaticallycreateamodelofthesystemundertest,fasterthanwewouldhavedoneitbyhand,orfromrecordedmessages.Someminormodificationsmaystillberequired(forexample,topresentadatabasethatisaccessedbyawebservice,butnotexposedbytheWSDL),butitwillgiveusafairlycompletepictureofthesystemwithaslittleworkaspossible.

11.3 Exercise:SynchronizingwiththeHotelFinderWSDL

1. Withinyourwebbrowser,youwillhavenoticedahotelbookingoptionbeingdisplayed,withaheadinglabeledFindaHotel.Clickthislink,andyoushouldseetheWSDLfortheHotelFinderwebservicedisplayedonyourscreen.SkimmingthroughtheWSDL,youshouldbeabletoseetheschemasusedbythewebservicesdescribedbytheWSDL,alongwiththerequiredconnectiondetails.

2. We’llimporttheWSDLintoRationalIntegrationTester.Thereareseveralwaystodothis,butinthiscasetheeasiestwillbetosimplycopytheWSDLURLfromourwebbrowser.WecanthengototheLogicalViewofArchitectureSchool,andpasteitusingCtrl+V.

3. TheCreateaNewExternalResourcedialogwillappear,showingtheHotelFinderWSDLlistedforyou.Atthisstage,wecouldaddotherWSDLs,butwe’lljuststickwithasingleoneforthisexercise.

Page 68: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page66of138©IBMCorporation2001,2012

4. PressNexttocontinue.You’llbegiventheoptiontoaddtheWSDLtooneoftheservice

componentscreatedearlier,ortocreateanewservicecomponent.ChoosetocreateanewcomponentcalledHotelFinder,andpressNext.

Page 69: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page67of138©IBMCorporation2001,2012

5. Thefollowingscreenwillcheckwhichenvironmentwewillusewhenwecreateresourcesfor

theHotelFinderservices.We’llkeepusingtheLocalenvironmentwecreatedearlier,socheckthatthisisselected,andpressNext.

Page 70: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page68of138©IBMCorporation2001,2012

6. ThefinalscreenofthewizardletsuschoosewhattodooncetheWSDLhasbeenaddedtoour

project.Normally,we’dchoosethelastoption–tosynchronizewithoutswitchingviews,sowecanseewhatiscreated.Forthisexample,though,we’llgothroughthesynchronizationmanually,soselectthesecondoption,OpenSynchronizationViewandletmechoosewhichitemstosynchronize.

Page 71: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page69of138©IBMCorporation2001,2012

7. PressFinish,andRationalIntegrationTesterwillswitchtotheSynchronizationView.

8. YoushouldthenseeashortlistofresourcescontainedintheWSDL–thelogicalandphysicalresourcesrequiredfortheHTTPconnection,andthegetHotelsandbookHoteloperations.PresstheSynchronize buttoninthetoolbartosynchronizewiththeWSDL.

9. YoushouldseethestatusofeachitemintheSynchronizationViewswitchfromNolocalcopy

existstoInsync.IfyounowgothroughtheLogicalandPhysicalViews,alongwiththeenvironment,youshouldseethatwenowhaveamodeldescribingtheinfrastructureoftheHotelFinderwebservices.Similarly,youwillbeabletoseethemessageschemasusedbythisservicewithintheSchemaLibrary.

10. IntheLogicalViewofArchitectureSchool,locatethegetHotelsoperation–ifyouneedto,youcanuseCtrl+Ftofindtheoperation.Onceyouhavefoundit,doubleclickittoopenit.

Page 72: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page70of138©IBMCorporation2001,2012

11. SwitchtotheMessageExchangePatterntabwithinthePropertieswindowthatappears.Youshouldseethatthishasbeenfilledinforyoualready,lettingusknowthatthegetHotelsoperationisRequest/Reply,andspecifyingtherequestandreplymessages,alongwithtransportinformationatthebottomofthewindow.

12. Wedon’tneedtochangeanyofthisinformation,buttheMessageExchangePatterndetailed

here–theMEP–willbeimportantinthefollowingexercise.Closethepropertieswindow.

13. Beforewecanusethisinformationtocreateastub,we’llwanttoeditthephysicalpropertiesoftheHTTPtransportdefinedintheWSDLwesynchronizedwith.AsthewebservicedescribedintheWSDLisrunningonport8089,astubcannotrunonthesameportonthesamemachine.We’llprovideadifferentportnumber,soswitchtothePhysicalViewtodothis.

14. OpentheHTTPresourceforlocalhost:8089bydoubleclickingonit.

15. Inthedialogthatappears,switchtotheServertab.

16. Here,thereisasettingintheSocketServerOverridessectionlabeledPort;thisshouldbeblankbydefault,whichtellsRationalIntegrationTestertousethesameportasthenormalservice.Inmostcases,thisisn’taproblem,butwhenthestubandtheliveservicearerunningonthesamemachine,itwillcauseaproblem,sosetitto8085.

17. PresstheTestTransportbuttontoverifythatRationalIntegrationTestercanbothtalktotheliveserviceandlistenonport8085.

18. PressOKtoclosethedialog.

Page 73: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page71of138©IBMCorporation2001,2012

12 Creating a Stub from MEP

Sofar,we’veconsideredstubsusingthesamemessagesthatwereprovidedwhenwerecordedthem.Inthischapter,wewilllookatmanipulatingthemessagesreferencedwithinourstub.Firstly,wewillcreateastubfromscratch,withoutreferencetorecordedmessages.Wewilltheneditthereplymessagebyhand,includinghandlingnewrequestsandrepeatingelementswithinmessages.

12.1 TheStubEditor

We’veseenthestubeditoronseveraloccasionsduringthepreviousexercises,butwehaven’ttakenagoodlookathowthedifferentpartsoftheeditorfittogether.Theeditorissplitintoseveraldifferenttabs:

Transitions.Thisiswherewewilldeterminehowthestubwillhandleevents,whetherinternallyorexternallycreated.

Behaviours.Behavioursallowustoaddpre‐programmedintelligencetothestub.Thiscouldbeassimpleassettingatimer,whichwillpromptanactionafteraperiodoftime,ormorecomplex,suchassimulatingamarketfeed.

Properties.Thisallowsustosetupstatesforthestub,aswellasinputparametersthatcandeterminehowthestubshouldactafteritisexecuted.

Logging.Loggingsettingsdeterminehowmuchinformationwillberecordedasthestubisexecuted.

Documentation.Thedocumentationtaballowstheusertoaddextrainformationaboutthestub.Thisisnotcompulsory,thoughitisadvisabletodoso,asitcanserveasanexplanationtofutureusersofthestub.Documentationwillbepublishedtotheserveralongwiththestub,sothatusersofRTCPcanchooseanappropriatestubtouseineachscenario.

Forthemoment,we’llmainlybeconcerningourselveswiththeTransitionstab.We’llbelookingattheothertabslateron,asweprogressthroughmorecomplexexamples.

12.2 Transitions

TheTransitionstabcontainsalistofallofthetransitionscontainedinthestub.Thesearenamedtransitions,astheycanbeusedtoswitchthestubbetweendifferentstates.However,forourfirstfewsimpleexamples,theymaybethoughtofaseventhandlers.

Whenastubreceivesanevent,itwilllookthroughthelistoftransitionstofindanappropriateresponse.StartingfromthetopofthelistseenintheTransitionspanel,thestubwillgodownthelistuntilitfindsatransitionthathasbeenspecifiedtohandletheeventreceived.Thismaybeduetofiltersonmessagesbeingreceived,whichmaymeanatransitionmightonlyhandleamessageifaparticular

Page 74: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page72of138©IBMCorporation2001,2012

fieldorsetoffieldscontainthecorrectdata;itmightbeduetothecurrentstateofthestub;oritmaybeduetothesourceofthecurrentevent(e.g.,whichoperationismeanttobehandedbythetransition).

Eachtransitionhasasetofpropertieslistednexttointhetophalfofthescreen.Someofthesewillbeusefultousnow,whileotherswillbecomerelevantlateron.ThemostimportantpartsofeachtransitionaretheActorandtheEvent–theActorletsusknowwheretheeventhasoriginated,whiletheEventspecifiesthetypeofevent(e.g.,theoperation).Formosttransitions,theActorwillbesettoUser–thismeansthatithasoriginatedfromauseroftheservice;we’llcomeacrossothersettingslateron.WheretheActorhasbeensettotheuser,theEventwillgenerallyspecifytheoperationbeinghandled.

TheFromandTocolumnsspecifythestartandendingstatesforthetransition–iftheseareleftblank,itisassumedthatthetransitionwillworkforanystateofthestub.Aswewillbelookingatstatelessstubsforourfirstexamples,thesecolumnswillbekeptblank.

TheGuardcolumnletsusspecifyifaneventwillbehandled,dependingonthedatareceivedwithinthatevent.Wemaychoosetoanalyzethedataheldwithinthemessageonitsown–forexample,wemightliketoresponddifferentlytoamessagecontainingastartandenddatewhentheenddatecomesbeforethestartdate.Wecanalsocomparereceiveddatatodataheldwithinadatamodel–we’lllookatanexampleofthislateron,whenwediscussdatamodelsindetail.

12.3 Exercise:CreatingastubfromtheMEP

Forthehotelsearchservice,wecouldeasilyuserecordedmessagestocreateanewstub,aswedidbefore.AswithrecordingMQmessages,thereissomesetuptobedoneforrecordingHTTPmessages–wewillseeanexampleofthislateroninthecourse.

Forthemoment,though,wewillcreateanewstubfromscratch,andfillitinwithourownvalues.

1. SwitchtotheTestFactoryperspective,andlocatethegetHotelsoperationintheTestFactoryTreeonthelefthandside.

2. Rightclickontheoperation,andselectNew>Stubs>StubusingMEP.ThiswillcreateastubbasedontheMessageExchangePatternwesawinthepreviousexercise.

3. CallthestubsingleHotel,andpressOK.

4. Yournewstubwillbeopeninthisperspective,solet’stakealookatit.Similartothefirststubswecreatedfortheflightbookingservices,thishasmessagedataontheInputandOutputtabs.However,whilethemessageschemahasbeencorrectlyapplied,you’llnoticethatnoneofthefieldshavebeenfilledinforus,sowe’llneedtotakecareofthatourselves.

5. WithintheInputtab,locatethecityElement–underneaththat,therewillbea(Text)node.Doubleclickonthistoeditit.

6. Withinthiseditor,wecanchoosewhattodowiththispartofthemessage–wecanuseittofilterincomingdata,validatethatthedataiscorrect,orstorethatdataforlateruse.Forthemoment,we’llfilterbasedonthecityname,sogototheFiltertab,andpressNew.

Page 75: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page73of138©IBMCorporation2001,2012

7. CheckthattheActionTypeissettoEquality,andenterBarcelonaforthevalue.PressOKtoreturntothemessage,whichshouldnowlookliketheimagebelow.MakesurethattheBarcelonavaluehasbeenplacedintherightlocation:

8. We’renowlookingoutforhotelsearchesinBarcelona;wedon’treallycareaboutthedates,

whichwouldbesetoutinthefromandtoTextnodes.SwitchtotheOutputtab,sowecanspecifywhatdetailswewillsendbackinresponse.

9. Wehaveanothermessagehere,againwiththecorrectschema,butemptyfields.Youcanenteralldetailsifdesired,butTomcatonlyrequiresaresponsethatincludesthehotelnameandtherate.

10. Savethestub.

12.4 UsingtheHTTPProxy

Earlier,whenweranastubforMQ,wesimplyinstructedthestubtotakemessagesfromthesamequeue(s)thattherealapplicationwasusing.However,forHTTP,it’sabitmorecomplicated.Undernormalcircumstances,therequestmessagewillbesenttoaparticulardestination,whichiswheretheapplicationishostedonthenetwork.

Page 76: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page74of138©IBMCorporation2001,2012

TogiveustheabilitytointeractwiththisHTTPtraffic(whichwillgiveustheabilitynotonlytostub,butalsotorecordtraffic),theRationalIntegrationTesterPlatformPackprovidesaHTTPproxy.Theclientapplicationcanthenbeconfiguredtousethisproxy–whenRationalIntegrationTesterandanystubsareinactive,trafficwillsimplypassthroughtheproxytoreachitsdestinationasusual.

However,ifweweretostartastub–whetherinsideRationalIntegrationTester,ordeployedtoanagent,thetrafficwillberedirected.RTCPisusedasthecentralcontrolpointforRITandallrelatedtools,sothestubsimplyneedstonotifytheserverthattrafficshouldberedirected;anyproxiesinthesystemwillthenbeadvisedofthischangebytheserver.

SimilarinteractionscanbeusedwhenHTTPrecordingisneeded.RationalIntegrationTesteradvisesRTCPthatitwantstorecordmessagesbeingsenttoaparticulardestination(orforaparticularoperation).TheserverinstructstheproxytosendacopyofeachmessagebacktoRationalIntegrationTester,whereitcanthenbepresentedintheRecordingStudio.NotethatHTTPrecordingmayalsobedonebypacketcapture,requiringonlyRationalIntegrationTester,butthismethodmaynotbeabletorecordallofthesametraffic,sotheproxymethodispreferred.

Page 77: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page75of138©IBMCorporation2001,2012

12.5 Exercise:HTTPStubExecution

1. InordertorunourstuboverHTTP,we’llbeusingtheHTTPProxyprovidedwithRationalIntegrationTester.Earlier,whenweviewedtheagentsavailableinRTCP,youmayhavenoticedanagentforHTTPtraffic.YoumightliketoreturntoRTCPtoverifythatthisispresent.

2. TheotherthingthatweneedtodobeforeattemptingtostubusingtheHTTPProxyistomakesurethattheapplicationsendingtherequestmessageisconfiguredtogothroughtheproxy.Inthiscase,it’sourTomcatserver,whichhasalreadybeenconfiguredinthisway.Ifyou’recurious,yourinstructorcanpointyoutowardsthecatalina.batscriptforyourTomcatserver,whereyoucanalsoverifythis.

3. RightclickonthesingleHotelstubyoucreatedintheaboveexerciseandclickonRun.Thestubshouldstartupwithoutanyerrorsasshownbelow:

4. Inyourwebbrowser,gototheWorldwideTravelhomepage,andsearchforahotelin

Barcelona.

5. Youwillnoticethatitdisplaysonlythesinglehotelprovidedinthepreviousexercise.Youcouldchoosetobookthehotelfromhereifdesired.

Page 78: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page76of138©IBMCorporation2001,2012

6. GototheTestLabperspectiveinRationalIntegrationTester.Theconsoleshouldshowthatthe

stubhasprocessedthehotelsearchasrequested.

7. Stopthestub,andsearchforahotelinBarcelonaagain.Thistime,therequestwillbeprocessed

bytheactualwebserviceratherthanthestub–threehotelswillbereturnedbytheservice,asshownbelow.

8. Atthemoment,you’llnoticethatthewebserviceonlyreturnsresultsforafewcities.For

example,youmightwanttosearchforhotelsinLondonusingtheservice.Thiscurrentlyreturnsnoresults:

12.6 Exercise:Handlingnewrequestoptions

Currently,ourstubcanonlyhandlerequestsforasinglecity.Ifanyotherrequestsaresent,theywillbeignored–noresponsewillbesentatall.Let’slookatprovidingawayofhandlingrequestsforanothercity,aswellasadefaultresponseforanyunrecognizedcities.

1. ReturntotheTestFactory.Atthetopofthescreen,wehavealistofthetransitionsthatwillhandleincomingmessages.Beforewegoanyfurther,let’saddadescriptiontothesingletransactionthatwecurrentlyhave.ClickintheDescriptionfield,andeditittocallitBarcelona Hotels.

2. Toaddanewwayofhandlingevents,presstheAddTransition buttonatthetopoftheeditor.Asecondemptytransitionwillbeadded.

Page 79: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page77of138©IBMCorporation2001,2012

3. Selectthisnewtransition,andclickintheActorcolumntorevealadropdownmenu.Theonly

optionhereforthemomentwillbeUser,soselectthat.

4. Similarly,intheEventcolumn,selectgetHotels.

5. Finally,intheDescriptionfield,enterEdinburgh Hotels.

6. YouwillnoticethattheInputandOutputtabsatthebottomofthescreenhavebecomeavailable.GototheInputtab,andfindthecityElementagain.

7. Doubleclickonthe(Text)nodeforthecity,andusetheFieldEditortoaddanewfilterlookingforEdinburghasthecity,inthesamewaythatwesearchedforBarcelonapreviously.

8. Onceyou’veaddedEdinburghhere,gototheOutputtab,andenterdetailsforahotel,againfollowingthesameprocedureaspreviously.

9. OurstubnowknowshowtorespondtomessageslookingforhotelsinBarcelonaandEdinburgh,butwillnotsendbackanyresponseforotherlocations.We’llnowaddawayofhandlingthosecases.Addanothertransition,settingtheActortoUserandtheEventtogetHotelsoncemore.ItshouldhaveaDescriptionofDefault.Youshouldnowhavethreetransitions,asshownbelow.

10. SelecttheDefaultcase.Thistime,wewon’tedittheInputmessageatall,sowewon’tfilterout

anyparticularresponsemessages.Instead,we’lljustprovidearesponsemessageforthisdefaultcase,soswitchtotheOutputtab.

11. ThemessageschemausedherehasamaingetHotelsResponse,whichmaycontainalistofhotels–eachhoteliscontainedinachildcalledgetHotelsReturn.Forthedefaultcase,wewon’treturnanyhotels,sorightclickonthegetHotelsReturnelement,andselectDelete.RationalIntegrationTesterwillaskforconfirmation–sayYestothis,andthensaveyourstub.

12. Runningthisnewversionofthestub,youshouldnowseethatyoureceiverepliesforsearchesonBarcelonaandEdinburgh,eachonehavingasinglehotel.Othercitiesnowreceiveareply,butnohotelswillbeshown.

13. Inthedefaultcase,we’veseenhowwecanremoveelementsfromthemessage–let’snowlookathowwecanaddelements.InthecaseofBarcelona,wemightliketosupplymorethanonehotel(whichisalreadysupportedbythemessageschemausedfortheresponsemessages).ReturntotheTestFactory,andselecttheBarcelonatransition.

14. GototheOutputtabforBarcelona,andyoushouldseethehoteldetailsyouenteredearlierforthatcity.Toaddasecondhotel,selectthegetHotelsReturnelement,rightclickonit,andselectCopy.ThenrightclickonthegetHotelsReponseelementaboveandselectPaste.

Page 80: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page78of138©IBMCorporation2001,2012

15. Youwillnowhavetwohotelentriesthatlookexactlythesame.Editthehotelnameandrateinthesecondhotel(wewon’tworryaboutanyotherdetails).Ifyouwant,youcanaddfurtherhotelsinthesameway.

16. Savethestub.Ifyouwerestillrunningit,RationalIntegrationTesterwillnowberunningthenewversionofthestub;ifnot,startthestubyourselfintheTestLab.

17. RunahotelsearchusingBarcelonaasthecity–youshouldnowseetwohotelslistedforyou.Beforeyougoanyfurther,Stopthestub,aswe’llbecreatingadifferentoneinthefollowingexercise.

Page 81: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page79of138©IBMCorporation2001,2012

13 Storing and Manipulating Data

13.1 TagsandtheTagDataStore

TagsarevariablesinternaltoRationalIntegrationTesterthatcanbeusedtostoreandretrievedata.Thereare3maintypesoftagsthatyoumayseewithinRationalIntegrationTester:

Systemtags:containvaluesthatareprovidedbyRationalIntegrationTester,andcannotbechangedbytheuser.Theseincludethingslikethetime,theprojectname,andthehostnameofthemachinerunningRationalIntegrationTester.

Environmenttags:containuser‐supplieddatathatcanchangefromenvironmenttoenvironment.

Testtags:containuser‐supplieddatathatislocaltoagiventestorstub.

Inadditiontothesemaintypes,youmayseeothertypesoftag.ThesearemainlytreatedasvarietiesofTesttags.Someexamplesofthesethatyoumayencounterare:

Globaltags:atesttagthathashaditsscopesettocoveralltestsinatestsuite.Globaltagsmaybeusedtopassvaluesbetweenmultipletestsinatestsuite,aslongasthetagisdefinedinbothtests,andmarkedasglobalinbothtests.Outsideatestsuite,thescopeofthetagislimitedtothecurrenttest.

OverriddenEnvironmenttags:itispossibletooverrideanenvironmenttagwithatesttag.Thesearemarkedtodifferentiatethemfromothertags;notethatthisisdiscouraged,butmayoccasionallyhappenwhencreatingenvironmenttagsforaprojectthatalreadycontainsasetoftests/stubs.

JavaProperties:bycreatingatesttagwiththesamenameasajavaproperty,itispossibletoaccessthatJavapropertywithinatestorstub(forexample,theJavapropertyfile.separator).

Forthepurposesofthismodule,wewillfocusonthe3maintypesoftag–Systemtags,Environmenttags,andTesttags.

AlltagsthatareavailabletoatestorstubcanbeviewedfromwithintheTagDataStore;thisdialogcanbeaccessedfromtheTagDataStore button,orfromthecontextmenuanywherewithinatest.TheimagebelowillustratesatypicalTagDataStore.Thetagsarelistedinalphabeticalorder.

Page 82: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page80of138©IBMCorporation2001,2012

Youshouldnoticethatthevaluesforenvironmenttagsreflectthecurrentlyactiveenvironment;ifyouswitchenvironments,thesewillupdate.

Thetooltipforthetagunderthemouse‐pointerdisplaystheoptionaldescriptionfieldforthetag

Youcancreatealogicalhierarchyoftagsbyseparatingmultiplenamesectionswiththe/character(e.g.,JMS/URLandJMS/UserwillbedisplayedtogetherundertheJMSsection).

13.2 CreatingTags

WithinRationalIntegrationTester,youcancreatenewEnvironmenttagsandTesttags.AsSystemTagsaremanagedbyRationalIntegrationTester,tagsofthattypecannotbecreatedoredited.

EnvironmenttagsmaybecreatedandeditedfromtheEnvironmentEditor(Project>EditEnvironments).WithintheEnvironmentEditor,youwillseealistofenvironmentsonthelefthandside,alongwithanitemlabeledDefaultProperties.DefaultPropertiesprovidesavalueforanytagswhichhaveundefinedvalueswithinanyenvironment.Forthisreason,itisadvisabletocreatenewtagswithintheDefaultProperties,andeditthemwithinanyenvironmentrequiringdifferentvalues.

Toeditorcreatetagswithinanenvironment,selectthatenvironmentonthelefthandside,andverifythatyouarelookingatthePropertiestabontherighthandside.Underneaththistab,youwillseealltagsforthecurrentenvironment.

Page 83: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page81of138©IBMCorporation2001,2012

Fromthistab,youcanedittagsforthecurrentenvironment:

New…createsanewtagwithinthecurrentenvironment,allowingyoutosetavalueanddescriptionwithinthatenvironment.Thetagisalsocreatedwithinallotherenvironments,butisnotassignedavalueoradescriptioninanyotherenvironment.

Edit…bringsupadialogwhichallowsyoutoeditthevalueanddescriptionofthecurrentlyselectedtagwithinthecurrentenvironment.Doubleclickingthetagwillbringupthesamedialog.

Clearresetsthevalueanddescriptionofthetagwithinthecurrentenvironment,leavingthemundefined.

Deleteremovesthetagfromallenvironments.

Ifatagdoesnothaveavalueordescriptionwithinanenvironment,itwillbelistedinhereas#undefined?,andwilltakeitsvalue/descriptionfromtheDefaultProperties,asdiscussedpreviously.

Newtesttagsneedtobecreatedwithinindividualtestsorstubs.Forthemostpart,theywillbecreatedfromtheTagDataStore,butcanalsobecreatedwithincertaintestactions:

Page 84: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page82of138©IBMCorporation2001,2012

Createonemanuallybyclickingonthe iconwithintheTagDataStore.IntheCreateTagdialog,enterthename,optionaldefaultvalue,anddescriptionforthenewtag.

Createmultipletagsbypastingalistoftagnamesdirectlyintothetagdatastorewindow.Firstcreatealistoftagnamesinatext‐basedfile–thenamesmaycontain/characterstocreateahierarchyasmentionedabove(e.g.,MYTEST/Name).Next,copythelistoftagnamesandpasteitintothedatastorewindow(pressCtrl+Vorclickthepasteicon ).Blanklineswillbeignoredwhenpastingtags.

UsetheQuickTagoptionwithinateststeptoautomaticallycreateatagwithanamecorrespondingtoaparticularmessagefield.

13.3 UsingTags

Asseenabove,tagsmaybegivenvalueswhentheyarecreated.Testtagsmayalsobegivennewvaluesduringtheexecutionofatestorstub.ThiswillusuallybedoneontheStoretabofatestaction;inthatcase,thetagisreferencedsimplybyitsname.

Toretrievethevalueofatag,youwillneedtosurroundthetagnamewithtwopercentagesignsateachend.ThismeansthatyoucanstoreavalueinatagcalledmyTagsimplybyreferringtoitsname,myTag,buttoretrievethevalueofthattag,youwillneedtorefertoitas%%myTag%%.

SomefeaturesofRationalIntegrationTesteruseECMAScript–withinanyofthesescripts,tagscanbereferencedbytheirname,unlessthatnameclasheswithareservedwordorvariable.Inthatcase,youcanreferencethetagastags["myTag"].

13.4 Exercise:Creatingandusingatag

Sofar,everyexamplewe’velookedhasusedstaticdata.Let’sseehowwecanusedynamicdatawithinourownstubsbyusingtags.We’llcreateanewstubthatwillreturnahotelforanycity,usingthatcity’sname.

1. WithintheTestFactory,createanewstubbyrightclickingonthegetHotelsoperation,andselectingNew>Stubs>StubusingMEP.CallthestubtaggedCity.

2. We’llonlyhavethesingletransitionforthisstub.Asbefore,makesuretheActorwithinthistransitionissettoUser,andtheEventtogetHotels.

3. IntheInputtabfindthecityelement,andselecttheTextnode.RightclickandchooseContents‐>QuickTag.Thiswillupdatethemessagebodylikeso:

4. Noticethe iconinnexttothewordcityintheActioncolumn.Thisletsusknowthatwe’llbestoringthevalueinthecityfieldintoatagcalledcity,whichwecanthenre‐uselateron.

Page 85: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page83of138©IBMCorporation2001,2012

5. NowselecttheOutputtabandlocatethenameelementwithingetHotelsReturn.Thetextfieldforthisiscurrentlyblank.We’lleditthissothattheusersees“citynameHotel”here.Todothis,doubleclickthetextfieldsothatyoucaneditit.Typein%%city%% Hotel.ThepercentagesignstellRationalIntegrationTesterthatwe’reretrievingavaluefromatagnamedcityatthisstage.

6. Fillouttheotherdetailsintheoutputmessagebyhand–mostofthemwon’tmatterthatmuchforourexample,butyouwillneedtocheckthatyouhavearateforthehotelinorderforthewebinterfacetowork.

7. Savethestub,andswitchtotheTestLab.Checkthatyouhavestoppedanyotherstubsthatmighthavebeenrunningpreviously.

8. Runthestub,andsearchforhotelsinanycity.Youshouldalwaysreceivearesponsethatthelocalhotelhasaroomavailable.

9. Stopthestubonceyouarefinished.

13.5 Guards

Bytaggingincomingdata,wecanalsoimplementextrafilteringonanyincomingmessages.Previously,we’vebeenabletofilterincomingdatabylookingatasinglefield–forexample,bylookingforhotelsinBarcelona.Wecouldalsofilterbasedonmultiplefields,aslongasthedatainthosefieldsisindependent–forexample,wecouldfilterforsearchesinBarcelonaonthe23rdofJanuary.However,ifweneededtolookattherelationshipofdatabetweendifferentfields(orbetweenfieldsinthemessageandadatamodelusedbythestub),wewouldneedtotakeadifferentapproach.

Aguardallowsustoprovidemorecomplexfiltering,ratherthanjustlookingatthevaluesinsideeachfieldonebyone.Itmightfilterdatabyexecutingashortscriptthatperformscomparisonsand/orcalculations.Itmayalsoprovidefilteringbycomparingincomingdatatodataheldwithinadatamodel,orevenjustmarkingthetransitionasthedefaulttouseifnootherfiltersallowtheincomingmessagetopass.

Soifweneedtomakesurethatmultiplefieldsinamessagerelatetoeachothercorrectly,wecantagthosefieldsintheinputmessageofatransition,andaddashortscriptthatwillverifythatrelationship.Forexample,ifwereceiveamessagecontaininganorder,itmightbeusefultocheckthatthepricesofallitemsadduptothestatedtotal,orthatafieldstatingtheamountoftaxhasbeencalculatedcorrectly.Dependingonwhetherornottheseconditionshavebeensatisfied,wemighttreatincomingdataindifferentways.

13.6 Exercise:UsingGuards

Inthisexercise,we’llextendthepreviousexamplesothatwecansendbackoneoftwoalternativeresponses.Iftheusermakesarequestforahotelinanycity,we’llsendbacktheoriginalresponse–aslongasthestartdateofthebookingcomesbeforetheenddate.Iftherequestusestherightformat,buthasinvaliddates,we’llsimplysendbackaresponsewithnohotelslisted.

Note:Thisexerciseusesdatesinaday/month/yearformat.Ifyouattempttheexerciseusingdatesintheformofmonth/day/year,youmayencountererrors.

1. MakeacopyofthetaggedCitystub,andcallithotelGuards.

2. Withinyournewstub,selectthesingletransitionthatispresent.PresstheClonebuttontomakeacopyofthistransition.

Page 86: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page84of138©IBMCorporation2001,2012

3. Makesureyouhaveselectedthetransitionatthetopofthelist.EdittheDescriptionfield–itshouldsayValid Input.

4. We’llusetheValid Inputtransitiononetocoverthecasewherewehavecompletelyvalidinput–acity,andastartdatethatcomesbeforetheenddate.WithintheInputtabforthistransition,tageachofthecity,from,andtotextfields.

5. SettheGuardforthetransitiontoOther.TheInputtabwillnowcontainaGuardsection.

6. MakesurethescriptinglanguageissettoECMAScript,andenterthescript:formatDateUTC( from, "yyyy‐MM‐dd'T'HH:mm:ss.SSS'Z'" ) < formatDateUTC( to, "yyyy‐MM‐dd'T'HH:mm:ss.SSS'Z'" )ThiswillconvertthefromandtotagstoUTC,sothattheycanbeeasilyrepresentednumerically,andcomparethem.Ifthefromdateisthenlessthanthetodate–ie,thefromdatecomesbeforethetodate–thenwe’llpasstheguard,andsothefilter,sendingbackamessagewithahotel.

7. Inthesecondtransition,enteraDescriptionofInvalid Dates.

8. TheInvalid Datestransitiondoesn’tneedanyguard,aswe’llfallstraightthroughtoit.Wewillfilteritsomewhat,though–we’llmakesurethatanyincomingmessagehasthecorrectmessagestructure.

9. SelectalloftheelementsinthemessagebodywithintheInputtab,thenrightclickandselectContents>FieldActions>Filter>DoesExist.

10. Aswe’vegotavalidmessagestructurewithinvaliddates,we’llsimplysendbackamessagestatingthattherearenohotelsavailable.SwitchtotheOutputtabofthistransition,anddeletethegetHotelsReturnnodefromthemessage.

11. Executethestub,andusetheGUItoentervaluesthatverifythatthestubisrespondingcorrectly.Whenthestartdatecomesbeforetheenddate,weshouldseethesamedatathatwesawinthepreviousexercise.However,ifyousetthestartandenddatestobethesame,youshouldseethatnohotelsareavailable.

Page 87: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page85of138©IBMCorporation2001,2012

14 Data Driven Stubs

Nowthatwe’veseenhowwecanstoreanduseasinglepieceofdatawithinastub,let’stakeitastepfurther.Whentesting,itisstandardpracticetouseanexternaldatasourcetoprovideinputsoroutputdata.WecandothiswhilevirtualizingaservicethroughtheuseofaDataSource.We’llseehowwecaninteractwithadatasource,firstbystartingwithasetofrecordedmessages,andthenbystartingagainusingtheMEPofanoperation.

14.1 DataSources

Thereare4typesofdatasourcesupportedbyRationalIntegrationTester.Eachoneishandledseparatelywithinaproject,toaccountforconfigurationsettingsthatwillvaryfromdatasourcetodatasource.Thedatasourcesareasfollows:

FileDataSource–readsdatafromanindividualfile.ThismaybesomethinglikeaCSVfile,fixedwidth,orotherdelimitedfile.

ExcelDataSource–readsdatafromasheetinanExcelspreadsheet.

DatabaseDataSource–readsdatafromatableinadatabase,ortheresultsofaqueryonadatabase.ThedatabasemustbesetupinArchitectureSchoolbeforethisdatasourcemaybecreated.

DirectoryDataSource–readsinasetoffiles(forexample,asetofXMLdocuments).

14.2 Exercise:CreatingParameterizedStubsfromRecordedMessages

1. GobacktotheRecordingStudioperspectiveinRationalIntegrationTester,andselectMakeBookingwithintheEventMonitors.Thisshouldfilteroutanyotherevents,leavingyouwithjustthe6MakeBookingrequestsandresponsesrecordedduringthepreviousexercises.Checkthesetomakesurethatyouhavearequestmessageforeachofthethreecardtypesallowedbythebookingsystem.Ifnot,you’llneedtorecordmoreinteractionswiththesystem.Ifyou’vegottoomany,thendeleteanyextrasfromtheEventsView.

2. Selectall6events,andpresstheSavebutton.

3. Again,we’llchoosetosavethemasastubinthefirstpageofthewizard.PressNextonceyou’vedonethis.

4. Onthesecondpageofthewizard,choosetoStoredatainasimpledataset.PressNext.

Page 88: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page86of138©IBMCorporation2001,2012

5. Thethirdpagechecksthateverythinghasbeenallocatedtothecorrectoperation.Youshouldsee6events,alllabeledasbeingrelatedtotheMakeBookingoperation.Ifso,pressNext.Ifnot,you’llneedtogobackandmakesureyou’veselectedtherightevents.

6. Thefourthpagechecksthattherequestsandreplieshavebeengroupedcorrectly.Again,thisshouldalreadybethecase,butyoucanchoosetochangegroupingshereorrestartifnecessary.PressNextonceyou’resatisfiedthatthisiscorrect.

7. You’llthengetapreviewofhowtherequestmessageswillbemappedintoourdataset.

RationalIntegrationTesterwillanalyzethemessagesusedintherecordedmessages,andlookfordifferencesbetweenthemessages.Bydefault,itwillrecorddatathatchangesintocolumnswithinthedataset;datathatappearstobestaticwillnotbeincluded.Takealookattherequestmessage–fieldsthataregoingtobeincludedinthedatasethaveastatusofNew ,whilethosethatarenotgoingtobeincludedarelistedasIgnored .

8. Withintherequestmessage,weonlycareaboutthecardtype,soselecteachoftheotherfields,

andpresstheIgnore button.ThisshouldleaveonlythecardtypelistedasNew,andeverythingelseIgnored.PressNexttogototheresponsemessageforMakeBooking.

9. Here,wecanseethatthereservationnumberisalsomarkedasNew.Inthiscase,wemayalsodecidethatweareinterestedinthestatusfieldaswell,eventhoughithadthesamevalueineachoftherecordedmessages.Findthestatusrow,whichshouldbemarkedasIgnored.Select

it,andpresstheColumn button.

10. Apopupdialogwillappear,allowingyoutonamethecolumnthatwillbecreatedforthestatuswithinourdatasource–bydefault,itwillbecalledstatus.Thiswillbefineforourpurposes,sopressOK.BoththereservationnumberandthestatusshouldnowbemarkedasNew.

11. PressNextagaintogotothesummaryscreen.Thisshouldinformyouthatastubwillbe

created,alongwithadatasourcecontaininginformationaboutthecardtype,reservationnumber,andstatus.Ifdifferentfieldsarelisted,you’llwanttohitbacktoreturntotheprevioussteps,andmakesurethateachfieldisbeingaddedtothedatasetorignored,asrequired.

12. CallthestubBookingsWithData,andgototheTestFactorytoviewwhatwe’veproduced.

Page 89: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page87of138©IBMCorporation2001,2012

13. UndertheMakeBookingoperation,youshouldseetwothingswiththenameBookingsWithData.Wehaveastub,aswe’vehadeveryothertime,butwealsohaveadatasource.DoubleclickonthiswithintheTestFactoryTreetoopenit.

14. Thefirstthingyoumightnoticeisthatthefilenamecontainsareferencetotherootdirectoryof

aproject,writteningoldandsurroundedbypercentagesigns.Thisisasystemtag–avariableinternaltoRationalIntegrationTester,whichwecan’teditdirectly.Thisallowsustorefertotheprojectfolder,nomatterwherethatmightbelocated.Iftheprojectismovedtoanotherfolderoranothermachine,thelinktotheCSVfilethatwe’reusingwillstillfunction.

15. PresstheRefreshbuttonatthebottomofthescreentoviewthedatawithinthedatasource–thisshouldcontainthethreecardtypesandreservationnumberswerecordedpreviously,alongwithastatuscolumnthatstatesSUCCESSforeach.Thereisalsoagroupingcolumnprovidedforus,incasewehadrecordeddatawithrepeatingelements(whichwouldrequiremultiplelinesofdata).Asourdataisfairlysimple,wedon’tneedtoworryaboutthisfornow.Closethedatasource.

16. Openthestubitself,andlookattheInputtab.Youshouldnoticethatthecardtypeisbeingstoredintoatag.

17. SwitchtotheOutputtab,andyou’llnoticethatnoresponseisbeingsenthere–infact,noresponsemessageappearstobepresentatall.Thisisbecausethestubthatwehavegeneratedwillrespondifitrecognizesafamiliarcardtype,butotherwisewillignoreanyincomingmessages.Toseehowwehandlethis,switchtotheBusinessLogictab.

Page 90: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page88of138©IBMCorporation2001,2012

18. TheBusinessLogictaballowsustospecifyourowncustomlogictodictatehowthestubwillrespondtoincomingmessages.Here,youcanseeaLookupTestDataaction,whichisfollowedbytwooptions–FoundandNotFound.Ifthelookupissuccessful,itwillsendareply.Ifnot,itwilldonothing.OpentheLookupTestDataactionbydoubleclickingonit.

19. Thishastwotabs–theConfigtabwillopenbydefault.Asyoushouldbeabletosee,we’re

tryingtomatchthevaluethatwestoredintothecardTypetagintheInputtabwiththecardTypecolumninthedatasource.

20. SwitchingtotheStoretab,you’llbeabletoseethatwe’regoingtosavethedatafromthe

columnsinthedatasourceintocorrespondingtagswithinthestub(withtheexceptionofthegroupingtag).Thiswillonlyhappenifwefindamatch–otherwise,anyvaluesthatmayexistwithinthosetagswillbeleftalone.ClosetheLookupTestDataAction.

21. OpentheSendReplyaction.ThiswillbeusedtosendareplyifandonlyifwefoundamatchwithintheLookupTestDataaction.

Page 91: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page89of138©IBMCorporation2001,2012

22. Observethemessagethatisbeingsentback–thisusesthevaluesthatweresavedintothestatusandnewReservationNumbertagswithintheLookupTestDataaction,sothesevalueswillbecomingdirectlyfromourdatasource.ClosetheSendReplyaction.

23. Runthestub,andsendsomerequeststoit.Youshouldnoticethateachcardtypegetsitsownreply,basedonthedatasource.

14.3 Exercise:Creatingadatasourcewithoutrecordedmessages

Nowthatwe’veseenhowwecandatadriveastubfromrecordedmessages,let’slookathowwecancreatesomethingsimilarourselves.We’llreturntotheHotelFinderexample,andcreateanewstubthatwilllookupthecityinaspreadsheet,andreturnanappropriatehotel.Thiswillgiveussomethingverysimilartowhatwascreatedforusautomaticallyinthepreviousexercise.Later,we’llextendthistohandlemultipleresultscomingbackfromthelookup–inourcase,thiswillmeanmultiplehotelswithinthesamecity.

1. CreateanothernewstubforgetHotelsusingtheMEP,andcallitHotelWithData.Aswedidearlier,storethecitydataintoatagontheInputtab.

2. Aswewillbesendingbackdifferentmessagesdependingonwhetherornotwefindahotelwithinourdatasource,wecan’tusethesinglemessagedescribedintheOutputtab.UnchecktheboxonthattablabeledSendResponse.

3. We’llbedoingmostofourworkontheBusinessLogictab,soswitchtothat,andsettheDataModelsettingtoOther.ThistellsRationalIntegrationTesterthat,whilewemayormaynotbeusingadatamodel–moreontheselater–wedowanttosupplysomeofourowncustomlogicforthestub.

4. Belowthat,theTestStepswillappear.Aswe’regoingtolookthingsupinadatasource,presstheEditorCreateTestData button.

5. TheCreateorEditTestDatawizardwillappear.PressBrowsenexttotheExcelFilesetting.ThiswillopenbydefaulttothefolderrepresentingthegetHotelsoperation.TypeinanamefortheExcelfile–e.g.,HotelData1.xls–andpressSelect.

6. PressthebuttonlabeledSelectTestDataColumnsinordertoselectwhichtagswillbeused.

7. TheSelectTagsdialogboxwillappear,showingthecitytagwecreatedearlier.We’llalsowanttousetagsforthehotelnameandhotelrate.PresstheNewTag button,andtheCreateTagdialogwillappear.Callyournewtagname–therestofthesettingscanbeleftalone.PressOKtoreturntotheSelectTagsdialog.

8. Createanothertaginthesameway–callitrate.

9. WhenyouhavereturnedtotheSelectTagsdialog,dragyourmouseoverallthreetagstoselectthem.

Page 92: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page90of138©IBMCorporation2001,2012

10. PressSelecttoreturntothemainwindowofthewizard.

11. Finally,we’llneedtostatehowwe’regoingtouseourdata.We’lluseitinanewLookupTestDataaction,andinsertitaftertheSendOutputaction(thislastpartdoesn’treallymatterthatmuchinourcase,astheSendOutputtestactionhasalreadybeendisabled).

12. Makesurethatyourdialoglooksliketheoneabove,thenpressNext.

13. Onthesecondscreen,youcanselectthemappingsusedintheLookupaction.Wewanttomatchrowsbasedonthecity,sopresstheEditLookupValues button,andmakesurethatthecitytagisselectedinthedialogboxthatappears.Theothertagsshouldbedeselected.

14. PressSelecttoclosethisdialogbox,thenFinishtoclosethewizard.

15. TheExcelspreadsheetshouldnowappearonyourmachine.We’llneedtoentersomedatahere.Youcanusethefollowingexampledata:

city  Name  rate 

London  Uptown  200 

Paris  Global  250 

Page 93: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page91of138©IBMCorporation2001,2012

Madrid  Superior  180 

Barcelona  Downtown  220 

16. Notethatthedatahasonehotelpercity–we’lllookathowwecanhandlemultiplehotelsinthefollowingexercise.Saveyourspreadsheet,andclosetheeditor.

17. BackintheBusinessLogictabofthestubeditor,you’llnowseeaLookupTestDataactioninsideyourstub.Thiswillrefertoyourdatasource,attempttolookupdatabasedonthecitytag(asselectedinthewizard),andretrievethehotelandrateinformationforthatcity.Openthisupandtakealookatitssettingstoacquaintyourselfwithwhatishappeninginsidethisstep.ClosethepropertiesoftheLookupactiononceyou’redone.

18. UnderneaththeLookupaction,youshouldseelinkeditemslabeledFoundandNotFound.

Theseletuscontrolwhatwillhappen,dependingonwhetherornotwecanfindamatchforthecityfieldincludedintherequestmessage.

19. RightclickontheFounditem,andchooseNew>Messaging>SendReply.ThiswillcreateanewactionunderneaththeFoundbranch.

20. DoubleclicktoopenthenewSendReplystep.

21. Youwillseethatthemessageiscurrentlyempty,anddoesnothaveaschemaatthemoment.Tofixthis,findthetext(String)inthemessage,rightclickandchooseSchema.

22. TheSelectSchemadialogwillappear.Onthefirstpage,selectWSDLsonthelefthandside,thentheHotelFinderWSDLinthemiddle.Ontherighthandside,youwillthenbeabletoselectthegetHotels___OUTPUT___getHotelsResponsemessageschema.PressNext.

23. Onthesecondpage,makesurethatIncludeoptionalfieldsischecked.PressFinish.

24. Themessageschemawillnowappearforyou.Selectthetextnodesforthehotelnameandrate;rightclick,andthenchooseContents>QuickTag.Thiswillinsertthetagnamesforthesetwofieldshere.Allotherfieldsmaybeleftblank,astheywillbeignoredbytheTomcatapplication.Ifyouwantedto,youcouldquicktagsomeoftheotherfields,andmakesurethatyouhavematchingcolumnsinyourdatasource,inordertodatadrivethosefieldsaswell.

Page 94: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page92of138©IBMCorporation2001,2012

25. PressOKtoclosetheSendReplyaction.

26. CopyandPastetheSendReplyaction,sothatthereisasecondcopyofitunderneaththeNotFoundbranch.Doubleclicktoeditthisnewaction.

27. Aswedidpreviously,we’regoingtodeletepartofthemessagetoshowthatnohotelswerefound.FindthegetHotelsReturnelement,anddeleteit.Thiswillalsodeleteallofitschildnodes.

28. ClosetheSendReplyaction.Yourtestshouldnowlooklikethefollowing:

29. Savethestubandrunit.

30. Attempttosearchforhotelsinthecitiesreferredtoinyourspreadsheet–youshouldnowgetthesamehotelthatyouhadinyourdatasource.Usingcitiesthatwerenotinthespreadsheetshouldresultinanemptylistofhotels.

14.4 Exercise:DataDrivingwithRepeatingElements

Ideally,we’dliketobeabletorespondwithmorethanonehotelpercity.DoingthisintheExcelspreadsheetwillbeprettysimple–wejustneedtoaddmorerows.Butwe’llneedtoconfiguretheoutputmessagecorrectlyinourstubtomakesureit’ssendingbacktherightdata.

We’llalsotakethisopportunitytolookathowyouwouldimportdatafromanalready‐existingdatasource.Thismeansthatwe’llneedtodoafewthingsmanuallythatRationalIntegrationTesterwasdoingforusinthepreviousexercise–forexample,we’llneedtotellthesoftwareifourcolumnshave

Page 95: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page93of138©IBMCorporation2001,2012

headings,andwhetherornotthereareanyblanklinesbeforeorafterthoseheadings.Inthepreviousexercise,RationalIntegrationTesterknewallofthisinformationaboutthedatasource,asithadbeencreatedinthesamesoftware,butherewewon’thavethatluxury.

1. Onyourdesktop,you’llhaveanExcelfilecalledHotelsByCity.xlsx.Openthistotakealook–youshouldseehotelsforLondon,Edinburgh,Barcelona,andMadrid.Closethefilewithoutmakinganychanges.

2. GototheTestFactory,andcreateanewstubforgetHotelsusingtheMEPmethod.CallitmultipleHotels.

3. Thisstubwillalsohavejusttheonetransition.SettheActorforthistransitiontoUser,andtheEventtogetHotels.

4. IntheInputtab,selectthecityTextnode,rightclick,andselectContents>QuickTag.Asbefore,thiswillstoretheincomingcitynameintoatagforus,sowecanuseittolookupthelistofhotelsforthatcity.

5. IntheOutputtab,unchecktheboxmarkedSendResponse.

6. IntheBusinessLogictab,settheDataModeltoOther.

7. You’llthenbeabletoaddanewLookupTestData actiontothestubbyselectingitfromthetoolbarthatappears.

8. Atthisstage,theLookupTestDataactionwillstatethatnotestdatasethasbeenallocated.Sincewehaven’tcreatedoneyet,we’llnowneedtodothat.RightclickongetHotelsintheTestFactoryTree,andselectNew>TestData>ExcelDataSource.CallithotelData.

9. ThesettingsfortheExceldatasourcewillappear.First,we’llneedtospecifythefilename,sofindthisfieldatthetopofthesettings,andpressBrowsetolocatetheHotelsByCity.xlsxfile.

10. Belowthat,wecanconfigureothersettings–thedefaultsshouldworkfineforthisexample.PresstheRefreshbuttonatthebottomofthesettingstoviewthefileasRationalIntegrationTesterunderstandsit.YoushouldseethesamedatathatyousawintheExcelfile,withthecolumnheadingsseparated.

11. PressthebuttonCopycolumnnamestoclipboard.Thiswillallowustocreatetagsthatmatch

ourcolumnnameswithinthestub.

12. SavetheExcelDatasourceandCloseit.

Page 96: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page94of138©IBMCorporation2001,2012

13. GobacktothemultipleHotelsstub,andontheBusinessLogictab,doubleclickontheLookupTestDataaction.

14. ThepropertiesoftheLookupactionwillappear.Thefirstthingweneedtodoisselectthedataset,sopresstheBrowsebuttonforthissetting,andselectthehotelDatathatyoujustcreated.

15. Onceyou’vedonethis,alookupsettingwillappearbelow.Thisallowsustosetthecriteriawe’regoingtouseformatchingrecordsinthedatasourcetotheincomingmessages.Bydefault,RationalIntegrationTesterwillselectthefirstcolumnasthecolumntouseforthelookup.Wecouldchangethis,butasit’sexactlywhatwe’reafter,we’llleavethatsettingalone.

16. Thatsaid,wedoneedtosaywhatvaluewe’llbelookingforinthecitycolumn.DoubleclickonittoedittheLookupValue,andinsertthecitytag,eitherbytyping%%city%%,orrightclickingandchoosingInsertTag>TestScope>city.

17. SwitchtotheStoretaboftheLookupTestDataaction’sproperties.Here,wecansaywhatwe’dliketodowithanymatchingdata.

18. Thefirstsettingallowsustochoosewhetherwe’dliketofindalldatathatmatchesourchosencity,orjustasinglelineofdata.We’dlikeeverything,soselectStoreallmatchingrowsintolists.

19. Belowthat,wecanseehowthedatainthedatasourcewillbemappedintoourtags.Currently,thecitydatawillbemappedintoourcitytag,buttheothertwocolumnsarelistedashavingNoMapping.

20. ClickingintheTagNamecolumnwillpresentyouwithapairoficonsontherowyouclickon.ClickontheTagNameforthehotelname,andthenclickontheEdit buttonthatappears.

21. TheSelectTagdialogwillappear.PressthePaste buttonatthetopofthedialogtopasteinthecolumnnameswehadinourdatasource.Thiswillcreatetagswithcorrespondingnames.

22. Selectthehotelnametagthatwascreatedinthepreviousstep.

23. Editthetagnamefortherate,andSelectthenewratetag.

24. VerifythattheStoretablookslikethefollowing,andpressOK:

25. Wenowneedtoaddthetwomessagesthatwillbesentback,dependingonwhetherornota

matchisfoundinthedatasource.RightclickontheFoundbranchoftheLookupaction,andselectNew>Messaging>SendReply.Doubleclickonthisnewactiontoeditit.

Page 97: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page95of138©IBMCorporation2001,2012

26. Rightclickonthetext(String),andselectSchema.ChoosethegetHotels___OUTPUT___getHotelsResponseschemafromtheHotelFinderWSDL,andpressFinishtoclosetheSchemadialog.

27. Inthetextfieldsforthehotel’snameandrate,editthemandthenrightclickandchooseInsertTag>TestScope,andthentheappropriatetags.

28. Aswemayhavemorethanoneresult,weneedtotellRationalIntegrationTesterthatthismaybethecase.RightclickonthegetHotelsReturnelement,andchooseMarkAsRepeating.Theelementshouldturngreen(youmightneedtoselectsomethingelsetoseethis).PressOK.

29. CopyandpastetheSendReplyactionsothatitalsoappearsundertheNotFoundbranch.

30. OpenupthissecondSendReply,anddeletethegetHotelsReturnelementfromthemessage.

31. SaveyourstubandrunitintheTestLab.Now,whenyousearchforhotelsthatarelistedinthedatasource,youshouldseemultipleresultsreturned.

14.5 Exercise:InputTags

Oneotherwaywecansupplydatatoastubistoprovidesomeconfigurationdatawhenthestubisexecutedbytheserver.Thiscanbedonethroughaninputtag.Aninputtagisatesttagthathasbeenmarkedasonethatcanreceiveinput.Generally,thisshouldhaveadefaultvalue.

WhenweexecutethestubfromRationalIntegrationTester,thedefaultvalueforthetagwillbeused,andthestubwillexecuteasitnormallydoes.Ifwepublishthestubtotheserver,thenwewillbegiventheoptionofusingadifferentvaluewhenwedeploythestub.

1. CreateacopyoftheHotelWithDatastubyoucreatedforgetHotels.CallitHotelsWithInput.

2. GototheBusinessLogictab,andclicktheTagDataStoreicon(firstontheleftofthetoolbar).

3. TheTagDataStorewillappear.PresstheNewTagbuttontocreateanewtag–callitfinal_rate,andpressOK.

4. Createasecondnewtag,andcallitmultiplier.Whenyoucreatethis,giveitadefaultvalueof1.0,andchoosetoExposeasInput.Thiswillbeourinputtag.PressOKtocreatethissecondtag.

5. Closethetagdatastore.

6. AddanewFunctionactionbeforetheSendReplyintheFoundbranchoftheLookupTestData,andeditit.

7. TheFunctionactionshouldbeusingECMAScript–enterthefollowingcode:final_rate = rate * multiplier

8. PressOKtoclosetheaction.

9. OpentheSendReplyactionintheFoundbranch.OntheConfigtab,youwillseethatthereplywaspreviouslyusingthevalueoftheratetag.Changethistousethefinal_ratetaginstead,andclosetheSendReplyaction.

10. Savethestub,andexecuteitintheTestLab.Youshouldnoticethatitstilloperatesinthesamewayitdidpreviously.

Page 98: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page96of138©IBMCorporation2001,2012

11. Stopthestub,andreturntotheTestFactory.

12. RightclickonthegetHotelsoperation,andchoosetoPublishthestubsforthatoperation,usingtheBooking SystemdomainandLocalenvironment.

13. InRTCP,choosetodeploytheHotelsWithInputstub.Asyoudothis,youshouldnoticethatthereareConfigurationsettings.Insidethissection,youwillseethemultipliertag,alongwithitsdefaultvalueof1.0.

14. Changethedefaultvalueto1.5–wewouldexpectthistoraiseallofthepricesforthehotels,possiblyforaholidayseason.

15. Startthestubfromtheserver,andattempttolookforhotelsfromyourwebbrowseronemoretime.Thistime,youshouldnoticethatthepriceshavegoneup.

16. Ifyouwant,youcanstopthestubintheserver,thenrestartitwithamultiplierof0.5,givingushalfpricehotelrooms.Stopthestubonceyouarefinished.

Page 99: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page97of138©IBMCorporation2001,2012

15 Database Stubs

15.1 Introduction

Whileitisveryusefultosimulatemessage‐basedsystems,sometimesitwouldbeusefultosimulateadatabaseaswell.VIEprovidesuswiththiscapability–wecanrecordanapplication’suseofadatabase,andusethisinformationtosimulatethatdatabaseinvisiblytotheapplication.

Whiledoingthis,wecanchoosetosimulatethatdatabaseinsuchawaythateverytimewestartthesimulationdatabase,itcontainsthesamedataset,orwemaychoosetopersistchangesmadetothesimulationdatabaseovertime.

Inordertodothis,newJDBCdriversneedtobesetupfortheapplication(s)thatwillbeaccessingthedatabase.ThisallowsVIEtointerceptthedatabaserequestsbeingmadebytheapplication.Thissetupwillvaryfromapplicationtoapplication.TheexamplediscussedinthischaptercovertheuseofagenericJavaprogram(Tomcat).

15.2 TheRITJDBCDriver

InordertouseVIE’scapabilitiestorecorddatabaseinteractionsandtocreatestubs,theapplicationthatisaccessingthedatabasemustbemodifiedtousetheRITJDBCdriverfordatabaseaccess.ThedefaultbehaviorfortheRITJDBCdriveristopassthroughanyJDBCcallstotherealdatabasedriver,whetherthatisDB2,Oracle,MySQL,orsomethingelse,allowingtheapplicationtobehavenormally.ThismodeisLivemode,andmaybeusedtorecordthedatapassingthroughtheRITJDBCDriver.

Page 100: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page98of138©IBMCorporation2001,2012

ThesecondpossiblemodeisLearnmode.ThisworksinmuchthesamewayasLivemode,butwe’llalsobesavingthedatareturnedbyanyqueriesintoourseparatesimulationdatabase.Notethatthesimulationdatabasemustbeofthesametypeasthelivedatabase(DB2,MySQL,etc),butdoesnotneedtobeonthesamemachine.Whenthedriverswitchesoutoflearnmode,alldataiscopiedfromthesimulationdatabaseintoRationalIntegrationTester’sinternalstorage.

ThefinalmodeisSimulationmode.ThisredirectsanyJDBCcallsthatwouldusuallybesenttothedatabasetooursimulationdatabaseinstead.ThesimulationdatabasewillberepopulatedwithwhateverdataisheldbyRationalIntegrationTesteratthistime.Whenweexitsimulationmode,wemaychoosetoagainsavethedataheldinsidethesimulationdatabase,overwritingwhatwasheldpreviously.Thisgivesustheoptionofhavingpersistentortransientdata.

Page 101: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page99of138©IBMCorporation2001,2012

15.3 Exercise:RecordingSQL

We’llnowlookathowwecanrecordtheSQLqueriesbeingsenttothedatabasethroughtheTomcatwebserver.Forthemoment,wewon’tworryaboutcreatingavirtualdatabase–we’lljustrecordtheSQLstatementsbeingused.

1. SwitchtotheRecordingStudioofRationalIntegrationTester,andclearanyEventMonitors.

2. ChoosetoAddanewEventMonitor.InordertoseetheWWTraveldatabase,youwillneedtoShowrecordableresources .

Page 102: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page100of138©IBMCorporation2001,2012

3. SelectWWTravel_DB,andpressOK.

4. IntheEventsView,clickontheRecording…buttontostartrecording.

5. Atthisstage,RationalIntegrationTesterwillinformyouthatavirtualdatabasehasnotbeensetupfortheWWTraveldatabase.Thismeansthatwewon'tbeabletocreateadatabasestubjustyet,butwewillbeabletoreviewanyinteractionswiththedatabase.Aswejustwanttoseethequeriesthatarebeingrunagainstthedatabaseatthistime,pressContinueRecordingtoproceed.

6. Withinyourwebbrowser,gotothesigninpagefortheWorldwideTraveladministration

services.Youshouldn’tactuallyneedaloginhere–youcanjustpresstheSubmitbuttonontheform.

7. Thiswillrunaquery,andreturnthevariousflightswithbookingsinyourdatabase.IfyouswitchtoRationalIntegrationTester,youshouldnowseethequeryrecordedforyouthereas

Page 103: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page101of138©IBMCorporation2001,2012

well.NotethatsimplyrecordingtheSQLlikethisdoesnotrecordtheresultsofthequery–we’llbeabletodothiswhenwecreateavirtualdatabasebyobservingtheresultsofqueries.

8. Inyourwebbrowser,clickonthelinkforaflight–thiswillgiveyouinformationaboutthebookingsforthatflight.InRationalIntegrationTester,youshouldnowseeasecondquerylistedforyou.

9. Inthiscase,youwon’tseetheentirequeryintheEventsView,asit’stoolongtofit.Similarly,ifyouselectthisevent,youwillseemoreofthequeryatthebottomofthescreen,withintheeventdetails,butyoustillwillnotseetheentirequery.

10. Toviewthecompletequerythatwassenttothedatabase,selecttherecordedeventintheEventsView,thendoubleclickthequerywithinthedetailsatthebottomofthescreen.Apopupwindowshouldappear,containingthecompletequerythatwassenttothedatabase.Closethiswindowafterviewingthequery.

11. Pauserecording,andreturntotheinitialsigninpageinyourwebbrowser.

15.4 Exercise:Creatingandexecutingadatabasestub

We’llnowrecordthesamedatabaseagain,butthistime,we’llrecordtheresultsofouractionsintoavirtualdatabase.Wewillthenbeabletousethisdatabaseasthebasisforastubthatwewillbeabletouseforsimulations.

1. SwitchtothePhysicalViewofArchitectureSchool.YoushouldseethephysicalresourcethatyoucreatedearlierfortheWWTraveldatabase.

2. Doubleclickonthisresourcetoopenupitsproperties.

3. SwitchtotheStubSettingstab,andenterthefollowingvalues(thepasswordisWelcome01):

Page 104: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page102of138©IBMCorporation2001,2012

4. PressTestStubConnectiontoverifythatyouhavesetuptheconnectioncorrectly,thenpress

OKtoclosethepropertiesofthephysicalresource.

5. ReturntotheRecordingStudioperspective,andthenstartrecordingagain.Thistime,youwillbeaskedwhatyouwanttodowiththerecordedevents.

6. WecouldjustrecordtheSQL,aswedidpreviously,butwe’realsonowpresentedwiththe

optiontocreateavirtualdatabase,usingthestubsettingsenteredintheArchitectureSchool.Inthetopofthedialog,choosethissecondoption.

7. Atthebottomofthedialog,choosetoCreateadatabasestubbutdon’tstartitafterfinishingrecording.CallthestubWWTravel Virtual DB.

Page 105: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page103of138©IBMCorporation2001,2012

8. PressStartRecording,andthenreturntoyourwebbrowser.

9. Logintothesystemagain,andinteractwithit,allowingittorunmultiplequeriesagainstthedatabase.Attheveryleast,youshouldmakesurethatyouviewthelistofpassengersforbothflights–youcaninteract.YoushouldseethequeriesappearwithintheRecordingStudioofRationalIntegrationTester,asbefore.

10. PausetherecordingwithintheRecordingStudio.

11. Apopupwillappear,indicatingthatthedatabasestubthatwehavecreatedmaynotbeeditedwithintheRecordingStudio.PressOKtoopenthedatabasestubwithintheTestFactoryperspective.

12. Youwillnowseeasummaryoftheinformationcontainedinthedatabasestub,splitintothree

sections.Thefirstsection,Queries,tellsuswhichquerieswereseenbythedriverwhencreatingthevirtualdatabase.Thesecond,Tables,letsusknowwhichtableshavebeencreated,andhowmanycolumnsandrowsarecontainedwithinthevirtualdatabase.Thefinalsection,Sequences,allowsustoseeanysequencesthatwereusedbyanyoftherecordeddata.Inourcase,thiswillbeblank,astheexampledatabasedoesnotcontainanysequences.

13. Withinthisview,wearealsoabletoviewandeditthedataheldbythevirtualdatabase.Forthemoment,though,we’llsimplyexecutethedatabasestub,andinteractwithit.Todothis,firstswitchtotheTestLabperspective.

14. WithintheTestLabTree,doubleclickontheWWTravel Virtual DBstub.YoushouldseethatitisrunningintheTaskMonitor.Watchtheconsoledatabelow,asitmaytakeamomentforthestubtoreachastatusofReady.

Page 106: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page104of138©IBMCorporation2001,2012

15. Oncethestubisrunning,signintotheairportsystemagain,torunasearchforflights.Youshouldseethesameflightsasbefore.Similarly,ifyouclickononeoftheflightstoseethepassengerlist,youshouldseethesameinformationthatyourecordedearlier.

16. We’lleditthedatainthesimulationdatabase,though,toprovethatwe’renottalkingtothelivedatabase.Selectapassenger,andedittheirAPICommentdatatosayChecked In.

17. Viewthelistofpassengersforthatflightagain–theAPICommentfieldwillbeupdatedtoOK: Checked In,asourdatawassenttoaseparateservice(theFlightConfirmationServer),beforebeingaddedtothedatabase.

18. InRationalIntegrationTester,Stopthestub.

19. Signintothesystemagain,andyoushouldseethatyourchangeshavedisappeared.Infact,evenifyouweretorestartthestub,youstillwouldn’tseethosechanges.ThisisbecauseRationalIntegrationTester’sdefaultbehavioristoresetthedatainthesimulationdatabaseeachtimethedatabasestubisstartedup.We’llhavealookatgettingmorecontroloverthedatainthesimulationdatabaseinthenextexercise.

15.5 Exercise:Modifyingthesimulationdatabase

We’llnowlookatthevariouswaysthatwecanmodifythesimulationdatabase.WecaneditthedatainatableusinganExcelspreadsheet,orwecanusewhateverdatabasetoolsareavailable.Wecanalsochoosetokeepchangestothesimulationdatabasebetweenexecutionsofthedatabasestub,ortodiscardanychanges.

1. MakesurethatyouhavestoppedanyexecutionofthedatabasestubintheTestLab.

2. ReturntotheTestFactory,andviewyourdatabasestub.

3. ChoosetoUseaspreadsheettoeditthisdatabasestub .

4. TheEditDatabaseStubwizardwillappear.Onthefirstpage,choosetoEditthecontentsofspecifictables,andpressNext.

5. Onthesecondpage,therewillbeasinglequerylisted–SELECT * FROM RESERVATION.Chooseit,andpressNextagain.

6. Yourspreadsheetwillthenappear,readytobeedited.

7. EditthedetailsforreservationA00001:changetheflightnumbertoWW121,andthefirstnameto

Mark.

8. Savethespreadsheetandcloseit.

Page 107: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page105of138©IBMCorporation2001,2012

9. WithinRationalIntegrationTester,theEditDatabaseStubdialogwillstillbeactive,asitiswaitingforconfirmationthatyouhavefinishededitingthedata.Aswe’venowmadeourchangestothespreadsheet,pressNexttotellRationalIntegrationTestertomoveon.

10. Asummarywillthenappear.PressFinishtoclosethewizard.

11. ChecktheboxmarkedPersistentatthetopofthedatabasestubeditor.Thiswillmeanthatanychangeswemaketothesimulationdatabasewhileitisrunningwillbesavedforfutureexecutionsofthedatabasestub.

12. Savethedatabasestub,andRunit.

13. Returntoyourwebbrowser,andthesign‐inpagefortheadministrationinterface.

14. Thistime,asyougothroughtheinterface,youshouldseeathirdflight–WW121.Thisflightwillhaveasinglereservation,forMarkThomson.

15. UpdatetheAPICommentfieldforthisentry,aswedidinthepreviousexercise,andmakesureyoucanseetheupdatedvalueonthepassengerlisting.

16. StopthestubinRationalIntegrationTester,andthenRunitagain.

17. Thistime,whenyousigninandviewtheinformationforMarkThomson,thechangesthatyoumadeearlierwillstillbevisible.

Page 108: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page106of138©IBMCorporation2001,2012

16 Alternative Message Formats

Sofar,we’velookedatXML‐basedmessagingformats.However,notallmessageswillbeinthisformat.We’lllookatexamplesofalternativeformats,andseehowtheyaredealtwithbyVIE.Bytheendofthischapter,youshouldseethatmovingfromonemessagingformattoanotherisfairlysimple,andthatyouwillbeabletoapplytheskillsthatyouhavelearntpreviously,withonlyminoradjustments.

16.1 Exercise:COBOLCopybookMessages

COBOLCopybookisamessagingformatthatmaybeencounteredwhendealingwitholdermainframesystems.CopybookinformationmaybestoredwithinafilethatcanbeimportedintoRationalIntegrationTester,andusedtoformatfixedwidthtextmessages.

Duringthisexercise,wewillfirstimportacopybookformatintotheSchemaLibrary,recordmessagesusingthatformat,andfinallycreateasimplestubfromtherecordedmessages.

1. SwitchtotheArchitectureSchoolofRationalIntegrationTester,thentotheSchemaLibrary.

2. PresstheNewCopybook icon.Adialogwillappear,askingyoutosupplythedetailsforthecopybookthatyou’reimporting.

3. LeavetheTypeasFile.TheNamespace,whichwouldallowustocreateanamespacewithinourprojectforthefieldscontainedinthecopybook,maybeleftblank,aswe’reonlyusingasinglecopybookinthisexample.TheStartColumnandEndColumn,whichcanbeusedtoaddmarginsatthebeginningandendofthefixedwidthtext,mayalsobeleftblank.

4. PresstheChangebuttontochangethecurrentlocation.YouwillthenbeabletoBrowsetothefilelocation–selectthefileAPI_INFO.CPY,foundonyourdesktop.

5. YoushouldthenseetheRESERVATION‐MSGmessageformatthatwascontainedwithintheAPI_INFOcopybook.

6. SwitchtotheRecordingStudio,andremoveanyEventMonitorsthatmightbeinplace.

7. AddanEventMonitorfortheWWTravel_MQtransport,andStartRecording.

8. Inyourwebbrowser,bringuptheWorldwideTraveladministrationsign‐inpage,andsignin.

9. Selectaflight,andthenareservationonthatflight.

10. Whileviewingthisreservation,youwillnoticethattheAPICommentfieldisaneditablefield.EnterPassport Seeninthisfield,andthenpressCheck‐In.

11. Youwillbereturnedtothelistofreservationsforthatflight.Findthereservationthatyoueditedinthepreviousstep.YoushouldseethattheAPICommentnowsaysOK: Passport seen.

12. ReturntoRationalIntegrationTester,whereyoushouldseeapairofmessagesintheEventsViewofRecordingStudio.

Page 109: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page107of138©IBMCorporation2001,2012

13. Selecttherequestmessage–youwillnoticethatitisformattedasasingletextstring.

14. Rightclickonthisstring,andselectShowAs>COBOLCopybook>API_INFO>RESERVATION‐MSG.Adialogwillappear,allowingyoutoenterinformationaboutthetextencodingofthefile,andtonoteanypaddingthatmaybepresent.Wedon’tneedtoworryabouteitherofthese,sopressOK.

15. Aseconddialogwillappear,givingyouapreviewoftheformattedmessage.PressOKtoapplytheformatting.

16. RationalIntegrationTesterwillthendisplaytheformattedmessagewithintheMessageDetailssection–youmayneedtoexpandthetreestructurethathasbeenappliedinordertoseetheentiremessage.

17. Switchtotheresponsemessage–ifRationalIntegrationTesterhasrecognizedthisasacopybookmessagethatithasencounteredbefore,thenitwillbeformattedforyouautomatically.Otherwise,youwillneedtofollowthesameprocedureasfortherequestmessage.

18. Oncebothmessagesareproperlyformatted,wecancreateanoperationandastubusingthem.Selectthetwomessages,andpresstheSavebutton.

19. Onthefirstscreenofthewizard,choosetocreatestubs.Anoperationwillbecreatedforusatthesametime.PressNext.

20. Onthesecondscreen,choosetoStoreDataashard‐codedvalues.

21. Next,youwillbeabletoallocatethestubtoanoperation.Aswedon’tyethaveavalidoperation,onewillbecreatedforus.Thedefaultnamefortheoperationshouldbewwtravel.checkin – wwtravel.checkin.reply.RenamethistoCheckin.IfRationalIntegrationTesteraskswhetheryouwouldliketoapplythechangetootherunselectedeventsusingthesameoperationname,sayYes.

22. PressNextafterrenamingtheoperation,andchoosetoCreateallresourcesundertheWWTravelservicecomponent(thisshouldalreadybeselectedforyouanyway).HitNextagain.

23. Wecanthengroupthemessagesintotransactions–asweonlyhavetwomessages,andthey’realreadygroupedtogether,wecanpressNexttogotothesummarypage.

24. Youshouldnowseethatwewillbecreatingasinglestub,underabrandnewCheckinoperation.PressFinishtocreatethestubandtheoperation.

25. Aswithotherrecordedstubs,thestubthatwe’vecreatedwillonlyworkwithasinglerequestmessage.We’lledititsothatit’smoreflexible–openthestubintheTestFactory,andviewtheInputtab.

26. Currently,thestubisattemptingtofilterbasedonthemessagecontents.Wedon’twanttodothis,soselectallofthetextfieldswithinthemessagebyusingCtrl+Click,thenrightclickandselectContents>FieldActions>Filter>Equalityfromthecontextmenu.

27. Withallofthesamenodesselected,rightclickandselectContents>QuickTag.ThemessagecontentswithintheInputtabshouldthenappearlikeso:

Page 110: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page108of138©IBMCorporation2001,2012

28. Mostofthisdatawillbeusedas‐iswithintheOutputtab,solet’sswitchtothattabnowtoset

thisup.YoushouldnoticethatnearlyallofthedatahereisthesameaswhatyouinitiallywouldhaveseenwithintheInputtab,withtheexceptionoftheCOMMENTfield,whichhasthetextOKaddedatthebeginning.

29. Togetthingsstarted,selectallofthetextnodesagainusingCtrl+Click,thenQuickTagthemagain.

30. Now,edittheCOMMENTfield.WecouldaddOKatthebeginning,asinthelivesystem,butwe’dprefertomakesurethestubresultscanbeeasilydistinguished.Instead,edittheCOMMENTfieldsothatitsaysDONE: %%COMMENT%%.

31. Savethestub,andrunitintheTestLab.

32. Youshouldnowbeabletocheckincustomersusingthewebinterface,andthecommentsshouldbeupdatedtoincludeDONEatthebeginning;stopthestub,anditshouldagainsayOK.

Page 111: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page109of138©IBMCorporation2001,2012

17 Data Masking

Sofar,we’verecordeddataandvirtualizedaservicewithoutworryingaboutthedatathatmightbeexposedinthatway.However,theremaybetimeswhenwedonotwantalldatawithinthesystemtobevisible.Forexample,theairlinebookingsystempassesacreditcardnumberbetweendifferentservices.Ifthesystemcurrentlyusesdummydatacreatedbythedevelopmentteam,recordingdatafromthesystemwillnotbeaproblem.Ontheotherhand,ifwearerecordingproductiondata,thiswouldbeaproblem.Aswerecordmessagesfromthesystem,wewouldbeabletoseecustomercreditcarddata,whichshouldbehiddenfromview.

Inordertohidethisdata,wecanaddadatamasktoparticularfields.Thedatamaskwillreplacethefieldvaluecompletelywheneverthefieldisencounteredduringrecording.Anyresourcescreatedusingthatrecordeddatawillthenusethevaluesuppliedbythemask.Masksmaybeimplementedinthreedifferentways:

FixedValueSubstitution

DataSourceSubstitution

AutomaticValueCreation

FixedValueSubstitutionisthesimplestdatamaskingscheme.Whensettingitup,youwillneedtoenterasinglevalue–thatvaluewillreplaceanydatarecordedforthatfield.

DataSourceSubstitutionusesadatasourcesuchasanExcelorCSVfiletosupplyalistofvaluesthatcanbeusedtoreplacerecordeddata.Thismethodofsubstitutionmaybeconfiguredtoallowanewsubstitutioneachtime,ortoallowthesamesubstitutionforagivenvalueeachtimethesubstitutionisperformed.

AutomaticValueCreationtakesaregularexpression,andcreatesnewvaluesmatchingthatexpression–sotoreplaceacreditcardnumber,wemayaskittogeneratenew16digitnumbersforus.Aswithdatasourcesubstitution,itmaybesetuptomaintaindataintegritybymakingsurethatthesameoriginalvaluesarealwaysreplacedwiththesamesubstitutionseverytime.

17.1 Exercise:FixedValueSubstitution

1. WithintheArchitectureSchoolperspective,gototheSchemaLibrary,andselecttheXSDstabonthelefthandside.

2. InthelistofXSDs,selecttheBookFlightRequest (XSD).

3. Youwillthenbeabletoviewthisschemaontherighthandside.FindtheTextnodeofthecardNumberelementandselectit,asshown:

Page 112: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page110of138©IBMCorporation2001,2012

4. IntheDataMaskingpanelatthebottom,clickontheAddbuttontoaddadatamasktothe

cardnumber.

5. SettheMaskingTechniquetoFixedValueSubstitutionandenteravalueintheFixedValuefieldasshown.Finally,Savethemask.Themaskicon( )willappearnexttothefieldthatisbeingmasked.

6. GototheRecordingStudioperspectiveandmakesurethattheMakeBookingoperationislisted

withintheEventMonitors.

7. ClickontheRecordingbuttontostartrecordingtheoperation.

8. Returntoyourwebbrowser,andmakeaflightbookingusingtheWorldwideTravelinterface.Makesurethatthecreditcardnumberthatyouenterhereisnotthesameasthevalueusedwhenyoucreatedthemask.

Page 113: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page111of138©IBMCorporation2001,2012

9. GobacktotheRecordingStudioandviewtherecordedevents.SelecttherequestmessageforMakeBooking,andfindthecreditcardnumberfield.Youshouldseethatthenumberyouenteredinyourwebbrowserhasbeenreplacedbythevalueenteredforthedatamask.

17.2 Exercise:DataSourceSubstitution

1. Createanexcelfilewithaseriesoffakecreditcardnumbers,andsaveitasData Masking.xls.

2. GototheTestFactoryandcreateanexceldatasourcecalledCardNumberMaskandselectthe

excelfilecreatedinthepreviousstep.Theotheroptionsinthisscreenmaybeleftattheirdefaultssettings–justpressRefreshtoviewapreview,andmakesurethatthedataisbeingimportedcorrectly.

3. Savethedatasourceandcloseit.

4. GototheSchemaLibrarytabinArchitectureSchoolandselecttheXSDstabonthelefthandside.

5. SelecttheBookFlightRequest schema,andthentheTextnodeofthecardNumberelement,asbefore.

Page 114: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page112of138©IBMCorporation2001,2012

6. IntheDataMaskingtabatthebottom,changetheMaskingTechniquetoDataSourceSubstitution.

7. ChoosetheCardNumberMaskasyourDataSource,andtheData MaskastheColumn.

8. Finally,youmaychoosetoturnonoroffthesettingEnforceDataIntegrity.Usingthissettingwillmeanthatthesamedatawillalwaysbemaskedbythesamevalue.Usingourexample,creditcardnumbersareusedacrossmultipleoperations(MakeBooking,ProcessGlobal,etc),anditwouldbeusefultoreplaceeachcreditcardnumberinthesamewayforeachoperation.Notethatintegrityisonlypreservedwithinasinglerecordingsession,soifyoustopandstartrecording,thereplacementvaluesmaynotbethesame.Youalsohavetheoptionofloopingthroughthedatatore‐usemasks,ortouseafixedvalueifyourunoutofmasks.We’llswitchontheEnforceDataIntegritysetting,andchoosetoReturntoStartoncewerunoutofdatamasks.

9. ReturntotheRecordingStudio,andrecordanewrequestforMakeBooking,asbefore.

10. Youshouldseethatthecreditcardnumberisnowmaskedusingvaluesfromyourdatasource.Ifyourecordfurtherbookingrequests,youshouldalsonoticethatthevaluesdisplayedchangeasyouchangecreditcardnumbers.

11. Stoprecording.

17.3 Exercise:AutomaticValueCreation

1. GototheSchemaLibrarytabinArchitectureSchoolandselecttheXSDstabonthelefthandside.

2. SelecttheBookFlightRequest schema,andthentheTextnodeofthecardNumberelement,asbefore.

3. IntheDataMaskingtabatthebottom,changetheMaskingTechniquetoAutomaticValue

Creation.

4. Enter\d{16}astheRegex.YoucanthenpresstheTestbuttontoverifythatthisissupplyingyouwith16digitnumbers.

Page 115: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page113of138©IBMCorporation2001,2012

5. Again,we’llchoosetoEnforceDataIntegrity.Inthiscase,thereisasecondoption–aLabel.Usingthesamelabelforapairofdatamasksthatusethesameregexwillallowthemtoenforcedataintegrityacrossmultiplefields.EnterCardNumbersastheLabel.

6. ReturntotheRecordingStudio,andagainrecordtheMakeBookingoperation.

7. Youshouldseethatthecreditcardnumberisnowmaskedusing16digitnumbers,asspecifiedwithinthedatamask.Ifyourecordfurtherbookingrequests,youshouldalsonoticethatthevaluesdisplayedchangeasyouchangecreditcardnumbers.

Page 116: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page114of138©IBMCorporation2001,2012

18 Data Model Stubs

Sofar,themessage‐basedstubsthatwehavedealtwithhavehadafairlysimplewayofdealingwithdata.Eachonehasusedthedatathatisprovidedwhenthestubisloadedintomemory,eitherhardcodedorthroughadatasource,andwillusethatsamedataeachtimethestubisstarted.

However,morecomplexsystemscannotbeeffectivelysimulatedwhendataistreatedinthisway.Wemayrequirepersistentstorageofdatasothatastubcansaveinformationbetweenoperations.Thiswouldallow,forexample,astubtoreactcorrectlywhenaskedtolistcustomersthathadbeencreatedviaadifferentoperation.Inordertodothis,we’llneedtosupportCRUDoperations–Create,Read,Update,andDelete.Betweenthese4operations,wecanperformanyactionthatwe’llneedonourdata.We’llalsoneedawayofstoringthedata.

Adatamodelallowsustobothunderstandthedataheldbythesystemthatwewanttosimulate,andtoprovidepersistentstorage.Dataisheldinsideasetofentities,eachwithasetofattributes.

Duringtheexercisesforthischapter,we’llbeusingthebookingsystemagain,thoughratherthansimplycreatingnewbookings,we’llalsowanttosimulatefindingbookings,updatingbookings,anddeletingbookings.Inordertodothis,we’llneedtorecordthepartsofthesystemthathandlesthisfunctionality.Thesystemthatwe’reusingwillalsohaveothermessagesthatwewon’tfocusonforthemoment–thesewilldealwiththeuser’sstatus(loggedinorloggedout).Forthemoment,ourstubwillassumethattheuserisalwaysloggedin;inthefollowingchapter,we’lllookathowwecandealwithstateandusersessions.

18.1 Exercise:RecordingaWebServicewithoutaWSDL

Inordertogetstartedwiththevariousservicesthatdealwithmanagingbookings,we’llneedtodefineoperationswithintheArchitectureSchool.However,inthiscase,wedon’thaveaWSDL.We’lllookatrecordingtheHTTPtrafficpassingthroughourproxy;inthefollowingexercise,we’llusethistraffictohelpputtogetherourdatamodelstub.

1. ReturntotheLogicalViewoftheArchitectureSchool.

2. SelecttheWWTravelservicecomponent,aswe’llbeaddingthebookingamendmentservicesinsidethat.Rightclick,andselectNew>Web>HTTPConnection.CallthisWWTravel_HTTP.

3. RightclickontheWWTravel_HTTPcomponent,andselectSetBindingIn>Local>CreateNewWebServer.

4. You’llthenbeabletosetupthephysicalconnectioninourcurrentenvironment.Theserverisonthelocalhost,usingport9080,soenterthosesettingsintheSettingstab.

5. OntheClienttab,weshouldenterthesettingsfortheHTTPProxy.Ifweeverwantedtotest

ourstuboutwithRationalIntegrationTester,thiswouldletanytestsknowtousetheproxyfortheirtraffic,ratherthantalkingtothewebservicedirectly.Rememberthatjustbecausewe

Page 117: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page115of138©IBMCorporation2001,2012

havesettheproxyupforTomcatdoesnotmeantthatitissetupforotherclientapplications–weneedtosetupeachclientapplicationseparately,andsinceRationalIntegrationTesterisanotherclientwhenitisrunningtests,thenitisincludedinthiscategory.SettheProxyHosttolocalhost,andtheProxyPortto3128.

6. AswiththeHotelFinderexample,we’llneedtosupplyadifferentporttousewhenrunninga

stub,sinceport9080isalreadyinusebytheliveservice.SwitchtotheServertab,andsetthePortintheSocketServerOverridessectionto9085.

7. TherearetwomethodstorecordtrafficoveraHTTPtransport–recordingbypacketcapture,orbyusingtheproxyprovidedbytheRationalIntegrationTesterPlatformPack.We’llbeusingtheproxy,soswitchtotheRecordingtab,andsettheRecordingModetoExternalProxyServer.

8. PressTestTransporttoverifythatthetransporthasbeensetupcorrectly,thenpressOK

twicetoreturntotheLogicalView.

9. SwitchtoRecordingStudio,anddeleteanyexistingEventMonitors.You’llalsowanttoclearanypreviousmessagesatthisstage.

10. Addaneweventmonitor,andselecttheWWTravel_HTTPconnectionastheeventmonitor.Startrecording.

11. Inyourwebbrowser,returntothemainWorldwideTravelpage.PresstheAmendMyFlightBookingbutton.You’llbepresentedwithaloginscreen.YoucanjustpresstheLoginbuttonhere,asnorealdetailsarerequiredbyourexamplesystem.

12. You’llthenbeabletosearchforabooking.EnterA00002asthebookingnumber,andpressFind.

13. YoushouldthenbepresentedwiththebookingdetailsforShinichi Nishimoto.Enteramiddlenameforthisbooking,andpressUpdateBookingDetails.

14. Youcannowsearchforasecondbooking–searchforA00003thistime,andupdatethedetailstochangethelastname.Youshouldnowhavetwoexamplesoffindingandupdatingbookings.

15. UsetheinterfacetofindandcancelbookingsforA00004andA00005.

16. Ifyouwant,youcanalsogobackandsearchfortwobookingsthatdonotexist.Inourcase,itwon’tmattertoomuch,aswe’llhandlethatcasebyhandlateron.

Page 118: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page116of138©IBMCorporation2001,2012

17. Finally,choosetheLogoutoptionsothatwehaveanexamplelogoutmessagethatwecanuselateron.

18. ReturntoRationalIntegrationTester’sRecordingStudio.Youshouldnowhavealonglistofrequest/replypairs,describingtheinteractionswe’vejustbeenthrough.

18.2 CreatingaDataModelStubandassociatedOperations

Note:Thestepsyou’llneedtocarryoutinthisexercisemaybedifferent,dependingontheorderinwhichyou’verecordedmessagesinthepreviousexercise.Thefirstfewstepswillbethesame,butthestepsdealingwithbuildingadatamodelfromrecordedmessagesmayrequireyoutodealwithdifferentpagesofthewizardinadifferentorder.

1. Ifwelookatthemessageswe’verecorded,we’vecoveredupdating,deleting,andlookingupdata.Wehaven’tgotanythingtodowithcreatingnewentries.You’llrecallthatthisisdonethroughtheMakeBookingoperation.Addthatasaneventmonitoragain,andcontinuerecording.

2. Inyourwebbrowser,makeapairofnewbookings(eachwithdifferentdetails,usingbothaBarcelonaandanEdinburghflight),thengobacktoRationalIntegrationTestertomakesurethatthey’vebeenrecordedsuccessfully.Stoprecordingnow.

3. Nowthatwe’vecoveredalloftheoperationsrequiredformanagingbookings,wecancreateadatamodelstub.Tostartthisprocess,makesurethatyoucanseeallrecordedmessages(ie,nothingisfilteredout),andselectallmessages.

4. PressSavetostarttheSaveRecordedEventswizard.Aswithpreviousstubs,selectstubsonthefirstpageofthewizard.Onthesecondpage,choosetoStoredatainadatamodel.

5. Thethirdpagewillattempttoidentifytheoperationsthatmakeupourrecordedevents.ForSOAPmessages,thiswillbetakenfromtheSOAPActionintheheaderifit’spresent.Inour

Page 119: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page117of138©IBMCorporation2001,2012

case,thiswillworkjustfine,soyoushouldseenewoperationscalledGetBookingByReservationNumber,UpdateBooking,andCancelBooking,inadditiontotheexistingMakeBooking.Thesewillcovertheoperationsthatwillbeusedbyourdatamodel.Inaddition,you’llalsoseetheoperationsisLoggedOn,logon,andlogoff,whichareusedtotrackindividualsessions.Ifthisisthecase,youcanjustpressNext.

6. Thenextpagewillaskwherethenewoperationsshouldbecreated–wecouldchoosethe

WWTravelservicecomponent,butitwouldbepreferabletogrouptheseoperationsseparately.PressSelecttochooseadifferentservicecomponent.

7. Inthedialogthatappears,you’llseetheservicecomponentsthatcurrentlyexistintheproject–we’llcreateanewoneunderneaththeWWTravelservicecomponent.Todothis,selecttheWWTravelservicecomponent,andpresstheNewServiceComponent button.Whenprompted,callthenewservicecomponentBookingManagement,andpressOK.ItshouldthenappearbelowtheWWTravelservicecomponent.

Page 120: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page118of138©IBMCorporation2001,2012

8. PressOKagain,andyoushouldreturntothewizard.PressNext.

9. Next,eventsshouldbegroupedintopairsofrequest/replymessages.IncaseswhereRationalIntegrationTesterisunabletorecognizethesegroupings,youmightneedtoselectcorrespondingpairs,andpresstheGroupbuttontoputthemintotheirowngroups.Onceyou’resatisfiedthateachpairisinsideitsowngroup,pressNext.

10. Thenextpartofthewizardisfairlylengthy,butmostpagesarefairlysimilar.We’llbeselectingthefieldsthataregoingtobeusedinourdatamodel,andhowtheywillbeused.ThefirstpagewillprobablybetherequestmessagefortheCancelBookingoperation.You’llnoticethatthisispresentedinaverysimilarfashiontotheparameterizedstubswesawearlier.

11. YouwillnoticethatseveralofthetextfieldswithinthemessagehavebeenassignedanEntity

andanAttributewithinthatEntity;theStatuscolumnforeachoftheseisalsolistedasNew,asinthescreenshotabove.Thishashappenedforanyfieldwheredifferentdatawasdetectedbetweenmessages.Aswewanttomodelthebookingdata,thisisfine.

12. PressNext,andyou’llseetheresponsemessagefortheCancelBookingoperation.

13. Asintheresponsemessage,thereisareservationnumber.However,whileithasalsobeenassignedtothesameentity–BookingType–ithasbeengivenadifferentattribute.Selectthat

Page 121: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page119of138©IBMCorporation2001,2012

field,andpresstheAttribute button.ThiswillallowyoutoassignthisfieldtothereservationNumberattributethatwecreatedpreviously.Thisletsthewizardknowthatthesetwofieldsrepresentthesamedata.

14. Wewillalsowanttomarkthereservationnumberasakeyfield,sowecanuseitforlookupslateron.Tickthecheckboxinthekey columnforthatfield–youshouldnoticethattheformat^A\d{5}$willbegeneratedforyou.Thisisdonebylookingatthereservationnumbers,andgeneratingaregularexpressionthatcoversallofthem.

Page 122: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page120of138©IBMCorporation2001,2012

15. PressNext,andyouwillbeshowntherequestmessageforgettingabooking.Youshouldnotneedtochangeanythinghere,asitshouldstatethatthereservationnumberisalreadyrecognisedwithinthedatamodel.

16. PressNextagain,andyou’llseetheresponsemessageforthisoperation.You’llnoticethata

groupoffieldsareassignedtonewattributes–butwealreadyhaveattributesforeachofthese.Selecteachone,andpresstheAttributebuttontoassignthemtotheexistingattributes.Inthecaseofthereservationnumber,thewizardshouldrecognizethisasakeyfield,anddisplaytheappropriateformat.

Page 123: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page121of138©IBMCorporation2001,2012

17. Inaddition,wehavetwonewpiecesofdatahere–theflightnumber,andtheweeknumber.

Selecteachoneofthese,andpresstheEntity buttontoassignthemtotheBookingTypeentity.Newattributeswillbecreatedautomatically.

Page 124: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page122of138©IBMCorporation2001,2012

18. Onthenextscreen,youwillseetherequestmessagefortheMakebookingoperation.YouwillnoticethatalotoffieldsarebeingassignedtothePaymentTypeentity.Asthisistheonlymessagewherepaymentdetailsareused,wewillnotworryaboutthese,soIgnoreallofthem.MakesureyoualsochoosetoIgnoretherowofthedatathatisassignedtothepaymentattribute,asitwouldbelinkedtothePaymentTypewhichwearenotgoingtocreate.

Page 125: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page123of138©IBMCorporation2001,2012

19. ThefollowingscreenistheresponsemessageforMakeBooking.Thereisonlyonepieceofdataherethatweareconcernedwith–thereservationnumber.AsthefieldiscallednewReservationNumber,thisisnotautomaticallymatchedwiththeexistingreservationNumberattribute.Selectthatrow,andpresstheAttributebuttontore‐assignittothereservationNumberattribute.Asbefore,itshouldrecognizethatthisisakeyfield.

Page 126: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page124of138©IBMCorporation2001,2012

20. AftertheMakeBookingmessages,weshouldseetheUpdateBookingrequestmessage.Asbefore,youwillprobablynoticethatseveralfieldshavebeenassignedtonewattributes,whentheexistingattributescouldtakecareofthisdataforus.Assignthisinformation(names,gender,etc.)totheappropriateattributes.

Page 127: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page125of138©IBMCorporation2001,2012

21. TheresponsemessageforUpdateBookingshouldnotneedanymodifications;justcheckthatthereservationnumberhasbeenassignedappropriately,andisakeyfield.

22. Afterthis,therestofthemessagingscreenswilldealwiththerequestsandresponsesforthe

isLoggedOn,logoff,andlogonmessages.MakesureyouthatallfieldshaveastatusofIgnoredasyoupressNextthrougheachmessage.

23. Eventually,youwillreachthesummarypage.Checktheinformationhere.Thesummaryshouldreportthatagroupofoperationswillbecreated,aswellasadatamodel.Thedatamodelshouldincludeasingleentity–theBookingTypeentity.Itwillcontainanumberofattributes(alloftypeString):

o reservationNumber

o firstName

o middleName

o lastName

o gender

Page 128: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page126of138©IBMCorporation2001,2012

o flightNumber

o weekNumber

o price

24. Ifthereareextraelementslistedinthedatamodel,youwillneedtopresstheBackbuttonthroughthemessagestofindoutwhy.Ifthereislogininformation,thiswillprobablybeintheloginmessages,andshouldbeignoredwhencreatingthedatamodelstub.Ifthereareattributesthatappeartoduplicateotherattributes,gobacktofindthem,andsettheattributestomatchup.Returntothesummarypageifyouhaveleftittofixanyissues.

25. GivethestubthenameDMStub1,andcallthedatamodelBookingModel.

26. PressFinishtocreatethedatamodelandthestub.We’venowcreatedastubwhichcancreate,

read,update,anddelete,usingmultipleoperationsandmultipletransports.Inthenextexercise,we’lllookathowwecanmakeitabitmoreintelligentbeforeweattempttouseit.

18.3 EditingtheDataModelStub

1. SwitchtotheTestFactory,andopenupDMStub1.Youshouldseethatthereare7transitionsavailabletoyou–oneforeachoperation.

Page 129: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page127of138©IBMCorporation2001,2012

2. Let’slookattheseeventsonebyone.We’llstartoffwiththeMakeBookingevent,soselectthat.

3. OntheInputtab,theGuardiscurrentlysettoRecordExists.Aswedon’tcareifabookingalreadyexistswhenwe’remakinganewone,setthistoNone.

4. OntheBusinessLogictab,settheDataModeltoCreate.Thiswillcreateabrandnewentryinourdatamodelthatcanbereferredtobytheotheroperations.

5. CancelBookingwillneedtohaveitsGuardsettoRecordExists,aswecan’tdeletesomethingthatdoesn’texist.Asthisisthedefault,wecanleavethatsettingas‐is,butwewillneedtogototheBusinessLogictabforthattransition,andmakesurethattheDataModelissettoDelete.

6. Similarly,UpdateBookingrequiresarecordtoexist,somakesurethattheguardissettoRecordExists.WithintheBusinessLogictab,theDataModelforthistransitionshouldbesettoUpdateorCreate.

7. Finally,we’llneedtolookatthetransitionfortheGetBookingByReservationNumberoperation.Thisone’salittlebittrickier,asitshouldworkdifferently,dependingonwhetherornottherecordforthegivenreservationnumberexists.Tohandlethis,we’llcreateasecondtransitionforthisoperation,toallowustocoverbothcases–whereitexists,andwhereitdoesn’texist.SelectthetransitionforGetBookingByReservationNumber,andpresstheClone buttoninthetoolbarabove.

8. Selectoneofthesetwotransitions,andontheInputtab,settheGuardtoRecordDoesn’tExist.Onthesametransition,theBusinessLogictabshouldstatethattheDataModelissettoNone.Ontheoutputtab,you’llneedtofindtheDetailsnode,anddeleteit,sincewecan’treturnanyreservationdetailsforsomethingthatdoesn’texist.

9. ThetransitionforGetBookingByReservationNumberwithaGuardofRecordExistscanbeleftalone.

10. Westillneedtodealwiththeoperationscontrollingloginsandsessions–wedon’twanttodealwiththisyet,butwe’llneedtofigureoutawayofdealingwiththis.Forthemoment,thesimplecheatwillbetologontothesystembeforestartingthestub,thenhavingourstubstatethatwearealwaysloggedon(we’llneedtologonfirst,sothattomcathasasessionID).Todothis,editthetransitionfortheisLoggedOnoperation,andgototheOutputmessage.SettheTextnodefortheisLoggedOnReturnElementto1.

11. WealsowanttomakesurethatthereisnoGuardfortheloginoperations–theseshouldn’tcareifrecordsexistwithinthedatamodel;infact,asweignoredanydatainsidethesemessagesasfarasthedatamodelisconcerned,wedon’tevenhaveanythingtolookuprecordswithanyway.

Page 130: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page128of138©IBMCorporation2001,2012

12. Checkthatyoursetoftransitionsnowappearsasintheimagebelow,andSavethestub.

13. Returntoyourwebbrowser,andmakesurethatyou’veloggedintothesystem(sothatwe’ve

gotasessionid),thenrunDMStub1inRationalIntegrationTester.

14. Usingthewebinterface,youshouldnowbeabletocreatenewbookings,lookupbookings,andupdatebookings.Thedatainsidethemodelwillbelimitedtotheinteractionswerecordedearlier,sowe’llhaveafairlysmalldataset.Giventhis,whilewecoulddeleteinformationfromthedatamodel,wewon’tdothisatthemoment,aswe’llbedevelopingthisstubfurtherinthefollowingexercises.

15. Stopthestubonceyou’redone.

Page 131: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page129of138©IBMCorporation2001,2012

19 State and Sessions

Advancedstubsmayrequiretheabilitytotracktheirinternalstate–forexample,alivesystemmayexpectdifferentinputsatdifferentstagesofagivenbusinessprocess,andanyvirtualizationofthatshouldalsoactinthesameway.

Similarly,astubmayneedtoactdifferentlytodifferentusers,dependingonthestateofthatuser’sinteractionswiththesystem.Thesimplestexampleofthis,andtheonewe’llbeusinginthismodule,istrackingsessioninformationforauserwhomightbeloggedinorloggedout.

Todothis,we’llcreateasessionkeywhenauserlogsin.Bystoringthesessionkeyintoasystemtagwhenevertheusersendsamessagetothesystem,RationalIntegrationTesterwillautomaticallylookupthestateoftheuser’ssession,andactappropriately.Wecanthenalsoassignstatestothetransitionswe’vecreated,andaddextrastatesthatwillactdifferentlyindifferentstates.

19.1 Exercise:TrackingUserSessions

1. WithintheDMStub1thatwe’vebeenusinginthepreviousexercise,gotothePropertiestab(abovetheTransitions).Inhere,wecansetuptheavailablestatesforourstub.

2. Findthesectionofthescreendealingwithsessionsandstates,andpresstheNewState buttontoaddanewstate.CallthefirststateLoggedIn,andpressOK.

3. Createasecondstateinthesameway,callingitLoggedOut.

4. Belowthesetwo,theInitialStateshouldbesettoLoggedOut.

5. WethenneedtocreateaConversationKey–wecandothissimplybytypinginanameforthetagthatwe’llusetoidentifythecurrentsession.CallitsessionID(usethesamecasehere,asscriptsinthefollowingchapterarecasesensitive,andmakeuseofthis).

6. ReturntotheTransitionstabofthestub,andfindthelogontransition.Youshouldnowbeable

toedittheFromandTocolumnshere.LogginginwilltakeusfromtheLoggedOutstatetotheLoggedInstate.

7. Thiswon’tbeenoughtotrackthestate,though–forthat,we’llneedtomakeuseoftheconversationkeythatwejustcreated.GototheBusinessLogictabforthistransition,andsettheDataModeltoOther.

8. ChoosetheCreateSession actionfromthetoolbarofactions,anddoubleclickittoeditit.

9. YoushouldseethesessionIDthatwecreatedearlierislistedhere.Beforewecangenerateavalueforthis,weneedtotellRationalIntegrationTesterwhatasessionIDlookslike,usingaregularexpression.IntheValuePatterncolumn,entertheregularexpressionS\d{4}HA\d{4}

Page 132: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page130of138©IBMCorporation2001,2012

10. PressEnter,andtheSampleValuecolumnshouldupdatetoshowyouanexamplesessionIDbasedontheregularexpressionwe’vechosen.Ifthislookscorrect,thenpressOK.

11. Bydefault,theCreateSessionactionwillhavebeenaddedaftertheSendOutputaction.Sincewe’llneedasessionIDtosendintheoutputmessage,wedon’twanttogenerateitafterwesendtheoutput.Swapthetwoactionsaroundbydragginganddropping.

12. GototheOutputtab,andfindthesessionIDthatwasbeingsentbythistransition(attheveryendofthemessage).Editthetext,firstbyremovingtheoldsessionkey,thenbyrightclickinginthefieldandselectingInsertTag>Built‐In>SESSION>KEY>sessionID.

13. Now,we’llhandlethelogoutoperation.SettheFromcolumntoLoggedIn,andtheTocolumntoLoggedOut.

14. Inordertomakesurewe’reloggingoutthecorrectsession,weneedtocheckthesessionID.Todothis,gototheInputtabofthistransition.Attheverybottomofthemessage,therewillbeaTextnodeholdingasessionID,followingthepatternwesetupearlier.Editthetextinthisfield,thenrightclickandchooseInsertTag>Built‐In>SESSION>KEY>sessionID

15. ThesessionIDshouldnowbegettingstoredforyou,asshownbelow:

16. Thisisallthatwe’llneedtodotomatchthislogoutactionwiththesessioncreatedbythelogin

action.However,westillwanttosetuptheisLoggedOnoperationsothatitrespondsappropriately,dependingonwhethertheuserisloggedinornot.Todothis,it’llneedtocoverbothpossibilities–loggedinandloggedout.Let’scovertheloggedinoptionfirst,sosettheFromandTocolumnsforthetransitiontoLoggedIn.

17. IntheInputtab,findtheTextnodeforthesessionID.Asbefore,editthefield,rightclick,andchooseInsertTag>Built‐In>SESSION>KEY>sessionID.

18. OntheOutputtab,notethatthereturnvalueshouldbesetto1(wedidthisinthepreviousexercisetostatethattheuserwasalwaysloggedin).

19. NowClonethetransitionfortheisLoggedOnoperation.Inoneofthecopies,changetheFromandTocolumnstotheLoggedOutstate.Inthiscopy,you’llalsowanttochangethereturnvalueontheOutputtabto0.

20. Atthisstage,wecanoptionallyapplystatetotheotheroperations(withtheexceptionofMakeBooking,whichdidnottrackanysessioninformation).Todothis,simplystorethesessionIDontheInputtabofthetransitionintotheSESSION/KEY/sessionIDtagagain,andsetboththeFromandTocolumnsforthetransitiontoLoggedIn.Thetransitionwillthenonlyworkifthesessioniscurrentlyloggedin.Note:IfyouattempttosettheFromstatewithoutstoringavalueintothesessionID,thetransitionwillnolongerwork;thisisbecauseitwouldbeattemptingtolookupanemptyvalueforthesessionID,andwillnotfindanemptysessionIDthatisintheLoggedInstate.

Page 133: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page131of138©IBMCorporation2001,2012

21. Savethestubandrunit.

22. Fromthewebinterface,youshouldnowbeabletologinandlogoutofthesystem,inadditiontomanagingbookings.

23. Stopthestubonceyouaredone.

Page 134: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page132of138©IBMCorporation2001,2012

20 Behaviours

Inthischapter,we’llcompleteourbookingmanagementstubbyaddingbehaviourstoit.Aswe’veseen,wecanalreadyaddcustomlogictoastub;behavioursletusgobeyondthisbyallowingustoaddcustomlogicthatrespondstoeventsbesidesmessages.Thisishowyoucanmakestubsproactivelypublishmessagesthatarenotjust‘responses’toanincomingmessage.

RationalIntegrationTestercomeswithtwosamplebehaviours:thefirstistheLifecyclebehaviour,whichallowsustoexecutecertainactionswhenthestubstartsuporshutsdown.Thiscanbeusedtosetupandlatercleanupanyresourcesthatmayberequiredbythestub.ThesecondistheTimerbehaviour–thisallowsustosetatimer,andafterasetperiodoftime,thestubwillreceiveanevent,whichitcanthenrespondto.

OtherbehaviourscanbeaddedtoRationalIntegrationTester,thoughthesewillrequirecustomJavacodetobewritten.Forexample,abehaviourcouldbecreatedtosimulateamessagefeedofsomesort,sendingdataupdatestothestubasappropriate.

Inthisexercise,we’lladdatimerbehaviourtothestubwe’vebeencreatingtomanagebookings.Thiswillautomaticallylogouttheuserafter30secondsofinactivity.

20.1 Exercise:TheTimerBehaviour

1. SwitchtotheTestFactoryperspective.Youshouldbelookingatthedatamodelstubthatwe’vebeenmodifyingduringthepasttwomodules.

2. OpentheBehaviourtab.Itwillbenearlyblank,sopresstheAddbuttontoaddanewbehaviour.

3. TheBehaviourdialogwillappear.SelecttheTimerbehaviourinthetoplefttoviewdetailsaboutit.

Page 135: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page133of138©IBMCorporation2001,2012

4. Inthebottomhalfofthedialog,wecanseethefourwayswecaninteractwiththetimer

behaviour.Wehavethreefunctionsthatwecancallwithinscripts–scheduleTimerEvent,scheduleRepeatingTimerEvent,andcancelTimerEvent–indicatedbyarrowspointingtotheright.Wealsohaveacallback(indicatedbythearrowpointingleft)namedonTimerEvent,whichwillprovideaneventtoourstubwhenatimerrunsout.We’llmakeuseofmostoftheselater.

5. Ourtimerbehaviourneedsaname,intheInstancefield.CallitlogoutTimer,thenpressAdd.

6. ThelogoutTimerthenappearsintheBehaviourtab.Notethatthereisadescriptionofittotherighthandside,whilebelowthereisanareaforconfigurationofthebehaviour.Asthetimerbehaviourdoesnothaveanysettings,thisisblank.

Page 136: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page134of138©IBMCorporation2001,2012

7. ReturntotheTransitionstab.

8. Wecannowsetatimer.Aswewanttosetatimerthatwilllogtheuseroutafteraperiodoftime,thebestplacetostartwillbethelogontransition,soselectthat.

9. Tostartatimer,we’llneedtoaddsomeofourowncustomlogic,sogototheBusinessLogictabofthistransition,andsettheDataModeltoOther.

10. AddanewFunctionactionbyrightclickingbelowtheexistingSendOutputtestactionandselectingNew>General>Function.

11. DoubleclickontheFunctionactiontoeditit.Makesurethatyou’relookingattheFunctiontab,andthatthedropdowndirectlyunderneathissettoECMAScript.

12. Typeinthefollowingcode:logoutTimer.scheduleTimerEvent("timerID", tags["SESSION/KEY/sessionID"], 30, java.util.concurrent.TimeUnit.SECONDS)

13. Let’sanalyzethis,soweunderstandwhatwe’redoing.Thefirstparameteristheidentifierthatwe’regivingthetimer,sothatwecancancelitorresetitlateronifrequired.Second,we’veusedthesessionIDtag.Thesecondparameterwillbegivenbacktothestubwhenthetimerrunsout–we’veputthesessionIDinhere,sothatweknowwhichsessiontologoutatthattime.Thethirdandfourthparametersspecifyhowlongthetimershouldrunfor–inourcase,30seconds.

14. Youmayhavespottedaproblemwiththis–thefactthatwe’vehardcodedtheidentifierforthetimermeansthatwe’renotgoingtobeabletosettimersformultipleusers.Ifweresetthetimerusingthesameidentifierwhenanotheruserlogson,thecurrenttimerwillbelost.Let’smodifythissothatwecanusemultipletimers,byusingthesessionIDastheidentifier.Thiswillgiveyouthefollowing:logoutTimer.scheduleTimerEvent(tags["SESSION/KEY/sessionID"], tags["SESSION/KEY/sessionID"], 30, java.util.concurrent.TimeUnit.SECONDS)

Page 137: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page135of138©IBMCorporation2001,2012

15. PressOKtoclosetheFunctionaction.WithintheBusinessLogic,dragtheFunctionactionsothatitisthemiddleaction–itwillneedtobeaftertheCreateSessionaction,orelsewewon’thaveasessionIDtoprovidetothetimer.

16. Next,we’llneedtohavesomethingtoactonthetimer.We’regoingtoaddanewtransitionto

thestubtodothis,soAddanewtransition.

17. First,aswe’renotactingonamessagefromtheuser,we’llneedtochangetheActorcolumninournewtransition.SetittothelogoutTimer.TheEventcolumnwillautomaticallybesetforus,totheonTimerEventcallback.

18. We’llalsoneedtosettheFromandTocolumns.AsthetimershouldtakeusfromtheLoggedInstatetotheLoggedOutstate,settheFromcolumntoLoggedIn,andtheTocolumntoLoggedOut.

19. Finally,we’llneedtocheckwhichsessionwe’reloggingout.Todothis,gototheInputtabof

thetransition.You’llnoticethattheonTimerEventcallbackwillgenerateashortmessageforus.TheparameterfieldinthismessagewillholdthesessionID,asthisiswhatweputintotheparameterfieldwhenwestartedthetimer.

20. DoubleclickontheparametertobringuptheFieldEditor,andgototheStoretabofthatdialog.

21. PressNewtoaddanewStoreaction,andsetthetagtoSESSION/KEY/sessionID.PressOKonceyou’redone.TheInputtabshouldnowlooklikeso:

22. We’venowdonethebareminimuminordertousethetimerbehaviourtoautomaticallylogout

auser,butwe’lldevelopthisabitfurther.Ifauserlogsout,weshouldprobablycancelthetimer.Todothis,openupthelogofftransition,andgototheBusinessLogicinthere.

Page 138: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page136of138©IBMCorporation2001,2012

23. Addanewfunctionactionaswedidbefore,withthefollowingscript:logoutTimer.cancelTimerEvent(tags["SESSION/KEY/sessionID"])

24. PressOKtoclosetheFunctionaction.Inthiscase,itshouldn’tmattertoomuchifwecancelthetimerbeforeorafterwesendthelogoutresponsemessage.

25. Currently,ourtimerwillautomaticallylogtheuseroutafter30seconds,nomatterwhatthey’redoing.Weshouldresetthetimeriftheusercarriesoutanyoftheactionsthatrequirethemtobeloggedin(checkingreservations,updatingreservations,ordeletingreservations).Todothis,allweneedtodoistosetthetimerto30secondsagain,usingthesameidentifier(ifweusedadifferentidentifier,we’dbecreatingasecondtimer,andtheoriginaltimerwouldstillterminateatthetimesetwhenitwasfirstgenerated).Theeasiestwaytodothisistocopyandpastethefunctionactionweusedwhenwefirstsetthetimerup,sogobacktotheBusinessLogictabofthelogontransition,andCopytheFunctionactionusedthere.

26. Next,gointotheBusinessLogicofeachoftheGetBookingByReservationNumber,CancelBooking,andUpdateBookingtransitions.SwitchtheDataModelheretoOther–you’llnoticesometestactionsherethatmanipulatethedatamodel,butdon’tgettooworriedaboutthese.Instead,simplyPastetheFunctionaction,andplaceitbeforetheSendOutputaction.

27. Saveyourstub,andtryitout.Notethatyoumayfindthat,ifyouareautomaticallyloggedout,thesystemtimesout.Thisisbecauseanumberoftheoperationsonlyworkifthecurrentsessionisloggedin–ifitisnotloggedin,theyignoretheinputmessage,anddonotsendbackanyresponse.Youdonotneedtobetooconcernedaboutthis–itisalimitationofthetestenvironment,asitdoesn’tprovideawayforthoseoperationstoreportaloginfailure.

Page 139: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page137of138©IBMCorporation2001,2012

21 Legal Notices

ThefollowingparagraphdoesnotapplytotheUnitedKingdomoranyothercountrywheresuchprovisionsareinconsistentwithlocallaw:INTERNATIONALBUSINESSMACHINESCORPORATIONPROVIDESTHISPUBLICATION"ASIS"WITHOUTWARRANTYOFANYKIND,EITHEREXPRESSORIMPLIED,INCLUDING,BUTNOTLIMITEDTO,THEIMPLIEDWARRANTIESOFNON‐INFRINGEMENT,MERCHANTABILITYORFITNESSFORAPARTICULARPURPOSE.Somestatesdonotallowdisclaimerofexpressorimpliedwarrantiesincertaintransactions,therefore,thisstatementmaynotapplytoyou.

Thisinformationcouldincludetechnicalinaccuraciesortypographicalerrors.Changesareperiodicallymadetotheinformationherein;thesechangeswillbeincorporatedinneweditionsofthepublication.IBMmaymakeimprovementsand/orchangesintheproduct(s)and/ortheprogram(s)describedinthispublicationatanytimewithoutnotice.

Ifyouareviewingthisinformationinsoftcopy,thephotographsandcolorillustrationsmaynotappear.

Anyreferencesinthisinformationtonon‐IBMwebsitesareprovidedforconvenienceonlyanddonotinanymannerserveasanendorsementofthosewebsites.ThematerialsatthosewebsitesarenotpartofthematerialsforthisIBMproductanduseofthosewebsitesisatyourownrisk.

Anyperformancedatacontainedhereinwasdeterminedinacontrolledenvironment.Therefore,theresultsobtainedinotheroperatingenvironmentsmayvarysignificantly.Somemeasurementsmayhavebeenmadeondevelopment‐levelsystemsandthereisnoguaranteethatthesemeasurementswillbethesameongenerallyavailablesystems.Furthermore,somemeasurementsmayhavebeenestimatedthroughextrapolation.Actualresultsmayvary.Usersofthisdocumentshouldverifytheapplicabledatafortheirspecificenvironment.

Informationconcerningnon‐IBMproductswasobtainedfromthesuppliersofthoseproducts,theirpublishedannouncementsorotherpubliclyavailablesources.IBMhasnottestedthoseproductsandcannotconfirmtheaccuracyofperformance,compatibilityoranyotherclaimsrelatedtonon‐IBMproducts.Questionsonthecapabilitiesofnon‐IBMproductsshouldbeaddressedtothesuppliersofthoseproducts.

AllstatementsregardingIBM'sfuturedirectionorintentaresubjecttochangeorwithdrawalwithoutnotice,andrepresentgoalsandobjectivesonly.

Thisinformationcontainsexamplesofdataandreportsusedindailybusinessoperations.Toillustratethemascompletelyaspossible,theexamplesincludethenamesofindividuals,companies,brands,andproducts.Allofthesenamesarefictitiousandanysimilaritytothenamesandaddressesusedbyanactualbusinessenterpriseisentirelycoincidental.

Thisinformationcontainssampleapplicationprogramsinsourcelanguage,whichillustrateprogrammingtechniquesonvariousoperatingplatforms.Youmaycopy,modify,anddistributethesesampleprogramsinanyformwithoutpaymenttoIBM,forthepurposesofdeveloping,using,marketingordistributingapplicationprogramsconformingtotheapplicationprogramminginterfacefortheoperatingplatformforwhichthesampleprogramsarewritten.Theseexampleshavenotbeenthoroughlytestedunderallconditions.IBM,therefore,cannotguaranteeorimplyreliability,serviceability,orfunctionoftheseprograms.Thesample

Page 140: 2012 10 23_2649_rational_integration_tester_vi

VIRTUALIZATIONWITHIBMRATIONALINTEGRATIONTESTER

Page138of138©IBMCorporation2001,2012

programsareprovided"ASIS",withoutwarrantyofanykind.IBMshallnotbeliableforanydamagesarisingoutofyouruseofthesampleprograms.

Trademarksandservicemarks

IBM,theIBMlogo,andibm.comaretrademarksorregisteredtrademarksofInternationalBusinessMachinesCorp.,registeredinmanyjurisdictionsworldwide.OtherproductandservicenamesmightbetrademarksofIBMorothercompanies.AcurrentlistofIBMtrademarksisavailableonthewebatwww.ibm.com/legal/copytrade.shtml.

MicrosoftandWindowsaretrademarksofMicrosoftCorporationintheUnitedStates,othercountries,orboth.

JavaandallJava‐basedtrademarksandlogosaretrademarksorregisteredtrademarksofOracleand/oritsaffiliates

Othercompany,product,orservicenamesmaybetrademarksorservicemarksofothers.