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://doselect.com/@79ae838ec2302a8711c590c66
попперс купить краснодар
https://app.talkshoe.com/user/aliciagreen
https://aniworld.to/user/profil/aliciagreen
https://rentry.co/cowm499x
https://apptuts.bio/aliciagreen-247988
https://site303626978.fo.team
https://beta.cent.co/aliciagreen/+hr9z9u
https://paiza.io/projects/niu3nCRcXzXE8XRjbLpaWw
https://sfx.thelazy.net/users/u/aliciagreen/
https://rentry.co/o6uh4a5i
https://site955760661.fo.team
https://www.gta5-mods.com/users/aliciagreen
https://www.bmwpower.lv/user.php?u=aliciagreen
купить попперс Михайловск
https://biomolecula.ru/authors/125966
https://telegra.ph/Vytyazhki-krona-01-21
https://zez.am/aliciagreen
https://1navmc.zombeek.cz
https://md.ctdo.de/s/fjNT4SNTjn
super p-forse
http://www.biblesupport.com/user/810088-aliciagreen/
https://rentry.co/b2e6ebf3
https://telegra.ph/Luchshie-rossijskie-detektivnye-serialy-rejting-12-17
вреден ли попперс
https://jruvih.zombeek.cz
https://telegra.ph/Posuda-centr-petrozavodsk-12-31
https://telegra.ph/Uvlazhniteli-vozduha-polza-i-vred-11-19
https://telegra.ph/Prodat-dollary-v-moskve-11-09
Dive deep into themed worlds and bonus explorations. In ignation login immersive quests yield great prizes. Quest on and conquer
сиалис махачкала
купить попперс Астрахань
https://tivkj4.zombeek.cz
wetten tipps vorhersagen
Feel free to visit my web page … wettbüro nähe
https://telegra.ph/Vremya-pribytiya-11-14
попперс Улан-Удэ
https://3vd6th.zombeek.cz
виагра сиалис левитра купить ростов
https://telegra.ph/Kanikuly-petrova-i-vasechkina-01-06
п о п п е р с
https://csvlkb.zombeek.cz
купить попперс Великий Новгород
сиалис продажа
https://site115998584.fo.team
paypal wettanbieter
Here is my blog Wetten Basketball VerläNgerung
https://snippet.host/yzjcdu
нюхает попперс анал
https://telegra.ph/Lotereya-na-yubilej-01-01
купить попперс Тамбов
https://telegra.ph/Poppers-sajt-01-16