I did some badness today.
I wanted an integration test to check to see if my @Transactional method actually did rollback on an optimistic lock failure. It’s a pretty business critical method so I wanted to be sure that the whole @Transactional and @Version annotation voodoo actually works.
The approach I took was to inject, what I called a “slowRepository” into the object with the @Transactional method. The slowRepository is just a mockito mock of the object which “answers” (using “thenAnswer”) to the “findBy…” with some custom code.
The idea is that at some point during the @Transactional method the slowRepository is called and the “answer” code is invoked. In the test, the answer code follows along the lines of:
1. Grab the data it requires from the (not slow) repository (the repository the slowRepository is mocking)
2. Switch back the slowRepository for the not slow repository
3. Invoke the @Transactional method again on a separate thread
4. Sleep for a bit
5. Wake up and return the data from step 1
The @Transactional call on the separate thread completes and commits before slowRepository wakes up. When it does, slowRepository returns stale data and the @Transactional method then fails accordingly.
The problem I encountered was using the setters for my @Autowired dependencies on the bean with the @Transactional method. I needed to use the setters so that I could switch in and out the slowRepository, but couldn’t because Spring AOP proxies are implementations of an interface, not subclasses (by default – yes I realise you can get Spring to proxy the target class using CGLIB). I found this blog post which explains how to get at the target object behind a Spring proxy. I converted it to Scala:
…which is pretty ninja.
сисси гипноз попперс
https://telegra.ph/Sodbik-03-07
виагра цена в аптеках твери
1xbet tr giri? 1xbet-47.com .
ебет на йоге ебет на йоге .
https://telegra.ph/Porno-s-hudymi-devushkami-11-12
https://www.bitsdujour.com/profiles/CKUpHS
https://site666672511.fo.team
сиалис индийские аналоги
https://teletype.link/karmaoel6283
https://telegra.ph/Kapusta-tushenaya-s-11-10
https://www.investagrams.com/Profile/tommy3625692
плинко app вход http://www.plinko61038.help
https://l8crq4.zombeek.cz
https://rentry.co/n9q4ande
купить сиалис 5 мг Новый Уренгой
https://telegra.ph/EHrik-ryzhij-02-05
https://rentry.co/8siw9bvx
купить сиалис астрахань
https://www.investagrams.com/Profile/dean3633155
попперс фист купить в москве
Jogo do Tigrinho ao vivo com narração: já jogou versão com locutor brasileiro?
https://snippet.host/iziodv
wetten italien deutschland
Also visit my web page … Basketball-wetten.Com
https://www.diggerslist.com/gaugehzz75/about
melbet скачать с официального сайта http://melbet36290.help
https://telegra.ph/Porno-skvirt-skachat-11-19
слотҳои казино мелбет слотҳои казино мелбет
1 x bet giri? 1xbet-52.com .
https://telegra.ph/Sialis-ceny-krasnoyarsk-02-05
https://www.bitsdujour.com/profiles/jfjxNR
https://telegra.ph/Klops-novosti-kaliningrada-i-oblasti-01-03
https://demo.wowonder.com/1773674446625305_532556
купить попперс в сексшопе
https://wx5wr9.zombeek.cz
https://paiza.io/projects/AQVL1Y1gDdckTew2rfxNkQ
https://site190635919.fo.team
bonus sportwetten ohne einzahlung
Also visit my blog … kombiwetten zum Nachtippen
https://telegra.ph/Market-dota-02-27
левитра почтой
bahis sitesi 1xbet 1xbet-47.com .
die besten Sportwetten gratiswette Ohne einzahlung
strategien
виагра купить в юрге
https://www.bitsdujour.com/profiles/dU50dy
мостбет тағйири парол mostbet95163.help
https://snippet.host/bnjneo
https://telegra.ph/Autoclick-11-17
https://rentry.co/p43i4w3x
есть ли в аптеке виагра
https://site79356746.fo.team