use of jakarta.ws.rs.client.ClientRequestContext in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getLanguageTest.
/*
* @testName: getLanguageTest
*
* @assertion_ids: JAXRS:JAVADOC:464; JAXRS:JAVADOC:479; JAXRS:JAVADOC:480;
*
* @test_Strategy: Get the language of the entity.
*
* ClientResponseFilter.filter
*/
@Test
public void getLanguageTest() throws Fault {
final Locale language = Locale.CANADA_FRENCH;
ContextProvider in = new ContextProvider() {
@Override
protected void checkFilterContext(ClientRequestContext requestContext, ClientResponseContext responseContext) throws Fault {
Locale responseLanguage = responseContext.getLanguage();
assertTrue(responseLanguage != null, "the #getLanguage is null");
assertTrue(language.equals(responseLanguage), "#getLanguage was supposed to be " + language + " but was " + responseLanguage);
logMsg("Found #getLanguage()=", responseLanguage);
}
};
Response response = Response.ok("entity").language(language).build();
invokeWithResponseAndAssertStatus(response, Status.OK, in);
}
use of jakarta.ws.rs.client.ClientRequestContext in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method hasEntityWhenNoEntityTest.
/*
* @testName: hasEntityWhenNoEntityTest
*
* @assertion_ids: JAXRS:JAVADOC:474; JAXRS:JAVADOC:479; JAXRS:JAVADOC:480;
*
* @test_Strategy: Check if there is a non-empty entity input stream is
* available in the response message.
*
* ClientResponseFilter.filter
*/
@Test
public void hasEntityWhenNoEntityTest() throws Fault {
ContextProvider in = new ContextProvider() {
@Override
protected void checkFilterContext(ClientRequestContext requestContext, ClientResponseContext responseContext) throws Fault {
boolean has = responseContext.hasEntity();
assertTrue(!has, "the #hasEntity found some entity");
logMsg("Found #hasEntity()=false");
}
};
Response response = Response.ok().build();
invokeWithResponseAndAssertStatus(response, Status.OK, in);
}
use of jakarta.ws.rs.client.ClientRequestContext in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getStatusTest.
/*
* @testName: getStatusTest
*
* @assertion_ids: JAXRS:JAVADOC:472; JAXRS:JAVADOC:479; JAXRS:JAVADOC:480;
*
* @test_Strategy: Get the status code associated with the response.
* ClientResponseFilter.filter
*/
@Test
public void getStatusTest() throws Fault {
ContextProvider provider = new ContextProvider() {
@Override
protected void checkFilterContext(ClientRequestContext requestContext, ClientResponseContext responseContext) throws Fault {
assertTrue(responseContext.getStatus() == 222, "unexpected status " + responseContext.getStatus());
TestUtil.logMsg("Found expected response status 222");
}
};
Response response = Response.status(222).build();
ClientRequestFilter filter = createRequestFilter(response);
Invocation i = buildInvocation(filter, provider);
Response r = invoke(i);
assertTrue(r.getStatus() == 222, "unexpected status " + r.getStatus());
}
use of jakarta.ws.rs.client.ClientRequestContext in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getHeaderStringIsNullTest.
/*
* @testName: getHeaderStringIsNullTest
*
* @assertion_ids: JAXRS:JAVADOC:463; JAXRS:JAVADOC:479; JAXRS:JAVADOC:480;
*
* @test_Strategy: the message header value. If the message header is not
* present then null is returned.
*
* ClientResponseFilter.filter
*/
@Test
public void getHeaderStringIsNullTest() throws Fault {
final String header1 = "header1";
ContextProvider in = new ContextProvider() {
@Override
protected void checkFilterContext(ClientRequestContext requestContext, ClientResponseContext responseContext) throws Fault {
String header = responseContext.getHeaderString(header1);
assertTrue(header == null, "the #getHeaderString is NOT null");
logMsg("#getHeaderString is null as expected");
}
};
Response response = Response.ok().build();
invokeWithResponseAndAssertStatus(response, Status.OK, in);
}
use of jakarta.ws.rs.client.ClientRequestContext 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);
}
Aggregations