Search in sources :

Example 56 with Response

use of javax.ws.rs.core.Response in project druid by druid-io.

the class AbstractListenerHandlerTest method testExceptionalHandleAll.

@Test
public void testExceptionalHandleAll() throws Exception {
    shouldFail.set(true);
    final Response response = abstractListenerHandler.handleGETAll();
    Assert.assertEquals(500, response.getStatus());
    Assert.assertEquals(ImmutableMap.of("error", error_message), response.getEntity());
}
Also used : Response(javax.ws.rs.core.Response) Test(org.junit.Test)

Example 57 with Response

use of javax.ws.rs.core.Response in project druid by druid-io.

the class AbstractListenerHandlerTest method testMissingDELETE.

@Test
public void testMissingDELETE() throws Exception {
    final Response response = abstractListenerHandler.handleDELETE("not going to find it");
    Assert.assertEquals(404, response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) Test(org.junit.Test)

Example 58 with Response

use of javax.ws.rs.core.Response in project druid by druid-io.

the class AbstractListenerHandlerTest method testHandleAll.

@Test
public void testHandleAll() throws Exception {
    final Response response = abstractListenerHandler.handleGETAll();
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals(all, response.getEntity());
}
Also used : Response(javax.ws.rs.core.Response) Test(org.junit.Test)

Example 59 with Response

use of javax.ws.rs.core.Response in project druid by druid-io.

the class AbstractListenerHandlerTest method testHandle.

@Test
public void testHandle() throws Exception {
    final Response response = abstractListenerHandler.handleGET(good_id);
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals(good_object, response.getEntity());
}
Also used : Response(javax.ws.rs.core.Response) Test(org.junit.Test)

Example 60 with Response

use of javax.ws.rs.core.Response in project druid by druid-io.

the class ExceptionalAbstractListenerHandler method testAbstractPostHandler.

@Test
public // Take a list of strings wrap them in a JSON POJO and get them back as an array string in the POST function
void testAbstractPostHandler() throws Exception {
    final AbstractListenerHandler handler = new ExceptionalAbstractListenerHandler() {

        @Nullable
        @Override
        public String post(@NotNull Map<String, SomeBeanClass> inputObject) throws Exception {
            return mapper.writeValueAsString(inputObject);
        }
    };
    final ListenerResource resource = new ListenerResource(mapper, mapper, handler) {
    };
    final List<String> strings = ImmutableList.of("test1", "test2");
    final Map<String, SomeBeanClass> expectedMap = new HashMap<>();
    for (final String str : strings) {
        expectedMap.put(str, new SomeBeanClass(str));
    }
    final String expectedString = mapper.writeValueAsString(expectedMap);
    final Response response = resource.serviceAnnouncementPOSTAll(new ByteArrayInputStream(StringUtils.toUtf8(expectedString)), req);
    Assert.assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatus());
    Assert.assertEquals(expectedString, response.getEntity());
}
Also used : Response(javax.ws.rs.core.Response) HashMap(java.util.HashMap) ByteArrayInputStream(java.io.ByteArrayInputStream) NotNull(javax.validation.constraints.NotNull) HashMap(java.util.HashMap) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Aggregations

Response (javax.ws.rs.core.Response)3808 Test (org.junit.Test)2883 JerseyTest (org.glassfish.jersey.test.JerseyTest)849 Test (org.testng.annotations.Test)342 Builder (javax.ws.rs.client.Invocation.Builder)298 ResteasyClientBuilder (org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder)287 WebTarget (javax.ws.rs.client.WebTarget)278 BaseTest (org.xdi.oxauth.BaseTest)274 Parameters (org.testng.annotations.Parameters)271 DBUnitTest (org.orcid.test.DBUnitTest)270 JSONException (org.codehaus.jettison.json.JSONException)253 URI (java.net.URI)230 JSONObject (org.codehaus.jettison.json.JSONObject)181 Path (javax.ws.rs.Path)153 Matchers.containsString (org.hamcrest.Matchers.containsString)142 URISyntaxException (java.net.URISyntaxException)124 ResponseType (org.xdi.oxauth.model.common.ResponseType)120 Produces (javax.ws.rs.Produces)113 RelationshipRepresentationTest (org.neo4j.server.rest.repr.RelationshipRepresentationTest)105 GET (javax.ws.rs.GET)104