use of jakarta.ws.rs.client.ClientResponseContext in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getLinksTest.
/*
* @testName: getLinksTest
*
* @assertion_ids: JAXRS:JAVADOC:469; JAXRS:JAVADOC:479; JAXRS:JAVADOC:480;
*
* @test_Strategy: Get the links attached to the message as header.
*
* ClientResponseFilter.filter
*/
@Test
public void getLinksTest() throws Fault {
final Link link = Link.fromUri(getUrl()).build();
ContextProvider in = new ContextProvider() {
@Override
protected void checkFilterContext(ClientRequestContext requestContext, ClientResponseContext responseContext) throws Fault {
Set<Link> links = responseContext.getLinks();
assertTrue(links != null, "the #getLinks is null");
assertTrue(links.size() == 1, "the links was supposed to be of size 1, was " + links.size());
assertTrue(links.contains(link), "#getLinks was supposed to contain " + link.getUri().toASCIIString());
logMsg("Found #getLinks()={", link.getUri().toASCIIString(), "}");
}
};
Response response = Response.ok().links(link).build();
invokeWithResponseAndAssertStatus(response, Status.OK, in);
}
use of jakarta.ws.rs.client.ClientResponseContext in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method setCorruptedStream.
protected AtomicInteger setCorruptedStream() {
final AtomicInteger ai = new AtomicInteger(0);
ClientResponseFilter filter = new ClientResponseFilter() {
@Override
public void filter(ClientRequestContext arg0, ClientResponseContext response) throws IOException {
CorruptedInputStream cis = new CorruptedInputStream(ResponseTest.ENTITY.getBytes(), ai);
cis.setCorrupted(true);
response.setEntityStream(cis);
}
};
addProvider(filter);
// do not use new entity stream in logging filter for the case of priority
// disfunction, the CorruptedInputStream would be then replaced, wrongly
// informing about not closing the stream
super.setPrintEntity(false);
return ai;
}
use of jakarta.ws.rs.client.ClientResponseContext in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getLocationNotPresentTest.
/*
* @testName: getLocationNotPresentTest
*
* @assertion_ids: JAXRS:JAVADOC:856;
*
* @test_Strategy: Get null when no present.
*/
@Test
public void getLocationNotPresentTest() throws Fault {
ResponseHeaderValue<URI> containerValue = new ResponseHeaderValue<>();
addProvider(new HeaderNotPresent<URI>(containerValue) {
@Override
protected void setHeader(ClientResponseContext responseContext, ResponseHeaderValue<URI> header) {
header.value = responseContext.getLocation();
}
});
Response response = invokeGet("entity");
URI responseLocation = response.getLocation();
assertHeaderNull(responseLocation, containerValue, "getLocation");
}
use of jakarta.ws.rs.client.ClientResponseContext in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getLastModifiedNotPresentTest.
/*
* @testName: getLastModifiedNotPresentTest
*
* @assertion_ids: JAXRS:JAVADOC:851;
*
* @test_Strategy: Get null if not present.
*/
@Test
public void getLastModifiedNotPresentTest() throws Fault {
ResponseHeaderValue<Date> containerValue = new ResponseHeaderValue<>();
addProvider(new HeaderNotPresent<Date>(containerValue) {
@Override
protected void setHeader(ClientResponseContext responseContext, ResponseHeaderValue<Date> header) {
header.value = responseContext.getLastModified();
}
});
Response response = invokePost("lastmodified", null);
Date responseDate = response.getLastModified();
assertHeaderNull(responseDate, containerValue, "getLastModified");
}
Aggregations