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://u4vkyj.zombeek.cz
попперс Новосибирск
https://telegra.ph/CHto-takoj-poppers-01-06
https://site199082947.fo.team
https://www.bitsdujour.com/profiles/ejmFeG
https://gxvkxeawwa.wordpress.com
https://telegra.ph/Poliklinika-94-nevskogo-rajona-samozapis-01-12
https://telegra.ph/SHnur-obezyana-i-orel-klip-smotret-11-18
https://paiza.io/projects/nemBBxPZWZhP_Tg_b9gshQ
https://telegra.ph/V-apteke-prodaetsya-viagra-12-03
самый мощный попперс
https://telegra.ph/Poppers-Nizhnekamsk-01-06
сиалис какие бывают
https://rentry.co/pof9p3n9
купить дженерики в спб
https://ybh8wf.zombeek.cz
https://azacgxicis.wordpress.com
https://site632683768.fo.team
https://azacgxicis.wordpress.com
отличие сиалис от тадалафила
попперсы отзывы женщин
https://www.bitsdujour.com/profiles/Y2wrQW
https://www.bitsdujour.com/profiles/f3pW77
https://www.bitsdujour.com/profiles/XEX0mh
попперс барнаул купить
https://zfcejfyxiv.wordpress.com
https://mozrqg.zombeek.cz
https://tdzhi9.zombeek.cz
купить попперс Серпухов
https://zfcejfyxiv.wordpress.com
купить попперс Пермь
https://telegra.ph/Kivi-na-bitkoin-11-25
https://site903871494.fo.team
дженерик левитра спб купить
was sind buchmacher
Also visit my web site :: basketball handicap wetten [Pauline]
https://telegra.ph/Kakoj-vopros-zadat-parnyu-chtoby-zainteresovat-ego-01-03
где купить виагру женскую
от виагры
wettstrategie gerade ungerade
Look into my site Alle wettseiten
https://telegra.ph/Modulnye-11-11
https://www.bitsdujour.com/profiles/kXxczV
анал под попперс порно
https://rentry.co/82akhv43
https://telegra.ph/Orudie-smerti-gorod-kostej-smotret-11-14
https://telegra.ph/Naciya-z-4-sezon-11-09
попперс Нижний Тагил
https://telegra.ph/Team-sokolov-ru-11-14
https://31c9zb.zombeek.cz
купить попперс Бердск
https://snippet.host/xgtudh