Search in sources :

Example 1 with ResponseBuilder

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

the class BuilderClientIT method allowStringArrayTruncateDuplicatesTest.

/*
   * @testName: allowStringArrayTruncateDuplicatesTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:875;
   * 
   * @test_Strategy: Set the list of allowed methods for the resource.
   */
@Test
public void allowStringArrayTruncateDuplicatesTest() throws Fault {
    String[] methods = { Request.OPTIONS.name(), Request.OPTIONS.name() };
    ResponseBuilder rb = RuntimeDelegate.getInstance().createResponseBuilder();
    Response response = rb.allow(methods).build();
    Set<String> set = response.getAllowedMethods();
    assertEqualsInt(1, set.size(), "Only one allow method should be present");
    assertEquals(set.iterator().next(), Request.OPTIONS.name(), Request.OPTIONS.name(), "has not been found in allowed methods");
    logMsg(Request.OPTIONS.name(), "has been found in allowed methods");
}
Also used : Response(jakarta.ws.rs.core.Response) ResponseBuilder(jakarta.ws.rs.core.Response.ResponseBuilder) Test(org.junit.jupiter.api.Test)

Example 2 with ResponseBuilder

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

the class JAXRSClientIT method getGenericTypeTest.

/*
   * @testName: getGenericTypeTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:904; JAXRS:JAVADOC:920; JAXRS:SPEC:85;
   * 
   * @test_Strategy: Get an array of the annotations formally declared on the
   * artifact that initiated the intercepted entity provider invocation.
   * 
   * If abortWith is invoked, execution is aborted
   */
@Test
public void getGenericTypeTest() throws Fault {
    ResponseBuilder builder = createResponse(ContextOperation.GETGENERICTYPE);
    Response fake = builder.build();
    addProviders(fake);
    setProperty(Property.SEARCH_STRING, String.class.getName());
    invoke();
}
Also used : Response(jakarta.ws.rs.core.Response) ResponseBuilder(jakarta.ws.rs.core.Response.ResponseBuilder) Test(org.junit.jupiter.api.Test)

Example 3 with ResponseBuilder

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

the class ResponseTest method statusTest.

@GET
@Path("status")
@Produces(value = "text/plain")
public Response statusTest(@QueryParam("status") int status) {
    StringBuffer sb = new StringBuffer();
    sb.append("status code in request = " + status);
    ResponseBuilder builder = Response.status(status);
    Response res = builder.header("TESTHEADER", sb.toString()).build();
    return res;
}
Also used : Response(jakarta.ws.rs.core.Response) ResponseBuilder(jakarta.ws.rs.core.Response.ResponseBuilder) Path(jakarta.ws.rs.Path) Produces(jakarta.ws.rs.Produces) GET(jakarta.ws.rs.GET)

Example 4 with ResponseBuilder

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

the class ResponseTest method getHeaderString.

@POST
@Path("headerstring")
public Response getHeaderString(String headers) {
    StringBuilder builder = new StringBuilder("s1");
    StringBuffer buffer = new StringBuffer("s2");
    StringBean bean = new StringBean("s3");
    ResponseBuilder response = Response.ok();
    if (headers != null && headers.length() != 0)
        response = response.header(builder.toString(), builder).header(buffer.toString(), buffer).header(bean.get(), bean);
    return response.build();
}
Also used : StringBean(ee.jakarta.tck.ws.rs.common.provider.StringBean) ResponseBuilder(jakarta.ws.rs.core.Response.ResponseBuilder) Path(jakarta.ws.rs.Path) POST(jakarta.ws.rs.POST)

Example 5 with ResponseBuilder

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

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