use of jakarta.ws.rs.core.Link in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method buildRelativizedThrowsIAEWhenNotSuppliedValuesTest.
/*
* @testName: buildRelativizedThrowsIAEWhenNotSuppliedValuesTest
*
* @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 buildRelativizedThrowsIAEWhenNotSuppliedValuesTest() 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);
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 in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method hasLinkWhenLinkTest.
/*
* @testName: hasLinkWhenLinkTest
*
* @assertion_ids: JAXRS:JAVADOC:862;
*
* @test_Strategy: Check if link for relation exists.
*/
@Test
public void hasLinkWhenLinkTest() throws Fault {
Link link = createLink("path", "rel");
Response response = Response.ok().links(link).build();
assertTrue(response.hasLink("rel"), "#hasLink did not found a Link");
logMsg("#hasEntity found the Link as expected");
}
use of jakarta.ws.rs.core.Link in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getLinkTest.
/*
* @testName: getLinkTest
*
* @assertion_ids: JAXRS:JAVADOC:853;
*
* @test_Strategy: Get the link for the relation.
*/
@Test
public void getLinkTest() throws Fault {
Link link = createLink("path", "getLinkTest");
Response response = Response.ok().links(link).build();
Link responseLink = response.getLink("getLinkTest");
assertTrue(link.equals(responseLink), "#getLink() returned unexpected Link" + responseLink);
logMsg("#getLink matches expected Link");
}
use of jakarta.ws.rs.core.Link in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getLinkBuilderForTheRelationTest.
/*
* @testName: getLinkBuilderForTheRelationTest
*
* @assertion_ids: JAXRS:JAVADOC:854;
*
* @test_Strategy: Convenience method that returns a Link.Builder for the
* relation.
*/
@Test
public void getLinkBuilderForTheRelationTest() throws Fault {
String rel = "anyrelation";
Response response = Response.ok().link("http://abc.com/b/", rel).build();
Link builderLink = response.getLinkBuilder("anyrelation").build();
response = Response.ok().links(builderLink).build();
Link responseLink = response.getLink("anyrelation");
assertNotNull(responseLink, "#getLinkBuilder('relation') returned null");
logMsg("#getLinkBuilder creates correct Link for given relation");
}
use of jakarta.ws.rs.core.Link in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method fromPathTest.
/*
* @testName: fromPathTest
*
* @assertion_ids: JAXRS:JAVADOC:1038;
*
* @test_Strategy: Convenience method to build a link from a path. Equivalent to
* fromUriBuilder(UriBuilder.fromPath(path)).
*/
@Test
public void fromPathTest() throws Fault {
String path = "somewhere/somehow";
UriBuilder builder = UriBuilder.fromPath(path);
Link.Builder linkBuilder = Link.fromUriBuilder(builder);
Link.Builder fromPathBuilder = Link.fromPath(path);
String fromUriBuilderString = linkBuilder.build().toString();
String fromPathString = fromPathBuilder.build().toString();
assertEquals(fromUriBuilderString, fromPathString, "fromUriBuilder()=", fromUriBuilderString, "differs from Link.fromPath()", fromPathString);
logMsg("fromUriBuilder(UriBuilder.fromPath(path)) is equivalent to fromPath(path)", "The link is", fromPathString);
}
Aggregations