use of jakarta.ws.rs.core.Link.Builder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method buildRelativizedThrowsUriBuilderExceptionTest.
/*
* @testName: buildRelativizedThrowsUriBuilderExceptionTest
*
* @assertion_ids: JAXRS:JAVADOC:1054; JAXRS:JAVADOC:1053;
*
* @test_Strategy: Throws: UriBuilderException - if a URI cannot be constructed
* based on the current state of the underlying URI builder.
* jakarta.ws.rs.ext.RuntimeDelegate.createLinkBuilder
*/
@Test
public void buildRelativizedThrowsUriBuilderExceptionTest() throws Fault {
Builder linkBuilder = RuntimeDelegate.getInstance().createLinkBuilder();
URI respect = null;
try {
respect = new URI(url());
} catch (URISyntaxException e) {
fault(e);
}
try {
Link link = linkBuilder.uri("http://@").buildRelativized(respect);
fault("UriBuilderException has not been thrown, link=", link.toString());
} catch (UriBuilderException iae) {
logMsg("UriBuilderException has been thrown as expected");
}
}
use of jakarta.ws.rs.core.Link.Builder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method titleTest.
/*
* @testName: titleTest
*
* @assertion_ids: JAXRS:JAVADOC:810; JAXRS:JAVADOC:1053;
*
* @test_Strategy: Convenience method to set a title on this link. If called
* more than once, the previous value of title is overwritten.
*
* jakarta.ws.rs.ext.RuntimeDelegate.createLinkBuilder
*/
@Test
public void titleTest() throws Fault {
String[] titles = { "tiTle1", "titlE2", "titLe3" };
Link.Builder builder = RuntimeDelegate.getInstance().createLinkBuilder().uri(url());
for (String title : titles) {
builder = builder.title(title);
Link link = builder.build();
assertTrue(link.getTitle().equals(title), "Title " + title + " not found in " + link);
}
logMsg("#title set expected title");
}
use of jakarta.ws.rs.core.Link.Builder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method baseUriStringThrowsIAETest.
/*
* @testName: baseUriStringThrowsIAETest
*
* @assertion_ids: JAXRS:JAVADOC:1126; JAXRS:JAVADOC:1053;
*
* @test_Strategy: throws java.lang.IllegalArgumentException - if string
* representation of URI is invalid.
*
* jakarta.ws.rs.ext.RuntimeDelegate.createLinkBuilder
*/
@Test
public void baseUriStringThrowsIAETest() throws Fault {
Builder linkBuilder = RuntimeDelegate.getInstance().createLinkBuilder();
try {
linkBuilder.baseUri("?:!@#$%^&*()");
fault("IllegalArgumentException has not been thrown");
} catch (IllegalArgumentException iae) {
logMsg("IllegalArgumentException has been thrown as expected");
}
}
use of jakarta.ws.rs.core.Link.Builder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method baseUriIsNotJustBaseStringTest.
/*
* @testName: baseUriIsNotJustBaseStringTest
*
* @assertion_ids: JAXRS:JAVADOC:1126; JAXRS:JAVADOC:1053;
*
* @test_Strategy: Set the base URI as a string 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 baseUriIsNotJustBaseStringTest() throws Fault {
URI uri = uri("something");
Builder linkBuilder = RuntimeDelegate.getInstance().createLinkBuilder();
linkBuilder = linkBuilder.baseUri(uri.toASCIIString());
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 buildThrowsIAEWhenSuppliedJustOneValueOutOfThreeTest.
/*
* @testName: buildThrowsIAEWhenSuppliedJustOneValueOutOfThreeTest
*
* @assertion_ids: JAXRS:JAVADOC:804;
*
* @test_Strategy: Throws: java.lang.IllegalArgumentException - if there are any
* URI template parameters without a supplied value
*/
@Test
public void buildThrowsIAEWhenSuppliedJustOneValueOutOfThreeTest() throws Fault {
// rfc6570
Builder linkBuilder = Link.fromUri(url() + "{x1}/{x2}/{x3}");
try {
Link link = linkBuilder.build("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");
}
}
Aggregations