ITeye博客

Restful TDD maven配置

kkcheng · 2012-04-16 13:38 · 企业架构 · Markdown

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

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。