use of jakarta.ws.rs.client.ClientResponseContext in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getHeadersIsMutableTest.
/*
* @testName: getHeadersIsMutableTest
*
* @assertion_ids: JAXRS:JAVADOC:462; JAXRS:JAVADOC:479; JAXRS:JAVADOC:480;
*
* @test_Strategy: Get the mutable response headers multivalued map.
*
* ClientResponseFilter.filter
*/
@Test
public void getHeadersIsMutableTest() throws Fault {
final String header1 = "header1";
final String value1 = "value1";
ContextProvider in = new ContextProvider() {
@Override
protected void checkFilterContext(ClientRequestContext requestContext, ClientResponseContext responseContext) throws Fault {
MultivaluedMap<String, String> headers = responseContext.getHeaders();
headers.add(header1, value1);
headers = responseContext.getHeaders();
assertTrue(headers != null, "the #getHeaders is null");
assertTrue(headers.size() == 1, "the #getHeaders size is " + headers.size() + " expected 1");
assertTrue(value1.equals(headers.getFirst(header1)), "#getHeaders was supposed to contain " + header1 + ":" + value1 + " header, but " + header1 + " is " + headers.getFirst(header1));
logMsg("#getHeaders is mutable as expected");
}
};
Response response = Response.ok().build();
invokeWithResponseAndAssertStatus(response, Status.OK, in);
}
use of jakarta.ws.rs.client.ClientResponseContext in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getLanguageNotPresentTest.
/*
* @testName: getLanguageNotPresentTest
*
* @assertion_ids: JAXRS:JAVADOC:850;
*
* @test_Strategy: Get null if not present.
*/
@Test
public void getLanguageNotPresentTest() throws Fault {
ResponseHeaderValue<Locale> value = new ResponseHeaderValue<>();
addProvider(new HeaderNotPresent<Locale>(value) {
@Override
protected void setHeader(ClientResponseContext responseContext, ResponseHeaderValue<Locale> header) {
header.value = responseContext.getLanguage();
}
});
Response response = invokePost("language", null);
Locale locale = response.getLanguage();
assertHeaderNull(locale, value, "getLanguage");
}
use of jakarta.ws.rs.client.ClientResponseContext in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getLinkNotPresentTest.
/*
* @testName: getLinkNotPresentTest
*
* @assertion_ids: JAXRS:JAVADOC:853;
*
* @test_Strategy: returns null if not present.
*/
@Test
public void getLinkNotPresentTest() throws Fault {
ResponseHeaderValue<Link> containerValue = new ResponseHeaderValue<>();
addProvider(new HeaderNotPresent<Link>(containerValue) {
@Override
protected void setHeader(ClientResponseContext responseContext, ResponseHeaderValue<Link> header) {
header.value = responseContext.getLink("getLinkTest");
}
});
Response response = invokePost("link", null);
Link responseLink = response.getLink("getLinkTest");
assertHeaderNull(responseLink, containerValue, "getLink");
}
use of jakarta.ws.rs.client.ClientResponseContext in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getEntityTagNotPresentTest.
/*
* @testName: getEntityTagNotPresentTest
*
* @assertion_ids: JAXRS:JAVADOC:847;
*
* @test_Strategy: Get null if not present.
*/
@Test
public void getEntityTagNotPresentTest() throws Fault {
ResponseHeaderValue<EntityTag> value = new ResponseHeaderValue<>();
addProvider(new HeaderNotPresent<EntityTag>(value) {
@Override
protected void setHeader(ClientResponseContext responseContext, ResponseHeaderValue<EntityTag> header) {
header.value = responseContext.getEntityTag();
}
});
Response response = invokePost("entitytag", null);
EntityTag responseTag = response.getEntityTag();
assertHeaderNull(responseTag, value, "getEntityTag");
}
use of jakarta.ws.rs.client.ClientResponseContext in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getAllowedMethodsTest.
/*
* @testName: getAllowedMethodsTest
*
* @assertion_ids: JAXRS:JAVADOC:457; JAXRS:JAVADOC:479; JAXRS:JAVADOC:480;
*
* @test_Strategy: Get the allowed HTTP methods from the Allow HTTP header.
* All methods will returned as upper case strings.
*
* ClientResponseFilter.filter
*/
@Test
public void getAllowedMethodsTest() throws Fault {
ContextProvider provider = new ContextProvider() {
@Override
protected void checkFilterContext(ClientRequestContext requestContext, ClientResponseContext responseContext) throws Fault {
Set<String> map = responseContext.getAllowedMethods();
logMsg("found methods:", JaxrsUtil.iterableToString(" ", map));
assertTrue(map.size() == 2, "Allowed mthods were not set");
assertTrue(map.contains("OPTIONS"), "OPTIONS allowed method were not found");
assertTrue(map.contains("GET"), "GET allowed method was not found");
}
};
Response response = Response.ok().header(HttpHeaders.ALLOW, "get").header(HttpHeaders.ALLOW, "options").build();
invokeWithResponseAndAssertStatus(response, Status.OK, provider);
}
Aggregations