Package javax.ws.rs.core

Examples of javax.ws.rs.core.Link$JaxbAdapter


        if (linkValues == null) {
            return Collections.emptyMap();
        } else {
            Map<String, Link> links = new HashMap<String, Link>();
            for (Object o : linkValues) {
                Link link = Link.valueOf(o.toString());
                links.put(link.getRel(), link);
            }
            return links;
        }
    }
View Full Code Here


public class LinkHeaderProviderTest extends Assert {
   
    @Test
    public void testFromSimpleString() {
        Link l = Link.valueOf("<http://bar>");
        assertEquals("http://bar", l.getUri().toString());
    }
View Full Code Here

        assertEquals("http://bar", l.getUri().toString());
    }
   
    @Test
    public void testFromSimpleString2() {
        Link l = Link.valueOf("</>");
        assertEquals("/", l.getUri().toString());
    }
View Full Code Here

        assertEquals("/", l.getUri().toString());
    }
   
    @Test
    public void testFromComplexString() {
        Link l = Link.valueOf("<http://bar>;rel=next;title=\"Next Link\";type=text/xml;method=get");
        assertEquals("http://bar", l.getUri().toString());
        String rel = l.getRel();
        assertEquals("next", rel);
        assertEquals("Next Link", l.getTitle());
        assertEquals("text/xml", l.getType());
        assertEquals("get", l.getParams().get("method"));
    }
View Full Code Here

    }
   
    @Test
    public void testToString() {
        String headerValue = "<http://bar>;rel=next;title=\"Next Link\";type=text/xml;method=get";
        Link l = Link.valueOf(headerValue);
        String result = l.toString();
        assertEquals(result, headerValue);
    }
View Full Code Here

    public void testLinks() {
        MetadataMap<String, Object> m = new MetadataMap<String, Object>();
        m.add("Link", "<http://example.com/page1>;rel=previous");
        m.add("Link", "<http://example.com/page3>;rel=next");
        Link.Builder linkBuilder = new Link.Builder();
        Link prevLink = linkBuilder.uri("http://example.com/page1").rel("previous").build();
        // Reset linkbuilder
        linkBuilder = new Link.Builder();
        Link nextLink = linkBuilder.uri("http://example.com/page3").rel("next").build();
        checkBuild(Response.ok().links(prevLink, nextLink).build(), 200, null, m);
    }
View Full Code Here

    public void testLinksNoReset() {
        MetadataMap<String, Object> m = new MetadataMap<String, Object>();
        m.add("Link", "<http://example.com/page1>;rel=previous");
        m.add("Link", "<http://example.com/page3>;rel=next");
        Link.Builder linkBuilder = new Link.Builder();
        Link prevLink = linkBuilder.uri("http://example.com/page1").rel("previous").build();
        linkBuilder = new Link.Builder();
        Link nextLink = linkBuilder.uri("http://example.com/page3").rel("next").build();
        checkBuild(Response.ok().links(prevLink).links(nextLink).build(), 200, null, m);
    }
View Full Code Here

    @Test
    public void testLinksWithReset() {
        MetadataMap<String, Object> m = new MetadataMap<String, Object>();
        m.add("Link", "<http://example.com/page3>;rel=next");
        Link.Builder linkBuilder = new Link.Builder();
        Link prevLink = linkBuilder.uri("http://example.com/page1").rel("previous").build();
        linkBuilder = new Link.Builder();
        Link nextLink = linkBuilder.uri("http://example.com/page3").rel("next").build();
        // CHECK: Should .links() do a reset? Undocumented feature; so we'll
        // test with the awkward <code>(Link[])null</code> instead..
        // Note: .cookie() has same behavior.
        checkBuild(Response.ok().links(prevLink).links((Link[])null).links(nextLink).build(), 200, null, m);
    }
View Full Code Here

       
        meta.add(HttpHeaders.LINK, "<http://next>;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://next", next.getUri().toString());
        assertEquals("next", next.getRel());
        assertEquals("http://prev", prev.getUri().toString());
        assertEquals("prev", prev.getRel());
    }
View Full Code Here

        if (linkValues == null) {
            return Collections.emptyMap();
        } else {
            Map<String, Link> links = new HashMap<String, Link>();
            for (Object o : linkValues) {
                Link link = Link.valueOf(o.toString());
                links.put(link.getRel(), link);
            }
            return links;
        }
    }
View Full Code Here

TOP

Related Classes of javax.ws.rs.core.Link$JaxbAdapter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.