use of ee.jakarta.tck.ws.rs.api.client.clientrequestcontext.ContextProvider in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method setMethodTest.
/*
* @testName: setMethodTest
*
* @assertion_ids: JAXRS:JAVADOC:452; JAXRS:JAVADOC:455; JAXRS:JAVADOC:456;
*
* @test_Strategy: Set the request method.
*/
@Test
public void setMethodTest() throws Fault {
String entity = "ENTITY";
ContextProvider provider = new ContextProvider() {
@Override
protected void checkFilterContext(ClientRequestContext context) throws Fault {
context.setMethod("PUT");
}
};
addProvider(provider);
setRequestContentEntity(entity);
setProperty(Property.REQUEST, buildRequest(Request.POST, "put"));
invoke();
String body = getResponseBody();
assertContains(body, entity);
}
use of ee.jakarta.tck.ws.rs.api.client.clientrequestcontext.ContextProvider in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getHeadersIsMutableTest.
/*
* @testName: getHeadersIsMutableTest
*
* @assertion_ids: JAXRS:JAVADOC:439; JAXRS:JAVADOC:455; JAXRS:JAVADOC:456;
*
* @test_Strategy: Get the generic entity type information.
*/
@Test
public void getHeadersIsMutableTest() throws Fault {
ContextProvider provider = new ContextProvider() {
@Override
protected void checkFilterContext(ClientRequestContext context) throws Fault {
MultivaluedMap<String, Object> headers = context.getHeaders();
headers.add("Accept-Language", "en_gb");
headers.add("Date", "Tue, 15 Nov 1994 08:12:31 GMT");
headers.add("tck", "cts");
}
};
addProvider(provider);
setProperty(Property.REQUEST, buildRequest(Request.GET, "headers"));
invoke();
String body = getResponseBody().toLowerCase();
assertContains(body, "accept-language");
assertContains(body, "date");
assertContains(body, "tck");
}
use of ee.jakarta.tck.ws.rs.api.client.clientrequestcontext.ContextProvider 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 ee.jakarta.tck.ws.rs.api.client.clientrequestcontext.ContextProvider 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