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://rentry.co/hhkzqd9o
1win verificare buletin 1win5758.help
1win Mastercard https://www.1win5758.help
1win cum primesc cashback https://www.1win62509.help
1win descarcare apk ultima versiune http://1win62509.help/
https://rentry.co/teow6ued
https://lessons.drawspace.com/post/1033318/onespotsocial-com
https://www.bitsdujour.com/profiles/QAyopr
доставка роллов доставка роллов .
tipp Punkte Wetten Basketball vorhersage
https://eufnsc.zombeek.cz
https://zhibts.zombeek.cz
https://t.me/Piastrix_wallet_official
купить попперс Петрозаводск
сиалис с доставкой сдэк
pinup toʻlov kartasi bog‘lash pinup toʻlov kartasi bog‘lash
виагра оригинальная купить
Its awesome designed for me to have a website which is good designed for my knowledge. thanks admin https://maximumvisa.com.ua/chomu-plastyk-pislya-ultrazvukovoho-nozha-ne.html
стратегия продвижения блог seo-blog20.ru .
1win mines pe mobil http://1win5758.help/
https://site789404611.fo.team
juego de avión 1win https://www.1win5772.help
This info is priceless. How can I find out more? https://saunalux.kiev.ua/instrument-shcho-okupaietsya-za-5-far-biznes.html
сколько можно вдыхать попперс
купить попперс Дербент
https://ltw2nr.zombeek.cz
маркетинговые стратегии статьи seo-blog21.ru .
доставка суши спб круглосуточно доставка суши спб круглосуточно .
чем опасен сиалис
https://telegra.ph/Programma-peredach-na-segodnya-rossiya-1-kanal-na-segodnya-01-04
попперс страпон
купить попперсы в краснодаре поперсмаг 32 ру
https://site378314528.fo.team
https://cy9ux3.zombeek.cz
bono 1win https://www.1win5772.help
https://rentry.co/shefqcqq
https://telegra.ph/Maz-yam-instrukciya-11-15
сео продвижение по трафику сео продвижение по трафику .
https://hedgedoc.stusta.de/s/mz4b3N9Dp
besten wett apps
Here is my web-site; alle sportwetten anbieter (Rashad)
sieg platz wette pferderennen
my homepage beste quoten sportwetten (Delmar)
в первый раз нет эрекции
роллы роллы .
https://www.investagrams.com/Profile/garret3626190
роллы бесплатная доставка спб роллы бесплатная доставка спб .
1win inregistrare cu email http://1win62509.help/
мостбет ios скачать приложение https://www.mostbet82043.help
online Dfb Pokal Wetten Tipps vergleich
This info is worth everyones attention. How can I find out more? https://share.google/Z30t1Cjr3wW8UVzlS
https://telegra.ph/4-stor-01-19