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://paiza.io/projects/bJtkl8JT1JrbHRQNAIXPZw
https://u86vsz.zombeek.cz
https://telegra.ph/Lichnyj-kabinet-gibdd-11-14
https://www.bitsdujour.com/profiles/FcnD51
попперс Балашиха
https://rentry.co/nkcnyuix
https://snippet.host/dsbncb
монтаж газового пожаротушения спб монтаж газового пожаротушения спб .
дал понюхать попперс
betmgm michigan Casino makes winners every single day. Claim up to 1000 deposit match and 25 free play right now. Experience the rush of live casino action from home.
https://snippet.host/zfstie
https://site241174195.fo.team
https://paiza.io/projects/yS33TPRUrkP8P6uFVu00Uw
https://telegra.ph/Porno-nigeriya-11-19
Я к у т с к
расчет газового пожаротушения расчет газового пожаротушения .
мостбет вход по email мостбет вход по email
https://rentry.co/2oorde55
купить варденафил Мурманск
net seo net seo .
как действует виагра на подростков
https://site846902244.fo.team
сиалис софт цена в аптеке
попперс Златоуст
https://rentry.co/cynd94ct
https://telegra.ph/Mebel-na-zakaz-vologda-11-11
https://site274767744.fo.team
https://bltkw6.zombeek.cz
https://omgtzs.zombeek.cz
купить попперс Петрозаводск
https://telegra.ph/Portvejn-777-cena-02-21
силденафил Пятигорск
https://www.bitsdujour.com/profiles/RNs6Xb
пробный набор дженериков
продвинуть сайт в москве продвинуть сайт в москве .
презерватив падает член
https://snippet.host/rrpgdw
дженерик виагра описание
View on the website: https://hedgedoc.eclair.ec-lyon.fr/s/xinirklfy
https://telegra.ph/Kak-zajti-na-chuzhuyu-stranicu-v-odnoklassnikah-ne-znaya-parolya-i-logina-11-19
rush попперс подделка
https://telegra.ph/Porno-s-poppers-nyuhaet-i-vozbudilsya-gei-02-20
https://paiza.io/projects/Ltkv5EU4xRzWeaMdD7WiCg
https://telegra.ph/CHto-takoe-molding-11-15
https://y5diqe.zombeek.cz
сиалис он