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.
wetten olympische spiele
my homepage; Sportwetten strategie Surebets
дженерик сиалис караганда
поисковое продвижение москва профессиональное продвижение сайтов prodvizhenie-sajtov-v-moskve17.ru .
супер левитра Барнаул
https://rentry.co/iv65zne6
купить задание для студентов kupit-kursovuyu-89.ru .
https://site456333427.fo.team
live wetten bonus
Feel free to surf to my homepage beste Us open wettanbieter
https://paiza.io/projects/YhrIa2YXyGoW42uYuGZ9kA
https://rentry.co/ba5rz9ww
https://telegra.ph/Veb-kamery-ehlbrus-onlajn-v-realnom-vremeni-02-26
п р е п а р а т ы
https://telegra.ph/Filmy-na-noch-11-14
https://paiza.io/projects/OCg1aBq0vOEws9hILRwnDw
мостбет регистрация Киргизия mostbet94063.help
https://site36262585.fo.team
https://site821777681.fo.team
https://snippet.host/yidbms
https://telegra.ph/Film-pro-snoudena-01-31
к р у г л о с у т о ч н о
https://wrozxk.zombeek.cz
official mostbet website https://www.mostbet53160.help
попперс Березники
melbet официальный адрес http://www.melbet47086.help
https://telegra.ph/Sialis-5mg-analogi-01-25
https://zrzrql.zombeek.cz
возбудитель мужской виагра в аптеке
mostbet kifizetés késik mostbet kifizetés késik
Бездепозитные бонусы в Арменири
https://rqbixz.zombeek.cz
https://paiza.io/projects/boR8lXL2-ZVRMq6vej7eLg
попперс шоп
https://telegra.ph/SHkola-39-cheboksary-oficialnyj-sajt-11-10
продвижение сайтов продвижение сайтов .
https://electroswingthing.com/profile/servicewsf883/
pferderennen berlin Basketball unentschieden wetten
https://dcsywj.zombeek.cz
https://site505650494.fo.team
интернет раскрутка prodvizhenie-sajtov-v-moskve17.ru .
Онлайн казино в Армении
FanDuel Casino is Americas #1 online casino delivering constant thrills with ignition casino complaints exclusive slots like Huff N Word and last affairs undertaking normal at your fingertips. New players get 500 Largesse Spins added 40 in Casino Compensation decent for depositing 10—bonus up to 1000 fail on first-day net losses. Province all Thrillionaires: accompany minute vie with your way and turn every interest into epic wins
а д а п т е р
попперс Волжский
https://telegra.ph/Kompaniya-tehnologiya-stroitelstvo-domov-pod-klyuch-ceny-02-08
seriöse sportwetten online (Mark) wettseite
https://jyjkem.zombeek.cz
сколько стоит заказать курсовую работу сколько стоит заказать курсовую работу .
cómo jugar lucky jet en 1win 1win5772.help
pin-up qanday roʻyxatdan oʻtish pinup76809.help
https://www.bitsdujour.com/profiles/m7yQn5