use of jakarta.ws.rs.client.ClientRequestFilter in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getHeaderStringUsesToStringTest.
/*
* @testName: getHeaderStringUsesToStringTest
*
* @assertion_ids: JAXRS:JAVADOC:780;
*
* @test_Strategy: Get a HTTP header as a single string value. Each single
* header value is converted to String using its toString method if a header
* delegate is not available.
*/
@Test
public void getHeaderStringUsesToStringTest() throws Fault {
final StringBean bean = new StringBean("bean");
ClientRequestFilter filter = new ClientRequestFilter() {
@Override
public void filter(ClientRequestContext ctx) throws IOException {
ctx.getHeaders().add(bean.get(), bean);
}
};
setProperty(Property.REQUEST, buildRequest(Request.POST, "headerstring"));
setProperty(Property.CONTENT, bean.get());
addProvider(filter);
setProperty(Property.SEARCH_STRING, bean.toString());
invoke();
logMsg("#getHeaderString() returned expected header converted by toString() method");
}
use of jakarta.ws.rs.client.ClientRequestFilter in project jaxrs-api by eclipse-ee4j.
the class ReaderClient method addProviders.
/**
* Register providers to client configuration
*
* @param response
* ClientRequestFilter#abortWith response
*/
protected void addProviders(Response response) throws Fault {
ClientRequestFilter requestFilter = createRequestFilter(response);
addProvider(requestFilter);
}
use of jakarta.ws.rs.client.ClientRequestFilter in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method createRequestFilter.
// ///////////////////////////////////////////////////////////////////////
/**
* Simulates server side
*
* @return Response containing request method and entity
*/
private static ClientRequestFilter createRequestFilter() {
ClientRequestFilter filter = new ClientRequestFilter() {
@Override
public void filter(ClientRequestContext ctx) throws IOException {
StringBuilder sb = new StringBuilder();
sb.append(ctx.getMethod()).append(";");
if (ctx.hasEntity())
sb.append(ctx.getEntity()).append(";");
Response r = Response.ok(sb.toString()).build();
ctx.abortWith(r);
}
};
return filter;
}
use of jakarta.ws.rs.client.ClientRequestFilter in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method createRequestFilter.
// ///////////////////////////////////////////////////////////////////////
/**
* Simulates server side
*
* @return Response containing request method and entity
*/
protected static ClientRequestFilter createRequestFilter() {
ClientRequestFilter filter = new ClientRequestFilter() {
@Override
public void filter(ClientRequestContext ctx) throws IOException {
StringBuilder sb = new StringBuilder();
sb.append(ctx.getMethod()).append(";");
sb.append(ctx.getUri().toASCIIString()).append(";");
if (ctx.hasEntity())
sb.append(ctx.getEntity()).append(";");
List<MediaType> list = ctx.getAcceptableMediaTypes();
for (MediaType type : list) sb.append(type).append(";");
Response r = Response.ok(sb.toString()).build();
ctx.abortWith(r);
}
};
return filter;
}
use of jakarta.ws.rs.client.ClientRequestFilter in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method createBadResponseFilter.
protected ClientRequestFilter createBadResponseFilter() {
ClientRequestFilter filter = new ClientRequestFilter() {
@Override
public void filter(ClientRequestContext arg0) throws IOException {
Response r = Response.status(Status.NOT_ACCEPTABLE).build();
arg0.abortWith(r);
}
};
return filter;
}
Aggregations