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/Walking-on-air-11-20
https://draudf.zombeek.cz
препарат виагра купить
https://telegra.ph/Proza-ehto-11-15
https://dvzj85.zombeek.cz
https://paiza.io/projects/fknUiSt6xfvAVrP0Qos18w
https://telegra.ph/Dvuhtarifnyj-schetchik-ehlektroehnergii-kupit-v-ekaterinburge-11-17
купить попперс Тула
https://telegra.ph/Freddi-fazber-12-01
считается ли попперс наркотиком
https://telegra.ph/Selezenka-bolit-simptomy-11-08
https://telegra.ph/Poppers-dlya-vozbuzhdeniya-01-25
https://site306775828.fo.team
https://paiza.io/projects/gG6OxhzyQbzt_BwuWxl3PA
https://krjwtp.zombeek.cz
https://snippet.host/fbokxu
сиалис купить в аптеках нижнего новгорода
https://jzviqh.zombeek.cz
попперс Уссурийск
https://telegra.ph/Winline-31-02-12
https://paiza.io/projects/iFrqBuAYAAvDV4n68NmGpQ
https://telegra.ph/Poppers-kupit-moskva-01-03
https://telegra.ph/Oficialnyj-sajt-vulkan-11-19
попперс Череповец
попперсы вк
https://site673509636.fo.team
https://telegra.ph/57-bolnica-moskva-oficialnyj-sajt-11-13
дженерик Новочеркасск
https://gtiv57.zombeek.cz
сиалис цена купить в челябинске
https://2fvoou.zombeek.cz
сиалис 80 мг купить
https://paiza.io/projects/uThLS6X7HhPx8Rje8I_SOw
простата сиалис
попперсы побочный эффект
sportwette vergleich
Have a look at my homepage – online-sportwetten (Margarette)
ароматизатор попперс
купить попперс Уфа
купить сиалис петербург
купить виагру в аптеке
https://site636069073.fo.team
https://telegra.ph/Pravoslavie-ru-kalendar-segodnya-11-17
виагра как действуют
sportwetten tipps kostenlos
My website … Buchmacher esc
https://telegra.ph/Elki-palki-adresa-v-moskve-01-06
wettbüro berlin spandau
My blog post :: basketball wetten strategien (Hermelinda)
https://telegra.ph/Usetv-pp-ua-11-18
https://telegra.ph/Mrunfiny-majnkraft-11-22
где заказать виагру