关于数据库论文范文素材,与文献综述内容相关论文格式模板
本论文是一篇关于数据库论文格式模板,关于文献综述内容相关毕业论文的格式范文。免费优秀的关于数据库及管理系统及档案管理方面论文范文资料,适合数据库论文写作的大学硕士及本科毕业论文开题报告范文和学术职称论文参考文献下载。
sultingcallchainwouldbe:myActionTest.getActionServlet().getRequestProcessor().getActions().Thisapproachdoesn'tworkwhenyoulookatthesequenceofcallsthatlinkMockStrutsTestCasetoStrutsactions.
Figure2illustratesthekeyinteractionsbetweenMockStrutsTestCaseandStrutsponents.
Figure2.InteractionsbetweenMockStrutsTestCaseandStrutsponents.
Theproblem,asshowninFigure2,involvesthetimingofStrutsactioncreation.MockinjectionintotheactionsneedstohappenbeforethecalltoMockStrutsTestCase.actionPerform().However,theactionsarenotyetavailablebecauseonlyafterthecalltoactionPerform()doesRequestProcessorcreatetheactioninstances.
SinceyoucannoteasilypropagatetheactioninstancetoMockStrutsTestCase,whynotjustsubclassRequestProcessorandoverridetheprocessActionCreate()methodIntheoverriddenmethod,youhaveaccesstoalltheactioninstances,socreating,configuring,andsettingamocktotherightactioninstancebeesstraightforward.BecauseMockControl.verify()shouldbecalledafteractionPerform(),youalsoneedtooverrideprocessActionPerform()tomaketheverificationcall.
Thissolutionisimpracticalfortestingnon-trivialStrutsapplications.Evenifallactionsinteractwithasinglemock,testingoneactionwouldlikelyrequiremultipletestmethods,eachwithdifferentmockexpectations.TheproposedsolutionwouldendupcreatingdifferentRequestProcessorsubclasses,eachsettingdifferentmockexpectations.MultipleStrutsconfigurationfilesarealsoneededtospecifythedifferentRequestProcessorsubclasses.Managingalargenumberoftestswouldbeeaheadache.
TheAOPsolution
Thus,somehowmakingtheactioninstanceavailabletoMockStrutsTestCasebeforetheactionexecutesisstilldesirable.IfyouarefamiliarwithAOP,yourecognizethesimplesolutionthatdirectlymapstothisrequirement.Thekeyistodefineapointcutthatcapturestheactionexecutionjoinpointandthenabeforeadvicetoinjectthemockintotheaction.
Here,IchoseAspectJtoimplementthesolution.OtherAOPimplementationssuchasSpringAOPshouldworkaswell.SpringAOPwouldrequireoneextrastepthatdelegatesStrutsactionmanagementtoSpringwithSpring'sDelegatingActionProxy.
Figure3showsthestaticmodeloftheunittestexamplewiththeAOP-basedsolution.
Figure3.StaticmodeloftheunittestexamplewiththeAOP-basedsolution.
SimpleActionisasubclassofaStrutsactionandcollaborateswithActionService.SimpleActionTestderivesfromMockStrutsTestCasetotestSimpleAction.
SimpleActionTestcreatesandsetsupamockActionServiceusingEasyMock.SimpleActionTestalsoimplementstheStrutsActionPreExecuteListenerinterfacetoreceivenotificationwhenSimpleAction'sexecutemethodisabouttorun.Aspartofthenotification,SimpleActionTestreceivestheSimpleActioninstancetoinjecttheActionServicemock.ItistheaspectclassStrutsActionPreExecuteNotifierthatnotifiesanytestclassthatimplementsthelistenerinterfaceandmakestheactioninstanceavailable.
HereishowStrutsActionPreExecuteNotifierisimplemented:
First,apointcutselectsthetestmethodexecutionjoinpoint.Thetestmethodresidesinthetestclassthatlistensfortheactionpre-executeevent.Thepointcutalsoexposesthecurrentexecutingtestclassobject:
pointcutmockStrutsTest(StrutsActionPreExecuteListeneractionTest):execution(publicvoidStrutsActionPreExecuteListener+.test*())&,&,this(actionTest),
Next,asecondpointcutcapturestheactionexecutionjoinpoint.Combiningitwiththefirstpointcut,thematchingscopeislimitedtowithinthecallflowoftheactiontestmethod.Thereducedscopefiltersoutactionexecutionthatisnottriggeredbythetestmethods.Asaresult,theaspectdoesnotaffectproductioncode.Boththeactionanditscorrespondingtestclassinstancesareexposedviapointcutparameters:
pointcutstrutsActionExecute(Actionaction,StrutsActionPreExecuteListeneractionTest):
execution(publicActionForwardAction+.execute(..))&,&,
this(action)&,&,
cflow(mockStrutsTest(actionTest)),
Finally,abeforeadviceassociatedwiththepreviouspointcutnotifiesthetestclasses,whoarelistenersoftheactionevent,andpassesalongtheactioninstanceformockinjection:
before(Actionaction,StrutsActionPreExecuteListeneractionTest):
strutsActionExecute(action,actionTest){
actionTest.preActionExecuteOccurred(action),
}
Figure4illustratesthedynamicinteractionsamongtheclasses.
Figure4.Dynamicinteractionsamongtheclasses.
Thedottedlinegoingfromtheactiontotheaspectrepresentsthecaptureoftheactionexecutionjoinpoint.Comparingthissecondsequencediagramtothefirstone,thesignificantdifferencesarethethreestepsoccurringjustbeforeactionexecution:
ApointcutcapturestheactionexecutionjoinpointindicatedbythedashedarrowgoingfromSimpleActiontoStrutsActionPreExecuteNotifier.
Theaspect'sbeforeadvicenotifiesthetestclassandpassesthecorrespondingactioninstancetoit.
Thetestclassinjectsthemockobjectintotheactioninstancethatisabouttostartexecuting.
Youcannowproceedwithwritingtheactiontestsfollowingthefivestepsoutlinedpreviously.ThecodebelowshowsthepartialcodelistingforSimpleActionTest,withinlinementshighlightingeachstep:
Parti
关于数据库论文范文素材,与文献综述内容相关论文格式模板参考文献资料: