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://zhwbn.com/bbs/space-uid-84977.html
https://site297390705.fo.team
https://forum.web.ru/memberlist.php?mode=viewprofile&u=83906
https://www.sportchap.ru/user/Michaelumz/
https://site498323566.fo.team
https://telegra.ph/Glagol-12-16
Vavada regularnie udostepnia nowe kody bonusowe, ktore zapewniaja darmowe spiny i premie bez depozytu.
Proces rejestracji jest szybki, a aktualne lustra gwarantuja stabilne polaczenie z serwerem.
Turnieje slotowe z wysoka pula nagrod przyciagaja zarowno nowych, jak i doswiadczonych graczy.
Zanim aktywujesz bonus, sprawdz wymagania obrotu i terminy waznosci promocji.
Biezace oferty znajdziesz tutaj: vavada code no deposit.
Pamietaj, aby grac odpowiedzialnie i ustalic limity depozytow.
http://pcbspeed.com/dis/home.php?mod=space&uid=353023
https://snippet.host/aayfbr
http://zhwbn.com/bbs/space-uid-90578.html
https://marshallyin.com/members/aliciagreen/
https://www.bitsdujour.com/profiles/y2fGOd
https://www.40billion.com/profile/354746484
https://www.bitsdujour.com/profiles/j6QpEi
https://telegra.ph/Kak-oplatit-zhkh-cherez-internet-11-18
https://www.sportchap.ru/user/Michaeltnr/
доставка цветов в день заказа
Подберем цветы по символике и значению
таблетки для продления полового акта купить в аптеке
http://pcbspeed.com/dis/home.php?mod=space&uid=323186
https://gratisafhalen.be/author/aliciagreen2/
https://forum.web.ru/memberlist.php?mode=viewprofile&u=84039
http://lsdsng.com/user/370937
силденафил Нефтекамск
https://lessons.drawspace.com/post/387282/album
попперсы аптека
https://lessons.drawspace.com/post/388646/album
сисси бой нюхают попперс видео
https://forum.web.ru/memberlist.php?mode=viewprofile&u=83972
попперс Черкесск
https://magazin.orgsoft.ru/forum/user/50528/
https://telegra.ph/Olivia-del-rio-11-24
в
https://magazin.orgsoft.ru/forum/user/50470/
http://www.tjgp.com/home.php?mod=space&uid=283927
https://telegra.ph/Far-kraj-primal-obzor-11-13
http://pcbspeed.com/dis/home.php?mod=space&uid=323255
тадалафил Орехово-Зуево
http://web.symbol.rs/forum/member.php?action=profile&uid=146410
сиалис аптека шах
http://www.openbuilds.co.kr/upload/index.php?members/georgetaumb.5002/
https://lnctqe.zombeek.cz
http://ucglossa.ru/forum/profile.php?mode=viewprofile&u=667857
https://esibev.zombeek.cz
Одной из сильных сторон Playn GO является их приверженность инновациям. Компания не боится экспериментировать с новыми механиками и темами предлагая игрокам свежий и оригинальный контент. Это проявляется в разнообразии их портфолио которое включает как классические фруктовые слоты так и современные видеослоты с комплексными сюжетами и уникальными игровыми механиками такими как Megaways или Grid.
https://forum.web.ru/memberlist.php?mode=viewprofile&u=83929
http://pcbspeed.com/dis/home.php?mod=space&uid=323395
https://paiza.io/projects/a48E57su8uVWN5Ulsgw56w
https://forum.web.ru/memberlist.php?mode=viewprofile&u=84045
https://telegra.ph/Gastello-21-11-08