Search in sources :

Example 1 with OnWriteExceptionThrowingStringBean

use of ee.jakarta.tck.ws.rs.ee.rs.ext.interceptor.writer.writerinterceptorcontext.OnWriteExceptionThrowingStringBean in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method proceedThrowsWebApplicationExceptionTest.

/*
   * @testName: proceedThrowsWebApplicationExceptionTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:936; JAXRS:JAVADOC:1009; JAXRS:JAVADOC:930;
   * 
   * @test_Strategy: Proceed to the next interceptor in the chain.
   * Throws:WebApplicationException - thrown by the wrapped {@code
   * MessageBodyWriter.writeTo} method.
   * 
   * proceed is actually called in every clientwriter.writerinterceptorcontext
   * test
   *
   * WriterInterceptor.aroundWriteTo
   */
@Test
public void proceedThrowsWebApplicationExceptionTest() throws Fault {
    addProvider(StringBeanEntityProvider.class);
    addHeader(TemplateInterceptorBody.OPERATION, ContextOperation.PROCEEDTHROWSWEBAPPEXCEPTION.name());
    setRequestContentEntity(new OnWriteExceptionThrowingStringBean(TemplateInterceptorBody.ENTITY));
    try {
        invoke();
    } catch (Exception e) {
        ProceedException p = assertCause(e, ProceedException.class, "Proceed did not throw exception");
        assertContains(p.getMessage(), TemplateInterceptorBody.WAE, "Unexpected message received", p.getMessage());
        logMsg(p.getMessage());
    }
}
Also used : ProceedException(ee.jakarta.tck.ws.rs.ee.rs.ext.interceptor.writer.writerinterceptorcontext.ProceedException) OnWriteExceptionThrowingStringBean(ee.jakarta.tck.ws.rs.ee.rs.ext.interceptor.writer.writerinterceptorcontext.OnWriteExceptionThrowingStringBean) ProceedException(ee.jakarta.tck.ws.rs.ee.rs.ext.interceptor.writer.writerinterceptorcontext.ProceedException) IOException(java.io.IOException) Test(org.junit.jupiter.api.Test)

Example 2 with OnWriteExceptionThrowingStringBean

use of ee.jakarta.tck.ws.rs.ee.rs.ext.interceptor.writer.writerinterceptorcontext.OnWriteExceptionThrowingStringBean in project jaxrs-api by eclipse-ee4j.

the class Resource method genericResponse.

@GET
@Path("{id}")
public Response genericResponse(@PathParam("id") String path) {
    ContextOperation op = ContextOperation.valueOf(path.toUpperCase());
    ResponseBuilder builder = createResponseBuilderWithHeader(op);
    switch(op) {
        case GETHEADERS:
            for (int i = 0; i != 5; i++) builder = builder.header(TemplateInterceptorBody.PROPERTY + i, "any");
            break;
        case PROCEEDTHROWSWEBAPPEXCEPTION:
            builder.entity(new OnWriteExceptionThrowingStringBean(TemplateInterceptorBody.ENTITY));
            break;
        default:
            break;
    }
    Response response = builder.build();
    return response;
}
Also used : Response(jakarta.ws.rs.core.Response) ContextOperation(ee.jakarta.tck.ws.rs.ee.rs.ext.interceptor.writer.writerinterceptorcontext.ContextOperation) OnWriteExceptionThrowingStringBean(ee.jakarta.tck.ws.rs.ee.rs.ext.interceptor.writer.writerinterceptorcontext.OnWriteExceptionThrowingStringBean) ResponseBuilder(jakarta.ws.rs.core.Response.ResponseBuilder) Path(jakarta.ws.rs.Path) GET(jakarta.ws.rs.GET)

Aggregations

OnWriteExceptionThrowingStringBean (ee.jakarta.tck.ws.rs.ee.rs.ext.interceptor.writer.writerinterceptorcontext.OnWriteExceptionThrowingStringBean)2 ContextOperation (ee.jakarta.tck.ws.rs.ee.rs.ext.interceptor.writer.writerinterceptorcontext.ContextOperation)1 ProceedException (ee.jakarta.tck.ws.rs.ee.rs.ext.interceptor.writer.writerinterceptorcontext.ProceedException)1 GET (jakarta.ws.rs.GET)1 Path (jakarta.ws.rs.Path)1 Response (jakarta.ws.rs.core.Response)1 ResponseBuilder (jakarta.ws.rs.core.Response.ResponseBuilder)1 IOException (java.io.IOException)1 Test (org.junit.jupiter.api.Test)1