首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

Restful TDD maven配备

2012-07-22 
Restful TDD maven配置!-- test -- dependencygroupIdcom.sun.jersey.contribs/groupIdartifactI

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的例子去研究。

热点排行