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/Lomonosova-22-02-12
https://lbwxze.zombeek.cz
https://telegra.ph/Gdz-po-russkomu-za-8-klass-ladyzhenskaya-11-10
левитра софт Новомосковск
bester wettanbieter online wetten ohne ausweis [Mai]
сиалис таблетки стоимость
https://telegra.ph/Gologramma-dlya-korolya-smotret-v-horoshem-kachestve-hd-1080-11-09
https://www.bitsdujour.com/profiles/YSKpL7
женская виагра
https://9ladxf.zombeek.cz
sportwetten neukundenbonus ohne einzahlung
Feel free to visit my page basketball-wetten.com
попперс для анального фистинга
сиалис характеристика
сиалис аналоги применение
https://9holce.zombeek.cz
где продают попперс
https://telegra.ph/Kupit-poppers-Magnitogorsk-01-17
https://telegra.ph/Qq-music-02-09
https://telegra.ph/Rybolovnyj-mir-bryansk-11-15
попперс госпожа порно
https://rentry.co/ekfpnqtm
https://www.bitsdujour.com/profiles/NEfsdZ
помощь виагры
попперс купить в кемерово
https://site249456904.fo.team
kombiwette rechner
My web site: Sport Bild Wett Tipps
купить попперс Сургут
абц попперс
https://telegra.ph/Canon-fc-128-02-11
https://site225069121.fo.team
https://telegra.ph/Leginsy-calzedonia-12-30
https://www.bitsdujour.com/profiles/QDAQ5W
https://telegra.ph/Tervolina-ekaterinburg-katalog-oficialnyj-sajt-01-12
попперс москва 24
https://site647725007.fo.team
https://telegra.ph/Dispozitivnaya-norma-ehto-11-10
https://site575063947.fo.team
п р и м е н е н и ю