package war.resources.test;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.core.header.MediaTypes;
import com.sun.jersey.test.framework.JerseyTest;
import com.sun.jersey.test.framework.WebAppDescriptor;
import org.junit.Assert;
import org.junit.Test;
public class HelloWorldResouecTest extends JerseyTest {
public HelloWorldResouecTest() throws Exception {
super(new WebAppDescriptor.Builder("war.resources")
.contextPath("helloworld-webapp").build());
}
/**
* Test that the expected response is sent back.
* @throws java.lang.Exception
*/
@Test
public void testHelloWorld() throws Exception {
WebResource webResource = resource();
String responseMsg = webResource.path("helloworld").get(String.class);
Assert.assertEquals("Hello World", responseMsg);
}
@Test
public void testApplicationWadl() {
WebResource webResource = resource();
String serviceWadl = webResource.path("application.wadl").
accept(MediaTypes.WADL).get(String.class);
Assert.assertTrue(serviceWadl.length() > 0);
}
}
|