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.
99 down caiu.site .
Казино лекс Казино лекс .
https://snippet.host/tqtvuu
купить попперс Керчь
https://paiza.io/projects/z3Jsvhjs9yJ7fbZqEd95cw
https://telegra.ph/Urdoksa-instrukciya-po-primeneniyu-02-04
https://site85973505.fo.team
заказать кухню стоимость zakazat-kuhnyu-1.ru .
comparador casas apuestas
Also visit my homepage: basketball-Wetten.com
https://snippet.host/augamk
casas de apuestas antes del mundial (Corazon) en linea
https://telegra.ph/Pandok-voronezh-oficialnyj-sajt-11-11
https://vzgaxn.zombeek.cz
услуги по перепланировке квартир услуги по перепланировке квартир .
попперс Смоленск
https://paiza.io/projects/XazFUv78z-4A-N0JiDr5rA
кухня по индивидуальному заказу спб kuhni-spb-41.ru .
https://telegra.ph/Televizor-kupit-kiev-so-sklada-11-18
заказать кухню рассчитать стоимость заказать кухню рассчитать стоимость .
https://telegra.ph/Pansionat-fregat-adler-oficialnyj-sajt-ceny-na-2017-god-12-21
как правильно использовать попперс
https://vog5la.zombeek.cz
https://rentry.co/794vphti
https://telegra.ph/Slovar-bankovskih-terminov-02-21
https://site584754933.fo.team
super p-force Батайск
https://telegra.ph/Kredit-vebmani-11-08-48
попперс в россии
https://telegra.ph/Vigrx-plus-02-21
сколько стоит сиалис в таблетках
https://paiza.io/projects/IL7oiseUlZmppIKSxOZCcw
https://telegra.ph/G-com-11-16
https://paiza.io/projects/H8jBJvmXMbLX3BBW5H93_Q
полиграфические работы https://bresdel.com/blogs/1432784/D0A2D09ED09F-D0B2D0BED0BFD180D0BED181D0BED0B2-D0BAD0BED182D0BED180D18BD0B5-D0BDD183D0B6D0BDD0BE-D0B7D0B0D0B4D0B0D182D18C-D0BCD0B5D0BDD0B5D0B4D0B6D0B5D180D183-D182D0B8D0BFD0BED0B3D180D0B0D184D0B8D0B8-D0BFD0B5D180D0B5D0B4-D0BFD0B5D187D0B0D182D18CD18E .
https://site752565609.fo.team
виагра цены омск
https://paiza.io/projects/A9m1yacxULe5gZ095-KLFA
https://telegra.ph/Pogoda-tyumencevo-01-11
https://telegra.ph/Transfer-kidnapper-kod-aktivacii-besplatno-02-02
https://telegra.ph/Mirra-imya-01-19
https://telegra.ph/960-evo-02-10
https://telegra.ph/Kak-sdelat-cifru-1-na-den-rozhdeniya-11-18
https://vwkhe0.zombeek.cz
https://telegra.ph/Mnogo-spermy-video-11-18
https://snippet.host/buypfw
https://telegra.ph/Skachat-pesni-kino-02-14
https://8orjfu.zombeek.cz
как пользоваться попперсом
https://yxgc4h.zombeek.cz
купить сиалис недорого