Search in sources :

Example 36 with Link

use of jakarta.ws.rs.core.Link 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 37 with Link

use of jakarta.ws.rs.core.Link 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 38 with Link

use of jakarta.ws.rs.core.Link 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 39 with Link

use of jakarta.ws.rs.core.Link 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 40 with Link

use of jakarta.ws.rs.core.Link 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

Link (jakarta.ws.rs.core.Link)84 Test (org.junit.jupiter.api.Test)69 Builder (jakarta.ws.rs.core.Link.Builder)37 UriBuilder (jakarta.ws.rs.core.UriBuilder)27 Response (jakarta.ws.rs.core.Response)23 URI (java.net.URI)19 ClientBuilder (jakarta.ws.rs.client.ClientBuilder)14 URISyntaxException (java.net.URISyntaxException)7 Path (jakarta.ws.rs.Path)4 POST (jakarta.ws.rs.POST)3 Client (jakarta.ws.rs.client.Client)3 ClientRequestContext (jakarta.ws.rs.client.ClientRequestContext)3 ClientResponseContext (jakarta.ws.rs.client.ClientResponseContext)3 UriBuilderException (jakarta.ws.rs.core.UriBuilderException)3 GET (jakarta.ws.rs.GET)2 ResponseBuilder (jakarta.ws.rs.core.Response.ResponseBuilder)2 JAXBContext (jakarta.xml.bind.JAXBContext)2 JAXBException (jakarta.xml.bind.JAXBException)2 Marshaller (jakarta.xml.bind.Marshaller)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2