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.drugs.ie/?URL=wm-lend.ru
https://webmasters.directorycritic.com/members/irvinrer-1463.html
https://dahuafu.us/?4597
https://telegra.ph/Remont-dzhakuzi-11-12
https://www.collectivemankind.com/forum/member.php?action=profile&uid=439
попперс принцип действия
http://bocauvietnam.com/member.php?1309832-GeorgeGuasy&tab=aboutme
https://bdsmboard.org/member.php?145642-Michaelrak
https://telegra.ph/Forsazh-8-12-31
http://aku.org.cn/home.php?mod=space&uid=375339
https://ny31d9.zombeek.cz
http://www.69zhouyi.com/home.php?mod=space&uid=804807&do=profile
http://www.zgbbs.org/home.php?mod=space&uid=121357&do=profile&from=space
http://bbs.topeetboard.com/home.php?mod=space&uid=58425
https://exsxgu.zombeek.cz
wettbüro
Here is my blog post … basketball Wett tipps forum (https://basketball-Wetten.com/)
http://bbs.topeetboard.com/home.php?mod=space&uid=59471
купить в аптеке днр сиалис
http://bbs.py27.com/home.php?mod=space&uid=364021&do=profile
https://f7szul.zombeek.cz
https://domain.opendns.com/wm-lend.ru
wetten sport online
My web-site: lizenz wettbüro (Frank)
супер сиалис Таганрог
https://www.nutsvolts.com/?URL=wm-lend.ru
https://paiza.io/projects/uL4FuQYuCSkQiMKR566dDQ
https://nervetumours.org.uk/?URL=wm-lend.ru
https://grantha.jiva.org/index.php?show=profile&m_no=31108
https://grantha.jiva.org/index.php?show=profile&m_no=30161
https://telegra.ph/Poppers-spb-kirovskij-01-06
https://ionpron.net/profile.php?mode=viewprofile&u=1609839
https://www.houseinformatica.it/forum/pop_profile.asp?mode=display&id=3837
https://www.bitsdujour.com/profiles/SjJbRb
https://www.houseinformatica.it/forum/pop_profile.asp?mode=display&id=8553
https://paiza.io/projects/kEnZSBFGWWpdCBAUmOq65w
https://www.ecmo.ru/users/antoniogex
https://www.ecmo.ru/users/peterphiff
левитра купить
лучшие службы доставки цветов
http://www.digitax-uk.com/forum/profile.php?mode=viewprofile&u=548875
попперс воронеж доставка
цветы с открыткой
https://vb.ckfu.org/u330151.html
https://rb8wny.zombeek.cz
https://www.bluelightbride.com/member.php?action=profile&uid=523981
https://forum.priboridetali.ru/member.php?u=388291
https://forum.priboridetali.ru/member.php?u=394815
https://telegra.ph/Kupit-poppers-Spb-01-25
https://f48.ee/?url=wm-lend.ru
попперс симферополь купить