Search in sources :

Example 31 with Link

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

the class JAXRSClientIT method closeOnClientInvocationWithLinkTest.

/*
   * @testName: closeOnClientInvocationWithLinkTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:409;
   * 
   * @test_Strategy: Close client instance and all it's associated resources.
   * Subsequent calls have no effect and are ignored. Once the client is closed,
   * invoking any other method on the client instance would result in an
   * IllegalStateException being thrown. Calling this method effectively
   * invalidates all WebTarget resource targets produced by the client instance.
   * Invoking any method on such targets once the client is closed would result
   * in an IllegalStateException being thrown.
   */
@Test
public void closeOnClientInvocationWithLinkTest() throws Fault {
    client.close();
    Link link = Link.fromUri("cts").build();
    assertException(IllegalStateException.class, client, "invocation", link);
}
Also used : Link(jakarta.ws.rs.core.Link) Test(org.junit.jupiter.api.Test)

Example 32 with Link

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

the class JAXRSClientIT method constructorTest.

/* Run test */
/*
     * @testName: constructorTest
     * 
     * @assertion_ids: JAXRS:JAVADOC:799;
     * 
     * @test_Strategy: see what happens when new Link() is used.
     */
@Test
public void constructorTest() throws Fault {
    Link link = new Link() {

        @Override
        public URI getUri() {
            return null;
        }

        @Override
        public UriBuilder getUriBuilder() {
            return null;
        }

        @Override
        public String getRel() {
            return null;
        }

        @Override
        public List<String> getRels() {
            return null;
        }

        @Override
        public String getTitle() {
            return null;
        }

        @Override
        public String getType() {
            return null;
        }

        @Override
        public Map<String, String> getParams() {
            return null;
        }

        @Override
        public String toString() {
            return "";
        }
    };
    // check no Exception is thrown
    assertTrue(link != null, "new Link() is null");
    logMsg("new Link() call iss successfull", link.toString());
}
Also used : Link(jakarta.ws.rs.core.Link) Test(org.junit.jupiter.api.Test)

Example 33 with Link

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

the class JAXRSClientIT method getParamsFromResourceTest.

/*
     * @testName: getParamsFromResourceTest
     * 
     * @assertion_ids: JAXRS:JAVADOC:792;
     * 
     * @test_Strategy: Returns an immutable map that includes all the link
     * parameters defined on this link. If defined, this map will include entries
     * for "rel", "title" and "type".
     */
@Test
public void getParamsFromResourceTest() throws Fault {
    String title = "Title";
    String value;
    Link link = Link.fromMethod(Resource.class, "producesSvgXml").title(title).build();
    Map<String, String> params = link.getParams();
    System.out.println(params);
    value = params.get("type");
    assertNull(value, "Unexpected media type in link found", value);
    value = params.get("title");
    assertContains(value, title);
    logMsg(params, "found as expected");
}
Also used : Link(jakarta.ws.rs.core.Link) Test(org.junit.jupiter.api.Test)

Example 34 with Link

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

the class JAXRSClientIT method fromMethodTest.

/*
     * @testName: fromMethodTest
     * 
     * @assertion_ids: JAXRS:JAVADOC:1037;
     * 
     * @test_Strategy: Convenience method to build a link from a resource method.
     * Note that path created from resource is relative to the application's root
     * resource.
     */
@Test
public void fromMethodTest() throws Fault {
    Link link = linkFromResource("consumesAppJson");
    String resource = link.toString();
    assertContains(resource, "<consumesappjson>");
    logMsg("Link", resource, "has been created");
}
Also used : Link(jakarta.ws.rs.core.Link) Test(org.junit.jupiter.api.Test)

Example 35 with Link

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

the class JAXRSClientIT method fromResourceTest.

/*
     * @testName: fromResourceTest
     * 
     * @assertion_ids: JAXRS:JAVADOC:1039;
     * 
     * @test_Strategy: Convenience method to build a link from a resource.
     */
@Test
public void fromResourceTest() throws Fault {
    Link link = Link.fromResource(Resource.class).build();
    String resource = link.toString();
    assertContains(resource, "<resource>");
    assertNotContains(resource, "type");
    logMsg("Link", resource, "has been created");
}
Also used : Link(jakarta.ws.rs.core.Link) Test(org.junit.jupiter.api.Test)

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