Transactional annotation avoids services being mocked

Please note that since Spring 4.3.1, ReflectionTestUtils should automatically unwrap proxies. So

ReflectionTestUtils.setField(validationService, "countryService", countryService);

should now work even if your countryService is annotated with @Transactional, @Cacheable… (that is, hidden behind a proxy at runtime)

Related issue: SPR-14050

Leave a Comment