Search in sources :

Example 1 with NoContentException

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

the class JAXRSClientIT method constructorNullStringTest.

/*
     * @testName: constructorNullStringTest
     * 
     * @assertion_ids: JAXRS:JAVADOC:1127;
     * 
     * @test_Strategy: Construct a new NoContentException instance. message - the
     * detail message (which is saved for later retrieval by the
     * Throwable.getMessage() method).
     */
@Test
public void constructorNullStringTest() throws Fault {
    NoContentException e = new NoContentException((String) null);
    assertNullMessage(e);
}
Also used : NoContentException(jakarta.ws.rs.core.NoContentException) Test(org.junit.jupiter.api.Test)

Example 2 with NoContentException

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

the class JAXRSClientIT method constructorThrowableTest.

/*
     * @testName: constructorThrowableTest
     * 
     * @assertion_ids: JAXRS:JAVADOC:1129;
     * 
     * @test_Strategy: Construct a new NoContentException instance.
     */
@Test
public void constructorThrowableTest() throws Fault {
    Throwable[] throwables = new Throwable[] { new RuntimeException(), new IOException(), new Error(), new Throwable() };
    for (Throwable t : throwables) {
        NoContentException e = new NoContentException(t);
        assertCause(e, t);
    }
}
Also used : IOException(java.io.IOException) NoContentException(jakarta.ws.rs.core.NoContentException) Test(org.junit.jupiter.api.Test)

Example 3 with NoContentException

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

the class JAXRSClientIT method constructorStringTest.

/* Run test */
/*
     * @testName: constructorStringTest
     * 
     * @assertion_ids: JAXRS:JAVADOC:1127;
     * 
     * @test_Strategy: Construct a new NoContentException instance. message - the
     * detail message (which is saved for later retrieval by the
     * Throwable.getMessage() method).
     */
@Test
public void constructorStringTest() throws Fault {
    NoContentException e = new NoContentException(MESSAGE);
    assertMessage(MESSAGE, e);
}
Also used : NoContentException(jakarta.ws.rs.core.NoContentException) Test(org.junit.jupiter.api.Test)

Example 4 with NoContentException

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

the class JAXRSClientIT method clientBigDecimalProviderTest.

/*
   * @testName: clientBigDecimalProviderTest
   * 
   * @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 clientBigDecimalProviderTest() throws Fault {
    setProperty(Property.REQUEST, buildRequest(Request.GET, "entity"));
    invoke();
    Response response = getResponse();
    response.getHeaders().add(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN_TYPE);
    try {
        BigDecimal entity = getResponseBody(BigDecimal.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) BigDecimal(java.math.BigDecimal) 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 5 with NoContentException

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

the class JAXRSClientIT method constructorStringThrowableTest.

/*
     * @testName: constructorStringThrowableTest
     * 
     * @assertion_ids: JAXRS:JAVADOC:1128;
     * 
     * @test_Strategy: Construct a new NoContentException instance.
     */
@Test
public void constructorStringThrowableTest() throws Fault {
    Throwable[] throwables = new Throwable[] { new RuntimeException(), new IOException(), new Error(), new Throwable() };
    for (Throwable t : throwables) {
        NoContentException e = new NoContentException(MESSAGE, t);
        assertMessage(MESSAGE, e);
        assertCause(e, t);
        e = new NoContentException(null, t);
        assertNullMessage(e);
        assertCause(e, t);
    }
}
Also used : IOException(java.io.IOException) NoContentException(jakarta.ws.rs.core.NoContentException) Test(org.junit.jupiter.api.Test)

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