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://site499862594.fo.team
paginas apuestas favoritos eurocopa online
купить виагра Липецк
попперс москва доставка на дом
https://telegra.ph/Kraton-oficialnyj-sajt-ceny-11-10
наклейки типография наклейки типография .
https://site246692260.fo.team
https://telegra.ph/Seks-brazzers-12-19
Good morning Learn vaccine mysterious effects to find interesting and valuable immune facts and strengthen your body shields see on the website for vaccine info Full information on the link – https://202fliks.site All the best and development in business
санкт петербург попперс
https://rentry.co/neb4z6og
https://telegra.ph/Akrosta-konkursy-dlya-detej-i-pedagogov-12-01
попперс Санкт-Петербург
como hacer buenas apuestas deportivas [Fr-betting.com] y
pronosticos de futbol
https://xrsdb4.zombeek.cz
https://rentry.co/r6sy9bcy
https://rentry.co/65zte76o
https://site284087079.fo.team
https://1ggpwm.zombeek.cz
https://www.bitsdujour.com/profiles/zzR44y
carrera de caballos con apuestas under over
https://telegra.ph/Operativnaya-pechat-11-08
https://8qseoi.zombeek.cz
https://onxncf.zombeek.cz
попперс fist купить
https://paiza.io/projects/IWxv4WBJ5C_R2PiS-Hmc_Q
https://telegra.ph/Uroki-ostorozhnosti-tetushki-sovy-01-13
попперс в москве купить с доставкой
https://site196067374.fo.team
https://telegra.ph/Kino-pik-01-12
https://telegra.ph/SHepelev-instagram-12-12
sissy попперс порно
дапоксетин Абакан
удлинить половой акт
1win поддержка кыргызча 1win поддержка кыргызча
1win mines на деньги https://www.1win91276.help
о р г а з м
печать стикеров печать стикеров .
https://rentry.co/g4frnv4e
мелбет сроки верификации https://melbet76815.help/
п о п п е р с
мостбет авторизация https://mostbet39081.help
заказать газовое пожаротушение montazh-gazovogo-pozharotusheniya-1.ru .
проект и монтаж газового пожаротушения проект и монтаж газового пожаротушения .
купить сиалис Элиста
https://site241967984.fo.team
seo продвижение и раскрутка сайта prodvizhenie-sajtov-v-moskve9.ru .
монтаж газового пожаротушения спб монтаж газового пожаротушения спб .
Awesome Its in fact awesome article I have got much clear idea regarding from this article. https://share.google/QeFQx5gmBWhlCRV2G