Search in sources :

Example 1 with VerificationResult

use of ee.jakarta.tck.ws.rs.api.rs.core.responseclient.VerificationResult in project jaxrs-api by eclipse-ee4j.

the class BuilderClientIT method statusTest2.

/*
   * @testName: statusTest2
   * 
   * @assertion_ids: JAXRS:JAVADOC:131; JAXRS:JAVADOC:154; JAXRS:JAVADOC:141;
   * JAXRS:JAVADOC:123; JAXRS:JAVADOC:124; JAXRS:JAVADOC:125;
   * 
   * @test_Strategy: Create an instance of ResponseBuilder Response.ok();
   * Setting status using ResponseBuilder.status(Status); verify that correct
   * status code is returned
   */
@Test
public void statusTest2() throws Fault {
    VerificationResult result = new VerificationResult();
    Response resp = null;
    ResponseBuilder respb = null;
    for (int i = 0; i < status_codes.length - 1; i++) {
        respb = Response.ok();
        respb = respb.status(resp_status[i]);
        resp = respb.build();
        result.append(verifyStatus(resp, status_codes[i]));
    }
    logMsg(result);
    assertTrue(result.pass);
}
Also used : Response(jakarta.ws.rs.core.Response) VerificationResult(ee.jakarta.tck.ws.rs.api.rs.core.responseclient.VerificationResult) ResponseBuilder(jakarta.ws.rs.core.Response.ResponseBuilder) Test(org.junit.jupiter.api.Test)

Example 2 with VerificationResult

use of ee.jakarta.tck.ws.rs.api.rs.core.responseclient.VerificationResult in project jaxrs-api by eclipse-ee4j.

the class BuilderClientIT method statusTest1.

/*
   * @testName: statusTest1
   *
   * @assertion_ids: JAXRS:JAVADOC:131; JAXRS:JAVADOC:153; JAXRS:JAVADOC:141;
   * JAXRS:JAVADOC:123; JAXRS:JAVADOC:125; JAXRS:JAVADOC:124;
   *
   * @test_Strategy: Create an instance of ResponseBuilder Response.ok();
   * Setting status using ResponseBuilder.status(int); verify that correct
   * status code is returned
   */
@Test
public void statusTest1() throws Fault {
    VerificationResult result = new VerificationResult();
    Response resp = null;
    ResponseBuilder respb = null;
    for (int status : status_codes) {
        respb = Response.ok();
        respb = respb.status(status);
        resp = respb.build();
        result.append(verifyStatus(resp, status));
    }
    logMsg(result);
    assertTrue(result.pass);
}
Also used : Response(jakarta.ws.rs.core.Response) VerificationResult(ee.jakarta.tck.ws.rs.api.rs.core.responseclient.VerificationResult) ResponseBuilder(jakarta.ws.rs.core.Response.ResponseBuilder) Test(org.junit.jupiter.api.Test)

Example 3 with VerificationResult

use of ee.jakarta.tck.ws.rs.api.rs.core.responseclient.VerificationResult in project jaxrs-api by eclipse-ee4j.

the class BuilderClientIT method variantsTest.

/*
   * @testName: variantsTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:884;
   * 
   * @test_Strategy: Add a Vary header that lists the available variants.
   */
@Test
public void variantsTest() throws Fault {
    List<String> encoding = Arrays.asList("gzip", "compress");
    List<String> vars = Arrays.asList(HttpHeaders.ACCEPT_LANGUAGE, HttpHeaders.ACCEPT_ENCODING);
    MediaType mt = MediaType.APPLICATION_JSON_TYPE;
    ResponseBuilder rb = Response.ok();
    rb = rb.variants(getVariantList(encoding, mt).toArray(new Variant[0]));
    Response response = rb.build();
    VerificationResult result = new VerificationResult();
    result.append(verifyVary(response, vars));
    logMsg(result.message);
    assertTrue(result.pass);
}
Also used : Response(jakarta.ws.rs.core.Response) VerificationResult(ee.jakarta.tck.ws.rs.api.rs.core.responseclient.VerificationResult) MediaType(jakarta.ws.rs.core.MediaType) ResponseBuilder(jakarta.ws.rs.core.Response.ResponseBuilder) Test(org.junit.jupiter.api.Test)

Example 4 with VerificationResult

use of ee.jakarta.tck.ws.rs.api.rs.core.responseclient.VerificationResult in project jaxrs-api by eclipse-ee4j.

the class BuilderClientIT method encodingTest.

/*
   * @testName: encodingTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:878;
   * 
   * @test_Strategy: Set the message entity content encoding.
   */
@Test
public void encodingTest() throws Fault {
    String[] encodings = { "gzip", "ccitt", "pic" };
    VerificationResult vr = new VerificationResult();
    for (String encoding : encodings) {
        Response response = Response.ok().encoding(encoding).build();
        vr.append(verifyEncoding(response, Collections.singletonList(encoding)));
    }
    logMsg(vr.message);
    assertTrue(vr.pass);
    logMsg("Found expected encodings");
}
Also used : Response(jakarta.ws.rs.core.Response) VerificationResult(ee.jakarta.tck.ws.rs.api.rs.core.responseclient.VerificationResult) Test(org.junit.jupiter.api.Test)

Aggregations

VerificationResult (ee.jakarta.tck.ws.rs.api.rs.core.responseclient.VerificationResult)4 Response (jakarta.ws.rs.core.Response)4 Test (org.junit.jupiter.api.Test)4 ResponseBuilder (jakarta.ws.rs.core.Response.ResponseBuilder)3 MediaType (jakarta.ws.rs.core.MediaType)1