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://w2bdyh.zombeek.cz
sportwette bonus
My homepage – wetten basketball verlängerung (Antwan)
https://snippet.host/skvcuu
генерация nejroset-dlya-ucheby-5.ru .
порно рассказ попперс
вся правда о дапоксетин
сиалис лечение отзывы
https://telegra.ph/Smotret-onlajn-besplatno-serial-grechanka-vse-serii-besplatno-11-25
купить super p-force Камышин
сайт для рефератов сайт для рефератов .
wettstrategie unentschieden
Here is my blog post … Wettanbieter mit Gratiswette; http://www.paveni.cz,
https://rentry.co/4eq9zwco
beste sportwetten deutschland
my web-site wettanbieter ohne Lizenz (gratis-wetten.Com)
https://xtmc8e.zombeek.cz
https://xojf7f.zombeek.cz
https://telegra.ph/Napitok-mohito-bezalkogolnyj-11-14
применение виагры для зачатия
https://telegra.ph/Projti-test-v-varfejs-i-poluchit-vip-na-7-dnej-02-21
сиалис лайт
в а р д е н а ф и л
sichere Sportwetten Tipps Vorhersagen Forum
heute
https://telegra.ph/Tor-kino-11-08
генерация генерация .
https://0pfjyp.zombeek.cz
https://telegra.ph/Vaz-21140-11-18
где можно заказать сиалис
нейросеть онлайн для учебы nejroset-dlya-ucheby-8.ru .
https://site66826830.fo.team
для повышения потенции таблетки
виагра для женщин
https://telegra.ph/SHerlok-serial-smotret-onlajn-1-sezon-12-12
https://telegra.ph/Smotret-serial-policejskij-s-rublevki-11-09
https://site392542608.fo.team
https://snippet.host/cuifnn
https://site760996298.fo.team
https://site420126257.fo.team
купить попперс Красноярск
https://telegra.ph/Olga-serebryakova-01-05
https://spdf2m.zombeek.cz
купить сиалис софт
нейросеть для учебы нейросеть для учебы .
согласование перепланировок согласование перепланировок .
https://telegra.ph/Ohotniche-sobakovodstvo-forum-12-02
виагра без цензуры
https://telegra.ph/Kupit-poppers-Volgodonsk-01-28
попперс english
https://www.bitsdujour.com/profiles/a34ys3
https://n2lnju.zombeek.cz
слабости виагра