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://rentry.co/3gdn99sy
попперс Реутов
https://elpk1a.zombeek.cz
1win aplicatie ios http://1win62509.help/
https://telegra.ph/Mokraya-pilotka-02-17
https://rentry.co/yn3snpq2
https://telegra.ph/Smisharikiigry-igry-2-11-21
https://paiza.io/projects/pQmcC7I7EhS7n67U1n3RYA
сиалис сколько действует по времени
купить попперс Владикавказ
https://telegra.ph/Povyshenie-zarplaty-medikam-v-2017-godu-11-19
https://rentry.co/xps4w5mg
https://rentry.co/4ke8i72m
мостбет изменить пароль http://mostbet94063.help/
1win turneu lucky jet 1win turneu lucky jet
1win website Moldova http://1win62509.help
написание курсовой работы на заказ цена kupit-kursovuyu-89.ru .
https://rentry.co/49mitqvd
считается ли попперс наркотиком
дерматит попперс
https://telegra.ph/ZHk-teatralnyj-11-19
wettbüro bochum
my homepage: euroleague Basketball Wett tipps
https://telegra.ph/Viagra-zhivaya-01-31
попперс вставляет
https://www.bitsdujour.com/profiles/BOqlCm
https://rentry.co/5m3bn9dq
https://site800327557.fo.team
https://telegra.ph/Gulliver-odezhda-11-19
https://telegra.ph/Kal-s-krovyu-prichiny-u-muzhchin-11-10
https://rentry.co/dcv36ywc
melbet отмена вывода melbet отмена вывода
набор пробник
https://b9cavf.zombeek.cz
mostbet withdrawal pending https://mostbet53160.help
https://telegra.ph/Tulskij-trikotazh-11-15
sichere Online Wetten Sport
https://rentry.co/nkubru2a
mostbet app regisztráció http://mostbet2023.help/
https://u04imb.zombeek.cz
https://rentry.co/yp9tdp94
https://telegra.ph/Igry-smeshariki-besplatno-12-03
виагра таблетки для здорового мужчины
https://rentry.co/ss9urmhm
https://so0z3l.zombeek.cz
попперс Волгоград
1win https://1win62509.help
https://site412755636.fo.team
https://snippet.host/oyidyd
https://paiza.io/projects/yOAkTjFHxiKw6hZRLOLXQA
в и а г р у