Search in sources :

Example 1 with EntityTag

use of jakarta.ws.rs.core.EntityTag in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method constructorTest1.

/*
     * @testName: constructorTest1
     * 
     * @assertion_ids: JAXRS:JAVADOC:62; JAXRS:JAVADOC:65; JAXRS:JAVADOC:67;
     * 
     * @test_Strategy: Create an EntityTag instance using entityTag(String)
     */
@Test
public void constructorTest1() throws Fault {
    String value = "cts test entity tag test";
    boolean strong = true;
    EntityTag et1 = new EntityTag(value);
    verifyEntityTag(et1, value, strong);
}
Also used : EntityTag(jakarta.ws.rs.core.EntityTag) Test(org.junit.jupiter.api.Test)

Example 2 with EntityTag

use of jakarta.ws.rs.core.EntityTag in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method toStringTest.

/*
     * @testName: toStringTest
     * 
     * @assertion_ids: JAXRS:JAVADOC:62; JAXRS:JAVADOC:63; JAXRS:JAVADOC:68;
     * 
     * @test_Strategy: Create two EntityTag instances using either entityTag(String,
     * boolean) and entityTag(String). Verify EntityTag.toString() works
     */
@Test
public void toStringTest() throws Fault {
    boolean pass = true;
    StringBuffer sb = new StringBuffer();
    String value = "cts test Strong EntityTag test";
    EntityTag et8 = new EntityTag(value);
    String header = et8.toString();
    sb.append(header + "." + newline);
    if (!header.contains(value)) {
        pass = false;
        sb.append("Strong EnttyTag ToString Test failed: " + header + " does not contain " + value);
    }
    value = "cts test Weak EntityTag test";
    EntityTag et9 = new EntityTag(value, true);
    header = et9.toString();
    sb.append(header + "." + newline);
    if (!header.contains(value)) {
        pass = false;
        sb.append("Weak EnttyTag ToString Test failed: " + header + " does not contain " + value);
    }
    assertTrue(pass, "At least one assertion failed: " + sb.toString());
    System.out.println(sb.toString());
}
Also used : EntityTag(jakarta.ws.rs.core.EntityTag) Test(org.junit.jupiter.api.Test)

Example 3 with EntityTag

use of jakarta.ws.rs.core.EntityTag in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method constructorTest2.

/*
     * @testName: constructorTest2
     * 
     * @assertion_ids: JAXRS:JAVADOC:63; JAXRS:JAVADOC:65; JAXRS:JAVADOC:67;
     * 
     * @test_Strategy: Create an EntityTag instance using entityTag(String, boolean)
     */
@Test
public void constructorTest2() throws Fault {
    String value = "cts test entity tag test weak";
    boolean strong = false;
    EntityTag et2 = new EntityTag(value, true);
    verifyEntityTag(et2, value, strong);
    strong = true;
    EntityTag et3 = new EntityTag(value, false);
    verifyEntityTag(et3, value, strong);
}
Also used : EntityTag(jakarta.ws.rs.core.EntityTag) Test(org.junit.jupiter.api.Test)

Example 4 with EntityTag

use of jakarta.ws.rs.core.EntityTag in project jaxrs-api by eclipse-ee4j.

the class ResponseTest method getEntityTag.

@POST
@Path("entitytag")
public Response getEntityTag(String tag) {
    ResponseBuilder builder;
    if (tag != null && tag.length() != 0) {
        EntityTag entityTag = new EntityTag(tag);
        builder = Response.notModified(entityTag);
    } else
        builder = Response.ok();
    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 5 with EntityTag

use of jakarta.ws.rs.core.EntityTag in project jaxrs-api by eclipse-ee4j.

the class ResponseFilter method getEntityTag.

public void getEntityTag() {
    EntityTag tag = responseContext.getEntityTag();
    setEntity(tag == null ? NULL : tag.getValue());
}
Also used : EntityTag(jakarta.ws.rs.core.EntityTag)

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