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://site696408177.fo.team
https://teletype.link/ownedrye212
https://site299204382.fo.team
виагра Владивосток
что такое женская виагра как действует
сколько стоит виагра в аптеке
https://www.bitsdujour.com/profiles/SZnK80
https://onz3l4.zombeek.cz
https://snippet.host/jvncvv
рецепт виагры дома
melbet скачать андроид melbet скачать андроид .
сиалис сколько стоит
https://sk84v7.zombeek.cz
заказ букета с доставкой по москве недорого – Кустовые розы в нежном оформлении купите
https://1qh2nb.zombeek.cz
https://9kb5yj.zombeek.cz
https://rentry.co/e8h36tp3
melbet скачать мобильное приложение melbet скачать мобильное приложение .
перепланировка квартиры цена перепланировка квартиры цена .
https://telegra.ph/Ivolga-pesnya-slushat-11-27
https://telegra.ph/Poppers-Nefteyugansk-01-14
https://rentry.co/9r5ys925
купить тадалафил Набережные Челны
проектная организация для перепланировки квартиры proekt-pereplanirovki-kvartiry22.ru .
официальная версия мелбет melbet-ru.it.com .
https://telegra.ph/Ssangyong-actyon-sport-11-15
пробуем попперс
https://telegra.ph/Oplata-bonusami-spasibo-ot-sberbanka-11-19
попперс Омск
внедрение 1с стоимость внедрение 1с стоимость .
https://telegra.ph/Gdz-lukashik-11-09
таблетки виагра стоимость
https://rentry.co/s3xhsaso
купить супер левитра Тюмень
виагра Элиста
https://site62881686.fo.team
купить попперс Брянск
https://paiza.io/projects/FsWmhOU6CuN6uiAgZzaWGg
https://site898024672.fo.team
скачать мелбет бесплатно http://mobilemelbet.ru .
https://www.bitsdujour.com/profiles/jm7zEd
https://telegra.ph/Kupit-viagra-soft-ZHukovskij-01-24
купить попперс Пятигорск
https://telegra.ph/Kupit-poppers-rush-11-07-2
купить женская виагра Набережные Челны
https://site43699850.fo.team
https://telegra.ph/Sse2-11-13
п о п п е р с
подсыпала сыну виагру
скачать приложение мелбет бесплатно скачать приложение мелбет бесплатно .