View
1.916
Download
11
Category
Tags:
Preview:
Citation preview
RationalIntegrationTesterTrainingGuide
Note
Beforeusingthisinformationandtheproductitsupports,readtheinformationin“Notices”onpage132.
©CopyrightIBMCorporation2001,2012.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page1of133©IBMCorporation2001,2012
1 INTRODUCTION ........................................................................................................................ 4
2 CONFIGURING RATIONAL INTEGRATION TESTER ........................................................................ 5
2.1 PRE-REQUISITES ............................................................................................................... 5
2.2 THE LIBRARY MANAGER .................................................................................................... 5
2.3 CONFIGURING THE LIBRARY MANAGER FOR WEBSPHERE APPLICATION SERVER AND MQ ...... 6
2.4 ADDING THE INTERCEPT DLL ............................................................................................. 7
3 RATIONAL INTEGRATION TESTER PROJECT SETUP .................................................................... 8
3.1 THE INITIAL SCREEN ......................................................................................................... 8
3.2 CREATING A NEW PROJECT ............................................................................................... 9
3.3 EXERCISE: CREATING THE TRAINING PROJECT .................................................................. 10
3.4 RATIONAL INTEGRATION TESTER LAYOUT .......................................................................... 14
3.5 RATIONAL INTEGRATION TESTER PERSPECTIVES ............................................................... 15
4 MODELING THE SYSTEM ......................................................................................................... 16
4.1 PERSPECTIVE OVERVIEW ................................................................................................ 16
4.2 WORKING IN MULTIPLE ENVIRONMENTS ............................................................................ 16
4.3 LOGICAL VIEW ................................................................................................................ 17
4.4 EXERCISE: SETTING UP THE LOGICAL VIEW FOR A SIMPLE SYSTEM ..................................... 19
4.5 PHYSICAL VIEW .............................................................................................................. 22
4.6 EXERCISE: SETTING UP PHYSICAL VIEW FOR A SIMPLE SYSTEM ......................................... 22
4.7 ENVIRONMENTS .............................................................................................................. 22
4.8 EXERCISE: CREATING AN ENVIRONMENT ........................................................................... 22
4.9 EXERCISE: SCHEMA LIBRARY ........................................................................................... 24
4.10 EXERCISE: THE MESSAGE EXCHANGE PATTERN (MEP) ................................................. 25
5 THE DEMONSTRATION ENVIRONMENT ..................................................................................... 27
5.1 MANAGING FLIGHT BOOKINGS .......................................................................................... 27
5.2 FINDING AND BOOKING HOTELS ....................................................................................... 28
5.3 FLIGHT ADMINISTRATION ................................................................................................. 28
6 USING SYSTEM DATA TO BUILD A SYSTEM MODEL .................................................................. 30
6.1 OVERVIEW ..................................................................................................................... 30
6.2 SYNCHRONISATION OVERVIEW ......................................................................................... 30
6.3 BUILDING A MODEL FROM RECORDED EVENTS .................................................................. 31
6.4 RECORDING MQ MESSAGES ............................................................................................ 31
6.5 EXERCISE: SETTING UP THE TRANSPORTS ........................................................................ 32
6.6 EXERCISE: ADDING THE FLIGHT BOOKING MESSAGE SCHEMAS .......................................... 37
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page2of133©IBMCorporation2001,2012
7 REQUIREMENTS LIBRARY ....................................................................................................... 38
7.1 OVERVIEW ..................................................................................................................... 38
7.2 THE MESSAGE EDITOR .................................................................................................... 38
7.3 EXERCISE: IMPORTING MESSAGES ................................................................................... 39
7.4 CREATING MESSAGES FROM A SCHEMA ............................................................................ 40
8 RECORDING EVENTS ............................................................................................................. 43
8.1 THE RECORDING STUDIO ................................................................................................. 43
8.2 EXERCISE: RECORDING EVENTS FROM A TRANSPORT ........................................................ 44
8.3 EXERCISE: BUILDING OPERATIONS FROM RECORDED EVENTS ............................................ 46
8.4 EXERCISE: COMPLETING THE SYSTEM MODEL ................................................................... 52
8.5 EXERCISE: RECORDING EVENTS FROM AN OPERATION ...................................................... 53
8.6 EXERCISE: CREATING AND RUNNING TRIGGERS ................................................................ 56
9 CREATING AND EDITING TESTS .............................................................................................. 58
9.1 TEST STRUCTURE ........................................................................................................... 58
9.2 BUSINESS VIEW AND TECHNICAL VIEW ............................................................................. 59
9.3 EXERCISE: CREATING TESTS FROM RECORDED EVENTS .................................................... 59
9.4 THE MEP WIZARD .......................................................................................................... 64
9.5 EXERCISE: CREATING TESTS WITH THE MEP WIZARD ........................................................ 65
9.6 COPYING AND LINKING REQUIREMENTS ............................................................................ 68
9.7 TEST TEMPLATES ........................................................................................................... 69
9.8 EXERCISE: CREATING A TEST FROM A TEMPLATE .............................................................. 69
10 TEST EXECUTION ............................................................................................................... 71
10.1 THE TEST LAB ............................................................................................................. 71
10.2 EXERCISE: RUNNING A TEST ........................................................................................ 71
10.3 EXERCISE: REPAIRING TESTS ....................................................................................... 72
10.4 EXERCISE: THE RULE CACHE ....................................................................................... 75
11 CREATING AND RUNNING A STUB ........................................................................................ 77
11.1 EXERCISE: CREATING A STUB FROM RECORDED EVENTS ................................................. 77
11.2 EXERCISE: EXECUTING A STUB FROM RATIONAL INTEGRATION TESTER ............................ 79
11.3 EXERCISE: MODIFYING THE STUB ON THE FLY ................................................................. 80
12 TEST AUTOMATION ............................................................................................................ 83
12.1 TEST SUITES ............................................................................................................... 83
12.2 EXERCISE: CREATING AND EXECUTING A TEST SUITE ..................................................... 83
12.3 RESULTS GALLERY ...................................................................................................... 85
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page3of133©IBMCorporation2001,2012
12.4 EXERCISE: VIEWING RESULTS ...................................................................................... 86
13 STORING AND MANIPULATING DATA .................................................................................... 88
13.1 TAGS AND THE TAG DATA STORE .................................................................................. 88
13.2 CREATING TAGS .......................................................................................................... 89
13.3 USING TAGS................................................................................................................ 91
13.4 EXERCISE: TESTING WITH TAGS .................................................................................... 91
13.5 DATA SOURCES ........................................................................................................... 92
13.6 EXERCISE: DATA DRIVEN TESTING ................................................................................ 92
14 REPEATING ELEMENTS ....................................................................................................... 97
14.1 OVERVIEW .................................................................................................................. 97
14.2 EXERCISE: PUBLISHING A SET OF ORDERS .................................................................... 99
15 TEST ACTIONS ................................................................................................................. 104
15.1 TEST ACTION SUMMARY ............................................................................................. 104
15.2 EXERCISE: RUN COMMAND ........................................................................................ 107
15.3 EXERCISE: LOG ......................................................................................................... 108
15.4 EXERCISE: LOOKUP TEST DATA .................................................................................. 109
15.5 FAILURE PATH AND PASS/FAIL .................................................................................... 111
15.6 EXERCISE: USING FAILURE PATHS .............................................................................. 112
16 INTERACTING WITH DATABASES ........................................................................................ 115
16.1 EXERCISE: CREATING A DATABASE COMPONENT MANUALLY .......................................... 115
16.2 EXERCISE: SQL COMMAND ........................................................................................ 117
16.3 EXERCISE: COLUMN AND CELL VALIDATIONS ............................................................... 117
17 RUN TEST ....................................................................................................................... 120
17.1 INTRODUCTION .......................................................................................................... 120
17.2 EXERCISE: CREATING THE CHILD TEST......................................................................... 120
17.3 EXERCISE: CREATING THE PARENT TEST ..................................................................... 121
17.4 EXERCISE: PASSING DATA BETWEEN THE TESTS .......................................................... 122
18 MONITORING LOG FILES ................................................................................................... 124
18.1 OVERVIEW ................................................................................................................ 124
18.2 EXERCISE: LOOKING FOR ERROR MESSAGES ............................................................... 124
19 ADVANCED STUBS ........................................................................................................... 127
19.1 EXERCISE: PARAMETERIZED STUBS ............................................................................ 127
20 LEGAL NOTICES ............................................................................................................... 132
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page4of133©IBMCorporation2001,2012
1 Introduction
ThisdocumentservesasatrainingmanualtohelpfamiliarizetheuserwiththefunctionalitypresentinIBM®Rational®IntegrationTester.Mostofthetrainingexercisesmakeuseofavarietyoftechnologies,includingIBMWebSphere®ApplicationServer,IBMWebSphereMQ,IBMDB2®,andwebservices.Itisassumedthatthereaderhasafairunderstandingofthesesystems.
ThemainobjectivesofthistrainingcoursearetopresentthevariousfunctionalitiesofRationalIntegrationTesterandhowbesttousethemintestingMessageOrientedMiddlewareapplications.Inthiscoursewewill:
WalkyouthroughtheinstallationofRationalIntegrationTesteronyourPC PresentthevariousperspectivesinRationalIntegrationTesterandhowandwhentheyare
used DemonstratehowRationalIntegrationTestercanfacilitatetestingofservicesinamessage
orientedmiddlewarearchitecturebyo Providingagraphicalinterfacesforthedisplayandcreationofmessageso Automaticallycomparingareceivedresponsewithapre‐programmedonetoensure
theymatcho Allowingtherunningofatesttoberepeatedoverandoverwithlittlemanual
interventiono Exposingthedetailsoftheprocesstoprovidebetterinformationfromthetestteam
tothedevelopmentteam,enablingtestfailurestobeexaminedindetail Createandrunautomatedtestsandtestsuites Illustratetheeaseofmessagedatamanipulationtofacilitatetestingbyusingvarioustest
actions Buildstubsandtriggers,whichareavitalpartofintegrationprojects Producedetailedreportsontestsuites
Beforewediveintothistrainingcourse,pleasemakesureyouhaveallthecorrectfilesinplace.
Ifyouareusingacloudinstance,thetrainingfilesshouldbelocatedonthedesktop Otherwise,yourinstructorwillletyouknowwheretofindanyrequiredfiles.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page5of133©IBMCorporation2001,2012
2 Configuring Rational Integration Tester
2.1 Pre‐requisites
Ifyouareusingacloudinstance,skiptosection2.3.
IfyouneedtoinstallRationalIntegrationTester,pleasemakesurethatthefollowingprerequisitesareinplace:
RationalIntegrationTesterprojectdatabase–notethatthiscanbesharedbetweenmultiplepeople.Thedatabasecanbesetupusingoneofthefollowing:
o MySQL5.0.1orhigherandMySQL5.1.x
o Oracle9.2i,10g,or11g
o MSSQLServer2005
Java7
o TheIBMJREisincludedandinstalledwiththeRationalIntegrationTester.TheJREisinstalledintheRationalIntegrationTesterinstallationdirectoryandisusedonlywhenRationalIntegrationTesterisexecuted.TheJREdoesnotaffecttheregistryoranyotherprogramsonthesystem.
MicrosoftExcel2003ornewer(orequivalent)
2.2 TheLibraryManager
TheLibraryManageristhemainconfigurationtoolforRationalIntegrationTester.ItprovidesthenecessarytoolstosetupconnectionstothewidevarietyoftechnologiessupportedbyRationalIntegrationTester,andsetupotherconfigurationoptionsasrequired.
RationalIntegrationTestersupportsanumberoftechnologiesoutofthebox–webservices,email,andanumberofdatabases.However,connectionstoanumberofotherproprietarytechnologieswillrequireexternalJavalibraries,whicharenormallysuppliedwithintheinstallationfilesofthatsoftware.
IfthatsoftwareisinstalledonthesamemachineasRationalIntegrationTester,thentheLibraryManagermaybeusedtopointRationalIntegrationTestertowardstheinstalledlocationoftherequiredlibraries.Otherwise,thoselibrariescanbecopiedacrosstothelocalmachine,andtheLibraryManagerusedtolocatethelocalcopiesofthosefiles.Ifyoudonotgothroughthisprocedure,youwillfindthatRationalIntegrationTesterwillgenerateerrorswhenyouattempttoconnectusinganytechnologiesthathavenotbeensetupcorrectly.
RegardlessofthetechnologiesthatyouplantotestwithRationalIntegrationTester,youwillneedtoruntheLibraryManageronceonanymachinethathasacopyofRationalIntegrationTester.ThiswillallowtheLibraryManagertoperformextrasetuptasks,suchascreatingRationalIntegrationTester’shomedirectory.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page6of133©IBMCorporation2001,2012
AnychangesmadeintheLibraryManagerwillnottakeeffectuntilthenexttimeyoustartRationalIntegrationTester.ThismeansthatifyouarerunningRationalIntegrationTesterwhilemakingchangesintheLibraryManager,youwillneedtorestartRationalIntegrationTester.
WewillnowlookatanexampleuseoftheLibraryManager–settingupconnectionstoJavalibrariesfortheIBMWebSphereApplicationServerandWebSphereMQtools.
2.3 ConfiguringtheLibraryManagerforWebSphereApplicationServerandMQ
DependingontheversionofWebSphereApplicationServerandMQ,specificproductlibrariesarerequired.PleasemakesurethatyouhaveconfiguredLibraryManagerwiththerightlibraries.Thishasalreadybeensetupforanycloudinstances.
1. IntheLibraryManager,clickontheIBMWebSphereApplicationServeritemonthelefthandside.Youwillnowseealistofproviders,foreachsupportedversionoftheWebsphereApplicationServer.
2. IntheProviderssectionontherighthandside,selectversion8.0ofWebSphereApplication
Server.
3. GodowntotheSettingssection,andmakesurethateachofthenecessary.jarshasbeenfound.Ifnot,selecteachoneinturn,pressingtheEditbuttontolocatethe.jars.Ifnecessary,yourinstructorwillbeabletoprovideyouwithacopyofeachfile.
4. Next,youwillneedtodothesameforIBMWebSphereMQ7.0.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page7of133©IBMCorporation2001,2012
2.4 AddingtheInterceptDLL
ThereareseveralwaysthatwecansetuprecordingforWebSphereMQ.Duringthistrainingcourse,wewillbeusingtheinterceptdllprovidedbyRationalIntegrationTester.ThiswillallowustoviewandrecordmessagessenttoanyqueueontheMQserver.Ifyouareusingacloudinstance,thishasalreadybeendoneforyou.
Pleaseviewsection6oftherit_wmq_ref.pdfpluginguideforinstructionsonhowtoconfigurethis.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page8of133©IBMCorporation2001,2012
3 Rational Integration Tester Project Setup
3.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.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page9of133©IBMCorporation2001,2012
OpenLink–followsalinktakenfromtheTestLabtonavigatetotheresultsofatestortestsuite.
Openanexistingproject–opensanexistingproject,eitherfromthelistofrecentprojectsshownbyRationalIntegrationTester,orbybrowsingtoa.ghpfile.
3.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.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page10of133©IBMCorporation2001,2012
Attheendofthewizard,anewprojectfolderwillbecreatedwithinyourfilesystem.Thisfolderwillholdallresources–amodelofthesystemundertest,alongwithanytests,stubsorotherresourcescreatedfortheproject.Datafilesusedbyyourprojectcanalsobestoredhere–thiscanhelpyoumakeyourprojectmoreportablebyincludingeverythinginoneplace.Alternatively,youmightwanttoincludethosedatafilesinanotherlocation–RationalIntegrationTesterwillbeabletorefertothemeitherway.
3.3 Exercise:CreatingtheTrainingproject
Wewillnowcreateabrandnewproject,whichwewillcontinuetouseforthedurationofthiscourse:
1. LaunchRationalIntegrationTesterbydouble‐clickingtheIBMRationalIntegrationTestershortcutonyourdesktop.
2. RationalIntegrationTesterwilllaunch,displayingtheinitialscreen.CreateanewprojectbyselectingNewProjectandclickingOK.
3. Wecannowgiveourprojectaname,usingtheProjectNamefield.We’llcallourproject
WWTravel Testing.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page11of133©IBMCorporation2001,2012
4. Ifdesired,modifytheOwnerandCommentsfields(thesearesavedwiththeprojectand
canbemodifiedlater).
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.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page12of133©IBMCorporation2001,2012
Settings Value
DatabaseURL jdbc:mysql://localhost:3306/projectdb
UserName root
Password root
9. ClickonTestConnection.Awindowshouldpopupstatingthattheconnectionwassuccessful.
10. Belowthedatabasesettings,wecanconnecttotheResultsServerandRTCP.WewillnotbeusingtheResultsServer,butRTCPmaybeneededlateron.Thedefaultsettinghereshouldbesufficient:
Settings Value
RTCPURL http://localhost:7819/RTCP
Domain Booking System
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page13of133©IBMCorporation2001,2012
11. Whenyouaresatisfiedwiththedetailsenteredonthisscreen,clickFinish.Ifuser‐basedpermissionsorconnectionstochangemanagementtoolswererequired,youwouldneedtochooseNext,andthensetthemuponthefollowingscreens.
12. ThenewprojectwillbeopenedinRationalIntegrationTester.Bydefault,itwilldisplaytheLogicalViewintheArchitectureSchoolperspective.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page14of133©IBMCorporation2001,2012
3.4 RationalIntegrationTesterlayout
ThemainwindowofRationalIntegrationTesterisaworkbenchthatcontainsseveraldockablewindows.Thesewindowsareorganizedinalogicalway,providinganintuitive,easy‐to‐usecentralworkspace.
Informationaboutyourcurrentprojectcanbefoundinthetitlebarandstatusbar.Atthetopofthescreen,thetitlebarindicatesthenameofthecurrentproject,alongwiththecurrentenvironment.Atthebottomofthescreen,thestatusbarindicatesthenameofthecurrenttestcycle,thecurrentuser,andthememoryusage.Forthepurposesofthismanual,wewillnotneedtobeconcernedwiththeinformationinthestatusbar,thoughyoumayfinditusefultokeepaneyeonthetitlebartocheckwhichenvironmentiscurrentlyactive.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page15of133©IBMCorporation2001,2012
3.5 RationalIntegrationTesterPerspectives
InthecenterofthescreenisthemainworkbenchofRationalIntegrationTester,showingthecurrentperspectiveview.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 .
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page16of133©IBMCorporation2001,2012
4 Modeling the System
4.1 PerspectiveOverview
TheArchitectureSchoolperspectiveisthedefaultperspectiveloadedwhenRationalIntegrationTesterisstarted.Thisperspectiveisusedformodelingthesysteminasimple,graphicalfashion.Thismodelissplitintoseveralparts.Asthemodelissplitintoseveralparts,theArchitectureSchoolperspectiveisalsosplitintoseveraldifferentviews.Inadditiontotheseviews,wealsouseanEnvironmenttobinddifferentpartsofthemodeltogether.
Theviewsarepresentedalongthebottomoftheperspective:
LogicalView
PhysicalView
Synchronisation
SchemaLibrary
DataModels
RuleCache
Forthemoment,we’regoingtolookatanexampleofasimplesystem,whichwillmakeuseofthefirsttwoviews,alongwithEnvironments,whichareusedtotietheLogicalandPhysicalviewstogether.We’llthenmovetotheSchemaLibrarytosetupmessageformats.
4.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.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page17of133©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.
4.3 LogicalView
TheLogicalViewprovidesanabstractmodelofthesystemthatweareinteractingwith.We’regoingtobuildasimplemodelheretodemonstratehowthisworks.Thismodelwillbemadeupofseveraldifferentelements:
Thefirstobjectwe’llneedtocreateisaServiceComponent.ServiceComponentsactascontainersforallotherelementswithintheLogicalView,andmaycontainotherServiceComponentstobuildupmorecomplexstructures.
Inmostcases,we’llwanttodefineOperationswithinaServiceComponent.Operationsdefinethefunctionalityofthesystem.Wewillbeabletocreateresourcesbasedupontheinformationprovidedwithineachoperation.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page18of133©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.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page19of133©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.
4.4 Exercise:SettinguptheLogicalViewforaSimpleSystem
1. Beforestarting,we’llneedtomakesurethatthewebservicewe’remodelingisactive.OntheWindowsdesktop,doubleclicktheAddNumbersServer.jartoexecuteit.Youshouldseethefollowingwindowappear:
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page20of133©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:
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page21of133©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,ensuretheSelectCursorbuttonisselected,andleftclickontheserviceorcomponentyouwishtomove,anddrag
ittothedesiredlocation.
o Ifyoueverwanttoresetthelayoutoftheservicesandcomponents,thentheLayoutAllNodesbutton willorganizethemintoanefficientlayout.
o Tosetthezoomlevelsothattheentirediagramfitsinsidethescreen,usetheFittoContentsbutton .
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page22of133©IBMCorporation2001,2012
4.5 PhysicalView
Onitsown,thelogicalviewthatwe’vecreatedisnotenoughtofullydescribeoursystem.Asmentionedpreviously,itdoesn’tcontaininformationabouttheaddressoftheserverwe’retalkingto,oranyconnectionsettingsthatmayberequired.We’regoingtospecifythisinformationseparately,inthePhysicalView.
Thisviewdisplaysavailablephysicalresourcesandtheirlocationwithintheenterprise.EachresourcelistedwithinthePhysicalViewrepresentsasingleconfigurationofaninfrastructurecomponentdescribedintheLogicalView.
Resourcesinthisviewareorganizedbysubnetandhost.Ifaresourceisnotassociatedwithasubnetorhost,itwillbedisplayedunderUnconnectedResources.We’regoingtocreatethephysicalresourcefortheAddNumberswebservice–asimplewebserver.
4.6 Exercise:SettingupPhysicalViewforaSimpleSystem
1. SwitchtoPhysicalViewusingthe tabatthebottomofthescreen.
2. We’regoingtoaddanewresourcehere.Alongthetopoftheperspective,you’llseeatoolbarcontainingoptionsforaddingnewresourcesfromdifferentcategories
3. ChoosetheWebcategory,andthenchoosetheWebServer option.
4. TheNewWebServerdialogwillappear.SettheHostsettingtolocalhostusingPort8088.
5. PressTestTransporttomakesurethatyouareabletoconnectproperlytothewebservice.Onceyouaresatisfiedthatitisworkingproperly,pressOKtoclosethedialogandsavethenewresource.
4.7 Environments
Oncewehavethelogicaldata,whichgivesusanabstractmodelofwhatinfrastructureisrequiredbyoursystem,andthephysicaldata,whichspecifiesthedifferentconfigurationsavailableforeachinfrastructurecomponent,wethenneedtomatchtheseup.Rememberingthatthiscouldchangebetweendifferentstagesofthelifecycleoftheproject,wecanuseasetofenvironmentstocoordinatethisprocess.
Anewprojectstartswithoutanenvironment,sowe’llcreateaninitialenvironmentinthisexercise.Otherenvironmentscouldbecreatedsubsequentlyasrequired.Thesewillallowustokeepusingthesametestresources,simplybyswitchingtonewenvironmentsastheybecomeavailable.
Environmentsdonothavetheirownview;instead,thereareanumberofoptionsintheProjectmenuwhichallowustoaccessandeditanenvironment:CreateNewEnvironment ,EditEnvironments ,andSwitchtoEnvironment .IfyouareusingthedefaultsettingswithinRationalIntegrationTester,theTitleBarwillalsoshowthenameofthecurrentenvironment.
4.8 Exercise:CreatinganEnvironment
1. SelectProject>CreateNewEnvironment
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page23of133©IBMCorporation2001,2012
2. Givetheenvironmentaname–forexample,Local(mostoftheenvironmentwe’reworkingwithinthistrainingcoursewillbeonthelocalhost).
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.Youshouldseethattheenvironment
nameisnowdisplayedintheTitleBar.
Onceanenvironmenthasbeencreated,wecanalsoviewandeditenvironmentaldatadirectlyfromtheLogicalView.Todothis,youcanrightclickonaninfrastructurecomponentinLogicalView,andselecteitherPhysicalResource,whichwillshowtherelatedphysicalresourceinthecurrentenvironment,orselectSetBindingIn...,whichwillallowyoutosetthebindinginanyenvironment.Thisinformationcanalsobeseenbyopeningtheinfrastructurecomponentbydoubleclickingonit,andgoingtotheBindingstab.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page24of133©IBMCorporation2001,2012
4.9 Exercise:SchemaLibrary
Wenowhavemostoftheinformationwewouldneedtocreateatestorstubforthissamplewebservice.However,we’restillmissinginformationabouttheformatofthemessagesgoingtoandfromthewebservice.MostofthisinformationcanbeprovidedthroughtheSchemaLibrary.
1. SwitchtotheSchemaLibraryusingthe tabatthebottomofthescreen.
2. Atthetopoftheperspective,thereisatoolbarcontainingbuttonsforimportingdifferent
typesofmessageschemas. 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.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page25of133©IBMCorporation2001,2012
Note:IfyouhavemistypedthenameoftheWSDL,youshouldreceiveawarning,andtherighthandsideofthescreenwillnotshowthemessageschemas.Ifyouendupinthissituation,youcanfixitinthefollowingmanner:
AmendthelocationoftheWSDLbyusingtheChange…buttonnexttotheWSDLLocationatthetopofthescreen.Followingthat,presstheRebuild buttontorebuildtheschemadata.
7. GototheConfigtabtovieweachindividualmessagetype.YoucanselecteachmessagetypeusingtheOperationdropdownjustunderthetabsalongthetopofthescreen.Usethistoviewthethreemessagetypes:addition__INPUT__addition,addition__OUTPUT__additionResponse,andaddition__FAULT__AdditionException.
4.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.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page26of133©IBMCorporation2001,2012
8. PressOKtoclosetheAdditionoperation.
Wenowhavealltheinformationwemightneedtoworkwithaverysimplewebservice.Formorecomplexsystems,itwouldbepreferabletoanalyzethesystemtoderivesomeorallofthisinformationautomatically.Wecandothisintwoways,dependingonthetechnologiesinvolved–bysynchronizingwiththesystem,orbybuildingamodelofthesystemfromrecordedevents.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page27of133©IBMCorporation2001,2012
5 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.
5.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.AllofthisisdonebyreferringtoaDB2databasewhichisusedtoholdbooking
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page28of133©IBMCorporation2001,2012
information.ThereservationnumberisthenpassedbacktoMakeBooking,toTomcat,andthentheuser.
Whenauserwantstomanageabooking,TomcatwillbeinteractingwithasetofwebservicesimplementedbyWebSphereApplicationServer.Theseserviceswillallowtheusertologintothebookingsystem,searchexistingbookings,updatebookings,ordeletethem.Searching,updating,anddeletingwillaccessthesamedatabasethatwasusedpreviouslyformakingbookings.
5.2 FindingandBookingHotels
Followingaflightbooking,ausermayrequireahotelinthatdestination.TheHotelFinderwebserviceallowstheusertolookupalistofhotelsthatareavailableinaparticularcitybetweenagivenpairofdates.Tomcatcanthenprovidethislisttotheuser.TheHotelFinderwebserviceishostedbyTomcatitself,ratherthanrunningonWebSphereApplicationServer.
5.3 FlightAdministration
Onthedayofaflight,usersfromtheairlinewillneedtocheckinpassengers.Theadministrationservicesallowtheusertofirstsearchthroughalistofflights,selectaflight,andthenselectparticularbookingonthatflight.ThisisalldonebyTomcat,directlyaccessingtheDB2databaseusedwhencreatingandmanagingbookings.
Whenapassengerischeckedin,theairlineuserwillneedtochecktheirpassport,andupdaterecordsaccordingly.Todothisonceabookinghasbeenselected,amessageispostedtoanMQqueueinCOBOLCopybookformat.Itispickedupbytheflightconfirmationservice(runningasitsownprocess),whichthenpostsareplyback,alsoinCopybookformat.Tomcatthenusestheinformationinthisreplymessagetoupdatethedatabase.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page29of133©IBMCorporation2001,2012
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page30of133©IBMCorporation2001,2012
6 Using System Data to Build a System Model
6.1 Overview
Obviously,ifwewantedtobuildalargersystemsuchasWorldwideTravelwithinRationalIntegrationTesterbyhand,aswedidforaddNumbers,itwouldtakesometime.Instead,dependingonthetechnologiesinusewithinthesystemundertest,therearetwomethodsofautomaticallygeneratingasystemmodel.Wecaneithersynchronizeoursystemmodelwiththesystemundertest,orwemayrecordeventswithinthesystem,andusetheserecordedeventstobuildasystemmodel.
6.2 SynchronisationOverview
Thesimpleroptionwhenbuildingamodelofthesystemundertestissynchronization.Thisprocessanalysestheservicesandinfrastructureprovidedbythesystem,andreplicatesthatwithintheArchitectureSchool.Thiswillsetupthelogicalandphysicalviews,anenvironment,andanymessageschemasusedbythevariousservicesinthesystem.
Inordertodothis,RationalIntegrationTesterrequiresavalidsynchronisationsourcetoexistwithinthesystemundertest,sothatitcanrequestinformationonthesystem.Supportedsynchronizationsourcesinclude:
WSDL
webMethodsIntegrationServer
TIBCOBusinessWorksProject/DesignTimeLibrary
SAPSystem
OracleSCADomain
Addinganyofthesetoyourprojectwillgiveyoutheoptiontosynchronisewiththedataheldbythatexternalresource.Tostartthesynchronisationprocess,youcanaddanyoneoftheseinfrastructurecomponentstotheLogicalViewofArchitectureSchool,orbyswitchingtoSynchronisationviewandaddingitthere.Eitherway,theprocessofaddingasynchronizationsourcewillprovidetheoptionofsynchronising.Multiplesynchronisationsourcesmaybeaddedtotheprojectifrequired.
Post‐synchronisation,thesystemundertestmaychange;asthiswillberecordedwithinthesynchronisationsource,itispossibleforRationalIntegrationTestertoupdatetheprojecttoreflectthesechanges.TodothiswithintheSynchronisationview,firstpressCheckSynchronisation –thiswillcomparethesystemmodelwithintheRationalIntegrationTesterprojectagainstanysynchronisationsources,anddisplayanydifferencesbetweenthese.Followingonfromthat,you
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page31of133©IBMCorporation2001,2012
canpresstheSynchronise button,whichwillthenupdatetheRationalIntegrationTesterprojecttoresolvethesedifferences.
6.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.
6.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:
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page32of133©IBMCorporation2001,2012
Theclientapplicationwillcommunicateviarequestandreplyqueueswithagivenservice.RationalIntegrationTesterwillreadtherequestandresponsemessagesbeingpostedtothequeueswithinthequeuemanager.Whilethequeuemanagermayactslightlydifferentlytoitsusualbehavior–forexample,bycopyingeachmessagetoamirrorqueue–themessagesthemselveswillbeuntouched,andtheactionsofthesystemundertestshouldalsobeunchanged.
Notethatwemaychoosetorecordjustagivenservice,ifwehaveanoperationdefinition(andsoknowwhichqueuestomonitor),orwemayrecordallqueueswithinthequeuemanagerbyrecordingtheMQtransport.
6.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.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page33of133©IBMCorporation2001,2012
4. Aswe’reusinganMQserveronthelocalmachine,enterlocalhostasthehost.Theportshouldbe1414.
5. WethenneedtosetuptheChannelandQueueManager.SettheChanneltowwtravelwebappandtheQueueManagertoQM_wwtravel.Thesettingsforthetransportshouldbeasfollows:
6. PressTestTransporttomakesureeverythingissetupcorrectlysofar.AfterRational
IntegrationTesterhasreportedthatithassuccessfullyconnectedtotheMQserver,whichmaytakeamoment,switchtotheRecordingtab.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page34of133©IBMCorporation2001,2012
7. UnderQueueRecording,settheRecordingModetoDynamicMirrorQueues.Allother
settingsherecanbeleftattheirdefaults.
8. Finally,switchtotheAdvancedtab.Here,setthenumberofQMConnectionsto5.Thiswillallowustomanagemoreconnectionswiththequeuemanager,incasewemaybeworkingonmultipletasksatthesametime(e.g.,recordingandstubbing).
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page35of133©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.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page36of133©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,then
pressOKtoclosethedialogbox.
18. YourLogicalViewshouldnowshowtheWWTravelservicecomponentlikeso(inadditiontotheAddNumbersservicecomponentcreatedearlier):
19. Finally,openuptheEnvironmentEditorusingProject>EditEnvironments,andverify
thatallofthelogicalandphysicalcomponentshavebeenboundcorrectly:
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page37of133©IBMCorporation2001,2012
WehavenowmodeledthebasicinfrastructureoftheWorldwideTravelsystem.Fromthispoint,wecouldmovedirectlytorecordingeventsfromthesystem,andmodelingtheoperationsfromthat.We’llmakethisabiteasierbyimportingsomemessageschemasbeforewebeginrecording.
6.6 Exercise:AddingtheFlightBookingMessageSchemas
1. ReturntotheSchemaLibrary.Here,weneedtoaddthreenewXMLschemas,sopressthe
XSDsbuttononthelefthandsideofthescreen toshowanyavailableXSDs–noneshouldbeshownatthemoment.
2. WecouldusetheXSD buttonintheSchemaLibrarytoolbartoaddnewXSDstotheproject,aswedidwiththeaddNumbersWSDL.However,aswe’vegotagroupoffiles,we’lljustdraganddropthemintotheschemalibrary.FindtheXSD Schemasfolderonyourdesktop,anddraganddropitintothecenterpaneloftheSchemaLibrary.
3. RationalIntegrationTestershouldnowshowthreenewXSDs–BookFlightRequest,BookFlightResponse,andPayment.
4. Youcanselecteachofthese,andviewtheassociatedmessageschemasontherighthand
sideofthescreen.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page38of133©IBMCorporation2001,2012
7 Requirements Library
7.1 Overview
IntheRequirementsLibraryperspective,theuserdefinestherequirementsforaninterfaceintheformofmessages.MessagescanbecreatedfromscratchorcapturedandsavedfromRecordingStudio.Thereareseveraladvantagesofhavingthesemessagerequirements:
TheyfacilitatethecreationoftestsbydragginganddroppingthesemessagesontoamessagingactiontypeintheTestSteps.
Ithelpskeeptestsconsistentacrossmultipleusersaseachcansharethisrepositoryofdefinedmessagestructuresforvariouscomponentsundertestandinessenceactsasamessagecatalogue
Itprovidesanexampleofhowthedatashouldlooklikeforaparticulartest.Ausermaydecidetouseamessagecapturedbysomeoneelsewiththeknowledgethatthedatahasbeencapturedandthereforeiscorrect.Examplesofuseareforcreatingtriggersandstubs.
ItisfairlycommonduringdevelopmentortestingofEAIorSOAprojectsthatcomponentsareunavailable.Wewilllookatcreatingstubsforsuchcomponentslaterinthisdocument.
Forthemoment,we’regoingtolookathowRationalIntegrationTesterprocessesdifferentmessageformats,usingtheRequirementsLibrary.
7.2 TheMessageEditor
ThiswillalsoserveasourintroductiontotheMessageEditorincludedinRationalIntegrationTester.TheMessageEditorformatsallmessagetypessupportedbyRationalIntegrationTesterintoatreestructure.Itwillalsoexportmessagesfromthatsametreestructureintotheappropriateformatwhensendingthatmessageoveratransport.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page39of133©IBMCorporation2001,2012
Dependingonthecontext,themessageeditorwillhaveanumberoftabs.Wewilllookattheseinmoredetailaswecometousethem,butthemaintabsyouwillseeare:
Config:Providesmainconfigurationinformation,includinginformationaboutthetransport.AlsoreflectsthesettingsusedintheValueorAsserttab.
Value/Assert:Providesvaluestosendforeachfield,orexpectedvaluesforthosefieldsifreceivingamessage.
Filter:Allowstheusertofiltermessagesbasedontheircontents
Store:Savesdataforlateruse
7.3 Exercise:ImportingMessages
1. Asanexample,we’regoingtousethesimpleexampleprovidedintheData Filesfolderonyourdesktop–additionInput.xml.Openthisfileinnotepadtotakealookatit–youwillseeasimpleXMLmessage.Donotopenthefileinyourwebbrowser,asitwillreformatpartofthemessagebyinsertingextracharacters.
2. SelecttheXMLtext,andcopyitusingCtrl+C.
3. SwitchbacktoRationalIntegrationTester,andmakesureyouareintheRequirementsLibraryperspective.RememberthatyoucanselectthiswiththeRequirementsLibrarybutton fromthePerspectivesToolbar,orbypressingF8.
4. Onthelefthandside,youwillseeatreestructuredescribingallofthelogicalelementswesawearlierintheArchitectureSchool.ThetreestructurewillmapdirectlytothestructureofthedifferentcomponentsintheLogicalView.FindtheAdditionoperationinthetree,thenrightclickonit,andchooseNew>Message.Callitexample_from_file.
5. Therighthandsidewillnowbepartlypopulated.Youshouldseeasimpletreestructurefor
yournewmessage,withaText (Message)aboveatext (String).Rightclickonthetext (String),andchoosetopastetheXMLdatawecopiedearlier.Youshouldendupwithamessagethatlookslikethefollowing:
6. Ifanerroroccurs,gobacktotheXMLdocumentinnotepad,andmakesurethatyouhave
copiedalloftheXMLbeforeattemptingtopasteitintoRationalIntegrationTesteragain.
7. ComparetheoriginalXMLdocumentwiththetreestructuregeneratedinRationalIntegrationTester,thenSavethismessage.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page40of133©IBMCorporation2001,2012
7.4 CreatingMessagesfromaSchema
Whilewecanimportmessagesbycopyingandpasting,therewillalsobetimeswhenwewanttoworkbyenteringvaluesintothestructureprovidedbythemessageschema.
1. RightclickontheAdditionoperationinthetreeonthelefthandside,andchooseNew>Messagetocreateasecondmessage.Callitexample_from_schema.
2. Youshouldseeamessagewhichsimplyhasatoplevelmessagenodecontainingasingletextstring,aswehadinthepreviousexercise.Rightclickonthetext (String)node,andselectSchema…
3. TheSelectSchemadialogwillappear.Onthefarleft,selectWSDLs.YoushouldthenseetheaddNumbersWSDLappearinthemiddleofthedialog–clickonittoselectit.
4. Ontherighthandside,youshouldgetapreviewofthemessagetypesavailableintheschema.ThismaybepartiallyhiddenbytheBindingProperties.Tocontrolwhatiscurrentlydisplayed/hidden,youcanusethearrowbuttons( ).PressthedownarrowtohidetheBindingProperties.
5. IntheOperationdropdown,wecanchoosewhichmessagetypewewouldliketouse–forthisexample,we’llbegeneratingamessagebasedonaddition__INPUT__addition,soselectthat.
6. PressNext–youwillnowseeasetofoptionsthatwillsometimesbeusefulwhenapplying
schemastoamessage.Inparticular,therewillbecircumstanceswheretheoptiontoIncludeoptionalfieldswillbeneeded.Forthismessageschema,however,therearenooptionalfields,sowecansimplypressFinish.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page41of133©IBMCorporation2001,2012
7. Youshouldnowseethemessageformattedusingtheinputmessageschemaforthe
addNumbersservice.Wecaneditthisfurther,asrequired.Forexample,youmaywanttodeletecertainnodesfromaparticularmessage–we’lldeletethesecondargumentfortheaddition.Todothis,selectthearg1 (Element)node,andpresstheDeletekey.RationalIntegrationTesterwillaskforconfirmation–answerYestothis.
8. Themessagestructurewillbeupdated,andyouwillseeorangeandredxsymbolstoinform
youthatthereisanerrorsomewhereinthemessage.Youcanhoveryourmouseoverthesesymbolstogetmoreinformation,butingeneral,anorangexsymbolindicatesthatthereisanerrorsomewherefurtherdownthatbranchofthetree,whilearedxsymbolindicatesthatthereisanerrorinsidethatspecificnode.Hoverovertheredx–youshouldseethattheschemaindicatesthattheadditionelementshouldhaveanarg1elementinsideit.
9. Toaddtheelementbacktotheschema,rightclickonthetns:addition (Element)node,andselectAddChild>arg1(Element).Themessagewillbeupdated,andasthemessagenowconformstotheschema,theerrormarkerswilldisappear.
10. Aswe’vestillgotnullvaluesforeachofthearguments,edittheText nodesforarg0andarg1,andenteranumberforeachone.
11. Savethemessage.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page42of133©IBMCorporation2001,2012
WehavenowseenhowtoimportexamplemessagesbycopyingandpastingthedataintoRationalIntegrationTester.Wehavealsocreatedanexamplemessagebyapplyingamessageschemaandenteringthedatamanually.
Aswewillseeinthenextsection,isitalsopossibletorecordmessagesfromthelivesystem,andsavethemasrequirementsforlateruse.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page43of133©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.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page44of133©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.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page45of133©IBMCorporation2001,2012
5. RightclickontheWWTravel_MQcomponent,andselectRecord.TheperspectivewillchangetotheRecordingStudio,andtheWWTravel_MQtransportshouldbelistedintheEventMonitors.
6. ClicktheStartRecordingbuttonintheEventsViewtoolbar tostartrecordingevents.
7. Inabrowserwindow,opentheWorldwideTravelbookingsite.Foracloudimage,thiswillbelistedinthefavoritesmenuofyourwebbrowser;otherwise,askyourtrainer.
8. Clickonthe“StanstedtoBarcelona”BookNowbutton.Here,youwillhavetheopportunity
tobookaflightandahotel.Forthemoment,we’llonlyworryaboutflights,soskipthehoteldataatthetopoftheform,andjustenterpassengerandpaymentdetailsforaflight.MakesurethatyouselectMultinationalasthecreditcard–theotherdetailsdonotmatter,aslongastheyarefilledin.
9. ClickProceedwhenfinishedandyoushouldseeaconfirmationpagewithareservationnumber.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page46of133©IBMCorporation2001,2012
10. ReturntoRationalIntegrationTesterandyoushouldseethat4eventshavebeenrecorded
intheEventsView.
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.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page47of133©IBMCorporation2001,2012
4. TheRecordedEventswizardwillappear,allowingustochoosewhatwewilldowiththe
selectedevents.Tobuildamodelofthesystemundertest,weneedtocreatesomeoperations,soselectthatoption,andthenpressNext.
5. RationalIntegrationTesterwillnowdisplaythe12recordedmessages,attemptingto
separatethemintodistinctoperations.Itshouldlooksomethinglikethefollowing:
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page48of133©IBMCorporation2001,2012
6. Astheoperationnamesaregeneratedfromthequeuenamesused,wemightliketochange
themtosomethingmoreuseful.Selectthefirstmessagebelongingtotheoperationthatiscurrentlynamedwwtravel.booking – wwtravel.booking.reply.
7. Youwillnowbeabletoenteranewnamebelow,soenterMakeBooking,andpressRename.Youwillbeaskedifyouwanttoapplythischangetoallothermessagesthatwereassociatedwiththesameoperation–answerYes.YoushouldthenseetheOperationcolumnupdateaccordingly.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page49of133©IBMCorporation2001,2012
8. Next,wewilladdthemessageschemasforMakeBooking.Todothis,selectoneoftherequestmessagesforMakeBookingonthelefthandsideofthedialog(itwillcontainallofthedatayouenteredintothewebformearlier).Ontherighthandside,selectthesecondlineofthemessage,beginningtext (String).
9. TheAddSchemabuttonshouldnowbeactive.Pressit,andtheSelectSchemadialogwill
appear.Onthelefthandside,selectXSDs,thentheBookFlightRequestXSD.PressFinishtoapplytheschematothismessage.Youshouldthenseethenamespaceupdatewithinallfieldsofthemessage:
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page50of133©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.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page51of133©IBMCorporation2001,2012
15. You’llnowseeasummary,lettingyouknowthatRationalIntegrationTesterwillbecreating
4operationsforyou.MakesurethatOpenresourceafterfinishisunchecked,thenpressFinishtocreateall4operations.YoucannowswitchbacktotheArchitectureSchooltoseewhathasbeencreated.
16. IntheLogicalView,youcannowdoubleclickoneachoperationtoviewitsproperties.Do
thisforoneoftheoperationsyoucreated,andviewtheMessageExchangePatterntab.Thisshouldshowyouthemessageschemasyousetearlierforrequestandreplymessages;
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page52of133©IBMCorporation2001,2012
itshouldalsoshowyouthetransportinformationusedbythatoperation,includingthenamesofthequeuesthatituses.
8.4 Exercise:CompletingtheSystemModel
1. WithintheLogicalViewofArchitectureSchool,wenowneedtoaddsomeextradependencyinformationtogiveourselvesacompletesystemmodel.Firstly,theMakeBookingoperationshouldhaveadependencyoneachofthecreditcardprocessingoperations.Forexample,toaddadependencyfromMakeBookingtoProcessMultinational,
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.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page53of133©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,ProcessGlobal,andProcessWorldwideoperations.NotethatiftherewereotheroperationshaddependenciesontheMakeBookingoperation,we
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page54of133©IBMCorporation2001,2012
couldselectthoseontheParentReferencestab;asnothingdependsonMakeBookinginoursystem,thiswillnotbenecessary.PressOKtocontinue.
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.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page55of133©IBMCorporation2001,2012
13. Again,you’llbeabletofilterbysource.Notethatyoucanselectmultipleeventmonitorsat
thesametimewhenfiltering,toshowmessagesfrommultipleoperations.
14. Wewillsavetwooftheseexamplemessagesasrequirements.WiththefirstmessageforMakeBookingselected,clickontheclickontheSaveicon ontheEventsViewtoolbartoopentheRecordedEventsWizard.
15. Selecttherequirementsoptiononthefirstscreen,andpressNext.
16. Onthesecondscreen,youwillbeaskedhowthedatawithinthemessageshouldbestored.Youchooseeitherhardcodedvalues,ortouseadatasource.We’lllookatusingdatasourceslaterinthecourse,sofornow,choosetoStoredataashardcodedvalues,andpressNext.
17. Followingthis,RationalIntegrationTesterwillconfirmthattherequirementisassociatedwiththecorrectoperation.Aswehaverecordedfromanoperation,thisshouldstateMakeBookingastheoperation.Thisiscorrect,sopressNextagain.
18. OntheSummaryscreenthatappears,youwillbeaskedtogivetherequirementaname.CallitexampleRequest.UnchecktheboxlabeledOpenResourceAfterFinish,andpressFinishtocreatethenewrequirement.
19. Dothesameforthecorrespondingreplymessage,callingitexampleReply.
20. YoucannowswitchtotheRequirementsLibrarytoviewthesavedmessages.
Sofar,wehavejuststoredasinglemessageforlaterre‐use.Laterexerciseswilllookatotherwayswecanre‐usethemessagesthatwehavesaved.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page56of133©IBMCorporation2001,2012
8.6 Exercise:CreatingandRunningTriggers
Atriggerisusedtosendaneventtothesystemundertest.Triggerscanbecreatedmanually,orfromapreviouslyrecordedevent.Inourexample,wewilluseanexistingevent.
1. IntheRecordingStudioperspective,selecttheTriggerstab,belowtheEventMonitorspanel:
2. IntheEventsViewpanelselectthefirstrecordedevent(therequest)andthenclickthe
Savetriggersfromselectedevents toolbarbutton.
3. GivethenewtriggerthenameTriggerMakeBooking–itwillbecreatedundertheComponentstreeintheTriggersview.
4. Ifnecessary,expandthetreetoshowthenewtrigger(expandeachnode,orclick toexpandallnodes).
5. Double‐clicktheTriggerMakeBookingtriggertoeditit.
6. TheEditTriggerdialogisdisplayed.SelecttheValuetabandupdateoneofthefields(e.g.changethepassengerFirstNamefield)inthebody.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page57of133©IBMCorporation2001,2012
7. ClickOKtosavethechangeandclosethedialog.
8. ClickRecordintheMonitorViewifithasbeenstopped.
9. RunthetriggerbyrightclickingitintheTriggersview,andselectingRunTriggerfromthecontextmenu.
10. AnewseriesofeventswillberecordedintheMonitorView.
11. Toverifythattherequestcontainstheupdatedfield,selecttheeventandviewtheupdatedfieldinthemessageviewbelow.
12. Stoptherecordingusingthe button.Donotcleartherecordedmessagesastheywillbeusedinthefollowingexercises.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page58of133©IBMCorporation2001,2012
9 Creating and Editing Tests
Nowthatwehaveamodelofthesystemundertest,wecanlookatcreatingtestsforthatsystem.Wewillalsolookatthebasicsofeditingthesetests.
Thereare4mainwaystocreatetestsinRationalIntegrationTester:
Creatinganewblanktest
Creatingatestfromrecordedevents
Creatingatest,oragroupoftests,usingtheMEPwizards
Creatingatestfromatemplate
CreatingatestfromrecordedeventscanbedonefromtheRecordingStudioperspective;allotheroptionsarehandledintheTestFactory.
We’llcreateourfirsttestfromrecordedevents.We’llthentakeacloserlookathowthattestisputtogether,andhowwecaneditit.Finally,we’lllookatothermethodsofcreatingtests–usingtheMEP,andusingtemplates.
9.1 TestStructure
Themainstructureofatestisputtogetherusingasetoftestactions–thereisnoscriptingrequiredinRationalIntegrationTester.Instead,RationalIntegrationTesterwilldeterminewhatitisrequiredtodobyanalyzingthesequenceofthesepre‐configuredactions.
Atatoplevelview,theactionswithinatestwillbesplitintothreephases:Initialise,TestSteps,andTear‐down.Thesesectionsaretreateddifferentlydependingonthetypeoftestbeingrun.Fornormalfunctionaltests,asinthistrainingcourse,thesethreesectionswillgenerallybeexecutedinsequence.However,forperformancetestsandstubs,wherethetestactionswillberepeatedmultipletimes,onlytheTestStepssectionwillberepeated–InitialiseandTear‐downstepswillberunonceonly.Similarly,certaintestactions(suchasthePassandFailactions)willskipanyfurthertestactionswithintheTestSteps,andgostraighttoanyactionswithintheTear‐downphase.Forthisreason,itissuggestedthattheInitialiseandTear‐downphasesareusedforsetup/clean‐up,suchasclearingdatabasetablesormovingfiles.
Thetestactionsthemselvesaregenerallyexecutedinsequence,thoughlogicmaybeaddedtothetesttoallowforbranchingandlooping.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page59of133©IBMCorporation2001,2012
9.2 BusinessViewandTechnicalView
RationalIntegrationTesterprovidestwodifferentviewsofTestActions.ThefirstoftheseistheTechnicalView,whichisthedefaultviewgeneratedbyRationalIntegrationTester.Thisdisplayseachactionusinginformationtakenfromitsconfiguration:
TheBusinessViewprovidesauser‐editableview.Bydefault,itisexactlythesameastheTechnicalView,butitmaybeeditedbytheusertoaddadescriptionoftheaction.Intheexamplebelow,thetwomessagingactionshavebeeneditedtoaddadescription;therestofthetesthasbeenleftalone:
SwitchingbetweenTechnicalViewandBusinessViewcanbedonebyusingtheTechnicalViewandBusinessView buttonsonthemaintoolbaratthetopoftheRationalIntegrationTesterwindow.
OnceyouarelookingattheBusinessView,actiondescriptionscanbeeditedinacoupleofways:
Clickonceontheactiontoselectit,thenonceagaintoeditthedescription.
Selecttheaction,thenpressF2.
Rightclickontheaction,andchooseRename.
9.3 Exercise:CreatingTestsfromRecordedEvents
1. IntheEventsViewintheRecordingStudioperspective,selectapairofeventsthathavebeenrecorded–arequestandaresponse.Toselectbothevents,youcanclickanddragwhileholdingtheleftmousebutton,orselectarangeofeventsusingthemouseandtheShiftkey.
2. ClickontheSavebutton intheEventsViewtoolbartobringuptheRecordedEventswizard.
3. Onthefirstpageofthewizard,choosetocreateanintegrationtest,andthenpressNext.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page60of133©IBMCorporation2001,2012
4. Thenextscreenprovidesachoiceofhowtostorethedatausedinthetest.Forthisexample,
taketheoptionofhardcodedvalues,andpressNext.
5. Thewizardwillthenallowyoutoverifythatthecorrectoperationhasbeenused–inour
case,weshouldjustseemessagesfromMakeBooking.Ifthisisnotthecase,you’llneedtorestartthewizard,makingsurethatyouhaveonlyselectedarequest/replypairforMakeBooking.Otherwise,pressNextagain.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page61of133©IBMCorporation2001,2012
6. Thefollowingpagechecksthatallrequestsandrepliesarematchedupcorrectly–inthis
case,thereisonlyasinglerequestandreply,andthesearealreadymatchedupforyou.PressNexttocontinuethroughthewizard.
7. OntheSummarypage,youcangivethetestaname–callitRegression1.Forsimplicity,
makesurethattheOpenresourceafterfinishoptionisenabledtoopenthetestintheTestFactoryaftersaving.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page62of133©IBMCorporation2001,2012
8. YouarenowintheTestFactoryperspective.Youshouldseeanewtestcreatedinafolder
calledTests,containedintheMakeBookingoperation.Thepaneltotherightdisplaysthenewtestandthestepsitcontains.
9. Double‐clickontheSendRequeststep.Youwillseethemessageschemapopulatedwiththe
detailsyouenteredinthebookingform.NotealsothattheTransport,FormatterandServicesettingshavebeenpopulatedforyou.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page63of133©IBMCorporation2001,2012
10. ClosetheSendRequeststep,anddouble‐clickontheReceiveReplystep.Again,notethat
themessagehasbeenpre‐populated.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page64of133©IBMCorporation2001,2012
Note:Whencreatingatestfromrecordedmessages,RationalIntegrationTesterwillusethemessagesinthesameorderthattheyarelistedintheEventsView.Thismeansthatyou’llneedtoselecttherequest,thentheresponse–usingrecordedeventslistedinthewrongorderwillcreateatestwiththemessagesinthewrongorder.
9.4 TheMEPWizard
TheMEPwizardsprovideuswithanotherwayofcreatingtests.RationalIntegrationTesterwilltaketheinformationthatyouhavesuppliedaspartoftheoperationundertestintheLogicalView,andusethattogenerateabasictestorsetoftests.You’llrecallthatwelookedattheMEP(orMessageExchangePattern)earlier–itcontainedinformationaboutthemessageschemasusedbytheoperation,alongwithtransportdetailsforthatoperation.
TheTestusingMEPandTestsusingMEPwizardswillreadthatinformationfromtheMEP,anduseittogenerateinputandoutputmessagesfortheoperation.ForanoperationwithaRequest/ReplyMEP,thiswillcreateatestwithaSendRequestandaReceiveReplyaction;both
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page65of133©IBMCorporation2001,2012
testactionswilltaketheirschemaandtransportinformationfromtheMEP.ThemaindifferencebetweenthetwoisthatcreatingasingletestusingtheMEPwillcreateaSendRequeststepwherethefieldswithinthemessageareallblank;creatingmultipletestswillfillintheinputmessageswithrandomorconstantdata,asselectedwithinthewizard.Inbothcases,theReceiveReplyactionwillcontainamessageusingtheappropriateschema,butallfieldswillbeblank,asRationalIntegrationTesterdoesnotknowhowthesystemismeanttorespondtothefirstmessage.Youcaneithereditthistestaction,orleaveittilllatertorepairintheTestLab–we’llmakeuseofthissecondoptionlater.
9.5 Exercise:CreatingTestswiththeMEPWizard
We’llnowcreateagroupoftestsusingtheTestsusingMEPwizard.
1. IntheTestFactoryperspective,right‐clickontheTestsvirtualfolderundertheMakeBookingoperationandselectNew>TestsusingMEP.Awizardislaunchedthatwillhelpyoucreatemultipleteststovalidateallpossibilitiesfromtheoperation’smessageexchangepattern(MEP).
2. Thefirstpageofthewizardletsyoucontrolthestructureoftherequestmessagesthatwillbegeneratedforeachtest.Youcanalterthatstructurebyselectinghowmanyoccurrencesofeachelementshouldbeincluded.Asthemessageschemaweareusingdoesnotallowforanyoptionalorrepeatingelements,everyelementshouldoccurexactlyonce.Thismeansthatwecanleaveallsettingsattheirdefaultsforthisexample.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page66of133©IBMCorporation2001,2012
3. ClickNext,whichbringsyoutothewizard’ssecondpage.Here,youcancontrolthecontentsofthemessagebyselectingdifferentcontenttypesforeachelementandvaluesforthoseelementsthatdonothaverandomcontentgeneratedforthem.
4. NoticethatIterate EnumisselectedforthePayment:cardTypeelement.Thiswillpromptthewizardtogenerateauniquetestforeachtypeofcreditcardthattheoperationcanprocess(threeinthiscase),whichcanbeverifiedinthenextpageofthewizard.
5. Insteadofallowingcompletelyrandomstringsforallfields,we’regoingtoeditsomeofthem.SettheflightNumberfieldtoaconstant,withavalueofWW100.
6. ForthepriceandweekNumberfields,we’llallowrandomvalues,butwe’llsetsomeconstraints.Inbothcases,we’dliketohavea2digitnumber.SettheTypeforthefieldtoRandomRegex,andtheValueto\d\d
7. Inthefinalscreenofthewizard,gototheWithTestssection,andselectDoNothing.ClickFinishtoclosethewizardandgeneratethetests.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page67of133©IBMCorporation2001,2012
8. Let’stakealookatwhatthiswizarddid.IntheTestFactoryperspective,lookattheTests
virtualfolderundertheMakeBookingoperation.Thewizardcreatedthreenewtests.
9. Double‐clicktoopenoneofthese:paymentcardType = multinational
10. Double‐clicktolookinsidetheSendRequestaction.
11. HereyouseetherequestmessagewhichwillbesentforthistestoftheMakeBookingoperation.Thewizardhascreatedthemessagewiththeexpectedstructureandpopulatedmostfieldsautomaticallywithrandomisedvalues.TheflightNumberfieldshouldbesettoWW100,whiletheweekNumberandpricefieldsshouldbesettorandom2digitnumbers.Similarly,thecardTypefieldshouldbepopulatedwithoneofthethreepossiblecardtypes(adifferentoneineachofthethreegeneratedtests)
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page68of133©IBMCorporation2001,2012
12. Closethiswindowwithoutmakingchanges.
13. OpentheReceiveReplyaction.AtthisstageRationalIntegrationTesterdoesn’tknowmuchabouttheexpectedresponsefromthisrequest.Thismessagestructurehasnotbeenpopulatedyet.
14. Closethiswindow.
9.6 CopyingandLinkingRequirements
Sofar,we’veseenhowwecancreatemessagedatawithinatestbyhand,orfromrandomdata.Inadditiontothis,wecanalsousepreviouslycreatedrequirementstofillinmessagedata.
Indoingthis,wecaneithercopythedatathatisheldwithintherequirement,orlinktotherequirement.Copyingthemessagedatawilloverwritetheinformationinthetestaction;itcanthenbeeditedfurtherasrequired,butanyupdatestotherequirementwillnotbereflectedinsidethetest.Linkingtotherequirementwillalsooverwritethedatainthetestaction,butinthiscase,thetestactionwillalwaysusewhateverdataisheldwithintherequirement.Thismeansthatupdatestotherequirementwillflowthroughtothetestactionaswell.
Tocopyorlinkarequirementtoatestaction,simplydraganddroptherequirementontothetestaction.Youwillthenbepresentedwiththeoptiontocopyorlinktherequirementintothetestaction.Notethatthiswillcopyorlinkallsettingsfromtherequirement,includingtransportsettings.Theonlyexceptionwillbeanytimeout/tolerancevaluesheldwithinthetestaction,whichcanbeeditedseparately.
Alternatively,youcanopenthetestaction,andgototheConfigtab.Abovethetransportand
messagesettingsonthistab,youwillfindtwolink icons.Thesecanbeusedtolinktheheader
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page69of133©IBMCorporation2001,2012
(includingtransportsettings)andthemessagebody;usingthetwoicons,wecanchoosewhatwewanttolink,ratherthanlinkingeverythinginonego.Fromtheseicons,youcanalsochoosetochangealinktouseadifferentrequirement,ortounlinkthemessage.Unlinkingamessagemeansthatthemessagewillthenholdacopyofwhateverwasintherequirementatthetime;futureupdateswillnotflowthroughtothetestactionautomatically.Ifdesired,youcanrelinktotherequirementlateron.
9.7 TestTemplates
Whencreatingnewtests,similarsequencesofactionsmayoftenbeused.Ratherthanrecreatingtheseeverytime,RationalIntegrationTesterprovidestheoptionoftesttemplates,whichcanbeusedtostorethosecommonsequencesforfastreusewhencreatingnewtests.Thesenewtestswillthenhavecopiesoftheactionsusedwithinthetemplate,whichcanbealteredasrequired.
Testtemplatesmaybecreatedinsimilarwaystotests–theycanbecreatedwithoutanytestactions,inthesamewayanemptytestmaybecreated.ItisalsopossibletocreateatemplatebasedontheMEPofanoperation.ThiswillbesimilartocreatingasingletestfromtheMEP–thetemplatewillcontainmessagesbasedontheschemasusedintheMEP,witheachfieldleftblankfortheusertofillin.Aftercreatingthetemplate,itcanthenbeeditedinexactlythesamewayasatest,usingthesamesettingsandtestactions.
Oncethetemplatehasbeensaved,testsmaythenbecreatedbasedonthetemplate.Thiswillcopyallofthepropertiesofthetemplateintoabrandnewtest.Notethatthisissimplyacopy,andanyfurtherupdatestothetemplateafterthattimewillnotautomaticallyflowthroughtothetestscreatedfromthetemplate.However,ifthetemplateuseslinkedrequirements,changestotherequirementswillstillflowthroughtoeachtest,aslongastherequirementsarenotunlinkedinthoseindividualtests.
9.8 Exercise:CreatingaTestfromaTemplate
We’llnowseehowwecanusetemplatesandlinkedrequirementstocreateasetofteststhatmaybeupdatedbyeditingapairofrequirements.Thismeansthatifamessageschemaweretochange,alltestscreatedfromthattemplatecouldbeupdatedsimplybyupdatingtherequirementsusedwithinthetemplate.
1. Testtemplates,liketests,arecreatedforoperations.ReturntotheMakeBookingoperationintheTestFactoryTree.
2. RightclickontheoperationandselectNew>Templates>TestTemplate.CallthetemplatebasicTemplate.
3. Anewemptytemplatewillbeavailabletoedit.Inordertosetthisupquickly,we’regoingtocopythestepsfromtheRegression1test.SelecttheRegression1testintheTestFactoryTree,thendraganddropitontotheTestStepssectionofyourtemplate.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page70of133©IBMCorporation2001,2012
4. ThetemplateshouldnowbepopulatedwiththesametestactionsastheRegression1test.
Saveandclosethetemplate.
5. We’llnowusethetemplatetocreateanewtest.RightclickontheMakeBookingoperation,thenselectNew>Tests>TestFromTemplate.
6. Withinthedialogthatappears,selectthebasicTemplate,andgiveyournewtestaname,suchasexampleFromTemplate.
7. Openthenewtest,andtakealook–itshouldcontainthesameactionsanddataasthetest
template.Youcannoweditthisfurther;forexample,youmightchangesomeofthedatawithintheSendRequestaction.Onceyou’refinished,saveandclosethetest.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page71of133©IBMCorporation2001,2012
10 Test Execution
10.1 TheTestLab
TheTestLaballowsustoexecutetests,testsuites,andstubs,andviewtheirexecutionstatus.AllavailableresourcesareshowintheTestExecutionTree,andcanberunbydoubleclicking,byrightclickingandselectingRun,orbyselectingtheresource,andusingtheRun buttoninthemaintoolbarofRationalIntegrationTester.
TheTaskMonitorwillthenshoweachexecutionofatestresource,showingaprogressbar,andthestatus(pass/fail)oftheresource.SelectingatestexecutionintheTaskMonitorwilldisplaymoreinformationforthattestexecutionintheConsole.Thiswillincludeasummaryofwhathappenedduringthetest,alongwithanylogginginformation.
10.2 Exercise:RunningaTest
1. SwitchtotheTestLabperspective.
2. RuntheRegression1testbyright‐clickingonitandselectingRunfromthecontextmenu,orselectthetestandclickRun inRationalIntegrationTester’smaintoolbar.AgraphicalsummaryoftheexecutionisdisplayedintheTaskMonitor,andadetailedreportofthetest
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page72of133©IBMCorporation2001,2012
resultscanbefoundintheConsole,inthelowerportionofthewindow.Inthiscase,thetestshouldfailbecausethereservationnumberdoesnotmatchwhatisexpected.
3. ClickontheReceiveReplyerrorinredontheConsole.TheViewMessageDifferences
windowpopsuptorevealthedifferenceintheExpectedandReceivedmessages.InthiscasethenewReservationNumberelementsaredifferent.
10.3 Exercise:RepairingTests
TheRegression1testfailedbecauseitdidn’ttakeintoaccountchangingreservationnumbers.We’renowgoingtolookathowwecanfixthetestfromtheTestLabperspective.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page73of133©IBMCorporation2001,2012
1. TheViewMessageDifferenceswindowgivesustheopportunitytocorrectanydiscrepanciesbetweentheexpectedandreceivedmessages.Inthiscase,we’lltrytoupdatethemessagebypressingtheOverwriteexpectedfieldbutton.
2. SelectthetestandclickRunintheTaskMonitortorunthetestagain.
3. Thetestshouldfailagainduetoareservationnumbermismatch.Thereservationnumbersincrementwitheachreservation,soattemptingtouseahardcodedvaluewillnotwork.
4. BringuptheViewMessageDifferenceswindowforthisnewrunofthetest.We’lltrytorepairthetestagain,butthistime,we’llusetheReplacewithregexmatchbuttontousearegexthatwillallowanyreservationnumber.
5. OpenupthetestinTestFactoryperspectiveanddouble‐clicktheReceiveReplystepandnotethatthevalueofthemessagefieldelementnewReservationNumberhasbeenreplacedbyaregularexpression.
6. Re‐runthetestintheTestLab.
7. Thistimethetestpasses.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page74of133©IBMCorporation2001,2012
8. BringuptheMessageDifferenceswindowforthislatestrunoftheRegression1test.Note
thattheregexisnowdisplayedaspartoftheexpectedmessage,allowingthereceivedmessagetopassthetest.
9. ThetestsgeneratedusingtheMEPwizardwillneedtobehandleddifferently,astheyhave
nodatadescribingwhattheexpectedmessageistolooklike.Tostart,runthepaymentcardType = globaltest.Thiswillfail.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page75of133©IBMCorporation2001,2012
10. BringuptheMessageDifferenceswindow.Youwillseethattheexpectedmessageismissingsomeofthefieldsfoundinthereceivedmessage.
11. Therefore,insteadofoverwritingjustasinglefield,chooseOverwriteexpectedmessage.
12. Ifwerunthetestagain,itwillstillfail.Thistime,itwillbeduetothereservationnumbernotmatching,asintheRegression1test.Wecouldrepairthefieldinthesamewaythatwedidpreviously,butwewouldneedtodothesamethingforeachoftheothertestsaswell.Instead,we’llusetheRuleCachetoapplyrepairstomultipletests.
10.4 Exercise:TheRuleCache
Whenvalidationerrorsarerepairedandcachedtherepairmethodissavedasavalidationrule.Theseruleswillbeappliedtothesamefieldfromwhichtheyarecreatedwhenthesameschemaisinuse.RulesaremanagedundertheRuleCacheviewinArchitectureSchool.Existingrulesarelistedontheleftsideoftheview,andtheycanbesortedbynamespaceorpathbyclickingontheappropriatecolumnheading.Thestar intheleftcolumnindicateswhetherornottheruleiscurrentlyenabled ordisabled .
1. RunthepaymentcardType = globaltestagain.Aspredicted,itshouldfailduetothereservationnumber.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page76of133©IBMCorporation2001,2012
2. BringuptheMessageDifferenceswindow,andchecktheboxAddtoRuleCache
3. Makesurethatthereservationnumberfieldisselected,andpresstheReplacewithRegexbutton
4. Youwillbeaskedtoconfirmthatyouwanttoapplythischangeasarule.
5. Afterthis,checkthatyouaresatisfiedwiththeproposedregex,andcarryoutthechangesasnormal.BeforeleavingtheMessageDifferenceswindow,youwillnoticethatastarhasbeenplacednexttoboththeexpectedandreceivedfields.
6. ClosetheMessageDifferenceswindow,andrunthetestagain.Itshouldnowpass.
7. SwitchtotheTestFactoryperspective,andopenthepaymentcardType = globaltest.
8. ViewtheReceiveReplystepofthetest,makingsurethatyouarelookingattheConfigtabofthedialog.Here,wecanseethattheregularexpressionhasbeenapplied,asinthepreviousexercise–butinthiscase,thereisastarnexttotheregularexpression,lettingusknowthataruleexists.
9. ReturntotheTestLabandruntheothertwoteststhatwehaven’tyetrepaired.Youwill
findthattheybothfailatfirst,astheexpectedmessageisincorrect.Thiscanbefixedasinthepreviousexercise.Onceyouhavedonethis,therewillbenoneedtoworryaboutthereservationnumbersanymore–theregularexpressionspecifiedwithintherulewillbeappliedforyouautomatically.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page77of133©IBMCorporation2001,2012
11 Creating and Running a Stub
Astubcanbeusedtosimulateasystemorprocessthatisunavailable.Intheexamplebelow,wewillcreateastubfromtherequest/replyeventsthatwererecordedearlier.Thisstubcanthenbeusedtosimulatethebusinessprocessthatisunavailable.
11.1 Exercise:Creatingastubfromrecordedevents
1. OpentheRecordingStudioperspectiveandclearanypreviouslyrecordedeventsfromtheEventsView.
2. InthelistofEventMonitors,choosetorecordtheMakeBookingoperation.
3. Makesurethatrecordingiscurrentlyswitchedon.
4. GototheTestLabperspectivetorunthepaymentcardType = worldwidetest,thenreturntotheRecordingStudio.
5. ClickonMakeBookingintheEventMonitorstofilteroutanymessagesfromothersources.
6. SelectarequestmessageandthecorrespondingreplymessageintheEventsView.
7. PresstheSavebutton.Thistime,wewillnotbecreatinganyoperations–instead,wewillcreateastub,soselectstubsonthefirstpageofthewizard,andpressNext.
8. Onthesecondpageofthewizard,wehavetheoptionofcreatingseveraldifferenttypesofstub.Asthisfirststubwillbeprettysimple,we’llchoosetoStoredataashardcodedvalues.PressNextonceyou’vedonethis.
9. Thenextpageofthewizardsimplyasksforverificationthatalleventshavebeensortedbythecorrectoperation.AswehavealreadyfilteredmessagesbytheMakeBookingoperation,thisshouldshowtwomessagesfromthatoperation.Ifso,pressNext.
10. Onthefollowingpage,themessageshavebeengroupedintotransactions.Asthereisonlyasinglepairofmessagesforthemoment,theseshouldbothbelistedasasingletransaction.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page78of133©IBMCorporation2001,2012
11. Onthefinalpage,youwillbeabletospecifyanameforthestub.SetthistoSimpleBookingStub,andmakesurethatOpenresourceafterfinishischecked.
12. PressFinishtocreatethestub.RationalIntegrationTestershouldthenswitchtotheTestFactoryperspective.
13. Wecannowtakealookatthestubwe’vecreated.IntheTransitionssection,wehavealistoftheeventsthatthestubwillrespondto.ThestubwehavecreatedonlyknowshowtorespondtoeventsforMakeBooking.
14. Belowthis,wecanseethemessageswerecordedpreviously,intheInputandOutputtabs.
15. Bydefault,thestubwillattempttofilteroutanythingthatdoesn’texactlymatchthedefaultmessagethatwereceived.Inthosecases,itwillnotsendaresponsemessage.Forourexample,we’dliketorespondtoanythingthatmatchesthesamemessagestructure;itmayormaynothavethesamevalueswithinthemessagefields.Thiswillmakeourstubabitmoreversatile.Togetstarted,switchtotheInputtab,andtakealookatthemessagebody.Youwillseethateachfieldhasasmallfiltericonnexttoit:
16. Wewanttoswitchoffanyfilteringthatischeckingforanexactfieldmatch.TheDoesExist
filterswon’tmatter,aslongasthebasicmessagestructureisthesame.Toswitchofffilteringfortheexactmatches,selectallofthefieldswithinthemessage(youmayneedtoscrolldowntodothis).Witheverythingselected,rightclickandchooseContents>FieldActions>Filter>Equality.Thiswilltoggletheequalitychecksoff,andthemessagebodyshouldthenappearwithfewerfiltericons,likeso:
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page79of133©IBMCorporation2001,2012
17. Theremainingfiltersaresimplycheckingthateachpartofthestructureofthereceived
messageisthesameaswhatweseehere.Thisisfine,asthereisonlyonevalidmessagestructureaccordingtotheschema.SwitchtotheOutputtab,andtakenoteofthereservationnumberthatwillbesentbythestub.Youshouldseethisagaininthefollowingexercise.
18. Saveyourstub–it’snowreadytobeexecuted.
11.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.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page80of133©IBMCorporation2001,2012
5. ReturntoRationalIntegrationTester,andswitchtotheTestLabperspective.
6. You’llstillseeyourstubinthetreeonthelefthandsideofthescreen.Runthestub,eitherbydoubleclickingonit,orbyselectingitandpressingtheRunbutton.
7. ThestubwillthenappearintheTaskMonitor.Someinitialdetailswillappeardownbelow,intheConsole.Thiswillbeupdatedlateron,asthestubreceivesincomingmessages,andrespondstothem.
8. Asitstands,thestubwillnowwaituntilitreceivessomeinput,solet’sprovidesomethingforittoworkwith.Youcaneitherdothisbymakinganewbookinginyourwebbrowser,orbyrunningatestfortheMakeBookingoperation.
9. IntheTestLabofRationalIntegrationTester,takealookattheconsoleoutputforyourstub.Youshouldnowseethatthestubhasreceivedamessage,andsentareply.
10. Ifyoumakeanotherbooking,youshouldseethatyouarereceivingthesamebooking
numbereverytime.Asweturnedoffthefilteringofmessageswithinthestub,itshouldn’tmakeanydifferencewhatbookingrequestwesendtothestub;wejustneedtobeusingthesamemessagestructure.
11.3 Exercise:Modifyingthestubonthefly
Astubcanbemodifiedasitisbeingexecuted.Simplymakeyourmodifications,savethestub,andRationalIntegrationTesterwillautomaticallyshutdowntheoldversionofthestub,andstartupthenewversion.Asasimpleexample,we’llnowupdateourstubtosendadifferentreservationnumbertotheuser.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page81of133©IBMCorporation2001,2012
1. WithinRationalIntegrationTester,returntotheTestFactoryperspective.
2. EdittheSimpleBookingStub,andgototheOutputtab.
3. Changethereservationnumbertosomethingdifferent–forexample,A01234.
4. Savethestub.RationalIntegrationTesterwilloffertoupdatetherunningstub.ChooseYes.
5. SwitchtotheTestLabperspective.
6. YoushouldseeintheTaskMonitorthatthestubhasautomaticallybeenstopped,andstartedagain:
7. Makeanotherbookinginyourwebbrowser–itshouldnowgiveyouthenewreservation
numberyouhaveentered.
8. Aswe’renowfinishedusingthisstub,we’llswitchbacktothelivesystem.WithintheTest
LabofRationalIntegrationTester,selectthecurrentlyrunningversionofthestubintheTaskMonitor(itwillbetheonewithaStatusofReady).
9. TheStop buttonintheTaskMonitortoolbarwillnowbeavailable–pressittostopthestub.
10. We’llnowwanttorestartthebookingserviceonWebSphereApplicationServer,soreturntoyourwebbrowser,andgobacktotheconsoleinterface.Ifyouclosedthebrowserpreviously,navigatebacktothelistofapplicationsagain.
11. Selectthecom.wwtravel.booking.appapplicationbycheckingtheboxnexttoitsname,andStartit.Allservicesshouldberunning,asshownbelow:
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page82of133©IBMCorporation2001,2012
12. Ifyoumakeanyfurtherbookings,youshouldnownoticethatyouarereceivingnew
reservationnumbersagaineachtimeyoumakearequest.
Itwouldbepossibletocreateamorecomplexstubwhichgeneratednewreservationnumbersforeachbooking.Thiswouldrequireuseofmorecomplexactionswithinthestub.Notethatthismayormaynotbenecessary,dependingonwhatyouintendtodowiththestub.Ifallyourequiretogetbackfromthestubisareservationnumber–anyreservationnumber–thentheremaynotbeanypointindevelopingthestubfurther.Ifyourequiremorecomplexbehavior,thenyouwillwanttodevelopthestubfurther.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page83of133©IBMCorporation2001,2012
12 Test Automation
12.1 TestSuites
Sofar,wehaverunallofourtestsandstubsmanually.Thisisfinewhilewearedevelopingtheseresources,butwhenwewanttorunlargenumbersoftests,thiswillnotscaleverywell.Wewillnowlookatautomatingourtests,whichwillinvolvetwotasks–theautomationitself,aswellasreportingtheresultsoftheseautomatedtests.
Atestsuiteisaresourcetypeprovidingamethodofaggregatingtestsand/orothertestsuites,whichcanberuninseriesorinparallel.Eachtestsuiteismadeupofoneormorescenarios;eachscenariomaycontaintests,performancetests,testsuites,andotherscenarios.
Eachscenarioprovidesconfigurationinformationfortheresourcesinsideit–whichenvironmenttouse,thetimingofthetests(inparallel,orspacedout),andwhatstubsshouldbeexecutingwhilethescenarioisactive.Formoreadvancedtestsuites,scenariosalsoprovidetheabilitytodatadrivethetestswithinthem,andtouseprobes(whereaperformancetestlicenseisavailable).
Inaddition,scenarioscanchoosetoterminateorcontinuewhenaresourcefails–thisallowssmoketeststobecarriedoutwherenecessary,butalsoforlargertestsuitestocontinuewhenalltestresultsarerequired.
12.2 Exercise:CreatingandExecutingaTestSuite
1. SwitchtotheTestFactoryperspective.
2. Right‐clickontheMakeBookingoperationandselectNew>Tests>TestSuite.
3. Youwillthenneedtoprovideasuitablenameforthesuite.CallitMakeBookingSuiteandclickOKtoproceed.
4. Thenewsuiteappearswithanewscenario,whichisopenedinitsowntabintheTest
Factory.Double‐clickonthescenarioicon.
5. Youcannowviewthescenariosettings.YoushouldnoticethattheEnvironmentsettingis<Undefined>‐thismeansitwillusethecurrentenvironment.ClickOKtoclosethescenariosettings.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page84of133©IBMCorporation2001,2012
6. Addthe3paymentcardteststhatwecreatedearlier.Thiscanbedoneeitherby
a. draggingthemfromtheTestsvirtualfolderunderMakeBookingoperationanddroppingthemunderthenewscenario,or
b. byclickingtheAddTestsbuttononthetoolbarabovethenewscenarioandselectingtheteststhatwerejustcreated
7. SavethenewsuitebyselectingFile>Save,orclickingtheSavebuttoninRational
IntegrationTester’smaintoolbar.
8. RunthesuitebyclickingRuninRationalIntegrationTester’smaintoolbarorbyright‐clickingthesuiteandselectingRunfromthecontextmenu
9. ThesuiteisopenedandexecutedintheTestLab.AgraphicalsummaryoftheexecutionisdisplayedintheTaskMonitor,andadetailedreportofeachiteminthesuitecanbefoundintheConsole,inthelowerportionofthewindow.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page85of133©IBMCorporation2001,2012
12.3 ResultsGallery
Whenatestsuiteisexecuted,resultswillberecordedintotheprojectdatabase,providedonehasbeensetuppreviously.TheseresultsmaythenbeviewedfromwithintheResultsGallery.
Resultsareviewedforeachresource.Theresourcetypeandnamecanbeselectedalongthetopoftheperspective,alongwiththeinstancetobedisplayed(foratestsuiteonly).Theinstancesaresortedbythetimeanddateofexecutionofthetestsuite,andarenamed–thedefaultnameistheenvironmentitwasrunin,butthiscanbechanged,aswewillseelater.
Belowthat,wecanseeanexecutionsummaryforthecurrentlyselectedtestresource–foratestsuite,thismeansthestatusofeachtestinsidethesuite.Forasingletest,thiswilldisplayasummaryofeverytimethatthetestwasexecutedandrecordedintothedatabase,rememberingthatbydefault,testsareonlyrecordedintotheprojectdatabaseaspartofatestsuiteortestcycle.
Atthebottomoftheperspective,wewillseethevariousreportsthatareavailable.Differentreportswillbeavailable,dependingontheresourcethatisselectedabove,andtheconfigurationofthesystemundertest:
TheReportstabdisplaysasummarizedreportfortheselectedtestortestsuite.
TheConsoletabdisplaystheconsoleoutputfortheselectedtest.
TheNotestaballowsyoutoannotateresults,updatingtheprojectdatabase.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page86of133©IBMCorporation2001,2012
TheSCACoverage,TibcoBWCoverage,andwebMethodsCoveragetabssupplycoveragereportsfortestsuitesrunagainstenvironmentswithanOracleSCADomain,TibcoBusinessWorks,orwebMethodsIntegrationServer.
TheTibcoBWErrorsandwebMethodsErrorstabssupplyinformationonanyerrorsloggedbyTibcoBusinessWorksorawebMethodsIntegrationServerduringtheexecutionofatestsuite.
TheTibcoBWPerformanceandwebMethodsPerformancetabssupplybasicperformancedatatakenfromTibcoBusinessWorksorawebMethodsIntegrationServerduringtheexecutionofatestsuite.
12.4 Exercise:ViewingResults
1. OpentheResultsGalleryperspective.TheResultsGallerycontainsallofthehistoricaldataforthetestsuitesinyourproject,lettingyouviewtheresultsofanysuiteandanyinstanceofthatsuite
2. Inthetophalfofthescreen,youshouldseeresultsfortheMakeBookingSuitedisplayed.Ifyoudonot,selectSuiteinthedropdownatthetopleft.YoucanthenpresstheBrowsebuttontoselecttheMakeBookingSuite.Ifyouhaverunthetestsuitemultipletimes,youwillbeabletochoosebetweentheseusingthedropdownmenuatthetopright.
3. Onceyou’vegottheMakeBookingSuiteselected,takealookattheResourcecolumninthesummarypane.Thiswilllistthescenario,alongwitheachoftheteststhatwerecontainedinsidethatscenario.SelecttheScenario,andtheReportstabatthebottomofthescreenshoulddisplayasummaryofresultsforthescenario,statingthatallthreeofyourtestshaveastatusofPassed.
4. Ifyouselectoneofthetestsinthesummarypane,theReportstabwillupdatetoshowa
reportdetailingwhattookplaceduringthetest.Scrollthroughthis–youshouldseetheteststepsthatwereexecuted,alongwiththemessagesthatweresentandreceived.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page87of133©IBMCorporation2001,2012
5. Whilekeepingthetestselected,switchtotheConsoletab.Youwillnowbeabletoseetheconsoleinformationthatwasreportedduringthetest.YoucanclickonanyofthelinksinheretobringuptheMessageDifferencingWindow,asintheConsoleintheTestLab.
6. Next,switchtotheNotestab.Here,wecanedittheLabelusedforthetestrun.SetthistoInitial Run,andpressSave.YoushouldthenseethelabelusedintheInstancedropdownatthetoprightupdatetoshowInitial Run,ratherthanLocal.
7. YoucanalsoaddextrainformationintheNotessection–typeinsomeextrainformationhere,andpressSaveagain.
8. Finally,viewtheresultsfortheothertests.Youmayalsoliketorunthetestsuiteagain;this
willgiveyoumultipleinstancestochoosefromtheInstancesdropdowninthetoprightcorner.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page88of133©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.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page89of133©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.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page90of133©IBMCorporation2001,2012
Fromthistab,youcanedittagsforthecurrentenvironment:
New…createsanewtagwithinthecurrentenvironment,allowingyoutosetavalueanddescriptionwithinthatenvironment.Thetagisalsocreatedwithinallotherenvironments,butisnotassignedavalueoradescriptioninanyotherenvironment.
Edit…bringsupadialogwhichallowsyoutoeditthevalueanddescriptionofthecurrentlyselectedtagwithinthecurrentenvironment.Doubleclickingthetagwillbringupthesamedialog.
Clearresetsthevalueanddescriptionofthetagwithinthecurrentenvironment,leavingthemundefined.
Deleteremovesthetagfromallenvironments.
Ifatagdoesnothaveavalueordescriptionwithinanenvironment,itwillbelistedinhereas#undefined?,andwilltakeitsvalue/descriptionfromtheDefaultProperties,asdiscussedpreviously.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page91of133©IBMCorporation2001,2012
Newtesttagsneedtobecreatedwithinindividualtestsorstubs.Forthemostpart,theywillbecreatedfromtheTagDataStore,butcanalsobecreatedwithincertaintestactions:
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:TestingwithTags
1. GototheTestFactory,andcreateanewtestbasedonthebasicTemplatewecreatedearlier.CallittagTest.
2. We’regoingtoaddanothersteptothetest,tologthenameofthetest,andtheenvironmentbeingused.RightclickontheTestSteps,andselectNew>Flow>Log.
3. AnewLogstepshouldappearinyourtest.DraganddropthisstepsothatitappearsasthefirstoftheTestSteps.
4. DoubleclicktheLogactiontoeditit.
5. IntheOutputMessage,rightclickandselectInsertTag>TEST>NAME.Youshouldseethetext%%TEST/NAME%%appearintheOutputmessage.
6. PressEntertoaddanewline.Rightclickagain,andselectInsertTag>ENVIRONMENT>NAME.Similarly,youshouldsee%%ENVIRONMENT/NAME%%appear.
7. The%%signsdesignateatag,andthispartofthetextwillbereplacedwhenweruntheLogaction.However,wecanalsoaddsomeextratext.Addsomecontextsothatyouknowwhatisbeingloggedlateron.Forexample:
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page92of133©IBMCorporation2001,2012
8. RunthetestintheTestLabview,andwatchtheconsole–youshouldseethenamesofthe
testandenvironment.
9. Tagscanalsobeusedtorecordinputsandoutputsforteststeps.Asabasicexample,we’regoingtologthereservationnumberreturnedbythesystem.Todothis,returntotheTestFactoryperspective,andopentheReceiveReplystep.
10. TheReceiveReplypropertieswillopenup–switchtotheStoretab.Thisiswherewecanconfigurewhichdatafieldswillberequiredforlateruse.
11. Atthebottomofthedialog,findthenewReservationNumberfield.Rightclickonit,andselectContents>QuickTag.Atagnameshouldappearinthe column,andthecheckboxinthe columnshouldbeticked.Notethatthesecolumnscanalsobefilledinmanually,ifyourequireaparticularnameforafield.
12. PressOKtoclosetheReceiveReplystep,andaddanotherLogsteptotheendoftheTestActions.ThecontentsofthisLogactionshouldbe:Reservation Number: %%newReservationNumber%%
Youcaneithertypethisindirectly,orusethesamemethodusedforthepreviouslogaction.
13. Savethetestandrunitagain.Theconsoleoutputshouldnowincludethereservationnumberthatwasgeneratedbythebookingprocess.
13.5 DataSources
Sofar,allofthedatathatwehaveusedwithinourtestshaseitherbeenhardcoded,orhasbeentakenfrominteractingwithmessagesorpre‐definedtags.However,itisstandardpracticewhentestingtouseexternaldatatoprovideinputs,ortohelpvalidateoutputs.Inordertoaccessthisdata,wewillneedtoaddaDataSourcetoourproject.TheDataSourcemaythenbeusedtoaccessthisexternaldataforthepurposeofdatadrivinganytestorstub.
Thereare4typesofdatasourcesupportedbyRationalIntegrationTester.Eachoneishandledseparatelywithinaproject,toaccountforconfigurationsettingsthatwillvaryfromdatasourcetodatasource.Thedatasourcesareasfollows:
FileDataSource–readsdatafromanindividualfile.ThismaybesomethinglikeaCSVfile,fixedwidth,orotherdelimitedfile.
ExcelDataSource–readsdatafromasheetinanExcelspreadsheet.
DatabaseDataSource–readsdatafromatableinadatabase,ortheresultsofaqueryonadatabase.ThedatabasemustbesetupinArchitectureSchoolbeforethisdatasourcemaybecreated.
DirectoryDataSource–readsinasetoffiles(forexample,asetofXMLdocuments).
13.6 Exercise:DataDrivenTesting
Inthissection,youwillgenerateaspreadsheetfromanexistingtest,andusethattodrivemultipleiterationsofthetestwithdifferentdata.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page93of133©IBMCorporation2001,2012
1. ReturntotheTestFactoryview,andcreateanewtestusingthebasicTemplatetesttemplate.CallitdataDrivenTest.
2. OpenthedataDrivenTest,andbringupthepropertiesfortheSendRequeststepofthetest.
3. GototheConfigtabofthetestaction.
4. Clickonthetns:flightNumber (Text)field,thenuseCtrl+clicktoselecteachofthefollowing(Text)fields,downtotns:passengerGender.Donotselectthe(Element)fields,orlaterstagesoftheexercisewillfail.
5. RightclickandselectContents>QuickTag.Themessagestructureshouldnowappearasbelow,withtagscreatedforeachoftheselectedfields:
6. Closethetestaction,andSavethetest.
7. Fromthetestactiontoolbar,presstheEditorcreatetestdata button.
8. IntheCreateoredittestdatadialogthatappears,therearesettingsforthelocationoftheExcelFileonthefilesystem,andtheTestDataSetwithintheproject.TheTestDataSetshouldbeunderMakeBooking,sothatit’swiththetest,buttheExcelFilesettingswillbeblank.PresstheBrowsebuttonforthatfieldtochoosealocation.
9. Anexplorerwindowwillappear,pointingtoafolderwithinyourRationalIntegrationTesterproject.We’llusethislocation,asitmeansthatwecaneasilymovetheentireproject,andanylinkstothisfilecanstaythesame.EnterafilenameofPassengerData.xls,andpressSelect.ThenameandlocationoftheexcelfilewillthenappearwithintheCreateoredittestdatadialog,usingasystemtagtorefertothelocationofthefile.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page94of133©IBMCorporation2001,2012
10. Next,we’llneedtoselectthetagswe’dliketouse,sopresstheSelectTestDataColumnsbutton.
11. ASelectTagswindowwillappear–dragtoselectallofthetagsthatarelistedthere,thenpressSelect.
12. IntheActionsectionofthedialog,choosetoUsethistestdatainanewactionoftype
IterateTestDataandinsertafterTestSteps.
13. MakesurethattheboxlabeledEditExceldataonOKischecked.Thedialogboxshouldnowlooklikethefollowing:
14. PressFinish.LibreOfficewilllaunch,displayingthespreadsheetthathasbeencreated.The
firstrowofthespreadsheetwillcontainsheadingsthatmatchthetagnamesfromthedatasource.Thesecondrowofthespreadsheetshouldcontainthevaluesthatwereintheoriginalmessagebeforewetaggedthefields.Thisisduetotwothings:firstly,whenwecreatedthetags,thedefaultvalueofeachonewassetasthevaluesgiveninsidethemessage
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page95of133©IBMCorporation2001,2012
wequicktagged.Secondly,thespreadsheetgeneratedusedthosedefaultvaluesofeachtagasthefirstrowofdata.
15. Inadditiontothisrowofdata,add3morerowsofpassengerinformation,thensavethedocumentandcloseLibreOffice.
16. ReturntoRationalIntegrationTester.IntheTestFactoryTree,thereshouldnowbeaTestDatasetcalledPassengerData.Openthis,sowecanvalidatethateverythinghasbeensetupcorrectly.
17. TheFileNameshouldpointtowardsthesamelocationthatwesawinthewizard.TheSheetnamewillbeblank–thisisfine,asthedefaultsettingistousethefirstsheetintheworkbook.UndertheFormatConfigurationsection,Arowofthefilecontainscolumnnamesshouldbechecked,with0rowsbeforeandafterthecolumnnames.Checkthatthisiscorrect,thenpresstheRefreshbuttonatthebottomofthescreen.Youshouldnowseethedatathatyouenteredintothespreadsheet.
18. ClosethePassengerDatadatasource,andreturntothedataDrivenTest.
19. Thisshouldhavethreetestactions–anIterateTestData,aSendRequest,andaReceiveReply.Tomakesurethatwesendarequestandreceiveareplyforeachlineofdata,draganddroptheSendRequestandReceiveReplyactionsontotheIterateTestDataaction.Yourtestshouldnowlooklikethefollowingimage:
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page96of133©IBMCorporation2001,2012
20. SavetheDataDrivenTest.ReturntotheTestLabperspective,andrunthetest.YoushouldseeaSendRequestandaReceiveReplylineintheconsoleforeachrowofdatainyourspreadsheet.
Note:WheneverchangesaremadetothetestdatasourcefromwithinRationalIntegrationTester(forexample,thefilename),thetestdatasourcewillneedtobesaved.Untilyousavethedatasource,otherpartsofRationalIntegrationTesterwillnotknowaboutthosechanges–sointhisexercise,forexample,theIterateTestDataactionwillnotbeawareofchangestothechosensheetnameifyoudonotsavethedatasourcefirst.NotethatthisonlyappliestoconfigurationsettingscontrolledinsideRationalIntegrationTester–youdonotneedtosavethedatasourceagainifanextracolumnisaddedtothedatasource,forexample.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page97of133©IBMCorporation2001,2012
14 Repeating Elements
14.1 Overview
ThisexamplelooksathowmessagescontainingrepeatingandoptionalelementsmaybehandledwithRationalIntegrationTester;inparticular,howtodatadrivetestscontainingsuchmessages.Fortheexample,XMLmessageswillbesentandreceivedoverMQ,butthestepswillbemuchthesameforothertechnologies.
Considertheorder.xsdexample(includedintheRepeating Elementsfolder)thatisusedtocreatemessagesforpublishingandvalidating.
TheXMLSchemacontainsanitemelementthatcanberepeatedmultipletimesinthemessage.
<xs:element name="item" maxOccurs="unbounded" type="itemtype"/>
Withintheitemelement,thereisanotherrepeatingdiscountcodeelementwhichisalsooptionalandsomaynotbeneeded.
<xs:element name="discountcode" type="stringtype" minOccurs="0" maxOccurs="unbounded" />
Finally,theremayalsobemultipleaddresselementswithinamessage:
<xs:element name="address" maxOccurs="unbounded" type="addresstype" />
WhenmatchedwiththeOrderTestData.xlstestdatawegetthefiveordersspecifiedbelow.WithouttheRepeatingElementsfunctionalityauserwouldmanuallyneedtocreatefivetests.Thisfunctionalityallowstheusertodefineasinglemessagethatmakesuseofrepeatingelementstodynamicallybuildthemessagefromthetestdatasetandtimeofpublishingorsubscribing.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page98of133©IBMCorporation2001,2012
ExpectedXMLMessages1‐5
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page99of133©IBMCorporation2001,2012
14.2 Exercise:PublishingaSetofOrders
1. InArchitectureSchool,createaServiceComponentobjectcalledOrdersandincludeanoperationinitcalledPublishOrders
2. Double‐clickonthePublishOrdersoperationtobringupitspropertiesandgototheMessageExchangePatterntab.
3. IntheBindingsection,Browsetoselectatransport,andchooseWWTravel_MQ.
4. IntheQueuesection,enterqueue.orders,thenpressOKtoclosethedialog.
5. NownavigatetotheSchemaLibraryandimportanewXSD .SelectthesuppliedXMLschema,order.xsd,whichcanbefoundintheData Files\Repeating Elementsfolderonyourdesktop.
6. Afterimporting,selectXSDsonthelefthandsideoftheSchemaLibrary–youshouldnowbeabletoviewtheorderschema.
7. Optionally,youcanreturntothePublishOrdersoperationtosettheMessageExchange
PatterntoPublish,andtousetheschemayouhavejustimported;wewillnotbemakinguseoftheMEPinthisexercise,butifyouwishtocreateothertestsusingMEP,thiswillbeuseful.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page100of133©IBMCorporation2001,2012
8. Otherwise,switchtotheTestFactory.Wewillnowcreateadatasourcetoimportourdata.Right‐clickonthePublishOrdersoperationandselectNew>TestData>ExcelDataSource.CallthedatasourceOrderData.
9. Intheconfigurationpane,pressBrowseandfindtheOrderTestData.xlsfilefoundintheRepeating Elementsfolder.Followingthat,checktheboxlabeledTreatemptystringsasnull.Thiswillallowthetooltogroupnesteddatacorrectly.AfterpressingtheRefreshbutton,youshouldseethefollowingdatainthePreviewpane:
10. Savethedatasource,andthencloseit.
11. Wewillnowcreateatesttoprocessthisdata.Right‐clickonthePublishOrdersoperationandselectNew>Tests>Test.CallitTestOrders.
12. AddanIterateTestDataactiontotheTestSteps.Create,thendraganddropaPublishaction,followedbyaSubscribeactionandthenaLogactionontotheIterateTestDataaction.Yourtestshouldlooklikethefollowing:
13. Double‐clickonthePublishactionandconfigureit:
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page101of133©IBMCorporation2001,2012
o SelectWWTravel_MQastheTransport
o IntheQueuesetting,enterqueue.orders
o LookundertheMQ Message (Message)node–thereshouldbeatext(String)underneathit.Ifthereisnot,rightclickonthenode,andselectAddChild>Choice>text(String)toaddthetextnode.PressOKinthedialogthatappearstoconfirmyourchoice.
o Right‐clickonthenewtext(String)nodeandselectSchema.Choosetheorderschema,andclickNext.
o ChecktheboxlabeledIncludeoptionalfields,andthenclickFinish.
o Youshouldnowseethemessageschemaappliedtoyourmessage.SelectthenQuicktagallthetextnodeswithinthemessage,alongwiththeorderidattribute.
o Right‐clickontheitem(Element)nodeandselectMarkasRepeating.
o DothesameforthediscountCode(Element)nodeandtheaddress (Element)node.
o Checkthatthetestactionnowappearsasbelow,thenpressOKtosaveyourchanges:
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page102of133©IBMCorporation2001,2012
14. Next,we’llconfiguretheSubscribeactiontoretrievethemessagethatwe’vejustsent,andholdtheentireXMLmessageinasingletag.OpenuptheSubscribeactionandconfigureitasfollows:
o Usethesametransportsettingsasthepublishaction(receivingamessagefromWWTravel_MQ,usingqueue.orders)
o Disablevalidationonthetext(String)partofthemessage.
o SwitchtotheStoretab,andsavethevalueoftheincomingmessagebyquicktaggingthetext(String)field.
o ClickOKtoclosethetestaction.
15. OpentheLogaction,add%%text%%asthetextmessage,thenclosethetestaction.
16. WenowhavetomapthetestdatatothetagsdefinedinthePublishaction.Double‐clickontheIterateTestDataactiontoconfigureit:
o IntheConfigtab,BrowsetotheOrderDatafortheTestdataset.
o IntheGroupdatabycolumnfieldselectid.
o SwitchtotheStoretabandcheckthateachfieldintheTagnamecolumnhasbeen
mappedappropriatelytotheincomingData.Thisshouldhavebeendoneforyouautomatically,butifyoudidnothavethetagsinthetestpriortosettingthedatasourceforthistestaction,itwouldnotbedoneforyou;similarly,ifyoudidnotsavethedatasourceearlier,thismappingwillnothavetakenplace.
o ClosetheIterateTestDataaction.
17. Savethetest,andrunitintheTestLab.
18. Youshouldseethetestpassandintheconsoleyoushouldseefiveordermessages,correspondingtothemessagesdescribedpreviously.Asanexample,thefinalmessageisshownbelow:
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page103of133©IBMCorporation2001,2012
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page104of133©IBMCorporation2001,2012
15 Test Actions
Testactionsarethemainbuildingblocksofourtests.Sofar,wehaveseenjustacoupleoftheactionsthatareavailabletous.Overthecourseofthenextcoupleofchapters,wewilllookatanumberoftheotheractionsavailableinRationalIntegrationTester.
15.1 TestActionSummary
ThefollowingtablesdescribethemajorityofthetestactionsusedwithinRationalIntegrationTester.ThetestactionsinRationalIntegrationTesterarecategorizedinto5groups,asseeninthetoolbaralongthetopofthetestfactory.ThesegroupsareMessaging,Flow,General,BPM,andPerformance.AsthismanualdoesnotdealwithBPMorPerformanceactions,thesummaryhasbeenlimitedtothefirstthreecategories.
MessagingActions
SendRequest:Sendamessageandwaitforaresponse
ReceiveReply:Receiveandvalidatearesponsetoarequest
ReceiveRequest:Chooseatransportandformattoreceiveamessage
SendReply:Respondtoapreviouslyreceivedrequestmessage
Publish:Publishamessageonatransport
Subscribe:Startlisteningformessagesonatransport
Unsubscribe:Stoplisteningformessagesonatransport
MessageSwitch:ConfigureasubscribertopickupamessagethatcanbepassedtothechildMessageCaseactions.
MessageCase:FilterthemessagereceivedbytheparentMessageSwitch.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page105of133©IBMCorporation2001,2012
FlowActions
Assert:Checkthatagivenconditionissatisfiedbeforetherestoftheteststepscanbeexecuted.
Decision:Chooseasetofactionsbasedonagivencondition.
Pass:Automaticallypassthetest.NosubsequentactionswithintheTestStepsphasewillbeexecuted.
Fail:Automaticallyfailthetest.NosubsequentactionswithintheTestStepsphasewillbeexecuted.
RunTest:Executeanothertestasasub‐test.
Sleep:Pausethetestforaspecifiedperiodoftime.
Iterate:Repeatteststepsanumberoftimes.
IterateWhile:Repeatteststepswhileaconditionissatisfied.
IterateTestData:Repeatteststepsforagivendataset.
FetchTestData:Retrievearowoftestdatafromadataset.
LookupTestData:Lookuptestdatafromadataset;Testactionswillbranch,dependentonwhetherthelookupissuccessful.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page106of133©IBMCorporation2001,2012
GeneralActions
Comment:Addnotestothetest
RunCommand:Specifyacommandorprogramtorun
Log:Outputmessagestotheconsole/loggingfile
UserInteraction:Asktheusertointeractwiththetestasitruns.
GUIInteraction:InteractwithfunctionaltestingtoolsintegratedwithRationalIntegrationTester
Map:TransformsXML‐baseddatausinganXSLTStylesheet.
CompareFiles:Comparestwologicalfilesources(bothofwhichmaybedirectories)containingrecorddata.
Function:Executeapredefinedorcustomfunction
SQLQuery:ExecuteanSQLSELECTagainstadatabase
SQLCommand:ExecuteSQLUPDATE/INSERT/DELETEagainstadatabase
StoredProcedure:Executeastoredprocedureagainstadatabase
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page107of133©IBMCorporation2001,2012
15.2 Exercise:RunCommand
TheRunCommandactiongivesallofthefunctionalityoftheWindowsCommandPromptinsideRationalIntegrationTester.Thisallowsyoutorunexternalbatchfilesandexecutablesorstoretheresultsofcommandsintags.
1. Toillustratethisfunctionalitywe’llcreateatestthatopensaNotepadwindow.
2. GototheTestFactoryperspectiveandcreateanewblanktest–callitRunCommand.
3. IntheTestSteps,right‐clickandselectNew>General>Run.
4. Double‐clicktoconfiguretheRuncommand.
5. ChecktheConnectionsettings.TheLocationshouldbesettoLocal,andtheWorkingDirectorycanbeleftblank.
6. We’lljuststartanewNotepadwindow,soenterthecommand:
notepad.exe
7. UnchecktheoptionWaitforcommandexecutiontofinish.
8. PresstheTestbuttontoexecutethecommand–anewnotepadwindowshouldappear.You
cansafelyclosethisstraightaway.
9. ClickOKtoclosethedialog,andswitchtotheTestLab.
10. Whenyourunthetest,itshouldpassandanotepadwindowshouldappearagain.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page108of133©IBMCorporation2001,2012
15.3 Exercise:Log
TheLogactionwritesinformationtotheconsole,oralogfile.Taggeddatacanbeincludedwithinthisinformation.WehavealreadyencounteredtheLogactionpreviously,butthistimewewilluseittowritetoanoutputfile.
1. InWindowsExplorer,createanewblankfilecalledreservationData.csv.Addonelineatthebeginning,whichshouldsimplygivecolumnnamesforourdata:
ReservationNo,FirstName,LastName
2. Savethefileandcloseit.
3. InRationalIntegrationTester’sTestFactory,createanewtestbasedonbasicTemplate,andcallit checkForDuplicates.
4. Sothatwehavesomethinginterestingtolog,we’lltagsomeofthedataintherequestandreplymessages.OpentheSendRequestaction,andgototheStoretab.Findthepassengerfirstandlastnamefields,andQuickTagbothofthem.ClosetheSendRequestaction.
5. Similarly,tagthenewReservationNumberfieldwithintheReceiveReplyaction.
6. AftertheSendRequestandReceiveReplyactions,addanewLogaction,andopenit.
7. WithintheOutputMessagefield,addeachofthetagswe’vecreated,separatedbycommas.Addanewlinebeforethetags,sothattheLogactionwilladdanewlinetothefilebeforeeachrowofdata.TheLogactionwilldoexactlywhatyoutellittodo,soifyouleaveoutthenewline,you’llendupwithonelongrowofdatathatwewon’tbeabletoprocessinRationalIntegrationTester.Youshouldendupwithsomethinglikethefollowing:
8. SettheoutputfiletothereservationData.csvfilecreatedatthebeginningofthisexercise.
9. MakesurethattheAppendcheckboxisticked.Thiswillmakesurethatweaddnewloginformationtotheendofthefile,ratherthanoverwritinganypreviouscontents.
10. TheRolefieldshouldbesettoInfobydefault–checkthatthisisthecase.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page109of133©IBMCorporation2001,2012
11. ClosetheLogaction,andrunthetestintheTestLab.
12. OpenthereservationData.csvfiletoverifythatithasthedetailsofthecustomerfromthetestwe’vejustrun,andthenclosethefilewithoutmakinganychanges.
13. GobacktotheLogactionintheTestFactory,andchangetheRoletoError.Observewhathappenswhenyourunthetest.
14. ChangetheLogactionagaintouseaRoleofWarning,andobservewhathappenstothetestwhenyouexecuteitthistime.
15. GobacktotheLogactiononelasttime,andchangetheRolebacktoInfo.
15.4 Exercise:LookupTestData
TheLookupTestDataactionwilllookupinformationfromadatasource,basedonakeyfield.We’regoingtouseittomakesurethatthatoursystemisnotcreatingduplicatereservationnumbers.
1. Inordertolookupanyinformation,wewillrequireadatasource.WhileintheTestFactory,rightclickontheMakeBookingoperation,andselectNew>TestData>FileDataSource.CallitReservationLog.
2. Asthefilesource,choosethereservationData.csvfilewecreatedinthepreviousexercise.ThefiletypeshouldbesetasDelimited.
3. IntheFormatOptions,theDelimiterOptionsshouldbesettoComma.
4. PresstheRefreshbuttonatthebottomofthescreentocheckthatthefilehasbeenloadedcorrectly.Youshouldseethesamedatayouloggedinthepreviousexercise.
5. SavetheReservationLogtestdatasourceandcloseit.
6. SwitchbacktothecheckForDuplicates test.AddaLookupTestData actiontothetest,andopenit.
7. OntheConfigtab,choosetoBrowseforthedataset,andselecttheReservationLogdata.
8. Youwillneedtoaddalookup,usingaColumnKeyofReservationNo,andaLookupValueof%%newReservationNumber%%.Closethetestaction.
9. Whenweperformthislookup,weexpectthatwewillnotfindanyduplicates–the
reservationnumbersshouldbeuniqueforeachreservation.Ifwedofindaduplicate,thenwewanttoreportthis.YoushouldseethattheLookupactioncomeswithtwopathsbelowit
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page110of133©IBMCorporation2001,2012
–FoundandNotFound.RightclickontheFoundoption,andaddanewLogactiontothispath.
10. ThenewLogactionshouldreportthatthereservationnumberisaduplicate.Itshouldnotbeaddedtoanyfile,butwillneedtohaveaRoleofError.Onceyouhavesettheroleandenteredanerrormessage,closetheLogaction.
11. Ifwedon’tfindthereservationnumberinthepreviouslog,thenthetesthassucceeded,andwewillwanttologthecurrentdata.ThiscanbedonesimplybydragginganddroppingtheLogactioncreatedinthepreviousexerciseontotheNotFoundpath.
12. SavethetestandrunitagainsttheWorldwideTravelsystem.Itshouldsucceed,andnewdatawillbeaddedtoourlogfile.Asthesystemalwaysproducesanewreservationnumber,thetestshouldpasseachtime.
13. However,wecananticipatewhatthenextreservationnumberwillbe,andinsertthatnumberintothelogfilethatwe’vecreated.Thiswouldfoolthetestintothinkingithadfoundaduplicatereservationnumber.Openthelogfile,andedititsothatthereisanentryforthenextreservationnumber.Savethefile,thenrunthetestagain–youshouldnowseeitfail.
14. TheLookupTestDataactioncanalsobeusedtoretrieveinformationfromthedatasource.Ifwefindaduplicate,we’llreportthefirstandlastnamesofthecustomerrecordedinthefile.Todothis,returntotheTestFactory,rightclickintheTestSteps,andopentheTagDataStore.
15. Pressthe buttonintheTagDataStoretoaddanewtagtothetest–callitlogFirstName.Dothisonemoretime,andcreateasecondtagcalledlogLastName.ClosetheTagDataStore.
16. OpentheLookupTestDataaction,andswitchtotheStoretab.
17. IntheOutputformat,selectStoreonematchingrowonly.Aswe’reattemptingtopreventanyduplicates,wewon’texpecttofindmorethanonerowofdatainsidethelogfileforeachreservationnumber.
18. IntheMappingssection,youwillseetheFirstNameandLastNamefieldsfromthedata
source.ClickontheFirstNamerow–apencil buttonwillappearattheright.PressthisbuttontobringuptheSelectTagsdialog.
19. ChoosethelogFirstNametag,andpressSelect.
20. GothroughthesameprocesstomatchtheLastNamefieldandthelogLastNametag.Onceyou’redone,thetestactionshouldnowappearasfollows:
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page111of133©IBMCorporation2001,2012
21. Closethetestaction,andamendtheLogactionusedforreportingerrors,sothatitlookslike
thefollowing:
22. Savethetest.
23. Takenoteofthemostrecentreservationnumber,andagainmakesurethatthereisanentryforthefollowingreservationnumberinyourlogfile.Sothatwecanverifythatdataisbeingextractedfromourdatasource,choosenewfirstandlastnamesforthisnewentry.Remembertosavethelogfileaftermakinganychanges.
24. Runthetestagain.Youshouldnowseeaduplicate,andthenameshownintheconsoleshouldbetheonethatyouenteredinthepreviousstep.
15.5 FailurePathandPass/Fail
FailurePathsandPassPathsallowyoutospecifywhatoccursinatestifaparticulartestactionpassesorfails.Thesemaybeaddedtoanytestactionbyrightclickingonit,andselectingAddPassPathorAddFailurePath.We’llbefocusingmainlyonfailurepaths–theseallowustocreateteststhatfailgracefully.Notethatwhenyouaddafailurepathtoatestaction,itmayincludemultiplebranches;mosttestactionswillonlyhaveonewayinwhichtheyfail,butmessagingactions(forexample)canhavetwowaystofail:eitheramessageisnotreceivedwithinthespecifiedtimeoutperiod,oramessageisreceived,butdoesnotsatisfythevalidationcriteria.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page112of133©IBMCorporation2001,2012
ThePass andFail actionscauseatesttopassandfailrespectively;testexecutionwillskipstraighttotheTearDownphaseofthetest,ignoringanyfurtheractionswithintheTestStepsphase.We’llnowcreateasimpletesttoillustratehowtoimplementthesefeatures,andthendiscusssomeofthemoreadvancedrealworldapplications.
15.6 Exercise:UsingFailurePaths
1. CreateanewtestbasedonthebasicTemplate–callitsubscriberTest.
2. GointotheReceiveReplyaction,andthentotheConfigtab.FindthenewReservationNumberfield.Itshouldcurrentlyhaveastarnexttoit,indicatingthatitisgovernedbyaruleintheRuleCache.Rightclickonthisline,andselectRuleCache>Disable.Onceyou’vedonethis,thestarwillstillappear,butwithalinethroughit:
3. GototheTestLab,andrunthetestagain.Itshouldnowfail,asit’snolongerreceivingthe
expectedreservationnumber.
4. We’regoingtomodifythetestsothatitwillpasswithawarningifthereanissuevalidatingthereplymessage.Anythingelseshouldstillcausethetesttofail(transportfailure,timeout,
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page113of133©IBMCorporation2001,2012
etc).ReturntotheTestFactory,rightclickontheReceiveReplystep,andchooseAddFailurePath.
5. RightclickonSubscriberErrorandselectNew>Flow>Fail.DoubleclickontheFailteststepandaddsometextintotheOutputMessagebox,e.g.Message timeout.ClickOK.
6. RightclickonValidationFailureandselectNew>Flow>Log.DoubleclickontheLogteststepandsometextintotheOutputMessagebox,e.g.Validation failed.SettheRoleoftheactiontoWarning.ClickOK.
7. Yourtestshouldnowlooklikethis:
8. Savethetest.
9. ReturntotheTestLab,andrunthetestagain.Intheconsole,youshouldbeabletoseethatthevalidationstepfailed,andawarningwasgiven,butthetesthasstillpassed:
10. IntheTestFactory,opentheReceiveReplystep.FindtheTimeoutfield,andsetitto5ms.
Runthetestagain,andyoushouldseeitfailthistime,astheerrordoesnotoccuratthevalidationstage.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page114of133©IBMCorporation2001,2012
Nowthatwe’veconstructedasimpleexampletohelpunderstandthebasicideabehindFailurePathsandPass/Failactions,wecanlookatamoreadvancedexamplethat’smoreapplicabletotherealworld.
TheabovediagramshowsastandardexampleSOAsystem.Service1receivesamessageandpassesthismessageontoService2,themessageisthenpassedfromService2toService3andbackagain,onwardtoService4andback,andfinallybacktoService1.Ifatanypointanerroroccurs,themessageispassedtoanexceptionqueue.
YoucouldsetupabasictestinRationalIntegrationTesterthatpublishesamessagetoService1,alongwithasubscribertoreceivethereply.AsecondsubscribercanbesetuphowevertolistenontheExceptionQueue.IfthissubscribertimesoutthenitmeansnothinghasbeenplacedontheExceptionQueueandsothetestshouldpass.Howeverifthesubscriberreceivesamessagethentherehasbeenanerrorassothetestshouldfail.
ThisfunctionalitycanbeachievedbyaddingaFailurePathtothesubscriber,andaddingaPassactiontotheSubscriberErrorandaFailactiontotheValidationFailure.(IfatimeoutoccursitwilltriggeraSubscriberErrorandsopass,ifamessageisreceiveditwilltriggeraValidationErrorandfail)
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page115of133©IBMCorporation2001,2012
16 Interacting with Databases
16.1 Exercise:Creatingadatabasecomponentmanually
Thissectiondetailsthestepsnecessarytocreateadatabasecomponentinyourproject.WewillusetheLogicalandPhysicalviewstomanuallyaddadatabasethatcanthenbeaccessedfromanytestintheproject.Thischapterwillassumeyou’reusingthesampledatabaseprovided,howeverthesameprocesscanbeusedforanydatabase.
1. EnsureyouhaveSQLitelistedasoneoftheDatabase(JDBC)providersinyourLibraryManager,usingthedriversqlitejdbc‐v056.jar.Ifnecessary,youcandothisbyaddinganewproviderandpointingtothefile,whichcanbefoundinC:\SQLite.
2. IfyouhavemadechangesintheLibraryManager,closeandrestartRationalIntegrationTestersothatitwillloadthosechangeswhenitrestarts.
3. GototheLogicalView.SelecttheWWTravelservicecomponent,thencreateanewdatabasecomponentbyrightclickingandselectingNew>General>DatabaseServer.NameitTest Database.
4. Wenowneedtocreateaphysicaldatabaseforourlogicaldatabasetopointto.SwitchtothePhysicalView,rightclickonthePhysicalComponentsrootfolderandselectNew>General>Database.
5. Openthenewdatabaseandinputthefollowingvalues:
MaxNumofConnections:1 Driver:org.sqlite.JDBC
(NotethattherearetwoSQLitedrivers;theotheronewillnotwork) DatabaseURL:
jdbc:sqlite:/C:\Users\<username>\Desktop\Data Files\Database\reservations.db(Modifydependinguponwhereyourdatabaseisstored)
6. ClickTestConnectiontoensureyourdatabaseconnectionissetupcorrectly.Ifthisdoesnotwork,thenyoumayneedtogobackandchecksteps1and2again.
7. GobacktotheLogicalViewandreopentheTest Databaseyoucreatedbefore.
8. GototheBindingstab.Forthecurrentenvironment,selecttheUNBOUNDfieldandpicktheSQLLitedatabaseyoujustcreated(jdbc:sqlite:/C:\Users\<username>\Desktop\Data Files\Database\reservations.db).
9. Tocheckthatthedatabaseisnowavailabletouseintests,we’llcreateatesttoquerythedatabase.SwitchtotheTestFactoryperspective
10. Previously,we’vecreatedallofourtestsunderneathoperations.Thisdoesnotneedtobethecase–youcancreatetestsunderneathservicecomponentsorevendatabasecomponents.CreateanewblanktestcalledqueryTest,undertheWWTravelservicecomponent.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page116of133©IBMCorporation2001,2012
11. AddtheSQLQueryactiontothetest.Edittheaction,andhittheBrowse…buttontoselecttheTest Database.IfyoudonotseetheTest Database,setObeyReferencestoNo.ThiswillignoreanydependenciessetinArchitectureSchool,andshowalldatabaseswithintheproject.
12. EnterthefollowingSQLQuery:
SELECT * FROM reservation ORDER BY reservation_number
13. ClickonTest.IfRationalIntegrationTestershowsanerrormessage,checkthatyouhave
enteredthequerycorrectly,andthattheTest Databasehasbeenselectedatthetopofthewindow.Otherwise,youwillseethecontentsoftheReservationtable.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page117of133©IBMCorporation2001,2012
14. ClickonOverwriteExpectedResultsandclickOKtoclosetheSQLQuerywindow.
15. Runthetest–itshouldpass.Wehaven’talteredthedatabase,sotheexpectedandactualresultsofthequerywillmatch.
16.2 Exercise:SQLCommand
TheSQLCommandactionallowsyoutorunINSERT,UPDATEorDELETEqueriesinRationalIntegrationTester.We’llnowcreateasimpletestthatperformsanSQLINSERTcommandtoinsertasinglerecordintoadatabase.Thissectionassumesyou’reusingthedatabasecreatedintheprevioussection.YouarefreetouseyourownhoweveryouwillneedtomakeappropriatechangestotheSQLquery.
1. CreateanewtestcalledInsertTest
2. AddanSQLCommandactionanddoubleclicktoopenit.
3. VerifythattheDatabaseServerissettotheTest Database.
4. PasteinthefollowingSQLCommand:
INSERT into reservation
VALUES ("Male","Lyon","Thomas","Jack","21","WW007","A05006")
5. RunthetestintheTestLab.
6. NowrunthequeryTestagain.Youshouldobservethatitnowfails,asthedatareturnedbythequerynolongermatchestheexpecteddataforthattest.
7. Openthemessagedifferencingwindowforthequeryresults,andyoushouldnowseethedifferencebetweentheexpectedandactualresults.Closethewindowwithoutmakinganychanges.
16.3 Exercise:ColumnandCellValidations
ThequeryTestiscurrentlyfailing,duetotheextrarowthatwasn’tintheexpectedresults.However,insomecases,we’llwanttovalidateasetofqueryresultsgivenmoregeneralcriteria,ratherthanspecifyingexactvaluestomatch.
1. ReturntotheTestFactory,andmakeacopyofthequeryTest.CallitcolumnValidations.
2. OpentheSQLQueryactioninyournewtest,andgototheAsserttabtoviewtheexpectedresults.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page118of133©IBMCorporation2001,2012
3. Selectanycell,andpresstheEditCell button.Alternatively,rightclickonthecell,andchooseEditCell.
4. Notethatyoucaneditthevalidationforthisparticularcell.Bydefault,thevalidationshouldhaveanActionTypeofEquality,andthevalueshouldbesettowhatevervalueiscurrentlyinthedatabasewithinthatfield.Closethisvalidationwindowwithoutmakinganychanges.
5. Similarly,toeditvalidationrulesforacolumn,wecanselectanycellwithinthecolumn,andpresstheEditColumn button,orwecanrightclickonthecolumnheading,andchooseEditColumn.Openthevalidationrulesforthegendercolumn.
6. PresstheNewbuttontoaddanewvalidationrule–choosetoevaluatethecontentsofthecolumnwithanActionTypeofRegex.
7. Fortheregularexpression,enter^(Male|Female)$
8. ThisshouldletusaccepteitherMaleorFemaleasvalidentries;anythingotherthantheseexactstringswillfail.CheckthisbytypingintotheDocumentfield,andverifyingthatthesevaluespass,andothersfail,whenyoupresstheTestbutton.
9. Onceyouaresatisfiedthattheregularexpressionisworkinghere,pressOKtoclosethe
dialog.Addmorevalidationrulesforothercolumns,usingregularexpressionsasfollows:
week_number ^\d{1,2}$
flight_number ^WW\d{3}$
reservation_number ^A\d{6}$
10. Theserulescanbeusedtogeneralizehowqueryresultswillbeevaluated.However,westillhavetheoriginalcellassertions,whichstatethateachcellmustbeequaltothevalueswe
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page119of133©IBMCorporation2001,2012
canseeinthetableinthisdialog.Inordertomakethingsmoregeneral,checktheboxlabeledDisableCellAssertions.Thiswillmeanthatonlythecolumnassertionsareused.
11. PressOKtoclosethedialog,andrunthetest.Youshouldseethatthetestpasses.
12. ReturntotheTestFactory,andmodifytheInsertTestsothatitusesaninvalidreservationnumber(forexample,changetheAatthebeginningtoB).
13. RunthemodifiedInsertTest,andthenrunthecolumnValidationstestonemoretime.ThecolumnValidationstestshouldfail,pointingouttheinvalidreservationnumber.
14. Inthenextexercise,we’llresetthedatabasetoitsoriginalstate,allowingbothqueryteststopassagain.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page120of133©IBMCorporation2001,2012
17 Run Test
17.1 Introduction
TheRunTestfeatureallowsyoutorunonetestfrominsideanother.Thisallowsyoutocreatetestswithreusablefunctionalityandrunthemfrommultipledifferenttestswithinyourproject.Thisissimilartotheideaofcreatingreusablemethodsinobjectorientatedprogramming.
Essentially,ifthereisataskthatmanytestswillneedtoperform(e.g.resettingadatabase,startingupanumberofexternalapplicationsetc…),thenyoucancreateasinglereusabletestthatperformsthattask,ratherthanrewritingthoseactionsforeverytest.Youcanthenre‐usethistestwherevernecessarywithinotherteststoperformtherequiredtask.
Inthissectionwe’llcreateamodified“InsertRecord”testthatinsertsagivenrecordintoadatabase,usingtagsratherthanhardcodingthevaluestobeinsertedintothedatabase.We’llthenusethisaspartofaseparatetesttoresetthedatabase.Aspartofthisprocess,we’llalsoseehowwecanpassdatafromonetesttoanother.
17.2 Exercise:Creatingthechildtest
1. GototheTestFactoryperspective,andfindtheInsertTestintheTestFactoryTree.Makeacopyofthistest,andcallitInsertWithTags.
2. OpentheSQLCommandaction.
3. ReplacetheSQLquerywiththefollowing:
INSERT into reservation VALUES ("%%ChildTestGender%%", "%%ChildTestLastName%%", "%%ChildTestMiddleName%%", "%%ChildTestFirstName%%", "%%ChildTestWeekNumber%%", "%%ChildTestFlightNumber%%", "%%ChildTestReservationNumber%%")
4. Youwillnoticethatallofthetagsareunderlined.Thisisbecausetheydonotexistyet.OpenuptheTagDataStoreandcreatethemnow.
5. ReopentheSQLCommandactionandcheckthetagsarenolongerunderlined.
6. Wewon’trunthistest–asthedefaultvalueforanewtagisnull,we’donlybeinsertingnullvaluesintothedatabase.Instead,simplySavethetest.
YoumaybewonderingwhyeverytagstartswithChildTest.Thisistohelpusidentifywhichtagsbelongtowhichtest,andwillbeveryusefulwhenwecometopassdatabetweentheparentandchildtests.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page121of133©IBMCorporation2001,2012
Wewillnowcreateatestthatwillresetadatabasebyremovingallcurrentrecordsthenenteringaselectionofsuppliedrecords.WewilldothisviatheRunTestactioncallingourInsertRecordtest.
17.3 Exercise:CreatingtheParentTest
1. CreateanewFileDataSource,andnameitDBResetData.
2. PresstheBrowse…buttonandselecttheinputData.csvfilelocatedinC:\Users\<username>\Desktop\Data Files\Database
3. PresstheRefreshbuttonandcheckthatfiverecordsaredisplayed.Saveandclose.
4. CreateanewtestandcallitResetDatabase.Thistestwillremoveallrecordsfromthedatabaseandpopulateitwithsampledatastoredinacsvfile.
5. AddanSQLCommandaction,openitandsettheDatabaseServertothelogicalDatabasecreatedpreviously,andenterthefollowingSQLcommandtoremoveallrecordsfromthedatabase:DELETE FROM reservation
6. SaveandclosetheSQLCommandaction,thenrightclickonTestStepsandselectTagDataStore.
7. Createthefollowingtags:ParentTestGender, ParentTestLastName, ParentTestMiddleName, ParentTestFirstName, ParentTestWeekNumber,
ParentTestFlightNumber, ParentTestReservationNumber.
8. ThesetagswillstorethevaluesofeachattributereadinfromtheCSVfile.AstheCSVfilecontainsmultiplerecords,we’regoingtomakeuseoftheIterateTestData actiontoapplyanactiontoeachrecordintheCSVfile.
9. AddanIterateTestData actionbelowtheSQLCommandaction.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page122of133©IBMCorporation2001,2012
10. Openit,presstheBrowse…buttonandselecttheDBResetDatadatasource.
11. GototheStoretab.Youshouldseealistofthetagsyoucreated.Selectthedropdownmenutotherightofeachtagandselecttheappropriateattribute.ClickOK.Thissetsthevalueofthetagsinthetesttothevaluesofeachcolumninthedatasource.
12. RightclickontheIterateTestDataactionandselectNew>Flow>RunTest.
13. OpenuptheRunTestaction,clicktheBrowse…buttonandselecttheInsertWithTagstestyoucreatedearlier.UncheckRunprocessinparallel.Thetestshouldnowlooklikeso:
17.4 Exercise:PassingDatabetweentheTests
Wenowhaveachildtestandaparenttest,andtheparenttestcanexecutethechildtestthroughtheRunTestaction.However,westillneedtospecifyhowdatawillbepassedbetweenthetwotests.Firstly,we’llgotothechildtest,andsetuptagsthatwillholdanyinputvalues.Then,we’llreturntotheparenttest,andfillinthosetagsappropriately.
1. ReturntotheInsertWithTagstest,andgotothePropertiesofthetest.ThiscanbefoundonatabnexttotheSteps.
2. LookingattheInterfaceforthetest,therewillbeInputandOutputsections.UndertheInputsection,makesureAllTagsisselected.Alltagsintheinserttesthavenowbeenenabledasinputs–butwestillneedtosaywhatdatawillgointothem.
3. Next,weneedtogobacktotheResetDatabasetest,andreopentheRunTeststep.
4. SelecttheValuetab.
5. YoushouldseeallthetagsyoucreatedintheInsertWithTagstestintheUnmappedbox.Pressthe<<buttontomovethemallintotheMappedbox.
6. Foreachtag,selectit,andintheboxbelowinsertthecorrespondingtagfromtheResetDatabasetest.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page123of133©IBMCorporation2001,2012
7. GototheTestLab,andruntheResetDatabasetest.
TheResetDatabasetestrunsaniterationoftheInsertWithTagstestwiththetagsinInsertRecordsettothevaluesspecifiedintheResetDatabasetest(whicharesetaccordingtothevaluesreadinfromtheCSVfile).TheIterateTestDataactionisusedtoruntheInsertRecordsubtestonceforeachrecordstoredinthetestdata.
YoumayquestiontheneedtouseaRunTestactioninthissituation,asyoucouldsimplyhavetheIterateTestDataactionrunaSQLCommanddirectly.Ifyouhadasingleparenttestandasinglesubtestthenthiswouldprobablybetrue.Howeverimaginethatyouhavemanyteststhatallinsertrecordsintothedatabase.YoucouldhaveaseparateSQLCommandactionineverysingleone,butifthedatabasechanges(e.g.afieldisremoved)thenyou’llhavetogothrougheverytestseparatelyandmaketheappropriatechanges.IfyouusetheRunTestfeaturehowever,youonlyneedtomakethechangeinasinglesubtest.
AnotheradvantageofusingasubtestcanbeseenifyouimaginethatinsteadofthesubtestcontainingasingleSQLCommandaction,itcontains50+commandsalongwithdecisionstepsetc.Ifyouwanttodosuchacomplicatedactionmorethanonceindifferentteststhroughoutyourproject,theRunTestactionhelpssavealotoftime.Onceagainanyonewithprogrammingexperiencewillnoticethesimilaritiesbetweenthisandtheideaofreusablemethodsincomputercode.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page124of133©IBMCorporation2001,2012
18 Monitoring Log Files
18.1 Overview
LogfilescanbemonitoredautomaticallywithRationalIntegrationTester,avoidingtheneedtomanuallycheckthemforchangesthatmayhaveresultedfromactionswithinatest.Inordertodothis,wesetuptheinfrastructureresourcewiththelocationofitslogfiles.Afterthat,wecansetupactionstoreacttochangesinthelogfiles.
18.2 Exercise:LookingforErrorMessages
1. GotoArchitectureSchool,andlocatetheWWTravel_MQcomponent.
2. Doubleclickontheresourcetoeditit,andgototheMonitoringtab.
3. ClickonAddtoaddaLogFile.Asasimpleexample,we’llbeusingtheexample.logfileonyourdesktop,andloggingnewinformationbyhand.
4. SetthePathtoC:\Users\db2admin\Desktop\Data Files.LeavetheFileas*.log,andpressOK.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page125of133©IBMCorporation2001,2012
5. InTestFactory,createanewemptytestundertheMakeBookingoperation,andcallitMonitorTest.
6. Addtwo Logactionstothetest,onetosay“StartingTest”,andtheothertosay“TestFinished”.
7. Aswewillupdateourlogfilebyhand,wewillneedthetesttopauseforashortperiod.Todothis,we’llusea Sleepaction.SetittoforaFixeddelay,of20000ms.Yourteststepsshouldnowlooklikethefollowing:
8. SwitchtotheMonitoringtabofthetest,andchooseAdd–itshouldautomaticallyfindthe
logfilelocationweselectedinArchitectureSchool.
9. FindtheActionstab,andswitchtothattotellthetesthowtorespondtochangeswithinthelogfile.
10. Pressthe Addbuttontoaddanewaction.
11. DoubleclickintheMatchfield.ItshouldbringupanEditRegexwindow,withacopyofthelogfileasitcurrentlystands.
12. Wewanttorespondifanerrorislogged–selectthetext[ERROR].
13. Apopupwillappearwithregexesthatmatchtheselectedtext.ChoosetheExactoption‐\[ERROR\].Itshouldnowappearatthebottomofthedialog,andthe[ERROR]textshouldnowbehighlighted,asbelow.PressOKtoreturntothetest.
14. UnderAction,chooseTreataserror,andmarktheEnabledcheckbox.
15. Savethetest,andgotoTestLab.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page126of133©IBMCorporation2001,2012
16. Runthetest.Whileitissleeping,edittheexample.logfileprovidedintheData Filesfolderonyourdesktoptoaddanotherlinestartingwith[ERROR],andsavethelogfile.
17. RationalIntegrationTestershoulddetectthechange,andthetestwillfail.
Note:IfRationalIntegrationTesterdoesnotshowanyerrors,makesurethatyouhaveeditedandsavedthefilewithinthe20secondsprovidedbytheSleepaction.Inaddition,defaultsettingsforreadingthelogfile(setinArchitectureSchool)statethatnewentriesinthelogfilemustendinanewline–simplyadding[ERROR]withoutanewlinewillnotregisteranerrorinyourtest.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page127of133©IBMCorporation2001,2012
19 Advanced Stubs
19.1 Exercise:ParameterizedStubs
Inthisexercise,youwillcreateaparameterizedstub.Thisismorecomplexthanthebasicstubwecreatedearlier,inthatitwillproducedifferentreplymessageswhengivendifferentrequestmessages.
1. Tostartcollectingdatatogeneratethestub,gototheRecordingStudio.Clearanymessagesrecordedpreviously.
2. CheckthattheMakeBookingoperationisbeingmonitored,andstartrecording.
3. SwitchtotheTestLab,andrunthetestsuitecreatedearlier.ReturntotheRecordingStudio,andyoushouldseethemessagesproducedforthatsetoftests.
4. SelectMakeBookingwithintheEventMonitors.Thisshouldfilteroutanyotherevents,leavingyouwithjustthe6MakeBookingrequestsandresponsesthatwererecorded.Checkthesetomakesurethatyouhavearequestmessageforeachofthethreecardtypesallowedbythebookingsystem.Ifnot,you’llneedtorecordmoreinteractionswiththesystem.Ifyou’vegottoomany,thendeleteanyextrasfromtheEventsView.
5. Selectall6events,andpresstheSavebutton.
6. Again,we’llchoosetosavethemasastubinthefirstpageofthewizard.PressNextonceyou’vedonethis.
7. Onthesecondpageofthewizard,choosetoStoredatainasimpledataset.PressNext.
8. Thethirdpagechecksthateverythinghasbeenallocatedtothecorrectoperation.Youshouldsee6events,alllabeledasbeingrelatedtotheMakeBookingoperation.Ifso,pressNext.Ifnot,you’llneedtogobackandmakesureyou’veselectedtherightevents.
9. Thefourthpagechecksthattherequestsandreplieshavebeengroupedcorrectly.Again,thisshouldalreadybethecase,butyoucanchoosetochangegroupingshereorrestartifnecessary.PressNextonceyou’resatisfiedthatthisiscorrect.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page128of133©IBMCorporation2001,2012
10. You’llthengetapreviewofhowtherequestmessageswillbemappedintoourdataset.RationalIntegrationTesterwillanalyzethemessagesusedintherecordedmessages,andlookfordifferencesbetweenthemessages.Bydefault,itwillrecorddatathatchangesintocolumnswithinthedataset;datathatappearstobestaticwillnotbeincluded.Takealookattherequestmessage–fieldsthataregoingtobeincludedinthedatasethaveastatusofNew ,whilethosethatarenotgoingtobeincludedarelistedasIgnored .
11. Withintherequestmessage,weonlycareaboutthecardtype,soselecteachoftheother
fields,andpresstheIgnore button.ThisshouldleaveonlythecardtypelistedasNew,andeverythingelseIgnored.PressNexttogototheresponsemessageforMakeBooking.
12. Here,wecanseethatthereservationnumberisalsomarkedasNew.Inthiscase,wemayalsodecidethatweareinterestedinthestatusfieldaswell,eventhoughithadthesamevalueineachoftherecordedmessages.Findthestatusrow,whichshouldbemarkedas
Ignored.Selectit,andpresstheColumn button.
13. Apopupdialogwillappear,allowingyoutonamethecolumnthatwillbecreatedforthestatuswithinourdatasource–bydefault,itwillbecalledstatus.Thiswillbefineforourpurposes,sopressOK.BoththereservationnumberandthestatusshouldnowbemarkedasNew.
14. PressNextagaintogotothesummaryscreen.Thisshouldinformyouthatastubwillbe
created,alongwithadatasourcecontaininginformationaboutthecardtype,reservationnumber,andstatus.Ifdifferentfieldsarelisted,you’llwanttohitbacktoreturntotheprevioussteps,andmakesurethateachfieldisbeingaddedtothedatasetorignored,asrequired.
15. CallthestubBookingsWithData,andgototheTestFactorytoviewwhatwe’veproduced.
16. UndertheMakeBookingoperation,youshouldseetwothingswiththenameBookingsWithData.Wehaveastub,aswe’vehadeveryothertime,butwealsohaveadatasource.DoubleclickonthiswithintheTestFactoryTreetoopenit.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page129of133©IBMCorporation2001,2012
17. Thefirstthingyoumightnoticeisthatthefilenamecontainsareferencetotheroot
directoryofaproject,writteningoldandsurroundedbypercentagesigns.Thisisasystemtag–avariableinternaltoRationalIntegrationTester,whichwecan’teditdirectly.Thisallowsustorefertotheprojectfolder,nomatterwherethatmightbelocated.Iftheprojectismovedtoanotherfolderoranothermachine,thelinktotheCSVfilethatwe’reusingwillstillfunction.
18. PresstheRefreshbuttonatthebottomofthescreentoviewthedatawithinthedatasource–thisshouldcontainthethreecardtypesandreservationnumberswerecordedpreviously,alongwithastatuscolumnthatstatesSUCCESSforeach.Thereisalsoagroupingcolumnprovidedforus,incasewehadrecordeddatawithrepeatingelements(whichwouldrequiremultiplelinesofdata).Asourdataisfairlysimple,wedon’tneedtoworryaboutthisfornow.Closethedatasource.
19. Openthestubitself,andlookattheInputtab.Youshouldnoticethatthecardtypeisbeingstoredintoatag.
20. SwitchtotheOutputtab,andyou’llnoticethatnoresponseisbeingsenthere–infact,noresponsemessageappearstobepresentatall.Thisisbecausethestubthatwehavegeneratedwillrespondifitrecognizesafamiliarcardtype,butotherwisewillignoreanyincomingmessages.Toseehowwehandlethis,switchtotheBusinessLogictab.
21. TheBusinessLogictaballowsustospecifyourowncustomlogictodictatehowthestub
willrespondtoincomingmessages.Here,youcanseeaLookupTestDataaction,whichis
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page130of133©IBMCorporation2001,2012
followedbytwooptions–FoundandNotFound.Ifthelookupissuccessful,itwillsendareply.Ifnot,itwilldonothing.OpentheLookupTestDataactionbydoubleclickingonit.
22. Thishastwotabs–theConfigtabwillopenbydefault.Asyoushouldbeabletosee,we’re
tryingtomatchthevaluethatwestoredintothecardTypetagintheInputtabwiththecardTypecolumninthedatasource.
23. SwitchingtotheStoretab,you’llbeabletoseethatwe’regoingtosavethedatafromthe
columnsinthedatasourceintocorrespondingtagswithinthestub(withtheexceptionofthegroupingtag).Thiswillonlyhappenifwefindamatch–otherwise,anyvaluesthatmayexistwithinthosetagswillbeleftalone.ClosetheLookupTestDataAction.
24. OpentheSendReplyaction.ThiswillbeusedtosendareplyifandonlyifwefoundamatchwithintheLookupTestDataaction.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page131of133©IBMCorporation2001,2012
25. Observethemessagethatisbeingsentback–thisusesthevaluesthatweresavedintothestatusandnewReservationNumbertagswithintheLookupTestDataaction,sothesevalueswillbecomingdirectlyfromourdatasource.ClosetheSendReplyaction.
Runthestub,andsendsomerequeststoit(eitherbyrunningtests,orbycreatingrequestsusingthewebinterface).Youshouldnoticethateachcardtypegetsitsownreply,basedonthedatasource.
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page132of133©IBMCorporation2001,2012
20 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,orfunctionofthese
RATIONALINTEGRATIONTESTERTRAININGGUIDE
Page133of133©IBMCorporation2001,2012
programs.Thesampleprogramsareprovided"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.
Recommended