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://telegra.ph/Gde-u-cheloveka-serdce-11-27
https://telegra.ph/Sokolova-nataliya-11-11
https://telegra.ph/Skolko-let-aleksandru-marshalu-12-03
https://site126238082.fo.team
https://telegra.ph/Amerikanskij-pirog-vikipediya-12-04
https://bgc7tp.zombeek.cz
https://www.bitsdujour.com/profiles/ACpGpw
https://twnkcu.zombeek.cz
https://telegra.ph/Otdyh-na-chernom-more-v-2017-godu-ceny-vse-vklyucheno-02-14
https://telegra.ph/Pozdravlenie-bratu-s-dnem-rozhdeniya-ot-sestry-v-proze-02-04
https://telegra.ph/Skachat-besplatno-onlajn-11-13
https://telegra.ph/Gde-kupit-poppers-v-moskve-01-18
лучший попперс для секса
к у п и т ь
https://paiza.io/projects/LoGwFz_4S7MptvRUG3xwwg
melbet скачать на андроид бесплатно melbet скачать на андроид бесплатно .
https://site741368897.fo.team
https://snippet.host/gtdxba
https://telegra.ph/Laki-dzhon-01-12
скачать приложение мелбет скачать приложение мелбет .
https://telegra.ph/Pogoda-v-tyurnyasevo-12-07
https://telegra.ph/Blochnye-luki-02-16
купить попперс Новосибирск
https://e1loz2.zombeek.cz
https://telegra.ph/Skachat-muzyku-didyulya-11-19
купить аванафил Каменск-Уральский
basketball wetten gerade ungerade (Verena) gratiswette
https://paiza.io/projects/l4nYV-JAe6NW34NDw81sgg
gute wettanbieter
my web blog; über unter wette strategie
ищу тебя Ростов на дону
https://site985100917.fo.team
https://teletype.link/kindfgn0347
купить софт набор Чита
попперс заказать в москве
https://telegra.ph/Btku-11-09
beste bonus sportwetten
Feel free to visit my webpage … vermittler von wetten bei pferderennen (https://aanpublishing.com/)
https://site79012693.fo.team
Встречи Ростов на дону
отличия виагра сиалис
https://www.bitsdujour.com/profiles/IIIvh3
https://telegra.ph/Magazin-pobeda-ulyanovsk-katalog-tovarov-ceny-skidki-01-03
https://paiza.io/projects/9KWQWh0eU1u-BA0rPnQvdg
live wetten app
Take a look at my site; beste esports wettseite
https://site474272996.fo.team
https://n4ixbw.zombeek.cz
https://ybtt7g.zombeek.cz
секс Ростов на дону
мелбет официальный сайт скачать мелбет официальный сайт скачать .
https://u0jevd.zombeek.cz