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.
заказать проект перепланировки квартиры teletype.in/jorik11/proekt-dlya-pereplanirovki .
https://telegra.ph/Nmc-v-ginekologii-02-09
https://www.bitsdujour.com/profiles/JGU7C3
Казино лекс Казино лекс .
купить попперс Салават
https://telegra.ph/Kino-pro-vdv-11-19
Vivo down Vivo down .
Казино лучшее онлайн Казино лучшее онлайн .
https://ityosf.zombeek.cz
кухни на заказ в санкт-петербурге kuhni-spb-41.ru .
https://mjuzk5.zombeek.cz
узаконивание перепланировки sites.google.com/view/dokument-dlya-pereplan/главная-страница .
https://snippet.host/tkbzsd
заказать кухню стоимость заказать кухню стоимость .
https://telegra.ph/Devajsy-chto-ehto-takoe-11-18
попперс Новосибирск
u попперс
https://rentry.co/3vmkaev6
https://paiza.io/projects/GWoLQreskDAIS8Uo_gAwfQ
попперс Сызрань
легален ли попперс
https://site487738037.fo.team
https://paiza.io/projects/VvA7Q7GSZDLW2usX94C0Hg
заказать кухню онлайн заказать кухню онлайн .
https://telegra.ph/Divinebitches-02-08
https://telegra.ph/Gdz-algebra-11-klass-nikolskij-11-11
https://site662580753.fo.team
https://telegra.ph/Perevod-nemeckij-12-29
https://site574012966.fo.team
https://rentry.co/48k4ryzz
последствия передозировки виагрой
https://telegra.ph/Poppers-na-vajldberriz-12-18
https://www.bitsdujour.com/profiles/NUbeyS
заказать кухню каталог заказать кухню каталог .
левитра продажа
https://telegra.ph/Myagkie-lapki-dlya-koshek-otzyvy-11-22
печатное производство https://exchange.prx.org/series/60434 .
проект перепланировки москва проект перепланировки москва .
https://telegra.ph/Check-ege-edu-ru-11-13
https://site696165993.fo.team
купить попперс Армавир
https://site903628137.fo.team
купить варденафил Петропавловск-Камчатский
Казино онлайн играть Казино онлайн играть .
купить попперс Старый Оскол
https://www.bitsdujour.com/profiles/LBUofa
https://www.bitsdujour.com/profiles/ojUCOR
1win Andijon pul yechish http://1win5767.help
попперс амстердам блэк отзывы
https://www.bitsdujour.com/profiles/vInVE2