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://site782409669.fo.team
п о п п е р с
https://b1aoml.zombeek.cz
https://telegra.ph/Kupit-poppers-rush-11-08-5
https://site810687698.fo.team
https://snippet.host/vsxgpg
https://nqzgwa.zombeek.cz
eurovision buchmacher
Feel free to surf to my webpage :: wetten gutschein ohne einzahlung – Ngan,
https://paiza.io/projects/NIN-_36YS__41S-BMJ9pfg
попперс jj black
https://site686991918.fo.team
super p force
https://telegra.ph/Rebekka-miller-12-23
捕风追影在线免费在线观看,海外华人专属平台采用机器学习个性化推荐,高清无广告体验。
продажа левитры
https://egikqe.zombeek.cz
esport wetten deutschland
Here is my webpage – ergebnisse sportwetten (Edison)
https://telegra.ph/Istihara-dua-11-18
https://telegra.ph/Kupit-poppers-Ufa-01-19
мальчики под виагрой
https://telegra.ph/Kartinki-chary-11-09
wettbüro mannheim
Look at my web site; wetten bonus (Kathie)
https://www.bitsdujour.com/profiles/txPzT0
https://www.bitsdujour.com/profiles/Aer1PA
https://telegra.ph/K-chemu-snyatsya-kury-11-19
https://teletype.link/explorationgyn4395
https://telegra.ph/Love-potion-oriflame-11-19
live wetten erklärung
Also visit my web blog :: wettbüro fürth
купить попперс Каспийск
купить попперс Кисловодск
https://rentry.co/4hc67q2e
https://telegra.ph/Dapoksetin-lekarstvo-02-04
https://telegra.ph/Otrosshaya-chelka-01-04
https://jlit7g.zombeek.cz
попперс Иркутск
https://rentry.co/853ze57u
https://telegra.ph/Stroenie-ehvgleny-zelenoj-11-10
быстродействующая виагра для мужчин в аптеках
https://telegra.ph/Prigotovlenie-testa-dlya-pirozhkov-01-31
https://mzwjir.zombeek.cz
电影网站推荐,海外华人专用,支持中英双语界面和全球加速。
https://telegra.ph/Nebesnye-fonariki-11-19
попперс побочки
wettquoten Online Sportwetten Vergleich
https://telegra.ph/Pticy-arktiki-01-16
сиалис цена в аптеке москва
https://snippet.host/eiyumy
sportwetten wett tipps Heute basketball prognosen
аванафил Кемерово