use of jakarta.ws.rs.core.Response.ResponseBuilder in project jaxrs-api by eclipse-ee4j.
the class BuilderClientIT method statusTest1.
/*
* @testName: statusTest1
*
* @assertion_ids: JAXRS:JAVADOC:131; JAXRS:JAVADOC:153; JAXRS:JAVADOC:141;
* JAXRS:JAVADOC:123; JAXRS:JAVADOC:125; JAXRS:JAVADOC:124;
*
* @test_Strategy: Create an instance of ResponseBuilder Response.ok();
* Setting status using ResponseBuilder.status(int); verify that correct
* status code is returned
*/
@Test
public void statusTest1() throws Fault {
VerificationResult result = new VerificationResult();
Response resp = null;
ResponseBuilder respb = null;
for (int status : status_codes) {
respb = Response.ok();
respb = respb.status(status);
resp = respb.build();
result.append(verifyStatus(resp, status));
}
logMsg(result);
assertTrue(result.pass);
}
use of jakarta.ws.rs.core.Response.ResponseBuilder in project jaxrs-api by eclipse-ee4j.
the class BuilderClientIT method variantsTest.
/*
* @testName: variantsTest
*
* @assertion_ids: JAXRS:JAVADOC:884;
*
* @test_Strategy: Add a Vary header that lists the available variants.
*/
@Test
public void variantsTest() throws Fault {
List<String> encoding = Arrays.asList("gzip", "compress");
List<String> vars = Arrays.asList(HttpHeaders.ACCEPT_LANGUAGE, HttpHeaders.ACCEPT_ENCODING);
MediaType mt = MediaType.APPLICATION_JSON_TYPE;
ResponseBuilder rb = Response.ok();
rb = rb.variants(getVariantList(encoding, mt).toArray(new Variant[0]));
Response response = rb.build();
VerificationResult result = new VerificationResult();
result.append(verifyVary(response, vars));
logMsg(result.message);
assertTrue(result.pass);
}
use of jakarta.ws.rs.core.Response.ResponseBuilder in project jaxrs-api by eclipse-ee4j.
the class BuilderClientIT method allowStringSetNullRemovesAllTest.
/*
* @testName: allowStringSetNullRemovesAllTest
*
* @assertion_ids: JAXRS:JAVADOC:876;
*
* @test_Strategy: if null any existing allowed method list will be removed.
*/
@Test
public void allowStringSetNullRemovesAllTest() throws Fault {
Set<String> methods = new TreeSet<String>();
methods.add(Request.OPTIONS.name());
methods.add(Request.TRACE.name());
ResponseBuilder rb = RuntimeDelegate.getInstance().createResponseBuilder();
Response response = rb.allow(methods).allow((Set<String>) null).build();
Set<String> set = response.getAllowedMethods();
assertEqualsInt(0, set.size(), "No one allow method should be present");
logMsg("Allowed methods has been removed by null value as expected");
}
use of jakarta.ws.rs.core.Response.ResponseBuilder in project jaxrs-api by eclipse-ee4j.
the class Resource method getHeaders.
@POST
@Path("getheaders")
public Response getHeaders(String header) {
ResponseBuilder builder = createResponseWithHeader();
for (int i = 0; i != 5; i++) builder = builder.header(header + i, header);
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 getHeaderStringByOperation.
@GET
@Path("getheaderstringoperation")
public Response getHeaderStringByOperation() {
ResponseBuilder builder = createResponseWithHeader();
Response response = builder.build();
return response;
}
Aggregations