Francisco A. Lozano
2011-12-14 21:35:08 UTC
Hi,
I'm trying to use the test framework with a LowLevelAppDescriptor ( in-memory).
To do so, my test inherits from JerseyTest and overrides the configure method:
@Override
protected AppDescriptor configure() {
if(dataDir==null)
dataDir = createTempDir();
ResourceConfig rc = new DefaultResourceConfig();
ConfigurableApplicationContext ctx = new
ClassPathXmlApplicationContext("classpath:"+getContextFile());
SpringComponentProviderFactory cpf = new
SpringComponentProviderFactory(rc, ctx );
return new LowLevelAppDescriptor.Builder(rc).build();
When I try to execute the test, I'm getting the Spring context loaded
and it seems that the resource classes are correctly registered to
Jersey:
INFO c.s.j.s.s.c.SpringComponentProviderFactory.registerSpringBeans -
Registering Spring bean, freemarkerViewProcessor, of type
com.flozano.example.server.http.html.FreemarkerViewProcessor as a
provider class
INFO c.s.j.s.s.c.SpringComponentProviderFactory.registerSpringBeans -
Registering Spring bean, indexHttpResource, of type
com.flozano.example.server.http.IndexHttpResource as a root resource
class
BUT when I try to execute a request, I get:
SEVERE: Missing dependency for constructor public
com.flozano.example.server.http.IndexHttpResource(com.flozano.example.server.core.IndexingService,com.flozano.example.server.core.IndexManagementService,com.flozano.example.server.core.SearchService,com.flozano.example.server.core.RawService,boolean,java.lang.String)
at parameter index 0
SEVERE: Missing dependency for constructor public
com.flozano.example.server.http.IndexHttpResource(com.flozano.example.server.core.IndexingService,com.flozano.example.server.core.IndexManagementService,com.flozano.example.server.core.SearchService,com.flozano.example.server.core.RawService,boolean,java.lang.String)
at parameter index 1
(...)
Of course, if I try to execute this in a full web-app with
SpringServlet, these resources are correctly constructor-injected and
the request is served correctly.
What am I doing wrong? I really need to use the in-memory adapter so
moving to a WebAppDescriptor and using SpringServlet is not an option
I'm afraid.
Thanks!
Francisco A. Lozano
I'm trying to use the test framework with a LowLevelAppDescriptor ( in-memory).
To do so, my test inherits from JerseyTest and overrides the configure method:
@Override
protected AppDescriptor configure() {
if(dataDir==null)
dataDir = createTempDir();
ResourceConfig rc = new DefaultResourceConfig();
ConfigurableApplicationContext ctx = new
ClassPathXmlApplicationContext("classpath:"+getContextFile());
SpringComponentProviderFactory cpf = new
SpringComponentProviderFactory(rc, ctx );
return new LowLevelAppDescriptor.Builder(rc).build();
When I try to execute the test, I'm getting the Spring context loaded
and it seems that the resource classes are correctly registered to
Jersey:
INFO c.s.j.s.s.c.SpringComponentProviderFactory.registerSpringBeans -
Registering Spring bean, freemarkerViewProcessor, of type
com.flozano.example.server.http.html.FreemarkerViewProcessor as a
provider class
INFO c.s.j.s.s.c.SpringComponentProviderFactory.registerSpringBeans -
Registering Spring bean, indexHttpResource, of type
com.flozano.example.server.http.IndexHttpResource as a root resource
class
BUT when I try to execute a request, I get:
SEVERE: Missing dependency for constructor public
com.flozano.example.server.http.IndexHttpResource(com.flozano.example.server.core.IndexingService,com.flozano.example.server.core.IndexManagementService,com.flozano.example.server.core.SearchService,com.flozano.example.server.core.RawService,boolean,java.lang.String)
at parameter index 0
SEVERE: Missing dependency for constructor public
com.flozano.example.server.http.IndexHttpResource(com.flozano.example.server.core.IndexingService,com.flozano.example.server.core.IndexManagementService,com.flozano.example.server.core.SearchService,com.flozano.example.server.core.RawService,boolean,java.lang.String)
at parameter index 1
(...)
Of course, if I try to execute this in a full web-app with
SpringServlet, these resources are correctly constructor-injected and
the request is served correctly.
What am I doing wrong? I really need to use the in-memory adapter so
moving to a WebAppDescriptor and using SpringServlet is not an option
I'm afraid.
Thanks!
Francisco A. Lozano