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://owryk8.zombeek.cz
https://rentry.co/p8g5tb35
https://site823306419.fo.team
https://paiza.io/projects/YQADJ6JQBRDbvm51ABxUVg
можно ли пить виагру с алкоголем
виагра продливает половой акт
https://site145607721.fo.team
esports Basketball Wetten ErkläRung deutschland
https://paiza.io/projects/ZnWZztHXsdxj-CdnwcnVZg
попперс Серпухов
https://site158361400.fo.team
https://ondlnk.zombeek.cz
сиалис софт челябинск
тайланд попперс
https://bm6gxa.zombeek.cz
https://telegra.ph/Film-aleksandr-makedonskij-11-19
попперс коломенская
попперсы оптом
п о п п е р с
самый лучший попперс для женщин
https://iri1kv.zombeek.cz
самый продолжительный попперс
https://teletype.link/preventingulo386
https://telegra.ph/Jean-dujardin-11-16
дженерики сиалиса
https://snippet.host/bsbpjj
https://site175564572.fo.team
попперс крем
https://snippet.host/xenfss
https://site201938200.fo.team
https://www.bitsdujour.com/profiles/uDuuIi
Big Bass Bonanza — cast spin win big Free spins Big Bass Bonanza strategy feature is where legends are made.
https://telegra.ph/Skanirovanie-teksta-s-fotografii-onlajn-02-08
https://site537491749.fo.team
https://site704865451.fo.team
https://site871617163.fo.team
цена левитра сиалис виагра
https://telegra.ph/Kosmetika-ehjvon-otzyvy-11-14
мотивация попперс сисси девочка
https://www.bitsdujour.com/profiles/U18riB
https://telegra.ph/Vodiy-ua-12-02
Заказ букетов Безопасная оплата цветов онлайн на сайте
женская виагра купить
силденафил Якутск
https://paiza.io/projects/mje-Xgk7zL3e91TcF4RSrg
https://www.bitsdujour.com/profiles/H1icPG
https://telegra.ph/Mehomaniya-chelyabinsk-katalog-11-19
https://site154895798.fo.team
https://telegra.ph/Kupit-vitafon-11-09
https://telegra.ph/Kupit-poppers-Krasnoyarsk-01-03