Search in sources :

Example 1 with Builder

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

the class JAXRSClientIT method fromUriStringTest.

/*
     * @testName: fromUriStringTest
     * 
     * @assertion_ids: JAXRS:JAVADOC:790;
     * 
     * @test_Strategy: Create a new instance initialized from an existing URI.
     */
@Test
public void fromUriStringTest() throws Fault {
    URI uri = uri(Request.GET.name());
    Builder builder = Link.fromUri(uri.toASCIIString());
    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.toASCIIString());
}
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 2 with Builder

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

the class JAXRSClientIT method getUriBuilderTest.

/*
     * @testName: getUriBuilderTest
     * 
     * @assertion_ids: JAXRS:JAVADOC:797;
     * 
     * @test_Strategy: Convenience method that returns a
     * jakarta.ws.rs.core.UriBuilder initialized with this link's underlying URI.
     */
@Test
public void getUriBuilderTest() throws Fault {
    URI uri = uri("get");
    Builder builder = Link.fromUri(uri);
    Link link = builder.build();
    UriBuilder uriBuilder = link.getUriBuilder();
    assertTrue(uriBuilder != null, "#getUriBuilder is null");
    URI uriFromLink = uriBuilder.build();
    assertTrue(uri.equals(uriFromLink), "#getUri() " + uriFromLink + " differes from original uri " + uri);
    logMsg("Original URI", uri, "equals obtained", uriFromLink);
}
Also used : Builder(jakarta.ws.rs.core.Link.Builder) UriBuilder(jakarta.ws.rs.core.UriBuilder) ClientBuilder(jakarta.ws.rs.client.ClientBuilder) UriBuilder(jakarta.ws.rs.core.UriBuilder) URI(java.net.URI) Link(jakarta.ws.rs.core.Link) Test(org.junit.jupiter.api.Test)

Example 3 with Builder

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

the class JAXRSClientIT method getRelIsEmptyListTest.

/*
     * @testName: getRelIsEmptyListTest
     * 
     * @assertion_ids: JAXRS:JAVADOC:793;
     * 
     * @test_Strategy: Returns the value associated with the link "rel" param, or
     * null if this param is not specified.
     */
@Test
public void getRelIsEmptyListTest() throws Fault {
    Builder builder = Link.fromUri(uri("get"));
    Link link = builder.build();
    String rel = link.getRel();
    assertTrue(rel == null, "#getRel is NOT null");
    logMsg("#getRel() returns expected null");
}
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 4 with Builder

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

the class JAXRSClientIT method getRelTest.

/*
     * @testName: getRelTest
     * 
     * @assertion_ids: JAXRS:JAVADOC:793;
     * 
     * @test_Strategy: Returns the value associated with the link "rel" param, or
     * null if this param is not specified.
     */
@Test
public void getRelTest() throws Fault {
    Builder builder = Link.fromUri(uri("get"));
    builder.rel("RELREL").title("TITLETITLE").type("TYPETYPE").param("NEWPARAM", "NEWPARAMVALUE");
    Link link = builder.build();
    String rel = link.getRel();
    assertTrue(rel.contains("RELREL"), "#getRel did NOT return expected RELREL");
    logMsg("#getRel() return expected rel");
}
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 5 with Builder

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

the class JAXRSClientIT method linkFromResource.

// ///////////////////////////////////////////////////////////////////
protected static Link linkFromResource(String method) {
    Builder builder = Link.fromMethod(Resource.class, method);
    Link link = builder.build();
    return link;
}
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)

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