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://lessons.drawspace.com/post/384448/65
https://www.40billion.com/profile/338487867
https://lessons.drawspace.com/post/384483/album
https://lessons.drawspace.com/post/384539/cs
https://telegra.ph/Bojcovskij-klub-smotret-onlajn-11-07
https://lessons.drawspace.com/post/384553/album
https://telegra.ph/Zavorozhenno-11-09
https://www.40billion.com/profile/1055819765
Мобильные турниры в казино Безопасность и надежность: Лицензированные мобильные казино используют передовые технологии шифрования для защиты личных данных и финансовых транзакций игроков обеспечивая высокий уровень безопасности.
https://lessons.drawspace.com/post/384862/pwauto-precision-works-youtube
https://lessons.drawspace.com/post/384703/2018
https://lessons.drawspace.com/post/385206/obedinenie-frantsii-v-12-15-vekah
https://lessons.drawspace.com/post/385522/only-exclusive-devushki
heute wetten
Here is my web page … basketball-wetten.com
https://www.40billion.com/profile/202745146
сеалекс и виагра
http://aku.org.cn/home.php?mod=space&uid=375339
http://bbs.51pinzhi.cn/home.php?mod=space&uid=3767911
http://bbs.51pinzhi.cn/home.php?mod=space&uid=3767563
https://a7dftu.zombeek.cz
http://bbs.51pinzhi.cn/home.php?mod=space&uid=3767409
Мобильные турниры в казино Несмотря на все преимущества мобильных казино важно помнить об ответственной игре. Азартные игры должны приносить удовольствие а не становиться источником проблем. Вот несколько советов которые помогут вам сохранить контроль:
купить виагра дешево
http://bbs.51pinzhi.cn/home.php?mod=space&uid=3767462
http://bbs.51pinzhi.cn/home.php?mod=space&uid=3767677
http://bbs.51pinzhi.cn/home.php?mod=space&uid=3767730
https://lgq7je.zombeek.cz
http://bbs.51pinzhi.cn/home.php?mod=space&uid=3767763
http://bbs.51pinzhi.cn/home.php?mod=space&uid=3767879
http://bbs.51pinzhi.cn/home.php?mod=space&uid=3614921
http://bbs.51pinzhi.cn/home.php?mod=space&uid=3767843
http://bbs.51pinzhi.cn/home.php?mod=space&uid=3767527
спб лиговский попперс
http://bbs.51pinzhi.cn/home.php?mod=space&uid=3768002
http://bbs.51pinzhi.cn/home.php?mod=space&uid=3768038
http://bbs.51pinzhi.cn/home.php?mod=space&uid=3767821
sportwetten gratiswette ohne einzahlung
Feel free to visit my blog post; Bester wettanbieter mit bonus
https://site689635573.fo.team
http://bbs.51pinzhi.cn/home.php?mod=space&uid=3768074
https://telegra.ph/Vetnamskie-porosyata-otzyvy-vladelcev-foto-11-19
http://bbs.51pinzhi.cn/home.php?mod=space&uid=3768102
http://bbs.51pinzhi.cn/home.php?mod=space&uid=3767970
http://bbs.51pinzhi.cn/home.php?mod=space&uid=3767490
https://b7t6kc.zombeek.cz
http://bbs.51pinzhi.cn/home.php?mod=space&uid=3767945
http://bbs.51pinzhi.cn/home.php?mod=space&uid=3692301
http://bbs.51pinzhi.cn/home.php?mod=space&uid=3768245
http://bbs.51pinzhi.cn/home.php?mod=space&uid=3768273
http://bbs.51pinzhi.cn/home.php?mod=space&uid=3769061
http://bbs.51pinzhi.cn/home.php?mod=space&uid=3768183