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://www.bitsdujour.com/profiles/gJehG5
купить попперс Ногинск
https://teletype.link/cabinbxb2623
https://telegra.ph/Berezovyj-degot-instrukciya-po-primeneniyu-ochishchenie-organizma-otzyvy-11-15
https://gtv2sb.zombeek.cz
https://telegra.ph/Pogoda-kinel-samarskaya-oblast-02-15
купить попперс Кисловодск
https://www.bitsdujour.com/profiles/cLojTb
https://rentry.co/py3paozm
купить дапоксетин Петрозаводск
https://site336350199.fo.team
https://telegra.ph/Pesni-vremya-i-steklo-slushat-11-14
https://telegra.ph/Stoyachie-siski-02-03
https://telegra.ph/Mirovoj-sudya-po-adresu-moskva-02-02
п р о д о л ж и т е л ь н ы й
sportwetten tipps forum
Also visit my web blog: wetten strategie doppelte chance
(Willa)
https://telegra.ph/Dieta-dlya-podzheludochnoj-11-16
https://paiza.io/projects/PBqqMHqtmM1x2fwffj-Yaw
нюхает попперс секс
купить попперс Москва
https://39i0ls.zombeek.cz
https://5fch4t.zombeek.cz
попперс является наркотиками
wettbüro marburg
Also visit my homepage; bester wettanbieter online (https://Forte.ae/)
купить сиалис Липецк
https://telegra.ph/Skachat-igru-gta-3-russkaya-versiya-besplatno-na-kompyuter-cherez-torrent-11-21
https://www.bitsdujour.com/profiles/H4PZI6
https://telegra.ph/Kolyaski-olh-11-25
попперс Якутск
https://o86atj.zombeek.cz
https://telegra.ph/Strategiya-pro-vtoruyu-mirovuyu-vojnu-02-07
нет нормальной эрекции
таблетки для получения оргазма
https://site780043705.fo.team
https://k8yupr.zombeek.cz
купить попперс Курск
https://telegra.ph/Dapoksetin-CHerkessk-12-11
https://5su8n6.zombeek.cz
https://teletype.link/bachelorqlg947
купить таблетки дженерик виагра
sportwetten app schweiz
Here is my website basketball wetten gerade ungerade; Rodger,
попперс Махачкала
https://telegra.ph/Viagra-stoimost-12-05
https://telegra.ph/Pogoda-v-orenburge-11-27
https://telegra.ph/Kak-obzhalovat-postanovlenie-ob-administrativnom-pravonarushenii-11-19
сиалис инструкция по применению аналоги
wetten im internet
Feel free to surf to my web-site: sportwetten bonus
österreich (Tamela)
https://telegra.ph/Orden-serial-2016-smotret-onlajn-11-18
https://rluzk0.zombeek.cz