Search in sources :

Example 1 with ResponseProcessingException

use of javax.ws.rs.client.ResponseProcessingException in project jersey by jersey.

the class ClientFilterTest method ioExceptionResponseFilterTest.

@Test
public void ioExceptionResponseFilterTest() {
    final WebTarget target = target();
    target.register(IOExceptionResponseFilter.class).register(LoggingFeature.class);
    boolean caught = false;
    try {
        target.path("test").request().get(Response.class);
    } catch (ResponseProcessingException e) {
        caught = true;
        assertNotNull(e.getCause());
        assertEquals(IOException.class, e.getCause().getClass());
        assertEquals(IOExceptionResponseFilter.class.getName(), e.getCause().getMessage());
    }
    assertTrue(caught);
}
Also used : ResponseProcessingException(javax.ws.rs.client.ResponseProcessingException) WebTarget(javax.ws.rs.client.WebTarget) IOException(java.io.IOException) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Example 2 with ResponseProcessingException

use of javax.ws.rs.client.ResponseProcessingException in project jersey by jersey.

the class EmptyEntityTest method testReceiveEmptyCharacter.

@Test
public void testReceiveEmptyCharacter() {
    WebTarget target = target("empty/getempty");
    final Response response = target.request("text/plain").get();
    assertEquals(200, response.getStatus());
    try {
        response.readEntity(Character.class);
        fail("ProcessingException expected.");
    } catch (ProcessingException ex) {
        assertSame(NoContentException.class, ex.getCause().getClass());
    }
    try {
        target.request("text/plain").get(Character.class);
        fail("ResponseProcessingException expected.");
    } catch (ResponseProcessingException ex) {
        assertSame(NoContentException.class, ex.getCause().getClass());
    }
}
Also used : Response(javax.ws.rs.core.Response) ResponseProcessingException(javax.ws.rs.client.ResponseProcessingException) WebTarget(javax.ws.rs.client.WebTarget) NoContentException(javax.ws.rs.core.NoContentException) ProcessingException(javax.ws.rs.ProcessingException) ResponseProcessingException(javax.ws.rs.client.ResponseProcessingException) Test(org.junit.Test)

Example 3 with ResponseProcessingException

use of javax.ws.rs.client.ResponseProcessingException in project jersey by jersey.

the class EmptyEntityTest method testReceiveEmptyJAXBbean.

@Test
public void testReceiveEmptyJAXBbean() {
    WebTarget target = target("empty/getempty");
    final Response response = target.request("application/xml").get();
    assertEquals(200, response.getStatus());
    try {
        response.readEntity(TestJaxbBean.class);
        fail("ProcessingException expected.");
    } catch (ProcessingException ex) {
        assertSame(NoContentException.class, ex.getCause().getClass());
    }
    try {
        target.request("application/xml").get(TestJaxbBean.class);
        fail("ResponseProcessingException expected.");
    } catch (ResponseProcessingException ex) {
        assertSame(NoContentException.class, ex.getCause().getClass());
    }
}
Also used : Response(javax.ws.rs.core.Response) ResponseProcessingException(javax.ws.rs.client.ResponseProcessingException) WebTarget(javax.ws.rs.client.WebTarget) NoContentException(javax.ws.rs.core.NoContentException) ProcessingException(javax.ws.rs.ProcessingException) ResponseProcessingException(javax.ws.rs.client.ResponseProcessingException) Test(org.junit.Test)

Example 4 with ResponseProcessingException

use of javax.ws.rs.client.ResponseProcessingException in project jersey by jersey.

the class EmptyEntityTest method testReceiveEmptyJAXBlist.

@Test
public void testReceiveEmptyJAXBlist() {
    WebTarget target = target("empty/getempty");
    final Response response = target.request("application/xml").get();
    assertEquals(200, response.getStatus());
    try {
        response.readEntity(new GenericType<List<TestJaxbBean>>() {
        });
        fail("ProcessingException expected.");
    } catch (ProcessingException ex) {
        assertSame(NoContentException.class, ex.getCause().getClass());
    }
    try {
        target.request("application/xml").get(new GenericType<List<TestJaxbBean>>() {
        });
        fail("ResponseProcessingException expected.");
    } catch (ResponseProcessingException ex) {
        assertSame(NoContentException.class, ex.getCause().getClass());
    }
}
Also used : Response(javax.ws.rs.core.Response) List(java.util.List) ResponseProcessingException(javax.ws.rs.client.ResponseProcessingException) WebTarget(javax.ws.rs.client.WebTarget) NoContentException(javax.ws.rs.core.NoContentException) ProcessingException(javax.ws.rs.ProcessingException) ResponseProcessingException(javax.ws.rs.client.ResponseProcessingException) Test(org.junit.Test)

Example 5 with ResponseProcessingException

use of javax.ws.rs.client.ResponseProcessingException in project jersey by jersey.

the class EmptyEntityTest method testReceiveEmptyInteger.

@Test
public void testReceiveEmptyInteger() {
    WebTarget target = target("empty/getempty");
    final Response response = target.request("text/plain").get();
    assertEquals(200, response.getStatus());
    try {
        response.readEntity(Integer.class);
        fail("ProcessingException expected.");
    } catch (ProcessingException ex) {
        assertSame(NoContentException.class, ex.getCause().getClass());
    }
    try {
        target.request("text/plain").get(Integer.class);
        fail("ResponseProcessingException expected.");
    } catch (ResponseProcessingException ex) {
        assertSame(NoContentException.class, ex.getCause().getClass());
    }
}
Also used : Response(javax.ws.rs.core.Response) ResponseProcessingException(javax.ws.rs.client.ResponseProcessingException) WebTarget(javax.ws.rs.client.WebTarget) NoContentException(javax.ws.rs.core.NoContentException) ProcessingException(javax.ws.rs.ProcessingException) ResponseProcessingException(javax.ws.rs.client.ResponseProcessingException) Test(org.junit.Test)

Aggregations

ResponseProcessingException (javax.ws.rs.client.ResponseProcessingException)35 Response (javax.ws.rs.core.Response)22 WebClient (org.apache.cxf.jaxrs.client.WebClient)16 URL (java.net.URL)14 Form (javax.ws.rs.core.Form)13 ProcessingException (javax.ws.rs.ProcessingException)11 Test (org.junit.Test)9 WebTarget (javax.ws.rs.client.WebTarget)8 IOException (java.io.IOException)7 NoContentException (javax.ws.rs.core.NoContentException)6 InputStream (java.io.InputStream)5 ClientAccessToken (org.apache.cxf.rs.security.oauth2.common.ClientAccessToken)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 PushbackInputStream (java.io.PushbackInputStream)4 ReaderInputStream (org.apache.cxf.io.ReaderInputStream)4 WebApplicationException (javax.ws.rs.WebApplicationException)3 ArrayList (java.util.ArrayList)2 ExecutionException (java.util.concurrent.ExecutionException)2 BadRequestException (javax.ws.rs.BadRequestException)2 JwsHeaders (org.apache.cxf.rs.security.jose.jws.JwsHeaders)2