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.
джангл джус попперс
melbet бонус на первый депозит http://melbet51923.help
угадай мелодию виагра 2 маши
apuestas euro copa – Rich, real madrid betis
https://teletype.link/pregnancythr261
internetagentur seo prodvizhenie-sajtov-v-moskve9.ru .
https://telegra.ph/Akkumulyatory-medved-otzyvy-02-16
https://telegra.ph/Poppers-nizhnij-novgorod-01-14
мелбет официальный сайт вход мелбет официальный сайт вход
casas colombia chile apuestas – Deana, bonos sin deposito
https://site465924406.fo.team
установка газового пожаротушения под ключ montazh-gazovogo-pozharotusheniya-1.ru .
попперс Нефтекамск
попперс сперма
попперс вызывает ли зависимость
https://rentry.co/ab5hthzk
https://www.bitsdujour.com/profiles/PKXDx9
сиалис русские аналоги
https://telegra.ph/Lozhitsya-spat-02-15
https://telegra.ph/Virtualnye-tury-02-20
https://site734591703.fo.team
https://telegra.ph/Voxtel-rx500-11-19
melbet не приходит код https://www.melbet30926.help
мелбет джекпот слоты melbet30926.help
https://telegra.ph/Console-log-02-19
https://site210122117.fo.team
виагре 50
https://telegra.ph/Raspisanie-ehlektrichek-ehlektrogorsk-pavlovskij-posad-01-19
https://telegra.ph/Konturnaya-karta-10-klass-11-15
мелбет mines стратегия мелбет mines стратегия
силденафил Якутск
продвижение сайта продвижение сайта .
https://rentry.co/aiovvxid
https://uo9hpi.zombeek.cz
стоимость монтажа газового пожаротушения montazh-gazovogo-pozharotusheniya-3.ru .
https://d7mq12.zombeek.cz
https://telegra.ph/Lichnyj-kabinet-megafon-kavkaz-12-09
попперс геи порно видео
воздействие виагры на мужчину
https://site574847931.fo.team
https://rentry.co/2py8qiau
https://telegra.ph/Porno-s-valentinoj-azarovoj-11-16
купить попперс Новошахтинск
купить попперс Новомосковск
https://telegra.ph/Osnooker-net-02-17
https://paiza.io/projects/wcKlvZ_5mn3Hg2UyM1JQyg
https://teletype.link/coinsyng4858
виагра интервью
аналог виагры без рецепта
https://site842000864.fo.team