Search in sources :

Example 1 with UriBuilderException

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

the class JAXRSClientIT method uriBuilderExceptionTest3.

/*
   * @testName: uriBuilderExceptionTest3
   * 
   * @assertion_ids: JAXRS:JAVADOC:234;
   * 
   * @test_Strategy: Create an UriBuilderException instance using
   * UriBuilderException(String msg, throwable ex). Verify that message msg is
   * associated with the exception.
   */
@Test
public void uriBuilderExceptionTest3() throws Fault {
    String msg = "JAX-RS Test Message: xyz";
    String msg1 = "JAX-RS Test Message Again: xyz";
    try {
        throw new UriBuilderException(msg, new Exception(msg1));
    } catch (UriBuilderException ube) {
        if (ube.getMessage().contains(msg)) {
            TestUtil.logTrace("Test Passed with correct message: " + ube.getMessage() + ".");
        } else {
            throw new Fault("Test Failed.  Expecting message," + msg + ", got " + ube.getMessage() + ".");
        }
    }
}
Also used : UriBuilderException(jakarta.ws.rs.core.UriBuilderException) URISyntaxException(java.net.URISyntaxException) UriBuilderException(jakarta.ws.rs.core.UriBuilderException) Test(org.junit.jupiter.api.Test)

Example 2 with UriBuilderException

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

the class JAXRSClientIT method buildRelativizedThrowsUriBuilderExceptionTest.

/*
     * @testName: buildRelativizedThrowsUriBuilderExceptionTest
     * 
     * @assertion_ids: JAXRS:JAVADOC:1054; JAXRS:JAVADOC:1053;
     * 
     * @test_Strategy: Throws: UriBuilderException - if a URI cannot be constructed
     * based on the current state of the underlying URI builder.
     * jakarta.ws.rs.ext.RuntimeDelegate.createLinkBuilder
     */
@Test
public void buildRelativizedThrowsUriBuilderExceptionTest() throws Fault {
    Builder linkBuilder = RuntimeDelegate.getInstance().createLinkBuilder();
    URI respect = null;
    try {
        respect = new URI(url());
    } catch (URISyntaxException e) {
        fault(e);
    }
    try {
        Link link = linkBuilder.uri("http://@").buildRelativized(respect);
        fault("UriBuilderException has not been thrown, link=", link.toString());
    } catch (UriBuilderException iae) {
        logMsg("UriBuilderException has been thrown as expected");
    }
}
Also used : Builder(jakarta.ws.rs.core.Link.Builder) UriBuilder(jakarta.ws.rs.core.UriBuilder) URISyntaxException(java.net.URISyntaxException) UriBuilderException(jakarta.ws.rs.core.UriBuilderException) URI(java.net.URI) Link(jakarta.ws.rs.core.Link) Test(org.junit.jupiter.api.Test)

Example 3 with UriBuilderException

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

the class JAXRSClientIT method buildNoArgsThrowsUriBuilderExceptionTest.

/*
     * @testName: buildNoArgsThrowsUriBuilderExceptionTest
     * 
     * @assertion_ids: JAXRS:JAVADOC:804;
     * 
     * @test_Strategy: throws UriBuilderException if a URI cannot be constructed
     * based on the current state of the underlying URI builder.
     */
@Test
public void buildNoArgsThrowsUriBuilderExceptionTest() throws Fault {
    Link.Builder builder = Link.fromUri("http://:@");
    try {
        Link link = builder.build();
        assertTrue(false, "No exception has been thrown for link " + link);
    } catch (UriBuilderException e) {
        logMsg("#build() throw UriBuilderException as expected");
    }
}
Also used : Builder(jakarta.ws.rs.core.Link.Builder) UriBuilderException(jakarta.ws.rs.core.UriBuilderException) Link(jakarta.ws.rs.core.Link) Test(org.junit.jupiter.api.Test)

Example 4 with UriBuilderException

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

the class JAXRSClientIT method buildObjectsThrowsUriBuilderExceptionTest.

/*
     * @testName: buildObjectsThrowsUriBuilderExceptionTest
     * 
     * @assertion_ids: JAXRS:JAVADOC:804;
     * 
     * @test_Strategy: throws UriBuilderException if a URI cannot be constructed
     * based on the current state of the underlying URI builder.
     */
@Test
public void buildObjectsThrowsUriBuilderExceptionTest() throws Fault {
    Link.Builder builder = Link.fromUri("http://:@");
    try {
        Link link = builder.build("aaa");
        assertTrue(false, "No exception has been thrown for link " + link);
    } catch (UriBuilderException e) {
        logMsg("#build(someNonURIObjects) throw UriBuilderException as expected");
    }
}
Also used : Builder(jakarta.ws.rs.core.Link.Builder) UriBuilderException(jakarta.ws.rs.core.UriBuilderException) Link(jakarta.ws.rs.core.Link) Test(org.junit.jupiter.api.Test)

Aggregations

UriBuilderException (jakarta.ws.rs.core.UriBuilderException)4 Test (org.junit.jupiter.api.Test)4 Link (jakarta.ws.rs.core.Link)3 Builder (jakarta.ws.rs.core.Link.Builder)3 URISyntaxException (java.net.URISyntaxException)2 UriBuilder (jakarta.ws.rs.core.UriBuilder)1 URI (java.net.URI)1