I have a big problem that in my GenericService I use an @Autowired in an HttpServletRequest (Even though I do not know the utility, therefore, I do not know the architecture so well), and I needed to use unit test for test battery in my services, however, when I'm injecting the bean into my test, spring can not inject this HttpServletRequest as it did before in the container.
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'br.com.field.service.TalhaoService':
Injection of autowired dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Could not autowire
field: private javax.servlet.http.HttpServletRequest
br.com.visioncore.service.GenericServiceImpl.httpRequest; nested exception
is org.springframework.beans.factory.NoSuchBeanDefinitionException: No
qualifying bean of type [javax.servlet.http.HttpServletRequest] found for
dependency: expected at least 1 bean which qualifies as autowire candidate
for this dependency. Dependency annotations:
{@org.springframework.beans.factory.annotation.Autowired(required=true)}
Does anyone know how to test this? I have already been able to get my context settings inside the Test and I only need this now.