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://gl62dt.zombeek.cz
https://telegra.ph/Multiki-anastasiya-03-07
1win бакай банк вывод https://1win54038.help/
sportwetten tipps gratis
Feel free to surf to my site … Buchmacher Berlin
This web site certainly has all of the information I wanted concerning this subject and didnt know who to ask. https://drive.google.com/file/d/1qBah9-Smn6JCWWOEe2HE48fQ8nbl1MNr/view?usp=sharing
https://rentry.co/v6qtz3wg
курсовая работа купить москва курсовая работа купить москва .
попперс Майкоп
Лучшие лицензированные казино сайты Азербайджана
wettbüro lichtenberg
Here is my web blog basketball wetten tipps
сиалис 5 мг Нижний Новгород
wettbüro ludwigsburg
My blog post … Sportwetten heute (http://Gratis-Wetten.com)
попперс Долгопрудный
рейтинг попперс сравнение
мостбет qiwi пополнение http://www.mostbet60172.help
https://site488539683.fo.team
https://paiza.io/projects/5mpZKMffBjo_E4gzYuj9QA
We absolutely love your blog and find nearly all of your posts to be just what Im looking for. Would you offer guest writers to write content for you? I wouldnt mind publishing a post or elaborating on many of the subjects you write in relation to here. Again awesome website https://drive.google.com/file/d/1CdUoyfUKzILmsGRouXxqk_F9YsH-i-3Q/view?usp=sharing
Бонусы онлайн-казино в Азербайджане
написание курсовых на заказ написание курсовых на заказ .
https://teletype.link/shaftteo42
https://paiza.io/projects/WoMgHje2wrl02a7gj0fRZw
купить курсовая работа купить курсовая работа .
https://site613605792.fo.team
попперс Нижнекамск
https://9qe45x.zombeek.cz
https://site959287206.fo.team
mostbet apk скачать на android http://mostbet94063.help
https://telegra.ph/Samolety-tupoleva-11-11
https://rentry.co/th4ve8t2
сайт для заказа курсовых работ сайт для заказа курсовых работ .
Бездепозитные бонусы в Азербайджане
https://site574501364.fo.team
лендинг виагра
как войти в mostbet https://mostbet82043.help
Sprawdz poradnik kamera fpv hd jesli szukasz najlepszych wskazowek przy wyborze kamery FPV na start. Wybierajac kamere FPV kieruj sie nie tylko danymi technicznymi ale i doswiadczeniami z testow terenowych.
mostbet verification failed mostbet verification failed
https://5arzfq.zombeek.cz
https://rentry.co/trbi99qp
mostbet mines játék http://mostbet2023.help/
https://6pcvkq.zombeek.cz
помощь курсовые kupit-kursovuyu-88.ru .
https://telegra.ph/Orcs-must-die-unchained-11-24
unentschieden wette ungültig kombiwette
Here is my webpage; wetten beim pferderennen (Btob.N-Marketing.net)
https://telegra.ph/Novye-multfilmy-2016-2017-goda-smotret-onlajn-besplatno-02-08
https://wbenvc.zombeek.cz
https://telegra.ph/Kupit-kvartiru-v-strogino-11-15
https://287lsf.zombeek.cz
https://site677449829.fo.team
сиалис сколько принимать таблеток