Restful TDD maven配置

<!-- 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>
                <!-- for external testing -->
                <dependency>
                    <groupId>com.sun.jersey.jersey-test-framework</groupId>
                    <artifactId>jersey-test-framework-external</artifactId>
                    <version>1.6</version>
                    <scope>test</scope>
                </dependency>


public class JerseyTestSample extends JerseyTest {
   
public JerseyTestSample() throws Exception {
super(new WebAppDescriptor.Builder("com.morningstar.cms.resources")
.contextPath("contentservice")
.contextParam("contextConfigLocation", "classpath:applicationContext-*.xml")
             .servletClass(SpringServlet.class)
             .contextListenerClass(ContextLoaderListener.class)
             .build());

}

@Test
public void testHelloWorld() throws Exception {
    WebResource webResource = resource();
    String responseMsg = webResource.path("test").get(String.class);
    Assert.assertEquals("helloword", responseMsg);
Assert.assertEquals(true, 1==1);
  }
}

相关的包和例子可以下载Restful-test-framework的例子去研究。

你可能感兴趣的:(Restful)