use of jakarta.ws.rs.client.WebTarget in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method queryParamNullValueTest.
/*
* @testName: queryParamNullValueTest
*
* @assertion_ids: JAXRS:JAVADOC:618;
*
* @test_Strategy: In case a single null value is entered, all parameters with
* that name are removed (if present) from the collection of query parameters
* inherited from the current target.
*/
@Test
public void queryParamNullValueTest() throws Fault {
WebTarget target = createWebTarget();
target = target.path("path").queryParam("paramName", new StringBuffer().append("value1"), new StringBuilder().append("value2"), "value3");
assertConfigurationSnapshot(target);
target = target.queryParam("param", (Object[]) null).path("path2");
URI uri = target.getUri();
assertUriContains(uri, "/path/path2");
logMsg("#paramName(name, null) removed values as expected");
}
use of jakarta.ws.rs.client.WebTarget in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method resolveTemplatesWithBooleanTrueReturnsTheSameTargetTest.
/*
* @testName: resolveTemplatesWithBooleanTrueReturnsTheSameTargetTest
*
* @assertion_ids: JAXRS:JAVADOC:948;
*
* @test_Strategy: A call to the method with an empty parameter map is
* ignored, i.e. same WebTarget instance is returned.
*/
@Test
public void resolveTemplatesWithBooleanTrueReturnsTheSameTargetTest() throws Fault {
WebTarget target = createWebTarget();
target = target.path("{path}");
WebTarget other = target.resolveTemplates(new TreeMap<String, Object>(), true);
assertEquals(target, other, "#pathParams did not return the same target when the input map is empty");
logMsg("#pathParams returned the same traget wehn empty as expected");
}
use of jakarta.ws.rs.client.WebTarget in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method resolveTemplatesFromEncodedTest.
/*
* @testName: resolveTemplatesFromEncodedTest
*
* @assertion_ids: JAXRS:JAVADOC:950;
*
* @test_Strategy: Create a new WebTarget instance by resolving a URI template
* with a given name in the URI of the current target instance using a
* supplied encoded value. A template with a matching name will be replaced by
* the supplied value. Value is converted to String using its toString()
* method and is then encoded to match the rules of the URI component to which
* they pertain. All % characters in the stringified values that are not
* followed by two hexadecimal numbers will be encoded.
*/
@Test
public void resolveTemplatesFromEncodedTest() throws Fault {
WebTarget target = createWebTarget();
StringBuilder sb = new StringBuilder();
sb.append(ENCODED);
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("path", sb);
target = target.path("{path}").resolveTemplatesFromEncoded(map);
assertConfigurationSnapshot(target);
URI uri = target.getUri();
assertUriContains(uri, "/" + ENCODED.replace("%%", "%25%"));
logMsg("URI", uri, "contains given path parameter");
}
use of jakarta.ws.rs.client.WebTarget in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method resolveTemplatesNullValueTest.
/*
* @testName: resolveTemplatesNullValueTest
*
* @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 resolveTemplatesNullValueTest() throws Fault {
Map<String, Object> map = new HashMap<String, Object>();
map.put("path", null);
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 resolveTemplatesWithBooleanFalseTest.
/*
* @testName: resolveTemplatesWithBooleanFalseTest
*
* @assertion_ids: JAXRS:JAVADOC:948;
*
* @test_Strategy: Create a new WebTarget instance by resolving one or more
* URI templates in the URI of the current target instance using supplied
* name-value pairs. A call to the method with an empty parameter map is
* ignored, i.e. same WebTarget instance is returned. A snapshot of the
* present configuration of the current (parent) target instance is taken and
* is inherited by the newly constructed (child) target instance.
*/
@Test
public void resolveTemplatesWithBooleanFalseTest() throws Fault {
Map<String, Object> map = new TreeMap<String, Object>();
map.put("path", new StringBuilder().append("lane"));
map.put("highway", new StringBuffer().append("route66"));
map.put("sidewalk", "pavement");
WebTarget target = createWebTarget();
target = target.path("{path}").path("{highway}").path("{sidewalk}");
target = target.resolveTemplates(map, false);
assertConfigurationSnapshot(target);
URI uri = target.getUri();
assertUriContains(uri, "/lane/route66/pavement");
logMsg("URI", uri, "contains given path parameters");
}
Aggregations