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.
how to win slot machines canada, usa casino bonuses
and how many casino are in australia, or best Dragon Quest 8 Casino strategy in london uk
гей секс под попперсами
плинко регистрация на сайте плинко регистрация на сайте
1xbet yeni adresi 1xbet yeni adresi .
порнуха нюхает попперсы геи
https://telegra.ph/Kupit-levitra-soft-Joshkar-Ola-12-27
https://teletype.link/creativityxjg307
canadian casino guide blackjack chart, online slots casino
australia and bingo the uk, or spin palace withdrawal canada
my web site; how to overcome gambling debt, Betsey,
mostbet казино вход mostbet казино вход
купить левитра Грозный
sweet bonanza ios встановлення sweet bonanza ios встановлення
виагра есть ли противопоказания
melbet воридкунӣ аз корт melbet20856.help
https://p5ilio.zombeek.cz
https://kzukfd.zombeek.cz
https://mvu5o9.zombeek.cz
п о п п е р с ы
https://site551249296.fo.team
подъем фундамента и усиление грунта usilenie-gruntov-1.ru .
melbet вход россия melbet41682.help
https://pwk0u3.zombeek.cz
New players at Betano start strong with an incredible welcome offer. https://tikitakagm.org/el/how-to-play/ Betano drops bonuses like most casinos drop excuses.
https://snippet.host/btgcwg
https://rentry.co/fcfdq8cp
curacao wettanbieter
Stop by my web site Basketball-Wetten.Com
гидроизоляция подвала гаража гидроизоляция подвала гаража .
https://telegra.ph/Deloniks-korolevskij-01-08
esport wetten strategie
my blog; Asiatische Buchmacher Deutschland
1xbet g?ncel adres 1xbet g?ncel adres .
виагра в москве цены
1win jocuri demo https://1win5808.help
https://site212203091.fo.team
https://v92ekw.zombeek.cz
https://telegra.ph/Ashan-na-krasnoselskoj-11-18
игра попперс
https://telegra.ph/Otrochestvo-povest-11-12
попперс 2
софт набор Улан-Удэ
mid united states casinos, united kingdom online casino free bonus no
deposit required and free online united kingdom casino, or 2021 no deposit
bonus codes uk
My web-site; Goplayslots.Net
https://xlc9ey.zombeek.cz
плинко вывод usdt http://plinko61038.help
переделанные виагры
https://telegra.ph/Tinkoff-bank-samara-oficialnyj-sajt-11-19
https://snippet.host/cxprua
1xbet giri? g?ncel 1xbet giri? g?ncel .
с а м о в ы в о з о м
https://paiza.io/projects/KFRIF3162dQ2FGMHVKZfTQ
https://rentry.co/z4qd2d7k
deutschland spiel wetten
My blog: beste online sportwetten seite – Ivory -
Собираете детскую площадку сами? Несколько советов от практика. Используйте строительный уровень заглубляйте стойки на 50-60 см все болты закрывайте заглушками. И обязательно бетонируйте опоры — качели создают серьёзную нагрузку.