Search in sources :

Example 51 with WebTarget

use of jakarta.ws.rs.client.WebTarget in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method resolveTemplatesFromEncodedThrowsNPEForNullNameTest.

/*
   * @testName: resolveTemplatesFromEncodedThrowsNPEForNullNameTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:950;
   * 
   * @test_Strategy: NullPointerException - if the name-value map or any of the
   * names or encoded values in the map is null.
   */
@Test
public void resolveTemplatesFromEncodedThrowsNPEForNullNameTest() throws Fault {
    WebTarget target = createWebTarget();
    HashMap<String, Object> map = new HashMap<String, Object>();
    map.put(null, "xyz");
    try {
        target.path("{path}").resolveTemplatesFromEncoded(map);
        throw new Fault("NullPointerException has not been thrown");
    } catch (NullPointerException npe) {
        logMsg("NullPointerException has been thrown as expected", npe);
    }
}
Also used : HashMap(java.util.HashMap) WebTarget(jakarta.ws.rs.client.WebTarget) Test(org.junit.jupiter.api.Test)

Example 52 with WebTarget

use of jakarta.ws.rs.client.WebTarget in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method matrixParamWithNullValueRemovesParamsWithTheNameOnMoreSegmentsTest.

/*
   * @testName:
   * matrixParamWithNullValueRemovesParamsWithTheNameOnMoreSegmentsTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:610; JAXRS:JAVADOC:612;
   * 
   * @test_Strategy: Create a new instance by appending a matrix parameter to
   * the existing set of matrix parameters of the current final segment of the
   * URI of the current target instance.
   *
   * In case a single null value is entered, all parameters with that name in
   * the current final path segment are removed (if present) from the collection
   * of last segment matrix parameters inherited from the current target.
   * 
   * Note that the matrix parameters are tied to a particular path segment;
   * appending a value to an existing matrix parameter name will not affect the
   * position of the matrix parameter in the URI path.
   * 
   * Create a new instance by appending path to the URI of the current target
   * instance.
   */
@Test
public void matrixParamWithNullValueRemovesParamsWithTheNameOnMoreSegmentsTest() throws Fault {
    WebTarget target = createWebTarget();
    target = target.matrixParam("matrix1", "segment1");
    assertConfigurationSnapshot(target);
    target = target.path("path1");
    assertConfigurationSnapshot(target);
    target = target.matrixParam("matrix2", "segment1");
    target = target.matrixParam("matrix2", new Object[] { null });
    assertConfigurationSnapshot(target);
    target = target.path("path2");
    assertConfigurationSnapshot(target);
    target = target.matrixParam("matrix1", "segment1");
    target = target.matrixParam("matrix1", new Object[] { null });
    assertConfigurationSnapshot(target);
    target = target.path("path3");
    URI uri = target.getUri();
    assertUriContains(uri, ";matrix1=segment1/path1/path2/path3");
    logMsg("URI", uri, "contains given matrix params");
}
Also used : WebTarget(jakarta.ws.rs.client.WebTarget) URI(java.net.URI) Test(org.junit.jupiter.api.Test)

Example 53 with WebTarget

use of jakarta.ws.rs.client.WebTarget in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method resolveTemplatesNullNameTest.

/*
   * @testName: resolveTemplatesNullNameTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:946;
   * 
   * @test_Strategy: NullPointerException - if the name-value map or any of the
   * names or values in the map is null.
   */
@Test
public void resolveTemplatesNullNameTest() throws Fault {
    Map<String, Object> map = new HashMap<String, Object>();
    map.put(null, "xyz");
    WebTarget target = createWebTarget();
    try {
        target.path("{path}").resolveTemplates(map);
        throw new Fault("NullPointerException has not been thrown");
    } catch (NullPointerException npe) {
        logMsg("NullPointerException has been thrown as expected", npe);
    }
}
Also used : HashMap(java.util.HashMap) WebTarget(jakarta.ws.rs.client.WebTarget) Test(org.junit.jupiter.api.Test)

Example 54 with WebTarget

use of jakarta.ws.rs.client.WebTarget in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method queryParamTest.

/*
   * @testName: queryParamTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:618;
   * 
   * @test_Strategy: Create a new instance by adding a query parameter to the
   * URI of the current target instance. If multiple values are supplied the
   * parameter will be added once per value.
   */
@Test
public void queryParamTest() throws Fault {
    WebTarget target = createWebTarget();
    target = target.queryParam("paramName", new StringBuffer().append("value1"), new StringBuilder().append("value2"), "value3");
    assertConfigurationSnapshot(target);
    URI uri = target.getUri();
    assertUriContains(uri, "?paramName=value1&paramName=value2&paramName=value3");
    logMsg("URI", uri, "contains given query parameter");
}
Also used : WebTarget(jakarta.ws.rs.client.WebTarget) URI(java.net.URI) Test(org.junit.jupiter.api.Test)

Example 55 with WebTarget

use of jakarta.ws.rs.client.WebTarget in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method pathTest.

/*
   * @testName: pathTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:612;
   * 
   * @test_Strategy: Create a new instance by appending path to the URI of the
   * current target instance. When constructing the final path, a '/' separator
   * will be inserted between the existing path and the supplied path if
   * necessary. Existing '/' characters are preserved thus a single value can
   * represent multiple URI path segments.
   */
@Test
public void pathTest() throws Fault {
    WebTarget target = createWebTarget();
    target = target.path("a/").path("/b/").path("/c/").path("d").path("e");
    assertConfigurationSnapshot(target);
    URI uri = target.getUri();
    assertUriContains(uri, "/a/b/c/d/e");
    logMsg("URI", uri, "contains given path");
}
Also used : WebTarget(jakarta.ws.rs.client.WebTarget) URI(java.net.URI) Test(org.junit.jupiter.api.Test)

Aggregations

WebTarget (jakarta.ws.rs.client.WebTarget)96 Test (org.junit.jupiter.api.Test)63 Client (jakarta.ws.rs.client.Client)52 JAXRSCommonClient (ee.jakarta.tck.ws.rs.common.JAXRSCommonClient)27 Response (jakarta.ws.rs.core.Response)24 Configuration (jakarta.ws.rs.core.Configuration)17 URI (java.net.URI)17 Invocation (jakarta.ws.rs.client.Invocation)16 Assertable (ee.jakarta.tck.ws.rs.api.rs.core.configurable.Assertable)14 SingleCheckAssertable (ee.jakarta.tck.ws.rs.api.rs.core.configurable.SingleCheckAssertable)14 JaxrsCommonClient (ee.jakarta.tck.ws.rs.common.client.JaxrsCommonClient)14 HashMap (java.util.HashMap)8 JdkLoggingFilter (ee.jakarta.tck.ws.rs.common.client.JdkLoggingFilter)6 ClientRequestContext (jakarta.ws.rs.client.ClientRequestContext)5 InboundSseEvent (jakarta.ws.rs.sse.InboundSseEvent)5 SseEventSource (jakarta.ws.rs.sse.SseEventSource)5 ConfigurableObject (ee.jakarta.tck.ws.rs.api.rs.core.configurable.ConfigurableObject)4 LinkedHolder (ee.jakarta.tck.ws.rs.common.util.LinkedHolder)4 Configurable (jakarta.ws.rs.core.Configurable)4 ThrottledClient (jaxrs.examples.client.custom.ThrottledClient)4