use of jakarta.ws.rs.client.ClientResponseContext in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method setStatusTest.
/*
* @testName: setStatusTest
*
* @assertion_ids: JAXRS:JAVADOC:477; JAXRS:JAVADOC:479; JAXRS:JAVADOC:480;
*
* @test_Strategy: Set a new response status code. ClientResponseFilter.filter
*/
@Test
public void setStatusTest() throws Fault {
ContextProvider in = new ContextProvider() {
@Override
protected void checkFilterContext(ClientRequestContext requestContext, ClientResponseContext responseContext) throws Fault {
responseContext.setStatus(Status.FORBIDDEN.getStatusCode());
}
};
Response response = Response.ok().build();
invokeWithResponseAndAssertStatus(response, Status.FORBIDDEN, in);
}
use of jakarta.ws.rs.client.ClientResponseContext 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.ClientResponseContext 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.ClientResponseContext 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.ClientResponseContext 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);
}
Aggregations