Adolphlwq 2012-04-16
<!--test-->
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-spring</artifactId>
<version>1.6</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.sun.jersey.jersey-test-framework</groupId>
<artifactId>jersey-test-framework-grizzly2</artifactId>
<version>1.6</version>
<scope>test</scope>
</dependency>
<!--forexternaltesting-->
<dependency>
<groupId>com.sun.jersey.jersey-test-framework</groupId>
<artifactId>jersey-test-framework-external</artifactId>
<version>1.6</version>
<scope>test</scope>
</dependency>
publicclassJerseyTestSampleextendsJerseyTest{
publicJerseyTestSample()throwsException{
super(newWebAppDescriptor.Builder("com.morningstar.cms.resources")
.contextPath("contentservice")
.contextParam("contextConfigLocation","classpath:applicationContext-*.xml")
.servletClass(SpringServlet.class)
.contextListenerClass(ContextLoaderListener.class)
.build());
}
@Test
publicvoidtestHelloWorld()throwsException{
WebResourcewebResource=resource();
StringresponseMsg=webResource.path("test").get(String.class);
Assert.assertEquals("helloword",responseMsg);
Assert.assertEquals(true,1==1);
}
}
相关的包和例子可以下载Restful-test-framework的例子去研究。