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 {
Response response = Response.ok().build();
EntityTag responseTag = response.getEntityTag();
assertTrue(responseTag == null, "response#getEntityTag() should be null, was" + responseTag);
logMsg("#getEntityTag() is null as expected");
}
use of jakarta.ws.rs.core.EntityTag in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method notModifiedTest3.
/*
* @testName: notModifiedTest3
*
* @assertion_ids: JAXRS:JAVADOC:129; JAXRS:JAVADOC:141; JAXRS:JAVADOC:123;
* JAXRS:JAVADOC:124; JAXRS:JAVADOC:125;
*
* @test_Strategy: Create an instance of Response using
* Response.notModified(EntityTag).build() verify that correct status code is
* returned
*/
@Test
public void notModifiedTest3() throws Fault {
VerificationResult result;
Response resp = null;
int status = 304;
String value = "TestOnly";
EntityTag et = new EntityTag(value);
HashMap<String, String> expected_map = new HashMap<String, String>();
expected_map.put("ETAG", value);
resp = Response.notModified(et).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 equalsTest.
/*
* @testName: equalsTest
*
* @assertion_ids: JAXRS:JAVADOC:62; JAXRS:JAVADOC:63; JAXRS:JAVADOC:64;
* JAXRS:JAVADOC:66;
*
* @test_Strategy: Create two EntityTag instances using either entityTag(String,
* boolean) and entityTag(String). Verify EntityTag.equals(Object) and
* hashCode() work
*/
@Test
public void equalsTest() throws Fault {
boolean pass = true;
StringBuffer sb = new StringBuffer();
String value = "cts test entity tag test";
EntityTag et4 = new EntityTag(value);
EntityTag et5 = new EntityTag(value, false);
if (!et4.equals(et5)) {
pass = false;
sb.append("Strong entity Tag equals test failed. " + et4.toString() + ";" + et5.toString() + ";");
}
if (et4.hashCode() != et5.hashCode()) {
pass = false;
sb.append("Strong entity Tag hashCode test failed. " + et4.toString() + ";" + et5.toString() + ";");
}
value = "cts test entity tag test weak";
EntityTag et6 = new EntityTag(value, true);
EntityTag et7 = new EntityTag(value, false);
if (et6.equals(et7)) {
pass = false;
sb.append("Weak entity Tag equals test failed. " + et6.toString() + ";" + et7.toString() + ";");
}
if (et6.hashCode() == et7.hashCode()) {
pass = false;
sb.append("Weak entity Tag hashCode test failed. " + et6.toString() + ";" + et7.toString() + ";");
}
assertTrue(pass, "At least one assertion failed: " + sb.toString());
}
use of jakarta.ws.rs.core.EntityTag in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method valueOfTest1.
/*
* @testName: valueOfTest1
*
* @assertion_ids: JAXRS:JAVADOC:69;
*
* @test_Strategy: EntityTag.valueOf(value) does not throw Exception
*/
@Test
public void valueOfTest1() throws Fault {
String value = "\"cts test Strong EntityTag test\"";
try {
EntityTag et10 = EntityTag.valueOf(value);
verifyEntityTag(et10, value, true);
} catch (Exception ilex) {
throw new Fault("Unexpected exception throw: " + ilex.getMessage());
}
}
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:461; JAXRS:JAVADOC:479; JAXRS:JAVADOC:480;
*
* @test_Strategy: Get the entity tag.
*
* ClientResponseFilter.filter
*/
@Test
public void getEntityTagTest() throws Fault {
final String value = "EntityTagValue";
final EntityTag tag = new EntityTag(value);
ContextProvider in = new ContextProvider() {
@Override
protected void checkFilterContext(ClientRequestContext requestContext, ClientResponseContext responseContext) throws Fault {
EntityTag etag = responseContext.getEntityTag();
assertTrue(etag != null, "the #getEntityTag is null");
assertTrue(value.equals(etag.getValue()), "The #getEntityTag " + etag.getValue() + " is not equal to what is inserted to the response: " + value);
logMsg("Found #getEntityTag()=", value);
}
};
Response response = Response.ok().tag(tag).build();
invokeWithResponseAndAssertStatus(response, Status.OK, in);
}
Aggregations