Search in sources :

Example 6 with EntityTag

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");
}
Also used : Response(jakarta.ws.rs.core.Response) EntityTag(jakarta.ws.rs.core.EntityTag) ClientResponseContext(jakarta.ws.rs.client.ClientResponseContext) Test(org.junit.jupiter.api.Test)

Example 7 with EntityTag

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);
}
Also used : Response(jakarta.ws.rs.core.Response) HashMap(java.util.HashMap) EntityTag(jakarta.ws.rs.core.EntityTag) Test(org.junit.jupiter.api.Test)

Example 8 with EntityTag

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");
}
Also used : EntityTag(jakarta.ws.rs.core.EntityTag) Test(org.junit.jupiter.api.Test)

Example 9 with EntityTag

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;
}
Also used : Response(jakarta.ws.rs.core.Response) EntityTag(jakarta.ws.rs.core.EntityTag) ResponseBuilder(jakarta.ws.rs.core.Response.ResponseBuilder) Path(jakarta.ws.rs.Path) POST(jakarta.ws.rs.POST)

Example 10 with EntityTag

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");
}
Also used : Response(jakarta.ws.rs.core.Response) EntityTag(jakarta.ws.rs.core.EntityTag) Test(org.junit.jupiter.api.Test)

Aggregations

EntityTag (jakarta.ws.rs.core.EntityTag)16 Test (org.junit.jupiter.api.Test)13 Response (jakarta.ws.rs.core.Response)9 POST (jakarta.ws.rs.POST)2 Path (jakarta.ws.rs.Path)2 ClientResponseContext (jakarta.ws.rs.client.ClientResponseContext)2 ResponseBuilder (jakarta.ws.rs.core.Response.ResponseBuilder)2 HashMap (java.util.HashMap)2 ClientRequestContext (jakarta.ws.rs.client.ClientRequestContext)1