use of jakarta.ws.rs.client.WebTarget in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method matrixParamOnTwoSegmentsTest.
/*
* @testName: matrixParamOnTwoSegmentsTest
*
* @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. 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 matrixParamOnTwoSegmentsTest() throws Fault {
WebTarget target = createWebTarget();
target = target.matrixParam("matrix1", "segment1");
assertConfigurationSnapshot(target);
target = target.path("path");
assertConfigurationSnapshot(target);
target = target.matrixParam("matrix2", "segment2");
assertConfigurationSnapshot(target);
URI uri = target.getUri();
assertUriContains(uri, ";matrix1=segment1/path;matrix2=segment2");
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 resolveTemplateFromEncodedTest.
/*
* @testName: resolveTemplateFromEncodedTest
*
* @assertion_ids: JAXRS:JAVADOC:944;
*
* @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 resolveTemplateFromEncodedTest() throws Fault {
WebTarget target = createWebTarget();
StringBuilder sb = new StringBuilder();
sb.append(ENCODED);
target = target.path("{path}").resolveTemplateFromEncoded("path", sb);
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 buildTarget.
protected static WebTarget buildTarget(ClientRequestFilter requestFilter, ContextProvider... providers) {
Client client = ClientBuilder.newClient();
client.register(requestFilter);
for (ContextProvider provider : providers) client.register(provider);
WebTarget target = client.target(getUrl());
return target;
}
use of jakarta.ws.rs.client.WebTarget in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method requestNoArgTest.
/*
* @testName: requestNoArgTest
*
* @assertion_ids: JAXRS:JAVADOC:622;
*
* @test_Strategy: Start building a request to the targeted web resource.
*/
@Test
public void requestNoArgTest() throws Fault {
WebTarget target = createWebTarget();
Response response = target.request().buildGet().invoke();
String body = response.readEntity(String.class);
assertContains(body, URL);
assertContains(body, MediaType.WILDCARD);
}
use of jakarta.ws.rs.client.WebTarget in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method resolveTemplateTest.
/*
* @testName: resolveTemplateTest
*
* @assertion_ids: JAXRS:JAVADOC:940;
*
* @test_Strategy: Create a new instance by resolving a URI template with a
* given name in the URI of the current target instance using a supplied
* value. In case a template name or value is entered a NullPointerException
* is thrown. 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 resolveTemplateTest() throws Fault {
WebTarget target = createWebTarget();
target = target.path("{path}").resolveTemplate("path", "lane");
assertConfigurationSnapshot(target);
URI uri = target.getUri();
assertUriContains(uri, "/lane");
logMsg("URI", uri, "contains given path parameter");
}
Aggregations