use of jakarta.ws.rs.client.ClientResponseContext in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method hasLinkWhenLinkTest.
/*
* @testName: hasLinkWhenLinkTest
*
* @assertion_ids: JAXRS:JAVADOC:475; JAXRS:JAVADOC:479; JAXRS:JAVADOC:480;
*
* @test_Strategy: Check if link for relation exists.
* ClientResponseFilter.filter
*/
@Test
public void hasLinkWhenLinkTest() throws Fault {
final String rel = "RelatiOn";
ContextProvider in = new ContextProvider() {
@Override
protected void checkFilterContext(ClientRequestContext requestContext, ClientResponseContext responseContext) throws Fault {
boolean has = responseContext.hasLink(rel);
assertTrue(has, "the #hasLink did not found the given link");
logMsg("#hasLink has found the given link");
}
};
Response response = Response.ok().link(getUrl(), rel).build();
invokeWithResponseAndAssertStatus(response, Status.OK, in);
}
use of jakarta.ws.rs.client.ClientResponseContext in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getLastModifiedTest.
/*
* @testName: getLastModifiedTest
*
* @assertion_ids: JAXRS:JAVADOC:465; JAXRS:JAVADOC:479; JAXRS:JAVADOC:480;
*
* @test_Strategy: Get the last modified date.
*
* ClientResponseFilter.filter
*/
@Test
public void getLastModifiedTest() throws Fault {
final Date lastModified = getNewDate();
ContextProvider in = new ContextProvider() {
@Override
protected void checkFilterContext(ClientRequestContext requestContext, ClientResponseContext responseContext) throws Fault {
Date date = responseContext.getLastModified();
assertTrue(date != null, "the #getLastModified is null");
assertTrue(lastModified.equals(date), "#getLastModified was supposed to be " + lastModified + " but was " + date);
logMsg("Found #getLastModified()=", date);
}
};
Response response = Response.ok().lastModified(lastModified).build();
invokeWithResponseAndAssertStatus(response, Status.OK, in);
}
use of jakarta.ws.rs.client.ClientResponseContext in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getHeaderStringTest.
/*
* @testName: getHeaderStringTest
*
* @assertion_ids: JAXRS:JAVADOC:463; JAXRS:JAVADOC:479; JAXRS:JAVADOC:480;
*
* @test_Strategy: the message header value.
*
* ClientResponseFilter.filter
*/
@Test
public void getHeaderStringTest() throws Fault {
final String header1 = "header1";
final String value1 = "value1";
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 null");
assertTrue(header.equals(value1), "the #getHeaderString=" + header + " differs from expected " + value1);
logMsg("#getHeaderString is", value1, "as expected");
}
};
Response response = Response.ok().header(header1, value1).build();
invokeWithResponseAndAssertStatus(response, Status.OK, in);
}
use of jakarta.ws.rs.client.ClientResponseContext in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getHeaderStringIsEmptyTest.
/*
* @testName: getHeaderStringIsEmptyTest
*
* @assertion_ids: JAXRS:JAVADOC:463; JAXRS:JAVADOC:479; JAXRS:JAVADOC:480;
*
* @test_Strategy: the message header value. If the message header is present
* but has no value then the empty string is returned.
*
* ClientResponseFilter.filter
*/
@Test
public <T> void getHeaderStringIsEmptyTest() throws Fault {
final String header1 = "header1";
RuntimeDelegate original = RuntimeDelegate.getInstance();
RuntimeDelegate.setInstance(new NullStringBeanRuntimeDelegate(original));
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 null");
assertTrue(header.equals(""), "the #getHeaderString is NOT empty, but " + header);
logMsg("#getHeaderString is empty string as expected");
}
};
Response response = Response.ok().header(header1, new StringBean("aa")).build();
try {
invokeWithResponseAndAssertStatus(response, Status.OK, in);
} finally {
RuntimeDelegate.setInstance(original);
StringBeanRuntimeDelegate.assertNotStringBeanRuntimeDelegate();
}
}
use of jakarta.ws.rs.client.ClientResponseContext in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method hasEntityWhenEntityTest.
/*
* @testName: hasEntityWhenEntityTest
*
* @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 hasEntityWhenEntityTest() throws Fault {
final String entity = "eNtitY";
ContextProvider in = new ContextProvider() {
@Override
protected void checkFilterContext(ClientRequestContext requestContext, ClientResponseContext responseContext) throws Fault {
boolean has = responseContext.hasEntity();
assertTrue(has, "the #hasEntity did not found the given entity");
logMsg("Found #hasEntity()=true");
}
};
Response response = Response.ok(entity).build();
invokeWithResponseAndAssertStatus(response, Status.OK, in);
}
Aggregations