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.
Start je winstreeks bij Betano https://betanogame.org/nl/bonuses/. Krijg 100 tot €500 plus 100 gratis spins bij je eerste storting. De beste slots tafelspellen en live streams zijn hier allemaal. Meld je nu aan en speel als een pro.
https://telegra.ph/Rotaru-skolko-by-zima-ne-mela-minus-11-09
https://lessons.drawspace.com/post/1034382/https-www-investagrams-com-profile-clay3629894
анал под попперс порно би
https://site855565664.fo.team
https://rentry.co/zezxq5zq
комплексное продвижение сайтов москва комплексное продвижение сайтов москва .
https://snippet.host/nnitwd
mostbet pul yechish vaqti http://mostbet02894.help/
1win kripto çıxarış neçə dəqiqə http://1win34861.help/
попперс дон
https://rentry.co/mrv7p83s
https://pluoty.zombeek.cz
раскрутка сайта москва раскрутка сайта москва .
https://telegra.ph/Skachat-alkogol-120-dlya-vindovs-7-cherez-torrent-11-19
https://telegra.ph/Shadow-fight-2-4pda-11-16
https://www.bitsdujour.com/profiles/NN4hQk
поисковое продвижение сайта в интернете москва поисковое продвижение сайта в интернете москва .
https://1zaiw9.zombeek.cz
https://rentry.co/5z6nwfv8
попперс как действует на мужчин
купить попперс Альметьевск
net seo net seo .
https://site30670732.fo.team
https://www.bitsdujour.com/profiles/LQdR96
wetten handicap erklärung
Feel free to surf to my blog … Wettanbieter Curacao
https://ub1cs4.zombeek.cz
mostbet KGS вывод mostbet KGS вывод
Fortune Rabbit vs Fortune Tiger: qual tem maior potencial de 5000x?
https://snippet.host/ixhcwk
продвижение сайта продвижение сайта .
https://www.diggerslist.com/gothicdsq66/about
wahl wetten deutschland
Here is my blog … sportwetten mit bonus ohne einzahlung
https://telegra.ph/Kashirskij-dvor-1-stroitelnyj-rynok-kak-doehat-11-19
https://paiza.io/projects/RaOP89Jy7icTSkZ0E6knzA
sportwetten schweiz gesetz
Feel free to visit my blog post :: basketball wetten doppeltes Ergebnis (basketball-Wetten.com)
seo продвижение сайтов агентство reiting-seo-kompanii.ru .
wettanbieter vergleichen
My blog; esc gewinner Wetten (horizonstech.one)
https://telegra.ph/Demmoksi-11-21
1win bonus 1win34861.help
1win lucky jet o‘yin http://www.1win5768.help
mostbet ставки на футбол Кыргызстан https://mostbet27541.help/
1win withdrawal methods 1win withdrawal methods
https://paiza.io/projects/fSY8cqumWv-h3JaN_qnLxQ
https://snippet.host/uxzicx
https://q8fzsp.zombeek.cz
глубокий комлексный аудит сайта глубокий комлексный аудит сайта .
https://snippet.host/ikppiw
глубокий комлексный аудит сайта глубокий комлексный аудит сайта .
продвижение сайтов продвижение сайтов .