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.
виагра дженерик спб телефон
проект на водопонижение vodoponizhenie-iglofiltrami-moskva.ru .
https://telegra.ph/Kinoafisha-belgoroda-11-11
мостбет правила пополнения http://mostbet61527.help/
https://site511468179.fo.team
в м е с т о
https://telegra.ph/Gladenkaya-gornolyzhnyj-kurort-01-06
https://teletype.link/suddenjvj22
О р е н б у р г
seriöse sportwetten anbieter
Stop by my web site Bester Wettanbieter
попперс новосибирск доставка
buchmacher app
my page; basketball-Wetten.com
https://dcayzf.zombeek.cz
водопонижение котлована водопонижение котлована .
согласование перепланировки под ключ согласование перепланировки под ключ .
https://a1p3qk.zombeek.cz
https://rentry.co/44ryn6of
https://telegra.ph/Drom-ru-krasnodarskij-kraj-avto-s-probegom-vaz-2112-11-17
https://5asr0k.zombeek.cz
best sms activation services github.com/SMS-Activate-Login .
водопонижение котлована xn—77-eddkgagrc5cdhbap.xn--p1ai .
https://telegra.ph/Video-moj-govoryashchij-hehnk-11-18
smsactivate smsactivate .
купить силденафил Архангельск
https://rentry.co/zyd9w7af
smsactivate smsactivate .
https://rentry.co/7wb6md6m
https://teletype.link/sandfdq0897
https://rentry.co/7gewwc7p
анонимно купить виагру
wettanbieter ohne lizenz
Stop by my site pferderennen deutschland wetten (Alexandra)
система водопонижения иглофильтрами vodoponizhenie-iglofiltrami-moskva.ru .
https://paiza.io/projects/i7EvNwu23N4XkQVoRZajlQ
https://k5ypoh.zombeek.cz
https://site716276080.fo.team
smsactivate smsactivate .
https://uzk3sy.zombeek.cz
какие бывают попперсы
online Ungarn Schweiz Wetten sport
в и а г р ы
english попперс
попперс Керчь
мостбет apk Киргизия https://mostbet61527.help
услуги по перепланировке квартир услуги по перепланировке квартир .
mostbet free spins http://www.mostbet61527.help
попперс Чебоксары
1win вывод на карту http://1win50742.help
https://www.bitsdujour.com/profiles/XSwHq2
sms activate login sms activate login .
виагру подсыпала брату в чай