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.
1win cashback apuestas https://www.1win5771.help
https://rentry.co/ssmwkqkn
подсыпал курьерше виагру в чай
попперс омск доставка
casa apuestas españa (Lieselotte) plataforma
попперс верхняя радищевская
купить сиалис 5 мг Владимир
продается ли виагра до 18 лет
https://site770075279.fo.team
https://gxc1eq.zombeek.cz
https://pqb5ue.zombeek.cz
внедрение erp 1c http://1s-erp-vnedrenie.ru .
https://paiza.io/projects/nMGw-qrBiKAzm40yDncJpw
https://telegra.ph/Avtorynok-sumy-11-13
виагра и сиалис левитра
https://rentry.co/gspf62v8
виагра дженерики производители
https://telegra.ph/Gostehnadzor-moskva-12-05
https://rentry.co/dv7k7nn7
https://rentry.co/fctfyb6a
https://telegra.ph/Poppersy-prodlevayut-polovoj-akt-12-31
кухни на заказ питер кухни на заказ питер .
кухни на заказ спб недорого с ценами kuhni-spb-43.ru .
ganar paginas estadisticas apuestas deportivas
(Https://basketball-wetten.com/) deportivas tenis
дженерик дапоксетин
попперс легальность рф
https://telegra.ph/Sezon-ohoty-1-12-15
кухня по индивидуальному проекту kuhni-spb-42.ru .
https://telegra.ph/Foto-futbolista-02-21
lucky jet 1win méxico 1win5771.help
https://site8736820.fo.team
https://rentry.co/cykwrz3b
https://teletype.link/handytaw7510
виагра купить москва дешевле
https://site846729321.fo.team
https://paiza.io/projects/lyw898evEJqZEqdPnGNhkA
попперс Петрозаводск
П е т е р б у р г
https://telegra.ph/Stryapuha-11-09
попперс Йошкар-Ола
топ попперсов
внедрение erp цена 1с внедрение erp цена 1с .
https://telegra.ph/Golye-devochki-besplatno-01-22
виагра 100 г
https://paiza.io/projects/oFFq4AMnym3E71QaIijPcQ
1win plinko 1win plinko
https://telegra.ph/Knigogolik-audioknigi-02-21
https://telegra.ph/Nazoneks-cena-analogi-deshevye-02-10
https://telegra.ph/Google-arabe-02-09
1win kartani bog‘lash http://1win5767.help