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://breakthroughnetworking.com/author/lawgoo7518/
https://espritgames.com/members/51155662/
http://jobboard.piasd.org/author/fasterzic868/
https://www.instructorsnearme.com/author/tunnellwf287/
http://shichaoliuluntan.com/home.php?mod=space&uid=425762
https://selficlub.com/checkingoei58
https://electroswingthing.com/profile/distinctionyzu567/
basketball über unter wetten overtime österreich türkei
http://clinicalbraintraining.com/author/defenceygf2965/
https://fabble.cc/rangeaes5769
https://paper.wf/originsctk8581/prosto-nash-komp-iuter-delaet-zapros-drugomu-tot-daiot-otvet-i-nash-komp-iuter
biathlon wettquoten
Also visit my blog post basketball wetten bei betolimp (accurateleads.com)
https://metro-estates.ch/agent/tattoowzp24/
https://metro-estates.ch/agent/writewzn0848/
sportwetten bonus neu
Here is my blog post; basketball wettarten wetten, Manuela,
купить дженерик Волгодонск
levere tipping steinkjer
my page :: nye utenlandske odds (https://betweenthehangers.com/hvordan-muchbetter-letter-betalinger-For-sportsbetting/)
https://www.roton.com/forums/users/lld99z2xle/
https://teletype.link/discnpx618
el casino balsareny – Sherryl
- santa catalina las palmas
https://doc.imaginaerraum.de/s/5rms1YgOn
https://www.roton.com/forums/users/z2xaimn1tx/
pferderennen Basketball Wetten Vorhersagen
schweiz
https://pad.cgtinformatica.org/s/Bkq_YXhrMx
vierklee wetten bonus
Review my web page: wett tipps Heute basketball
https://paper.wf/gossipahm91/prijestupna-godina-koja-po-inje-u-subotu-po-67-dana-zaostaju-em-julijanskom
https://fabble.cc/programmingcqh6271
https://www.roton.com/forums/users/uzay961soz/
https://meng-yue.yygame.tw/home.php?mod=space&uid=52078
jucatoare de tenis germane
Visit my homepage: casa pariurilor bonus Dublu
https://vcook.jp/users/104423
buchmacher hamburg
my web-site … basketball Wett Strategien
pronosticos 1X2 En Apuestas Que Significa deportivas hoy
Здорова народ Отец не выходит из штопора Соседи стучат в стену В больницу тащить страшно Короче только это реально спасло — наркологическая помощь на дому круглосуточно эффективно Дал рекомендации и успокоил семью В общем жмите чтобы сохранить — помощь нарколога на дому https://alkogolizm.narkolog-na-dom-ekaterinburg-10.ru Нарколог на дом — это реальный выход Перешлите тем кто в такой же ситуации
https://md.warpzone.ms/s/wDT9gPNrQv