---
title: "Restful TDD maven配置"
author: "kkcheng"
date: "2012-04-16T13:38:53Z"
tags: []
categories: ["企业架构"]
slug: "restful-tdd-maven"
draft: false
lastmod: "2012-04-16T13:38:53Z"
id: 1487480
url: "https://kkcheng.iteye.com/blog/1487480"
---

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