use of jakarta.ws.rs.client.ClientRequestContext in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method setUriTest.
/*
* @testName: setUriTest
*
* @assertion_ids: JAXRS:JAVADOC:454; JAXRS:JAVADOC:447; JAXRS:JAVADOC:455;
* JAXRS:JAVADOC:456;
*
* @test_Strategy: Set a new request URI. Get the request URI.
*/
@Test
public void setUriTest() throws Fault {
String entity = "ENTITY";
ContextProvider provider = new ContextProvider() {
@Override
protected void checkFilterContext(ClientRequestContext context) throws Fault {
URI uri = context.getUri();
try {
uri = new URI(uri.toASCIIString().replace("qwerty", "post"));
} catch (URISyntaxException e) {
throw new Fault(e);
}
context.setUri(uri);
}
};
addProvider(provider);
setRequestContentEntity(entity);
setProperty(Property.REQUEST, buildRequest(Request.POST, "qwerty"));
invoke();
String body = getResponseBody();
assertContains(body, entity);
}
use of jakarta.ws.rs.client.ClientRequestContext in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getEntityStreamTest.
/* Run test */
/*
* @testName: getEntityStreamTest
*
* @assertion_ids: JAXRS:JAVADOC:437; JAXRS:JAVADOC:451; JAXRS:JAVADOC:455;
* JAXRS:JAVADOC:456;
*
* @test_Strategy: Get the entity output stream. Set a new entity output
* stream.
*/
@Test
public void getEntityStreamTest() throws Fault {
final String entityStreamWorks = "ENTITY_STREAM_WORKS";
ContextProvider provider = new ContextProvider() {
@Override
protected void checkFilterContext(ClientRequestContext context) throws Fault {
OutputStream stream = context.getEntityStream();
ReplacingOutputStream wrapper = new ReplacingOutputStream(stream, 'X', 'T');
context.setEntityStream(wrapper);
}
};
ByteArrayInputStream entity = new ByteArrayInputStream(entityStreamWorks.replace('T', 'X').getBytes());
addProvider(provider);
setRequestContentEntity(entity);
setProperty(Property.REQUEST, buildRequest(Request.POST, "post"));
invoke();
String body = getResponseBody();
assertContains(body, entityStreamWorks);
}
Aggregations