use of jakarta.ws.rs.core.Link.Builder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method buildRelativizedThrowsIAEWhenSuppliedJustOneValueOutOfThreeTest.
/*
* @testName: buildRelativizedThrowsIAEWhenSuppliedJustOneValueOutOfThreeTest
*
* @assertion_ids: JAXRS:JAVADOC:1054;
*
* @test_Strategy: Throws: java.lang.IllegalArgumentException - if there are any
* URI template parameters without a supplied value
*/
@Test
public void buildRelativizedThrowsIAEWhenSuppliedJustOneValueOutOfThreeTest() throws Fault {
// rfc6570
Builder linkBuilder = Link.fromUri(url() + "{x1}/{x2}/{x3}");
URI respect = null;
try {
respect = new URI(url());
} catch (URISyntaxException e) {
fault(e);
}
try {
Link link = linkBuilder.buildRelativized(respect, "p");
fault("IllegalArgumentException has not been thrown when value is not supplied, link=", link.toString());
} catch (IllegalArgumentException iae) {
logMsg("IllegalArgumentException has been thrown as expected when a value has not been supplied");
}
}
use of jakarta.ws.rs.core.Link.Builder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method buildRelativizedDoesNotSharePrefixTest.
/*
* @testName: buildRelativizedDoesNotSharePrefixTest
*
* @assertion_ids: JAXRS:JAVADOC:1054;
*
* @test_Strategy: If the underlying link is absolute but does not share a
* prefix with the supplied URI, this method is equivalent to calling
* build(java.lang.Object[])
*/
@Test
public void buildRelativizedDoesNotSharePrefixTest() throws Fault {
String relative = "a/b/c";
String prefix = "ssh";
URI underlay = null, respect = null;
try {
underlay = new URI(url() + relative);
respect = new URI(url().replace("http", prefix));
} catch (URISyntaxException e) {
fault(e);
}
Builder linkBuilder = RuntimeDelegate.getInstance().createLinkBuilder();
linkBuilder = linkBuilder.uri(underlay);
Link link = linkBuilder.buildRelativized(respect);
Link build = linkBuilder.build(respect);
assertContains(link.toString(), relative);
assertContains(link.toString(), url());
// |=|
assertContains(link.toString(), build.getUri().toASCIIString());
logMsg("When a prefix is not shared, the methods is equivalent to build() as expected");
}
use of jakarta.ws.rs.core.Link.Builder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method baseUriIsNotJustBaseURITest.
/*
* @testName: baseUriIsNotJustBaseURITest
*
* @assertion_ids: JAXRS:JAVADOC:1125; JAXRS:JAVADOC:1053;
*
* @test_Strategy: Set the base URI for resolution of relative URIs. Provide a
* URI that is not just base, i.e. schema and authority, but also a path
*
* jakarta.ws.rs.ext.RuntimeDelegate.createLinkBuilder
*/
@Test
public void baseUriIsNotJustBaseURITest() throws Fault {
URI uri = uri("something");
Builder linkBuilder = RuntimeDelegate.getInstance().createLinkBuilder();
linkBuilder = linkBuilder.baseUri(uri);
URI createdUri = linkBuilder.uri("/a/b/c").build().getUri();
logMsg("Created URI", createdUri.toASCIIString());
assertFalse(createdUri.toASCIIString().contains(uri.toASCIIString()), "Base Uri " + uri.toASCIIString() + " is not a base uri built as " + createdUri.toASCIIString());
assertContains(createdUri.toASCIIString(), url());
}
use of jakarta.ws.rs.core.Link.Builder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method baseUriStringTest.
/*
* @testName: baseUriStringTest
*
* @assertion_ids: JAXRS:JAVADOC:1126; JAXRS:JAVADOC:1053;
*
* @test_Strategy: Set the base URI as a string for resolution of relative URIs.
*
* jakarta.ws.rs.ext.RuntimeDelegate.createLinkBuilder
*/
@Test
public void baseUriStringTest() throws Fault {
URI uri = null;
try {
uri = new URI(url());
} catch (URISyntaxException use) {
fault(use);
}
Builder linkBuilder = RuntimeDelegate.getInstance().createLinkBuilder();
linkBuilder = linkBuilder.baseUri(uri.toASCIIString());
URI createdUri = linkBuilder.uri("/a/b/c").build().getUri();
logMsg("Created URI", createdUri.toASCIIString());
assertContains(createdUri.toASCIIString(), uri.toASCIIString());
}
use of jakarta.ws.rs.core.Link.Builder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method uriUriTest.
/*
* @testName: uriUriTest
*
* @assertion_ids: JAXRS:JAVADOC:812; JAXRS:JAVADOC:1053;
*
* @test_Strategy: Set underlying URI template for the link being constructed.
*
* jakarta.ws.rs.ext.RuntimeDelegate.createLinkBuilder
*/
@Test
public void uriUriTest() throws Fault {
URI uri = uri("get");
Link.Builder builder = RuntimeDelegate.getInstance().createLinkBuilder().uri(uri);
Link link = builder.build();
assertTrue(link.toString().contains(uri.toASCIIString()), "uri(URI) " + uri + " not used in " + link);
logMsg("#uri(URI) affected link", link, "as expected");
}
Aggregations