use of javax.ws.rs.core.Link in project cxf by apache.
the class ResponseImplTest method testGetLinks.
@Test
public void testGetLinks() {
ResponseImpl ri = new ResponseImpl(200);
MetadataMap<String, Object> meta = new MetadataMap<String, Object>();
ri.addMetadata(meta);
assertFalse(ri.hasLink("next"));
assertNull(ri.getLink("next"));
assertFalse(ri.hasLink("prev"));
assertNull(ri.getLink("prev"));
meta.add(HttpHeaders.LINK, "<http://localhost:8080/next;a=b>;rel=next");
meta.add(HttpHeaders.LINK, "<http://prev>;rel=prev");
assertTrue(ri.hasLink("next"));
Link next = ri.getLink("next");
assertNotNull(next);
assertTrue(ri.hasLink("prev"));
Link prev = ri.getLink("prev");
assertNotNull(prev);
Set<Link> links = ri.getLinks();
assertTrue(links.contains(next));
assertTrue(links.contains(prev));
assertEquals("http://localhost:8080/next;a=b", next.getUri().toString());
assertEquals("next", next.getRel());
assertEquals("http://prev", prev.getUri().toString());
assertEquals("prev", prev.getRel());
}
use of javax.ws.rs.core.Link in project cxf by apache.
the class BookStoreSpring method getBookLink.
@GET
@Path("/link")
public Response getBookLink() {
URI selfUri = ui.getBaseUriBuilder().path(BookStoreSpring.class).build();
Link link = Link.fromUri(selfUri).rel("self").build();
return Response.ok().links(link).build();
}
use of javax.ws.rs.core.Link in project tomee by apache.
the class LinkTest method get.
@Test
public void get() throws IOException {
final Response response = ClientBuilder.newClient().target(base.toExternalForm()).path("openejb/link").property("org.apache.cxf.http.header.split", true).request(WILDCARD_TYPE).get();
assertEquals(2, Collection.class.cast(response.getHeaders().get("a")).size());
final Set<Link> actual = response.getLinks();
assertEquals(2, actual.size());
final Set<Link> expected = new LinkEndpoint().doLink().getLinks();
assertEquals(expected, actual);
}
use of javax.ws.rs.core.Link in project jersey by jersey.
the class JerseyClientTest method testCreateLinkBasedInvocation.
/**
* Regression test for JERSEY-1192.
*/
@Test
public void testCreateLinkBasedInvocation() {
final JerseyClient jerseyClient = new JerseyClient();
try {
jerseyClient.invocation(null);
fail("NullPointerException expected.");
} catch (NullPointerException ex) {
// success.
}
try {
jerseyClient.invocation(null);
fail("NullPointerException expected.");
} catch (NullPointerException ex) {
// success.
}
Link link1 = Link.fromUri(UriBuilder.fromPath("http://localhost:8080/").build()).build();
Link link2 = Link.fromUri(UriBuilder.fromPath("http://localhost:8080/").build()).type("text/plain").build();
assertNotNull(jerseyClient.invocation(link1).buildPost(null));
assertNotNull(jerseyClient.invocation(link2).buildPost(null));
assertNotNull(jerseyClient.invocation(link1).buildPost(Entity.text("Test.")));
assertNotNull(jerseyClient.invocation(link2).buildPost(Entity.text("Test.")));
assertNotNull(jerseyClient.invocation(link1).buildPost(Entity.xml("Test.")));
assertNotNull(jerseyClient.invocation(link2).buildPost(Entity.xml("Test.")));
}
use of javax.ws.rs.core.Link in project jersey by jersey.
the class LinkTest method testInvocationFromLinkNoEntity.
@Test
public void testInvocationFromLinkNoEntity() {
Link l = Link.fromUri("http://examples.org/app").type("text/plain").build();
assertNotNull(l);
javax.ws.rs.client.Invocation i = client.invocation(l).buildGet();
assertNotNull(i);
}
Aggregations