Search in sources :

Example 46 with Builder

use of jakarta.ws.rs.core.Link.Builder in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method fromUriTest.

/*
     * @testName: fromUriTest
     * 
     * @assertion_ids: JAXRS:JAVADOC:788;
     * 
     * @test_Strategy: Create a new instance initialized from an existing URI.
     */
@Test
public void fromUriTest() throws Fault {
    URI uri = uri(Request.GET.name());
    Builder builder = Link.fromUri(uri);
    Link link = builder.build();
    assertContains(link.toString(), url());
    assertContains(link.toString(), "resource");
    assertContains(link.toString(), "get");
    logMsg("Link", link, "has been created from URI", uri);
}
Also used : Builder(jakarta.ws.rs.core.Link.Builder) UriBuilder(jakarta.ws.rs.core.UriBuilder) ClientBuilder(jakarta.ws.rs.client.ClientBuilder) URI(java.net.URI) Link(jakarta.ws.rs.core.Link) Test(org.junit.jupiter.api.Test)

Example 47 with Builder

use of jakarta.ws.rs.core.Link.Builder in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method getTypeTest.

/*
     * @testName: getTypeTest
     * 
     * @assertion_ids: JAXRS:JAVADOC:795;
     * 
     * @test_Strategy: Returns the value associated with the link "type" param, or
     * null if this param is not specified.
     */
@Test
public void getTypeTest() throws Fault {
    Builder builder = Link.fromUri(uri("get"));
    builder.rel("RELREL").title("TITLETITLE").type("TYPETYPE");
    Link link = builder.build();
    String type = link.getType();
    assertTrue(type != null, "#getType() did NOT return expected title");
    assertContains(type, "TYPETYPE");
}
Also used : Builder(jakarta.ws.rs.core.Link.Builder) UriBuilder(jakarta.ws.rs.core.UriBuilder) ClientBuilder(jakarta.ws.rs.client.ClientBuilder) Link(jakarta.ws.rs.core.Link) Test(org.junit.jupiter.api.Test)

Example 48 with Builder

use of jakarta.ws.rs.core.Link.Builder in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method getLinkBuilderTest.

/*
   * @testName: getLinkBuilderTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:468; JAXRS:JAVADOC:479; JAXRS:JAVADOC:480;
   * 
   * @test_Strategy: Convenience method that returns a
   * jakarta.ws.rs.core.Link.Builder for the relation. ClientResponseFilter.filter
   */
@Test
public void getLinkBuilderTest() throws Fault {
    final String rel = "RELATION";
    ContextProvider in = new ContextProvider() {

        @Override
        protected void checkFilterContext(ClientRequestContext requestContext, ClientResponseContext responseContext) throws Fault {
            Builder builder = responseContext.getLinkBuilder(rel);
            assertTrue(builder != null, "the #getLinkBuilder is null");
            assertTrue(builder.build().getUri().toASCIIString().contains(getUrl()), "#getLinkBuilder.build was supposed to contain " + getUrl() + " but was " + builder.build().getUri().toASCIIString());
            logMsg("Found #getLinkBuilder()=", builder.build().getUri().toASCIIString());
        }
    };
    Response response = Response.ok().link(getUrl(), rel).build();
    invokeWithResponseAndAssertStatus(response, Status.OK, in);
}
Also used : ClientRequestContext(jakarta.ws.rs.client.ClientRequestContext) Response(jakarta.ws.rs.core.Response) Builder(jakarta.ws.rs.core.Link.Builder) ClientBuilder(jakarta.ws.rs.client.ClientBuilder) ClientResponseContext(jakarta.ws.rs.client.ClientResponseContext) Test(org.junit.jupiter.api.Test)

Aggregations

Builder (jakarta.ws.rs.core.Link.Builder)48 Test (org.junit.jupiter.api.Test)46 Link (jakarta.ws.rs.core.Link)37 UriBuilder (jakarta.ws.rs.core.UriBuilder)34 URI (java.net.URI)18 ClientBuilder (jakarta.ws.rs.client.ClientBuilder)16 URISyntaxException (java.net.URISyntaxException)9 Response (jakarta.ws.rs.core.Response)4 UriBuilderException (jakarta.ws.rs.core.UriBuilderException)3 ClientRequestContext (jakarta.ws.rs.client.ClientRequestContext)2 JAXRSCommonClient (ee.jakarta.tck.ws.rs.common.JAXRSCommonClient)1 Client (jakarta.ws.rs.client.Client)1 ClientRequestFilter (jakarta.ws.rs.client.ClientRequestFilter)1 ClientResponseContext (jakarta.ws.rs.client.ClientResponseContext)1 WebTarget (jakarta.ws.rs.client.WebTarget)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1