当前位置 —论文写论文— 范文

关于数据库论文范文素材,与文献综述内容相关论文格式模板

本论文是一篇关于数据库论文格式模板,关于文献综述内容相关毕业论文的格式范文。免费优秀的关于数据库及管理系统及档案管理方面论文范文资料,适合数据库论文写作的大学硕士及本科毕业论文开题报告范文和学术职称论文参考文献下载。

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

1 2 3 4 5 6

关于数据库论文范文素材,与文献综述内容相关论文格式模板参考文献资料:

骨科论文怎么写

快速写论文

编写操作系统

如何写论文提要

如何用word写论文

写论文吧

论文不会写怎么办

如何写化学论文

初中生怎样写议论文

写一篇议论文600字

文献综述内容(5)WORD版本 下载地址