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://www.majalahsains.com/careers/employer/tracyqjk639/
https://rentry.co/enzzoq5f
лучшие агентства seo продвижения reiting-seo-kompanii.ru .
mostbet депозит https://mostbet34518.help
https://paiza.io/projects/KpKT4zMYlXzwpRfND6EbTA
купить попперс Ногинск
https://site735531429.fo.team
создать сайт прогнозов на спорт в москве создать сайт прогнозов на спорт в москве .
https://www.bitsdujour.com/profiles/paj6Gm
виагра для мужчин цена аналоги дешевые
https://snippet.host/vjujmb
обзор попперсов
продвижение сайта продажи kak-prodat-sajt.ru .
https://telegra.ph/Kotova-irina-korolevskaya-krov-1-chitat-onlajn-11-17
попперс Владикавказ
ебля попперс
https://site712513853.fo.team
melbet md site melbet md site
https://bf4btr.zombeek.cz
sportwetten vorhersagen heute
Take a look at my homepage: basketball wm wetten
https://telegra.ph/Rutaksi-03-09
https://telegra.ph/Kupit-super-viagra-Pervouralsk-01-18
wetten gratis ohne einzahlung
My site … sportwetten öSterreich (https://WWW.Nexc.cloud/)
https://telegra.ph/Sport-ehkspress-sportivnyj-portal-11-17
как продать сайт как продать сайт .
https://telegra.ph/Skachat-valhak-11-11
https://telegra.ph/Poleznye-svojstva-tvoroga-02-16
https://snippet.host/acacha
unblock 1win unblock 1win
сиалис Екатеринбург
мелбет кз ставка не принята мелбет кз ставка не принята
https://paiza.io/projects/oddkZ67aCOV26pMfJ0j3fg
https://telegra.ph/Karaoke-centr-12-18
seo ranking services seo ranking services .
купить попперс Старый Оскол
https://telegra.ph/Tvorozhnye-keksy-v-silikonovyh-formochkah-recepty-02-17
mostbet ios https://mostbet2017.help/
über tore wetten tipps
Have a look at my homepage :: Beste Wettanbieter Paypal (Https://Prosperitywealthplanning.Centsai.Co/Online-Casinos-Apple-Pay)
1win hesab açılması 1win34861.help
https://31lwbx.zombeek.cz
https://ph1ncr.zombeek.cz
https://snippet.host/odueiu
https://lxxjkd.zombeek.cz
купить дапоксетин в москве заказ по телефону
https://site23540048.fo.team
попперс Находка
https://site552329180.fo.team
oglinda functionala melbet oglinda functionala melbet
gratiswette für neukunden
Also visit my page: buchmacher app
мелбет идентификация melbet06374.help