use of jakarta.ws.rs.client.ClientResponseContext in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getMediaTypeTest.
/*
* @testName: getMediaTypeTest
*
* @assertion_ids: JAXRS:JAVADOC:471; JAXRS:JAVADOC:479; JAXRS:JAVADOC:480;
*
* @test_Strategy: Get the media type of the entity.
*
* ClientResponseFilter.filter
*/
@Test
public void getMediaTypeTest() throws Fault {
ContextProvider provider = new ContextProvider() {
@Override
protected void checkFilterContext(ClientRequestContext requestContext, ClientResponseContext responseContext) throws Fault {
MediaType type = responseContext.getMediaType();
assertTrue(MediaType.APPLICATION_SVG_XML_TYPE.equals(type), "Unexpected mediatype found " + type);
TestUtil.logMsg("Found expected MediaType.APPLICATION_SVG_XML_TYPE");
}
};
Response response = Response.ok("TEST", MediaType.APPLICATION_SVG_XML).build();
invokeWithResponseAndAssertStatus(response, Status.OK, provider);
}
use of jakarta.ws.rs.client.ClientResponseContext in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getLengthTest.
/*
* @testName: getLengthTest
*
* @assertion_ids: JAXRS:JAVADOC:466; JAXRS:JAVADOC:479; JAXRS:JAVADOC:480;
*
* @test_Strategy: Get Content-Length value.
*
* ClientResponseFilter.filter
*/
@Test
public void getLengthTest() throws Fault {
final String entity = "ENTITY";
ContextProvider in = new ContextProvider() {
@Override
protected void checkFilterContext(ClientRequestContext requestContext, ClientResponseContext responseContext) throws Fault {
int len = responseContext.getLength();
assertTrue(len == entity.length(), "#getLength was supposed to be " + entity.length() + " but was " + len);
logMsg("Found #getLength()=", len);
}
};
Response response = Response.ok().header(HttpHeaders.CONTENT_LENGTH, entity.length()).build();
invokeWithResponseAndAssertStatus(response, Status.OK, in);
}
use of jakarta.ws.rs.client.ClientResponseContext in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getLocationTest.
/*
* @testName: getLocationTest
*
* @assertion_ids: JAXRS:JAVADOC:470; JAXRS:JAVADOC:479; JAXRS:JAVADOC:480;
*
* @test_Strategy: Get the location. ClientResponseFilter.filter
*/
@Test
public void getLocationTest() throws Fault {
URI uri = null;
try {
uri = new URI(getUrl());
} catch (URISyntaxException e) {
throw new Fault(e);
}
final URI location = uri;
ContextProvider in = new ContextProvider() {
@Override
protected void checkFilterContext(ClientRequestContext requestContext, ClientResponseContext responseContext) throws Fault {
URI responseLocation = responseContext.getLocation();
assertTrue(responseLocation != null, "the #getLinks is null");
assertTrue(location.equals(responseLocation), "#getLocation was supposed to be " + location + " but was " + responseLocation);
logMsg("Found #getLocation=", location.toASCIIString());
}
};
Response response = Response.ok().location(location).build();
invokeWithResponseAndAssertStatus(response, Status.OK, in);
}
use of jakarta.ws.rs.client.ClientResponseContext in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getCookiesTest.
/*
* @testName: getCookiesTest
*
* @assertion_ids: JAXRS:JAVADOC:458; JAXRS:JAVADOC:479; JAXRS:JAVADOC:480;
*
* @test_Strategy: Get any new cookies set on the response message.
*
* ClientResponseFilter.filter
*/
@Test
public void getCookiesTest() throws Fault {
ContextProvider provider = new ContextProvider() {
@Override
protected void checkFilterContext(ClientRequestContext requestContext, ClientResponseContext responseContext) throws Fault {
Map<String, NewCookie> map = responseContext.getCookies();
assertTrue(map.size() == 2, "Cookies were not set");
}
};
NewCookie cookie1 = new NewCookie("cookie1", "cookie1");
NewCookie cookie2 = new NewCookie("cookie2", "cookie2");
Response response = Response.ok().cookie(cookie1).cookie(cookie2).build();
invokeWithResponseAndAssertStatus(response, Status.OK, provider);
}
use of jakarta.ws.rs.client.ClientResponseContext in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getDateTest.
/*
* @testName: getDateTest
*
* @assertion_ids: JAXRS:JAVADOC:459; JAXRS:JAVADOC:479; JAXRS:JAVADOC:480;
*
* @test_Strategy: Get message date.
*
* ClientResponseFilter.filter
*/
@Test
public void getDateTest() throws Fault {
final Date date = getNewDate();
ContextProvider in = new ContextProvider() {
@Override
protected void checkFilterContext(ClientRequestContext requestContext, ClientResponseContext responseContext) throws Fault {
assertTrue(date.equals(responseContext.getDate()), "The #getDate " + responseContext.getDate() + " is not equal to what is inserted to the response " + date);
logMsg("Found #getDate()=", responseContext.getDate());
}
};
Response response = Response.ok().header("Date", date).build();
invokeWithResponseAndAssertStatus(response, Status.OK, in);
}
Aggregations