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/Ural-5323-12-13
умная нейросеть для учебы nejroset-dlya-ucheby-5.ru .
попперс Саратов
https://site903237577.fo.team
сиалис Петербург
https://snippet.host/vtgggt
https://2s3fnt.zombeek.cz
и н с т р у к ц и я
допаксетен
https://www.bitsdujour.com/profiles/fGuHgo
попперс привыкание
super p-force форум
виагра 123 с алкоголем
https://tbmw2e.zombeek.cz
заказать оригинальный сиалис
https://telegra.ph/Kupit-bilet-v-teatr-11-19
https://2wlvao.zombeek.cz
https://telegra.ph/Kupit-poppersy-vladivostok-01-06
чат нейросеть для учебы чат нейросеть для учебы .
https://sjeif7.zombeek.cz
ии для учебы студентов ии для учебы студентов .
https://teletype.link/senatorsdwx56
https://telegra.ph/Uchit-kitajskij-yazyk-s-nulya-11-09
https://snippet.host/focvfi
https://site423803787.fo.team
https://telegra.ph/Avarijnye-11-09
https://bq81q3.zombeek.cz
генерация генерация .
https://whtx6u.zombeek.cz
попперс оптом купить
супер p-forse
сиалис виагра и другие
купить супер виагра Калининград
магазин попперс
https://telegra.ph/Moskva-tailand-bilety-11-16
https://zucn8h.zombeek.cz
попперс москва магазин
https://site161331767.fo.team
купить виагра софт Нижний Новгород
абц попперс воронеж
сиалис виагра купить в интернет магазине
https://www.bitsdujour.com/profiles/WAC8n6
https://telegra.ph/Spas-na-krovi-sankt-peterburg-12-05
реферат через нейросеть реферат через нейросеть .
услуги по перепланировке квартир услуги по перепланировке квартир .
https://www.bitsdujour.com/profiles/ncMQOZ
https://snippet.host/rdfgvc
https://site64194587.fo.team
https://site377483084.fo.team
https://vyce4a.zombeek.cz