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://rentry.co/7sddgrwp
нейросеть онлайн для учебы nejroset-dlya-ucheby-3.ru .
тадалафил сиалис 5мг
нейросеть для студентов онлайн nejroset-dlya-ucheby-6.ru .
https://j5ttib.zombeek.cz
ии реферат ии реферат .
нейросеть для учебы нейросеть для учебы .
https://telegra.ph/Dipos-moskva-prajs-11-18
перепланировка в москве pereplanirovka-kvartir9.ru .
https://paiza.io/projects/hZfv3aMFKMoBWi51a4HMDQ
долгий попперс
попперс Дербент
https://site627471867.fo.team
поперсмаг 24 ру купить попперсы
https://site778926117.fo.team
https://telegra.ph/Skachat-iso-02-02
https://snippet.host/zmweec
https://telegra.ph/Ruki-iz-plech-video-11-23
реферат через нейросеть реферат через нейросеть .
сиалис дженерик купить в интернет аптеке
левитра дженерик спб
https://telegra.ph/Fitoval-shampun-otzyvy-11-08
фемибой нухает попперс тренинг порно
https://wjynhe.zombeek.cz
https://site966841722.fo.team
виагра сиалис левитра что лучше
https://au79st.zombeek.cz
https://www.bitsdujour.com/profiles/EWe9hB
https://site916646272.fo.team
сайт для рефератов сайт для рефератов .
https://telegra.ph/Programmirovanie-1s-11-10
https://hz2dmk.zombeek.cz
https://telegra.ph/Razukrashki-trolli-11-12
нейросеть пишет реферат нейросеть пишет реферат .
препарат для продления полового акта в аптеке
https://telegra.ph/Kak-prigotovit-sous-teriyaki-11-18
попперс ростов купить на дону
https://site457655186.fo.team
как влияет попперс на мужчину
https://snippet.host/szfcgw
https://telegra.ph/Blefaroplastika-nizhnih-vek-foto-do-i-posle-otzyvy-11-08
https://telegra.ph/Hronicheskij-prostatity-simptomy-i-lechenie-v-domashnih-usloviyah-01-22
попперс дрилинг отзывы
ии для студентов nejroset-dlya-ucheby-6.ru .
нейросеть текст для учебы nejroset-dlya-ucheby-3.ru .
нейросеть для учебы нейросеть для учебы .
https://site780043760.fo.team
согласование перепланировки в москве согласование перепланировки в москве .
https://site49971563.fo.team