use of jakarta.ws.rs.core.Response.ResponseBuilder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getHeadersHeadersSetTest.
/*
* @testName: getHeadersHeadersSetTest
*
* @assertion_ids: JAXRS:JAVADOC:923; JAXRS:JAVADOC:920; JAXRS:SPEC:85;
*
* @test_Strategy: Get mutable map of HTTP headers.
*
* ReaderInterceptor.aroundReadFrom If abortWith is invoked, execution is
* aborted
*/
@Test
public void getHeadersHeadersSetTest() throws Fault {
ResponseBuilder builder = createResponse(ContextOperation.GETHEADERS);
for (int i = 0; i != 5; i++) {
setProperty(Property.UNORDERED_SEARCH_STRING, TemplateInterceptorBody.PROPERTY + i);
builder = builder.header(TemplateInterceptorBody.PROPERTY + i, "any");
}
Response fake = builder.build();
addProviders(fake);
setTextCaser(TextCaser.LOWER);
setProperty(Property.UNORDERED_SEARCH_STRING, TemplateInterceptorBody.OPERATION);
invoke();
}
use of jakarta.ws.rs.core.Response.ResponseBuilder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method proceedThrowsWebApplicationExceptionTest.
/*
* @testName: proceedThrowsWebApplicationExceptionTest
*
* @assertion_ids: JAXRS:JAVADOC:925; JAXRS:JAVADOC:1008; JAXRS:JAVADOC:920;
* JAXRS:SPEC:85;
*
* @test_Strategy: Throws: WebApplicationException - thrown by the wrapped
* {@code MessageBodyReader.readFrom} method.
*
* Proceed is tested in any of the intercepter tests.
*
* ReaderInterceptor.aroundReadFrom If abortWith is invoked, execution is
* aborted
*/
@Test
public void proceedThrowsWebApplicationExceptionTest() throws Fault {
ResponseBuilder builder = createResponse(ContextOperation.PROCEEDTHROWSWEBAPPEXCEPTION);
Response fake = builder.build();
addProviders(fake);
addProvider(ExceptionThrowingStringBeanEntityProvider.class);
invoke();
// Exception thrown, caught in InterceptorBodyOne
StringBean bean = getResponseBody(ExceptionThrowingStringBean.class);
//
assertContains(bean.get(), TemplateInterceptorBody.WAE, "WebApplicationException has not been thrown and the message is", bean.get());
logMsg("WebApplicationException has been thrown as expected", bean.get());
}
use of jakarta.ws.rs.core.Response.ResponseBuilder 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 GETANNOTATIONS:
Annotation[] annotations = ContextOperation.class.getAnnotations();
builder = builder.entity(TemplateInterceptorBody.ENTITY, annotations);
break;
case GETMEDIATYPE:
builder = builder.type(MediaType.APPLICATION_JSON_TYPE);
break;
case SETTYPE:
ByteArrayInputStream bais = new ByteArrayInputStream(TemplateInterceptorBody.ENTITY.getBytes());
Reader reader = new InputStreamReader(bais);
builder = builder.entity(reader);
break;
default:
break;
}
Response response = builder.build();
return response;
}
use of jakarta.ws.rs.core.Response.ResponseBuilder in project jaxrs-api by eclipse-ee4j.
the class Resource method createResponseBuilderWithHeader.
// ///////////////////////////////////////////////////////////////////////
ResponseBuilder createResponseBuilderWithHeader(ContextOperation op) {
Response.ResponseBuilder builder = Response.ok();
// set a header with ContextOperation so that the filter knows what to
// do
builder = builder.header(TemplateInterceptorBody.OPERATION, op.name());
builder = builder.entity(TemplateInterceptorBody.ENTITY);
return builder;
}
use of jakarta.ws.rs.core.Response.ResponseBuilder in project jaxrs-api by eclipse-ee4j.
the class Resource method createResponseBuilderWithHeader.
// ///////////////////////////////////////////////////////////////////////
static ResponseBuilder createResponseBuilderWithHeader(ContextOperation op) {
Response.ResponseBuilder builder = Response.ok();
// set a header with ContextOperation so that the filter knows what to
// do
builder = builder.header(TemplateInterceptorBody.OPERATION, op.name());
builder = builder.entity(TemplateInterceptorBody.ENTITY);
return builder;
}
Aggregations