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://teletype.link/continuedlqw627
вывод из запоя на дому в ростове вывод из запоя на дому в ростове .
нарколог вывод из запоя в ростове нарколог вывод из запоя в ростове .
https://ayi4no.zombeek.cz
установка газового пожаротушения цена установка газового пожаротушения цена .
https://telegra.ph/Gdz-russkij-yazyk-5-klass-bystrova-02-08
https://site63336140.fo.team
https://telegra.ph/SHohbonui-chin-11-12
https://rioyf6.zombeek.cz
вывод из запоя на дому нарколог в ростове vyvod-iz-zapoya-v-rostove-2.ru .
психиатр нарколог на дом в ростове психиатр нарколог на дом в ростове .
https://4m5iib.zombeek.cz
попперс москве
https://snippet.host/uwudmz
apuestas antes del españA Mundial apuestas
https://telegra.ph/Skachat-vord-s-oficialnogo-sajta-besplatno-11-16
с и а л и с
1win вывод через о деньги инструкция 1win вывод через о деньги инструкция
что лучше сиалис или виагра форум
1вин вывод Киргизия 1вин вывод Киргизия
https://site356360182.fo.team
п о п п е р с
pin-up apk rəsmi yükləmə https://pinup09715.help
mostbet ios linki https://mostbet13670.help
mostbet oyun provayderi http://mostbet13670.help/
https://www.bitsdujour.com/profiles/qqm3Wx
mostbet aktual mirror tap https://mostbet13670.help
https://fqeil1.zombeek.cz
вывод из запоя в ростове вывод из запоя в ростове .
нарколог на дом в ростове-на-дону нарколог на дом в ростове-на-дону .
нарколог на дом ростов круглосуточно нарколог на дом ростов круглосуточно .
анонимный вывод из запоя в ростове анонимный вывод из запоя в ростове .
https://www.bitsdujour.com/profiles/jfZ7MJ
лучший попперс отзывы
legislacion casas de apuestas de futbol Seguras para hoy españa
нарколог вывод из запоя на дому в ростове vyvod-iz-zapoya-v-rostove-1.ru .
нарколог вывод из запоя в ростове нарколог вывод из запоя в ростове .
монтаж газового пожаротушения москва монтаж газового пожаротушения москва .
https://rentry.co/ewnze3es
https://www.bitsdujour.com/profiles/GujVxl
нарколог на дом ночью ростов-на-дону narkolog-na-dom-v-rostove-2.ru .
https://telegra.ph/ZHk-zima-leto-sankt-peterburg-oficialnyj-sajt-01-26
https://qjmrkp.zombeek.cz
вывод из запоя на дому в ростове на дону вывод из запоя на дому в ростове на дону .
mostbet qeydiyyat http://mostbet13670.help/
купить в краснодаре сиалис дженерик
https://telegra.ph/Komnatnye-rasteniya-v-interere-kvartiry-01-24
https://6uvxd1.zombeek.cz
вывод из запоя на дому в ростове на дону вывод из запоя на дому в ростове на дону .
https://qgsszl.zombeek.cz