Package javax.ws.rs.core

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


    }
   
    @Test
    public void testBuildManyRels() throws Exception {
        Link.Builder linkBuilder = new LinkBuilderImpl();
        Link prevLink = linkBuilder.uri("http://example.com/page1").rel("1").rel("2").build();
        assertEquals("<http://example.com/page1>;rel=\"1 2\"", prevLink.toString());
    }
View Full Code Here


    @Test
    public void testBuildRelativized() throws Exception {
       
        Link.Builder linkBuilder = new LinkBuilderImpl();
        URI base = URI.create("http://example.com/page2");
        Link prevLink = linkBuilder.uri("http://example.com/page1").rel("previous").buildRelativized(base);
        assertEquals("<page1>;rel=\"previous\"", prevLink.toString());
    }
View Full Code Here

   
    @Test
    public void testRelativeLink() throws Exception {
        Link.Builder linkBuilder = Link.fromUri("relative");
        linkBuilder.baseUri("http://localhost:8080/base/path");
        Link link = linkBuilder.rel("next").build();
        assertEquals("<http://localhost:8080/base/relative>;rel=\"next\"", link.toString());
    }
View Full Code Here

   
    @Test
    public void testRelativeLink2() throws Exception {
        Link.Builder linkBuilder = Link.fromUri("/relative");
        linkBuilder.baseUri("http://localhost:8080/base/path");
        Link link = linkBuilder.rel("next").build();
        assertEquals("<http://localhost:8080/relative>;rel=\"next\"", link.toString());
    }
View Full Code Here

    }
   
    @Test
    public void testSeveralAttributes() throws Exception {
        Link.Builder linkBuilder = new LinkBuilderImpl();
        Link prevLink = linkBuilder.uri("http://example.com/page1").rel("previous").title("A title").build();
        assertEquals("<http://example.com/page1>;rel=\"previous\";title=\"A title\"", prevLink.toString());
    }
View Full Code Here

    }
   
    @Test
    public void testCreateFromMethod() throws Exception {
        Link.Builder linkBuilder = Link.fromMethod(TestResource.class, "consumesAppJson");
        Link link = linkBuilder.build();
        String resource = link.toString();
        assertTrue(resource.contains("<consumesappjson>"));
    }
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

    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

TOP

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

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.