inject a mockups to a bean that has @autowired annotations
- by santiagozky
I have a bean that has a couple of beans injected with the autowire annotation (no qualifier). Now, for testing reasons I want to inject some mocks to the bean instead of the ones being autowired (some DAOs). Is there any way I can change which bean is being injected without modifying my bean? I don't like the idea of adding annotations my code just to test it and then remove then for production. I am using spring 2.5.
The bean look like this:
@Transactional
@Service("validaBusinesService")
public class ValidaBusinesServiceImpl implements ValidaBusinesService {
@Autowired
OperationDAO operationDAO;
@Autowired
BinDAO binDAO;
@Autowired
CardDAO cardDAO;
@Autowired
UserDAO userDAO;
...
...
}