use of jakarta.ws.rs.core.Link.Builder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method buildObjectsTest.
/*
* @testName: buildObjectsTest
*
* @assertion_ids: JAXRS:JAVADOC:804;
*
* @test_Strategy: Finish building this link using the supplied values as URI
* parameters.
*/
@Test
public void buildObjectsTest() throws Fault {
StringBuilder path1 = new StringBuilder().append("p1");
ByteArrayInputStream path2 = new ByteArrayInputStream("p2".getBytes(Charset.defaultCharset())) {
@Override
public String toString() {
return "p2";
}
};
URI path3;
try {
path3 = new URI("p3");
} catch (URISyntaxException e) {
throw new Fault(e);
}
String expected = "<" + url() + "p1/p2/p3" + ">";
Link.Builder builder = Link.fromUri(url() + "{x1}/{x2}/{x3}");
Link link = builder.build(path1, path2, path3);
assertTrue(link != null, "#build should return an instance");
assertTrue(link.toString().equals(expected), "Link " + link + " differs from expected " + expected);
logMsg("#build() finished building a link and returned the instance", link);
}
use of jakarta.ws.rs.core.Link.Builder in project jaxrs-api by eclipse-ee4j.
the class ResponseFilter method getLinkBuilder.
public void getLinkBuilder() {
Builder builder = responseContext.getLinkBuilder(RELATION);
if (builder != null) {
Link link = builder.build();
setLinkForGetLink(link);
} else
setEntity(NULL);
}
use of jakarta.ws.rs.core.Link.Builder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method buildNoArgsThrowsUriBuilderExceptionTest.
/*
* @testName: buildNoArgsThrowsUriBuilderExceptionTest
*
* @assertion_ids: JAXRS:JAVADOC:804;
*
* @test_Strategy: throws UriBuilderException if a URI cannot be constructed
* based on the current state of the underlying URI builder.
*/
@Test
public void buildNoArgsThrowsUriBuilderExceptionTest() throws Fault {
Link.Builder builder = Link.fromUri("http://:@");
try {
Link link = builder.build();
assertTrue(false, "No exception has been thrown for link " + link);
} catch (UriBuilderException e) {
logMsg("#build() throw UriBuilderException as expected");
}
}
use of jakarta.ws.rs.core.Link.Builder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method relMoreNamesTest.
/*
* @testName: relMoreNamesTest
*
* @assertion_ids: JAXRS:JAVADOC:809; JAXRS:JAVADOC:1053;
*
* @test_Strategy: More than one "rel" value can be specified by using one or
* more whitespace characters as delimiters according to RFC 5988. The effect of
* calling this method is cumulative; relations are appended using a single
* space character as separator.
*
* jakarta.ws.rs.ext.RuntimeDelegate.createLinkBuilder
*/
@Test
public void relMoreNamesTest() throws Fault {
String[] names = { "name1", "name2" };
Link.Builder builder = RuntimeDelegate.getInstance().createLinkBuilder().uri(url());
for (String name : names) builder = builder.rel(name);
Link link = builder.build();
String search = JaxrsUtil.iterableToString(" ", (Object[]) names);
assertTrue(link.getRel().contains(search), "rel " + search + " not found in " + link);
logMsg("#rel added expected relations");
}
use of jakarta.ws.rs.core.Link.Builder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method baseUriIsIgnoredStringTest.
/*
* @testName: baseUriIsIgnoredStringTest
*
* @assertion_ids: JAXRS:JAVADOC:1126; JAXRS:JAVADOC:1053;
*
* @test_Strategy: If the underlying URI is already absolute, the base URI is
* ignored. jakarta.ws.rs.ext.RuntimeDelegate.createLinkBuilder
*/
@Test
public void baseUriIsIgnoredStringTest() throws Fault {
String ignored = "http://ignored.com";
URI uri = uri("something");
Builder linkBuilder = RuntimeDelegate.getInstance().createLinkBuilder();
linkBuilder = linkBuilder.uri(uri);
linkBuilder = linkBuilder.baseUri(ignored);
URI createdUri = linkBuilder.build().getUri();
logMsg("Created URI", createdUri.toASCIIString());
assertFalse(createdUri.toASCIIString().contains(ignored), "Base Uri " + ignored + " is not ignored, though " + uri.toASCIIString() + "is absolute");
assertContains(createdUri.toASCIIString(), url());
logMsg("The base uri", ignored, "has been ignored as expected");
}
Aggregations