Skip to content
Snippets Groups Projects
Select Git revision
  • 4aa6ce10db93ad389364370695339075257b900e
  • main default protected
  • version_pour_projet_2
  • dev
  • LIVRABLE_3
  • LIVRABLE_2
  • LIVRABLE_1
7 results

MyResourceTest.javaTEMPO

Blame
  • MyResourceTest.javaTEMPO 1.30 KiB
    package fil.sr2.flopbox;
    
    import jakarta.ws.rs.client.Client;
    import jakarta.ws.rs.client.ClientBuilder;
    import jakarta.ws.rs.client.WebTarget;
    
    import org.glassfish.grizzly.http.server.HttpServer;
    
    import org.junit.After;
    import org.junit.Before;
    import org.junit.Test;
    import static org.junit.Assert.assertEquals;
    
    public class MyResourceTest {
    
        private HttpServer server;
        private WebTarget target;
    
        @Before
        public void setUp() throws Exception {
            // start the server
            server = Main.startServer();
            // create the client
            Client c = ClientBuilder.newClient();
    
            // uncomment the following line if you want to enable
            // support for JSON in the client (you also have to uncomment
            // dependency on jersey-media-json module in pom.xml and Main.startServer())
            // --
            // c.configuration().enable(new org.glassfish.jersey.media.json.JsonJaxbFeature());
    
            target = c.target(Main.BASE_URI);
        }
    
        @After
        public void tearDown() throws Exception {
            server.stop();
        }
    
        /**
         * Test to see that the message "Got it!" is sent in the response.
         */
        @Test
        public void testGetIt() {
            String responseMsg = target.path("myresource").request().get(String.class);
            assertEquals("Got it!", responseMsg);
        }
    }