Search in sources :

Example 51 with ResponseBuilder

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

the class JAXRSClientIT method checkCreatedResponseBuilderTest.

/*
   * @testName: checkCreatedResponseBuilderTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:288;
   * 
   * @test_Strategy: Check that RuntimeDelegate.createResponseBuilder makes no
   * exception and is not null
   * 
   */
@Test
public void checkCreatedResponseBuilderTest() throws Fault {
    ResponseBuilder builder = delegate.createResponseBuilder();
    assertTrue(builder != null, "ResponseBuilderTest has not been created");
}
Also used : ResponseBuilder(jakarta.ws.rs.core.Response.ResponseBuilder) Test(org.junit.jupiter.api.Test)

Example 52 with ResponseBuilder

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

the class JAXRSClientIT method getPropertyNamesIsReadOnlyTest.

/*
   * @testName: getPropertyNamesIsReadOnlyTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:1007; JAXRS:JAVADOC:920; JAXRS:SPEC:85;
   * 
   * @test_Strategy: Returns immutable java.util.Collection containing the
   * property names available within the context of the current request/response
   * exchange context.
   * 
   * ReaderInterceptor.aroundReadFrom If abortWith is invoked, execution is
   * aborted
   */
@Test
public void getPropertyNamesIsReadOnlyTest() throws Fault {
    ResponseBuilder builder = createResponse(ContextOperation.GETPROPERTYNAMESISREADONLY);
    Response fake = builder.build();
    addProviders(fake);
    setProperty(Property.UNORDERED_SEARCH_STRING, TemplateInterceptorBody.NULL);
    invoke();
}
Also used : Response(jakarta.ws.rs.core.Response) ResponseBuilder(jakarta.ws.rs.core.Response.ResponseBuilder) Test(org.junit.jupiter.api.Test)

Example 53 with ResponseBuilder

use of jakarta.ws.rs.core.Response.ResponseBuilder 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 54 with ResponseBuilder

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

the class BuilderClientIT method allowStringArrayNullRemovesAllTest.

/*
   * @testName: allowStringArrayNullRemovesAllTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:875;
   * 
   * @test_Strategy: if null any existing allowed method list will be removed.
   */
@Test
public void allowStringArrayNullRemovesAllTest() throws Fault {
    String[] methods = { Request.OPTIONS.name(), Request.GET.name() };
    ResponseBuilder rb = RuntimeDelegate.getInstance().createResponseBuilder();
    Response response = rb.allow(methods).allow((String[]) null).build();
    Set<String> set = response.getAllowedMethods();
    assertEqualsInt(0, set.size(), "No one allow method should be present");
    logMsg("Allowed methods has been removed by null value as expected");
}
Also used : Response(jakarta.ws.rs.core.Response) ResponseBuilder(jakarta.ws.rs.core.Response.ResponseBuilder) Test(org.junit.jupiter.api.Test)

Example 55 with ResponseBuilder

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

the class BuilderClientIT method allowStringArrayTest.

/*
   * @testName: allowStringArrayTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:875;
   * 
   * @test_Strategy: Set the list of allowed methods for the resource.
   */
@Test
public void allowStringArrayTest() throws Fault {
    String[] methods = { Request.OPTIONS.name(), Request.TRACE.name() };
    ResponseBuilder rb = RuntimeDelegate.getInstance().createResponseBuilder();
    Response response = rb.allow(methods).build();
    Set<String> set = response.getAllowedMethods();
    String responseMethods = JaxrsUtil.iterableToString(" ", set);
    for (String method : methods) {
        assertContains(responseMethods, method, "Expected allow method", method, "was not found in response allowed methods", responseMethods);
        logMsg("Found expected allowed method", method);
    }
}
Also used : Response(jakarta.ws.rs.core.Response) ResponseBuilder(jakarta.ws.rs.core.Response.ResponseBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

ResponseBuilder (jakarta.ws.rs.core.Response.ResponseBuilder)80 Response (jakarta.ws.rs.core.Response)69 Path (jakarta.ws.rs.Path)41 Test (org.junit.jupiter.api.Test)34 POST (jakarta.ws.rs.POST)27 GET (jakarta.ws.rs.GET)14 Date (java.util.Date)6 ByteArrayInputStream (java.io.ByteArrayInputStream)4 Annotation (java.lang.annotation.Annotation)4 VerificationResult (ee.jakarta.tck.ws.rs.api.rs.core.responseclient.VerificationResult)3 StringBean (ee.jakarta.tck.ws.rs.common.provider.StringBean)3 NewCookie (jakarta.ws.rs.core.NewCookie)3 RuntimeDelegate (jakarta.ws.rs.ext.RuntimeDelegate)3 IOException (java.io.IOException)3 StringBeanWithAnnotation (ee.jakarta.tck.ws.rs.common.provider.StringBeanWithAnnotation)2 Produces (jakarta.ws.rs.Produces)2 WebApplicationException (jakarta.ws.rs.WebApplicationException)2 EntityTag (jakarta.ws.rs.core.EntityTag)2 Link (jakarta.ws.rs.core.Link)2 InputStreamReader (java.io.InputStreamReader)2