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:467; JAXRS:JAVADOC:479; JAXRS:JAVADOC:480;
*
* @test_Strategy: Get the link for the relation.
*
* ClientResponseFilter.filter
*/
@Test
public void getLinkTest() throws Fault {
final String rel = "RELATION";
ContextProvider in = new ContextProvider() {
@Override
protected void checkFilterContext(ClientRequestContext requestContext, ClientResponseContext responseContext) throws Fault {
Link link = responseContext.getLink(rel);
assertTrue(link != null, "the #getLink is null");
assertTrue(link.getUri() != null, "the #getLink.getUri is null");
assertTrue(link.getUri().toASCIIString().contains(getUrl()), "#getLink was supposed to contain " + getUrl() + " but was " + link.getUri().toASCIIString());
logMsg("Found #getLink()=", link.getUri().toASCIIString());
}
};
Response response = Response.ok().link(getUrl(), rel).build();
invokeWithResponseAndAssertStatus(response, Status.OK, in);
}
use of jakarta.ws.rs.core.Link in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getLinksTest.
/*
* @testName: getLinksTest
*
* @assertion_ids: JAXRS:JAVADOC:469; JAXRS:JAVADOC:479; JAXRS:JAVADOC:480;
*
* @test_Strategy: Get the links attached to the message as header.
*
* ClientResponseFilter.filter
*/
@Test
public void getLinksTest() throws Fault {
final Link link = Link.fromUri(getUrl()).build();
ContextProvider in = new ContextProvider() {
@Override
protected void checkFilterContext(ClientRequestContext requestContext, ClientResponseContext responseContext) throws Fault {
Set<Link> links = responseContext.getLinks();
assertTrue(links != null, "the #getLinks is null");
assertTrue(links.size() == 1, "the links was supposed to be of size 1, was " + links.size());
assertTrue(links.contains(link), "#getLinks was supposed to contain " + link.getUri().toASCIIString());
logMsg("Found #getLinks()={", link.getUri().toASCIIString(), "}");
}
};
Response response = Response.ok().links(link).build();
invokeWithResponseAndAssertStatus(response, Status.OK, in);
}
use of jakarta.ws.rs.core.Link in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method closeOnClientTargetWithLinkTest.
/*
* @testName: closeOnClientTargetWithLinkTest
*
* @assertion_ids: JAXRS:JAVADOC:409;
*
* @test_Strategy: Close client instance and all it's associated resources.
* Subsequent calls have no effect and are ignored. Once the client is closed,
* invoking any other method on the client instance would result in an
* IllegalStateException being thrown. Calling this method effectively
* invalidates all WebTarget resource targets produced by the client instance.
* Invoking any method on such targets once the client is closed would result
* in an IllegalStateException being thrown.
*/
@Test
public void closeOnClientTargetWithLinkTest() throws Fault {
client.close();
Link link = Link.fromUri("cts").build();
assertException(IllegalStateException.class, client, "target", link);
}
use of jakarta.ws.rs.core.Link in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method closeOnClientTargetWithUriBuilderTest.
/*
* @testName: closeOnClientTargetWithUriBuilderTest
*
* @assertion_ids: JAXRS:JAVADOC:409;
*
* @test_Strategy: Close client instance and all it's associated resources.
* Subsequent calls have no effect and are ignored. Once the client is closed,
* invoking any other method on the client instance would result in an
* IllegalTStateException being thrown. Calling this method effectively
* invalidates all WebTarget resource targets produced by the client instance.
* Invoking any method on such targets once the client is closed would result
* in an IllegalStateException being thrown.
*/
@Test
public void closeOnClientTargetWithUriBuilderTest() throws Fault {
client.close();
Link link = Link.fromUri("cts").build();
UriBuilder builder = UriBuilder.fromUri(link.getUri());
assertException(IllegalStateException.class, client, "target", builder);
}
use of jakarta.ws.rs.core.Link in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method targetLinkTest.
/*
* @testName: targetLinkTest
*
* @assertion_ids: JAXRS:JAVADOC:420;
*
* @test_Strategy: Build a new web resource target.
*/
@Test
public void targetLinkTest() throws Fault {
URI uri = UriBuilder.fromPath(getUrl("call")).build();
Link link = Link.fromUri(uri).build();
target = client.target(link);
assertTrue(target != null, "WebTarget is null");
}
Aggregations