Package javax.ws.rs.core

Examples of javax.ws.rs.core.Response.readEntity()


    public void testPreMatchContainerFilterThrowsException() {
        String address = "http://localhost:" + PORT + "/throwException";
        WebClient wc = WebClient.create(address);
        Response response = wc.get();
        assertEquals(500, response.getStatus());
        assertEquals("Prematch filter error", response.readEntity(String.class));
        assertEquals("prematch", response.getHeaderString("FilterException"));
        assertEquals("OK", response.getHeaderString("Response"));
        assertEquals("OK2", response.getHeaderString("Response2"));
        assertNull(response.getHeaderString("DynamicResponse"));
        assertNull(response.getHeaderString("Custom"));
View Full Code Here


    public void testPostMatchContainerFilterThrowsException() {
        String address = "http://localhost:" + PORT + "/bookstore/bookheaders/simple?throwException";
        WebClient wc = WebClient.create(address);
        Response response = wc.get();
        assertEquals(500, response.getStatus());
        assertEquals("Postmatch filter error", response.readEntity(String.class));
        assertEquals("postmatch", response.getHeaderString("FilterException"));
        assertEquals("OK", response.getHeaderString("Response"));
        assertEquals("OK2", response.getHeaderString("Response2"));
        assertEquals("Dynamic", response.getHeaderString("DynamicResponse"));
        assertEquals("custom", response.getHeaderString("Custom"));
View Full Code Here

        WebClient wc = WebClient.create(address, providers);
        Book theBook = new Book("Echo", 123L);
        Response r = wc.post(theBook);
        assertEquals(201, r.getStatus());
        assertEquals("http://localhost/redirect", r.getHeaderString(HttpHeaders.LOCATION));
        Book responseBook = r.readEntity(Book.class);
        assertSame(theBook, responseBook);
    }
   
    @Test
    public void testPostBook() {
View Full Code Here

    }

    @Override
    public DataPoint<ConnectionPool> collect() throws Exception {
        Response clientResponse = getResponse(constructResourceString());
        JsonObject response = clientResponse.readEntity(JsonObject.class);
        JsonObject entity = response.getJsonObject("extraProperties").
                getJsonObject("entity");

        int numconnfree = getIntVal(entity, "numconnfree", "current");
        int numconnused = getIntVal(entity, "numconnused", "current");
View Full Code Here

    @Override
    public DataPoint<String> collect() throws Exception {
        authenticator.get().addAuthenticator(client, username.get(), password.get());
        Response response = getResponse("sessions");
        JsonObject result = response.readEntity(JsonObject.class);
        JsonObject extraProps = result.getJsonObject("extrapProperties");
        String token = extraProps.getString("token");
        return new DataPoint<>("token", token);
    }
}
View Full Code Here

        final int INTERVAL_VALUE = 5;
        //activation
        JsonObject interval = Json.createObjectBuilder().add("interval", INTERVAL_VALUE).build();
        Response response = super.mainTarget.request().post(Entity.json(interval));
        Assert.assertThat(response.getStatus(), is(200));
        JsonObject jsonObject = response.readEntity(JsonObject.class);
        String nextTimeout = jsonObject.getString("nextTimeout");
        Assert.assertNotNull(nextTimeout);
        //status
        response = super.mainTarget.request().get();
        Assert.assertThat(response.getStatus(), is(200));
View Full Code Here

        String nextTimeout = jsonObject.getString("nextTimeout");
        Assert.assertNotNull(nextTimeout);
        //status
        response = super.mainTarget.request().get();
        Assert.assertThat(response.getStatus(), is(200));
        JsonObject status = response.readEntity(JsonObject.class);
        nextTimeout = status.getString("nextTimeout");
        assertNotNull(nextTimeout);
        String currentInterval = status.getString("interval");
        assertNotNull(currentInterval, is(Integer.parseInt(currentInterval)));
        //stop
View Full Code Here

    public String changeInterval(String location,int newValue){
        JsonObject interval = Json.createObjectBuilder().add("interval", newValue).add("location",location).build();
        WebTarget administrationTarget = getAdministrationTarget();
        final Response response = administrationTarget.request().post(Entity.json(interval));
        return response.readEntity(JsonObject.class).getString("nextTimeout");

    }

    private WebTarget getAdministrationTarget() {
        return this.client.target(getUri());
View Full Code Here

        return this.client.target(getUri());
    }

    public Pair<String,String> status(){
        Response response = getAdministrationTarget().request().get();
        JsonObject status = response.readEntity(JsonObject.class);
        String nextTimeout = status.getString("nextTimeout");
        String currentInterval = status.getString("interval");
        return new Pair<String, String>(currentInterval,nextTimeout);

View Full Code Here

                request(MediaType.APPLICATION_JSON).get(Response.class);

        if (response.getStatus() == 404) {
            return null;
        }
        return new PoolStatistics(response.readEntity(JsonObject.class));
    }

    public String getUri() {
        return model.serverUriProperty().get() + "/resources/applications/{application}/ejbs/{ejb}/pool";
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.