use of jakarta.ws.rs.core.EntityTag in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getEntityTagNotPresentTest.
/*
* @testName: getEntityTagNotPresentTest
*
* @assertion_ids: JAXRS:JAVADOC:847;
*
* @test_Strategy: Get null if not present.
*/
@Test
public void getEntityTagNotPresentTest() throws Fault {
ResponseHeaderValue<EntityTag> value = new ResponseHeaderValue<>();
addProvider(new HeaderNotPresent<EntityTag>(value) {
@Override
protected void setHeader(ClientResponseContext responseContext, ResponseHeaderValue<EntityTag> header) {
header.value = responseContext.getEntityTag();
}
});
Response response = invokePost("entitytag", null);
EntityTag responseTag = response.getEntityTag();
assertHeaderNull(responseTag, value, "getEntityTag");
}
use of jakarta.ws.rs.core.EntityTag in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method tagTest2.
/*
* @testName: tagTest2
*
* @assertion_ids: JAXRS:JAVADOC:139; JAXRS:JAVADOC:141; JAXRS:JAVADOC:155;
* JAXRS:JAVADOC:123; JAXRS:JAVADOC:124; JAXRS:JAVADOC:125;
*
* @test_Strategy: Create an instance of Response using
* Response.ResponseBuilder.tag(EntityTag).build() verify that correct status
* code is returned
*/
@Test
public void tagTest2() throws Fault {
VerificationResult result;
int status = 200;
EntityTag et1 = new EntityTag("StrongEntityTagTest", true);
EntityTag et2 = new EntityTag("TestOnly", false);
HashMap<String, String> expected_map = new HashMap<String, String>();
expected_map.put("ETAG", "TestOnly");
Response resp = Response.status(status).tag(et1).tag(et2).build();
result = verifyStatus(resp, status);
result.append(verifyHeaders(resp, expected_map));
logMsg(result);
assertResultTrue(result);
}
use of jakarta.ws.rs.core.EntityTag in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method checkCreatedHeaderDelegateEntityTagTest.
/*
* @testName: checkCreatedHeaderDelegateEntityTagTest
*
* @assertion_ids: JAXRS:JAVADOC:287; JAXRS:JAVADOC:294; JAXRS:JAVADOC:296;
*
* @test_Strategy: Check that RuntimeDelegate.createHeaderDelegateEntityTag
* makes no exception and is not null
*
*/
@Test
public void checkCreatedHeaderDelegateEntityTagTest() throws Fault {
String tagValue = "tagValue";
HeaderDelegate<EntityTag> hdet = delegate.createHeaderDelegate(EntityTag.class);
assertTrue(hdet != null, "HeaderDelegate<EntityTag> has not been created");
EntityTag tag = new EntityTag(tagValue);
String toString = hdet.toString(tag);
EntityTag serialized = hdet.fromString(toString);
assertTrue(tagValue.equals(serialized.getValue()), "HeaderDelegate<EntityTag> fromString(),toString() failed");
}
use of jakarta.ws.rs.core.EntityTag in project jaxrs-api by eclipse-ee4j.
the class Resource method getEntityTag.
@POST
@Path("getentitytag")
public Response getEntityTag(String tagName) {
ResponseBuilder builder = createResponseWithHeader();
if (tagName != null && tagName.length() != 0) {
EntityTag tag = new EntityTag(tagName);
builder = builder.tag(tag);
}
Response response = builder.build();
return response;
}
use of jakarta.ws.rs.core.EntityTag in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getEntityTagTest.
/*
* @testName: getEntityTagTest
*
* @assertion_ids: JAXRS:JAVADOC:847;
*
* @test_Strategy: Get the entity tag.
*/
@Test
public void getEntityTagTest() throws Fault {
EntityTag tag = new EntityTag("getEntityTag");
Response response = Response.notModified(tag).build();
EntityTag responseTag = response.getEntityTag();
assertTrue(tag.equals(responseTag), "response#getEntityTag()" + responseTag + "is unequal to expected EntityTag" + tag);
logMsg("#getEntityTag is", responseTag, "as expected");
}
Aggregations