Search in sources :

Example 6 with NoContentException

use of jakarta.ws.rs.core.NoContentException in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method clientIntegerProviderTest.

/*
   * @testName: clientIntegerProviderTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:863;
   * 
   * @test_Strategy: Integer, text/plain media type
   * 
   * the pre-packaged primitive type MessageBodyReader implementations MUST
   * throw a NoContentException for zero-length message entities.
   * 
   * readEntity throws Processing Exception
   */
@Test
@Tag("xml_binding")
public void clientIntegerProviderTest() throws Fault {
    setProperty(Property.REQUEST, buildRequest(Request.GET, "entity"));
    invoke();
    Response response = getResponse();
    response.getHeaders().add(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN_TYPE);
    try {
        Integer entity = getResponseBody(Integer.class);
        fault("No expcetion thrown and entity is", entity);
    } catch (Exception e) {
        ProcessingException p = assertCause(e, ProcessingException.class, "Processing exception has not been thrown", e);
        NoContentException nce = assertCause(e, NoContentException.class, "NoContentException has not been thrown", p);
        logMsg("Found expected NoContentException", nce);
    }
}
Also used : Response(jakarta.ws.rs.core.Response) NoContentException(jakarta.ws.rs.core.NoContentException) ProcessingException(jakarta.ws.rs.ProcessingException) IOException(java.io.IOException) NoContentException(jakarta.ws.rs.core.NoContentException) ProcessingException(jakarta.ws.rs.ProcessingException) Test(org.junit.jupiter.api.Test) Tag(org.junit.jupiter.api.Tag)

Example 7 with NoContentException

use of jakarta.ws.rs.core.NoContentException in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method clientBooleanProviderTest.

/*
   * @testName: clientBooleanProviderTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:863;
   * 
   * @test_Strategy: Boolean, text/plain media type
   * 
   * the pre-packaged primitive type MessageBodyReader implementations MUST
   * throw a NoContentException for zero-length message entities.
   * 
   * readEntity throws Processing Exception
   */
@Test
@Tag("xml_binding")
public void clientBooleanProviderTest() throws Fault {
    setProperty(Property.REQUEST, buildRequest(Request.GET, "entity"));
    invoke();
    Response response = getResponse();
    response.getHeaders().add(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN_TYPE);
    try {
        Boolean entity = getResponseBody(Boolean.class);
        fault("No expcetion thrown and entity is", entity);
    } catch (Exception e) {
        ProcessingException p = assertCause(e, ProcessingException.class, "Processing exception has not been thrown", e);
        NoContentException nce = assertCause(e, NoContentException.class, "NoContentException has not been thrown", p);
        logMsg("Found expected NoContentException", nce);
    }
}
Also used : Response(jakarta.ws.rs.core.Response) NoContentException(jakarta.ws.rs.core.NoContentException) ProcessingException(jakarta.ws.rs.ProcessingException) IOException(java.io.IOException) NoContentException(jakarta.ws.rs.core.NoContentException) ProcessingException(jakarta.ws.rs.ProcessingException) Test(org.junit.jupiter.api.Test) Tag(org.junit.jupiter.api.Tag)

Example 8 with NoContentException

use of jakarta.ws.rs.core.NoContentException in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method clientCharProviderTest.

/*
   * @testName: clientCharProviderTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:863;
   * 
   * @test_Strategy: Character, text/plain media type
   * 
   * the pre-packaged primitive type MessageBodyReader implementations MUST
   * throw a NoContentException for zero-length message entities.
   * 
   * readEntity throws Processing Exception
   */
@Test
@Tag("xml_binding")
public void clientCharProviderTest() throws Fault {
    setProperty(Property.REQUEST, buildRequest(Request.GET, "entity"));
    invoke();
    Response response = getResponse();
    response.getHeaders().add(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN_TYPE);
    try {
        Character entity = getResponseBody(Character.class);
        fault("No expcetion thrown and entity is", entity);
    } catch (Exception e) {
        ProcessingException p = assertCause(e, ProcessingException.class, "Processing exception has not been thrown", e);
        NoContentException nce = assertCause(e, NoContentException.class, "NoContentException has not been thrown", p);
        logMsg("Found expected NoContentException", nce);
    }
}
Also used : Response(jakarta.ws.rs.core.Response) NoContentException(jakarta.ws.rs.core.NoContentException) ProcessingException(jakarta.ws.rs.ProcessingException) IOException(java.io.IOException) NoContentException(jakarta.ws.rs.core.NoContentException) ProcessingException(jakarta.ws.rs.ProcessingException) Test(org.junit.jupiter.api.Test) Tag(org.junit.jupiter.api.Tag)

Aggregations

NoContentException (jakarta.ws.rs.core.NoContentException)8 Test (org.junit.jupiter.api.Test)8 IOException (java.io.IOException)6 ProcessingException (jakarta.ws.rs.ProcessingException)4 Response (jakarta.ws.rs.core.Response)4 Tag (org.junit.jupiter.api.Tag)4 BigDecimal (java.math.BigDecimal)1