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://www.bitsdujour.com/profiles/DWCjXS
https://bbs.sanesoft.cn/home.php?mod=space&uid=1301126
https://rentry.co/uy7dpcao
https://site265477247.fo.team
http://iapple.minfish.com/home.php?mod=space&uid=5893919
https://www.9tj.net/home.php?mod=space&uid=479193
http://huaihuagongshe.com/home.php?mod=space&uid=496069
https://paiza.io/projects/MR8xCe27jSgCL89lvS6oZA
https://site530886677.fo.team
попперсы русское порно
https://telegra.ph/Sejchas-v-kinoteatrah-moskvy-02-16
https://telegra.ph/E-academie-11-24
https://wmgz6i.zombeek.cz
https://paiza.io/projects/mpqRrG02SRg3Rx24Rw9b1Q
препарат левитра
online basketball wetten tipps europa league [Harrison] mit startguthaben
https://site975031545.fo.team
попперс Волжский
https://www.bitsdujour.com/profiles/ijNrgf
besten sportwetten apps
Feel free to surf to my web site :: buchmacher wetten
мужская виагра лучшая
https://k7fjnt.zombeek.cz
https://telegra.ph/Nyashki-nyu-01-11
https://rentry.co/bufhumrx
https://site977976178.fo.team
kombiwetten strategie
Here is my web-site – wetten gewinn ideen (gratis-wetten.com)
https://zrdgjl.zombeek.cz
купить попперс в ярославле
https://telegra.ph/Do-inauguracii-trampa-ostalos-02-10
https://telegra.ph/Amoksiklav-1000-cena-v-spb-11-19
аптека купить попперс
https://telegra.ph/SHatura-yaroslavl-11-16
https://telegra.ph/Ikarus-55-11-10
esc wetten quoten
my page Beste Buchmacher Deutschland
https://snippet.host/ajtmty
https://telegra.ph/Kak-zaregistrirovatsya-na-sajte-gosuslugi-12-04
You ought to be a part of a contest for one of the most useful blogs on the internet. I am going to recommend this site!
https://telegra.ph/Kalkulyator-metallov-02-04
виагра аптеки воронеж
https://telegra.ph/Prodazha-volos-11-20
купить попперс Альметьевск
как проявляется виагра
https://teletype.link/bathskpp7943
попперсы москва круглосуточно
попперсы amsterdam
yusaon gold slots, is it legal best way to play craps odds play online slots in australia and casino chips value uk,
or fully cashable no deposit bonus australia
https://sbcr2o.zombeek.cz
попперс Копейск
попперс Кемерово
https://telegra.ph/Prishvina-22-11-19