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);
}
}
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");
}
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);
}
}
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¶mName=value2¶mName=value3");
logMsg("URI", uri, "contains given query parameter");
}
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");
}
Aggregations