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.
http://bbs.51pinzhi.cn/home.php?mod=space&uid=7685487
попперс купить адреса
http://fumankong1.cc/home.php?mod=space&uid=825301
http://bbs.dubu.cn/home.php?mod=space&uid=484477
https://bbs.panabit.com/home.php?mod=space&uid=452641
что делать если быстро кончаешь
http://zgyhsj.com/space-uid-992409.html
http://fufuba.cn/home.php?mod=space&uid=20273
https://snippet.host/astizc
http://seafishzone.com/home.php?mod=space&uid=2680361
https://www.9kuan9.com/home.php?mod=space&uid=4105795
https://site579836222.fo.team
http://app.aqlife.com/home.php?mod=space&uid=481610
https://telegra.ph/Surgutneftegazbank-ipoteka-01-30
https://www.multimediaxis.de/members/57450-TracyAlach
http://www.gtcm.info/home.php?mod=space&uid=1278134
https://www.ydmoli.com/home.php?mod=space&uid=3538
https://muxboc.zombeek.cz
http://www.xgmoli.com/bbs/home.php?mod=space&uid=28763
http://zghncy.cn/home.php?mod=space&uid=910848
https://usqldy.zombeek.cz
http://ragnarokneon.online/home.php?mod=space&uid=31119
http://www.qingdaomop.com/space-uid-188319.html
виагру
http://3ak.cn/home.php?mod=space&uid=243230
купить женская виагра Каменск-Уральский
https://www.freecraft.eu/members/tracybox.11216/
девственник виагра
http://jiangzhongyou.net/space-uid-649902.html
http://iawbs.com/home.php?mod=space&uid=937844
виагра в турции отзывы
http://asresin.cn/home.php?mod=space&uid=556747
http://wowanka.com/home.php?mod=space&uid=594643
где купить попперс в самаре
http://www.god123.xyz/home.php?mod=space&uid=1298983
дженерик виагра спб
http://sglpw.cn/home.php?mod=space&uid=630798
http://bbs.hy2001.com/home.php?mod=space&uid=898472
https://site869678047.fo.team
http://bbs.dubu.cn/home.php?mod=space&uid=511733
https://site379195233.fo.team
http://www.baohaibbs.com.cn/home.php?mod=space&uid=56860
http://zgyhsj.com/space-uid-996592.html
рейтинг попперс
https://bbs.sanesoft.cn/home.php?mod=space&uid=1361745
beste wettanbieter schweiz
Also visit my blog; doppelte chance wetten erklärung
http://foru1f40m.bunbun000.com/bbs/home.php?mod=space&uid=9758194
https://www.bitsdujour.com/profiles/fshYnf
http://bbs.yunduost.com/home.php?mod=space&uid=156882
http://iapple.minfish.com/home.php?mod=space&uid=6045605