Search in sources :

Example 26 with Response

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

the class JAXRSClientIT method statusTest3.

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

Example 27 with Response

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

the class JAXRSClientIT method getLastModifiedNotPresentTest.

/*
   * @testName: getLastModifiedNotPresentTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:851;
   * 
   * @test_Strategy: Get null if not present.
   */
@Test
public void getLastModifiedNotPresentTest() throws Fault {
    Response response = Response.ok().build();
    Date responseDate = response.getLastModified();
    assertTrue(responseDate == null, "response#getLastModified() should be null, was" + responseDate);
    logMsg("#getLastModified() is null as expected");
}
Also used : Response(jakarta.ws.rs.core.Response) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 28 with Response

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

the class JAXRSClientIT method getStringHeadersUsingHeaderDelegateTest.

/*
   * @testName: getStringHeadersUsingHeaderDelegateTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:859;
   * 
   * @test_Strategy: Get view of the response headers and their string values.
   * Each single header value is converted to String using a
   * RuntimeDelegate.HeaderDelegate or using its toString
   */
@Test
public void getStringHeadersUsingHeaderDelegateTest() throws Fault {
    RuntimeDelegate original = RuntimeDelegate.getInstance();
    RuntimeDelegate.setInstance(new StringBeanRuntimeDelegate(original));
    try {
        StringBuilder builder = new StringBuilder("s1");
        StringBuffer buffer = new StringBuffer("s2");
        StringBean bean = new StringBean("s3");
        Response response = Response.ok().header(builder.toString(), builder).header(buffer.toString(), buffer).header(bean.get(), bean).build();
        MultivaluedMap<String, String> headers = response.getStringHeaders();
        String header = headers.getFirst(bean.get());
        assertContainsIgnoreCase(bean.get(), header, "Header", bean.get(), "has unexpected value", header);
        logMsg("#getStringHeaders contains expected values", JaxrsUtil.iterableToString(",", headers.entrySet()));
    } finally {
        RuntimeDelegate.setInstance(original);
        StringBeanRuntimeDelegate.assertNotStringBeanRuntimeDelegate();
    }
}
Also used : Response(jakarta.ws.rs.core.Response) StringBeanRuntimeDelegate(ee.jakarta.tck.ws.rs.common.provider.StringBeanRuntimeDelegate) StringBean(ee.jakarta.tck.ws.rs.common.provider.StringBean) RuntimeDelegate(jakarta.ws.rs.ext.RuntimeDelegate) StringBeanRuntimeDelegate(ee.jakarta.tck.ws.rs.common.provider.StringBeanRuntimeDelegate) Test(org.junit.jupiter.api.Test)

Example 29 with Response

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

the class JAXRSClientIT method notAcceptableTest.

/*
   * @testName: notAcceptableTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:127; JAXRS:JAVADOC:141; JAXRS:JAVADOC:123;
   * JAXRS:JAVADOC:124; JAXRS:JAVADOC:125; JAXRS:JAVADOC:91; JAXRS:JAVADOC:268;
   * JAXRS:JAVADOC:267; JAXRS:JAVADOC:266; JAXRS:JAVADOC:265; JAXRS:JAVADOC:263;
   * JAXRS:JAVADOC:264;
   * 
   * @test_Strategy: Create an instance of Response using
   * Response.notAcceptable(vts).build() verify that correct status code is
   * returned
   */
@Test
public void notAcceptableTest() throws Fault {
    VerificationResult result;
    Response resp = null;
    int status = 406;
    List<String> encoding = Arrays.asList("gzip", "compress");
    MediaType mt = new MediaType("text", "plain");
    List<Variant> vts = getVariantList(encoding, mt);
    resp = Response.notAcceptable(vts).build();
    result = verifyStatus(resp, status);
    logMsg(result);
    assertResultTrue(result);
}
Also used : Response(jakarta.ws.rs.core.Response) Variant(jakarta.ws.rs.core.Variant) MediaType(jakarta.ws.rs.core.MediaType) Test(org.junit.jupiter.api.Test)

Example 30 with Response

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

the class JAXRSClientIT method notModifiedTest2.

/*
   * @testName: notModifiedTest2
   * 
   * @assertion_ids: JAXRS:JAVADOC:130; JAXRS:JAVADOC:141; JAXRS:JAVADOC:123;
   * JAXRS:JAVADOC:124; JAXRS:JAVADOC:125;
   * 
   * @test_Strategy: Create an instance of Response using
   * Response.notModified(String).build() verify that correct status code is
   * returned
   */
@Test
public void notModifiedTest2() throws Fault {
    VerificationResult result;
    Response resp = null;
    int status = 304;
    String tags = "TestOnly";
    HashMap<String, String> expected_map = new HashMap<String, String>();
    expected_map.put("ETAG", tags);
    resp = Response.notModified(tags).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) Test(org.junit.jupiter.api.Test)

Aggregations

Response (jakarta.ws.rs.core.Response)665 Test (org.junit.jupiter.api.Test)551 AsyncInvoker (jakarta.ws.rs.client.AsyncInvoker)78 ClientRequestContext (jakarta.ws.rs.client.ClientRequestContext)71 ResponseBuilder (jakarta.ws.rs.core.Response.ResponseBuilder)67 Invocation (jakarta.ws.rs.client.Invocation)65 CompletionStageRxInvoker (jakarta.ws.rs.client.CompletionStageRxInvoker)51 Path (jakarta.ws.rs.Path)44 IOException (java.io.IOException)43 SyncInvoker (jakarta.ws.rs.client.SyncInvoker)41 ClientResponseContext (jakarta.ws.rs.client.ClientResponseContext)33 POST (jakarta.ws.rs.POST)27 Client (jakarta.ws.rs.client.Client)25 WebTarget (jakarta.ws.rs.client.WebTarget)24 Link (jakarta.ws.rs.core.Link)23 Status (jakarta.ws.rs.core.Response.Status)23 MediaType (jakarta.ws.rs.core.MediaType)22 Annotation (java.lang.annotation.Annotation)22 Date (java.util.Date)21 GET (jakarta.ws.rs.GET)18