use of jakarta.ws.rs.client.WebTarget in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method resolveTemplateWithBooleanFalseTest.
/*
* @testName: resolveTemplateWithBooleanFalseTest
*
* @assertion_ids: JAXRS:JAVADOC:942;
*
* @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.
*
* if true, the slash ('/') characters in template values will be encoded if
* the template is placed in the URI path component, otherwise the slash
* characters will not be encoded in path templates.
*/
@Test
public void resolveTemplateWithBooleanFalseTest() throws Fault {
WebTarget target = createWebTarget();
target = target.path("{path}").resolveTemplate("path", ENCODED, false);
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 resolveTemplatesFromEncodedReturnsTheSameTargetTest.
/*
* @testName: resolveTemplatesFromEncodedReturnsTheSameTargetTest
*
* @assertion_ids: JAXRS:JAVADOC:950;
*
* @test_Strategy: A call to the method with an empty parameter map is
* ignored, i.e. same WebTarget instance is returned.
*/
@Test
public void resolveTemplatesFromEncodedReturnsTheSameTargetTest() throws Fault {
WebTarget target = createWebTarget();
target = target.path("{path}");
WebTarget other = target.resolveTemplatesFromEncoded(new TreeMap<String, Object>());
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 getUriBuilderTest.
/*
* @testName: getUriBuilderTest
*
* @assertion_ids: JAXRS:JAVADOC:609;
*
* @test_Strategy: Get the URI builder initialized with the URI of the current
* resource target. The returned URI builder is detached from the target, i.e.
* any updates in the URI builder MUST NOT have any effects on the URI of the
* originating target.
*/
@Test
public void getUriBuilderTest() throws Fault {
WebTarget target = createWebTarget();
URI uri = target.getUriBuilder().build();
assertContains(uri.toASCIIString(), URL);
logMsg("URI", uri, "contains", URL);
}
use of jakarta.ws.rs.client.WebTarget in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method createWebTarget.
protected WebTarget createWebTarget() throws Fault {
Client client = ClientBuilder.newClient();
client.register(FILTER);
WebTarget target = client.target(URL);
assertConfigurationSnapshot(target);
return target;
}
use of jakarta.ws.rs.client.WebTarget in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getClassesIsImmutableTest.
/*
* @testName: getClassesIsImmutableTest
*
* @assertion_ids: JAXRS:JAVADOC:992; JAXRS:JAVADOC:758;
*
* @test_Strategy: Get the immutable set of registered provider classes to be
* instantiated, injected and utilized in the scope of the configured instance.
* A provider class is a Java class with a jakarta.ws.rs.ext.Provider annotation
* declared on the class that implements a specific service interface.
*
* Register a provider class to be instantiated
*/
@Test
public void getClassesIsImmutableTest() throws Fault {
Assertable assertable = new Assertable() {
@Override
public void check1OnClient(Client client) throws Fault {
assertSizeAndLog(client.getConfiguration(), 0);
registerNewProviderInstance(client.getConfiguration());
assertSizeAndLog(client.getConfiguration(), 0);
}
@Override
public void check2OnTarget(WebTarget target) throws Fault {
registerNewProviderInstance(target.getConfiguration());
assertSizeAndLog(target.getConfiguration(), 0);
}
void assertSizeAndLog(Configuration config, int count) throws Fault {
if (config.getClasses().size() == 1)
logMsg("Found", config.getClasses().iterator().next());
assertTrue(config.getClasses().size() == count + registeredClassesCnt, "config.getClasses() return unexcepted size " + getLocation() + " : " + config.getClasses().size());
logMsg("Found", config.getClasses().size(), "providers");
}
void registerNewProviderInstance(Configuration config) {
Class<?> clz = CallableProvider.class;
try {
config.getClasses().add(clz);
} catch (Exception e) {
// can throw exception or do nothing
// when adding to this immutable set
// or it can be a new hard copied set
}
}
};
checkConfigWithProperties(assertable);
}
Aggregations