HelloWorldResouecTest.java :  » Location » picture-history » war » resources » test » Android Open Source

Android Open Source » Location » picture history 
picture history » war » resources » test » HelloWorldResouecTest.java
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);
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.