users@jersey.java.net

[Jersey] Re: JerseyTest with Spring Annotation

From: Tarjei Huse <tarjei_at_scanmine.com>
Date: Tue, 28 Jun 2011 12:36:46 +0200

On 06/28/2011 05:48 AM, lenming.yeung_at_gmail.com wrote:
> Hi,
>
> I'm a bit lost here. I've a Spring integration test that extends
> JerseyTest (1.7) using Grizzly test container. However, My web service
> spring dependencies aren't wired up at all when it invokes the my
> method.
>
> My test constructor looks like this:
> super(new WebAppDescriptor.Builder("my.package")
> .contextPath("mypath")
> .contextParam("contextConfigLocation",
> "classpath:spring-config/*.xml")
> .servletClass(SpringServlet.class)
> .contextListenerClass(ContextLoaderListener.class)
> .build());


Have you tried adding each resource separately? This works for me:
WebAppDescriptor ad = new WebAppDescriptor.Builder("com.example.web")
        .contextPath("/")
       
.contextParam("contextConfigLocation","classpath:/applicationContext-HSQLdb.xml
classpath:/applicationContext-model-test-common.xml" +
                " classpath:/applicationContext-resources.xml" +
                " classpath:/applicationContext-activemq.xml" +
                   " classpath:/applicationContext-service.xml" +
                   " classpath:/applicationContext-security.xml"
                   )
        .servletClass(SpringServlet.class)
        .contextListenerClass(ContextLoaderListener.class)
        .requestListenerClass(RequestContextListener.class)
       
        .build();

Also note the path you are using "spring-config/*".. maybe you are
missing a / in front?

Regards,
Tarjei
> From Naresh's blog
> (http://blogs.oracle.com/naresh/entry/jersey_test_framework_re_visited)
> it indicated that this is possible, as well as samples from
> http://download.java.net/maven/2/com/sun/jersey/samples/spring-annotati
> ons/1.1.1-ea/
>
> Any suggestions are greatly appreciated!
>
> Cheers


-- 
Regards / Med vennlig hilsen
Tarjei Huse
Mobil: 920 63 413