package Ġcz . enc irc led . j put . runner . junit Ċ Ċ import Ġcz . enc irc led . j put . J Put Ċ import Ġcz . enc irc led . j put . annotation . Performance Test Ċ import Ġcz . enc irc led . j put . context . Configuration Builder Ċ import Ġcz . enc irc led . j put . context . context Ċ import Ġcz . enc irc led . j put . runner . Base Test Executor Ċ import Ġcz . enc irc led . j put . runner . Reactive Test Executor Ċ import Ġcz . enc irc led . j put . runner . Thread Based Test Executor Ċ import Ġjunit . framework . Assertion Failed Error Ċ import Ġorg . junit . Ass umption Vi olated Exception Ċ import Ġorg . junit . internal . runners . model . Each Test Notifier Ċ import Ġorg . junit . runner . Description Ċ import Ġorg . junit . runner . notification . Run Notifier Ċ import Ġorg . junit . runners . model . Framework Method Ċ import Ġorg . junit . runners . model . Statement Ċ Ċ /** Ċ Ġ* ĠAll ĠJ Unit Ġrun ners Ġshould Ġdelegate Ġexecution Ġto Ġthis Ġclass Ċ Ġ* Ċ Ġ* Ġ@ author ĠV lad Ġon Ġ 2 2 - Sep - 1 9 . Ċ Ġ*/ Ċ class ĠJ Put Test Executor For JUnit Runner Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġthread Based Executor : ĠBaseTest Executor Ġ= ĠThread Based Test Executor () ĊĊĠĠĠ Ġprivate Ġvar Ġreactive Executor : ĠBaseTest Executor Ġ= ĠReactive Test Executor () ĊĊĠĠĠ Ġvar Ġis Initialized Ġ= Ġfalse ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĊĠĠĠĠĠĠĠ Ġ/** ĊĠĠĠĠĠĠĠĠ Ġ* ĠHack Ġfor Ġ[ Invoke Method With Params ] Ġ- Ġthere Ġis Ġno Ġother Ġeasy Ġway Ġhow Ġto Ġpass Ġthe Ġ[ J Put ] Ġargument Ġto Ġthe Ġunit Ġtest ĊĠĠĠĠĠĠĠĠ Ġ* Ġand Ġat Ġthe Ġsame Ġtime Ġre - use Ġexisting ĠJ Unit ĠState ments Ġ( like ĠBefore Test , ĠAfter Test Ġetc ) ĊĠĠĠĠĠĠĠĠ Ġ*/ ĊĠĠĠĠĠĠĠ Ġval Ġj Put Ġ= ĠThread Local < J Put ?> () ĊĊĠĠĠĠĠĠĠ Ġ/** ĊĠĠĠĠĠĠĠĠ Ġ* ĠHack Ġfor Ġ[ Invoke Method With Params ] Ġ- Ġthere Ġis Ġno Ġother Ġeasy Ġway Ġhow Ġto Ġreceive Ġreturn Ġvalue Ġfrom Ġthe Ġunit Ġtest ĊĠĠĠĠĠĠĠĠ Ġ* Ġand Ġre - use Ġexisting ĠJ Unit ĠState ments Ġ( like ĠBefore Test , ĠAfter Test Ġetc ) ĊĠĠĠĠĠĠĠĠ Ġ*/ ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= ĠThread Local < Any ?> () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġexecute Test ( method : ĠFramework Method , Ġnot ifier : ĠRun Notifier , Ġdescription : ĠDescription , Ġstatement : ĠStatement ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġeach Notifier Ġ= ĠEach Test Notifier ( notifier , Ġdescription ) ĊĠĠĠĠĠĠĠ Ġeach Notifier . fire Test Started () ĊĊĠĠĠĠĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġannotation Ġ= Ġmethod . getAnnotation ( Performance Test :: class . java ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( context . is Performance Test Enabled Ġ&& Ġannotation Ġ!= Ġnull ) Ġrun J Put Test ( annotation , Ġmethod , Ġstatement ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġelse Ġstatement . evaluate () ĊĠĠĠĠĠĠĠ Ġ} Ġcatch Ġ( e : ĠThrowable ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( e . cause Ġis ĠAss umption Vi olated Exception ) Ġeach Notifier . add Failed Ass umption ( e . cause Ġas ĠAss umption Vi olated Exception ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġelse Ġeach Notifier . add Failure ( e ) ĊĠĠĠĠĠĠĠ Ġ} Ġfinally Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġeach Notifier . fire Test Finished () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġrun J Put Test ( annotation : ĠPerformance Test , Ġmethod : ĠFramework Method , Ġstatement : ĠStatement ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġconf Ġ= ĠConfiguration Builder . build Config ( annotation , Ġmethod . method ) ĊĠĠĠĠĠĠĠ Ġval Ġexecutor Ġ= Ġif Ġ( conf . is Reactive ) Ġreactive Executor Ġelse Ġthread Based Executor ĊĊĠĠĠĠĠĠĠ Ġval Ġexecution Ġ= Ġexecutor . execute Test ( conf ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġj Put . set ( it ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstatement . evaluate () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresult . get () ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġif Ġ( execution . vi olations . isNotEmpty ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthrow ĠAssertion Failed Error (" Performance Ġtest Ġfailed .\ n ${ execution . vi olations ErrorMessage }") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ Ċ }