Search in sources :

Example 6 with UriBuilder

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

the class JAXRSClientIT method buildFromMapWithBooleanThrowsIAEWhenNullValueTest.

/*
   * @testName: buildFromMapWithBooleanThrowsIAEWhenNullValueTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:890;
   * 
   * @test_Strategy: java.lang.IllegalArgumentException - if a template
   * parameter value is null.
   */
@Test
public void buildFromMapWithBooleanThrowsIAEWhenNullValueTest() throws Fault {
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("x", new StringBuilder("x%yz"));
    map.put("y", new StringBuffer("/path-absolute/test1"));
    map.put("z", null);
    map.put("w", "path-rootless/test2");
    UriBuilder builder = UriBuilder.fromPath("").path("{w}/{x}/{y}/{z}/{x}");
    try {
        uri = builder.buildFromMap(map, false);
        fault("No exception has been thrown");
    } catch (IllegalArgumentException e) {
        logMsg("IllegalArgumentException has been thrown as expected");
    }
}
Also used : HashMap(java.util.HashMap) UriBuilder(jakarta.ws.rs.core.UriBuilder) Test(org.junit.jupiter.api.Test)

Example 7 with UriBuilder

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

the class JAXRSClientIT method resolveTemplatesMapBooleanSlashEncodedTest.

/*
   * @testName: resolveTemplatesMapBooleanSlashEncodedTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:965;
   * 
   * @test_Strategy: Resolve one or more URI templates in this UriBuilder
   * instance using supplied name-value pairs.
   */
@Test
public void resolveTemplatesMapBooleanSlashEncodedTest() throws Fault {
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("x", new StringBuilder("x%yz"));
    map.put("y", new StringBuffer("/path-absolute/%25test1"));
    map.put("z", new Object() {

        public String toString() {
            return "fred@example.com";
        }
    });
    map.put("w", "path-rootless/test2");
    UriBuilder builder = UriBuilder.fromPath("").path("{w}/{x}/{y}/{z}/{x}");
    uri = builder.resolveTemplates(map, true).build();
    gotExpectedPass(uri.getRawPath(), ENCODED_EXPECTED_PATH);
    assertPassAndLog();
}
Also used : HashMap(java.util.HashMap) UriBuilder(jakarta.ws.rs.core.UriBuilder) Test(org.junit.jupiter.api.Test)

Example 8 with UriBuilder

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

the class JAXRSClientIT method resolveTemplatesMapBooleanThrowsIAEOnNullMapTest.

/*
   * @testName: resolveTemplatesMapBooleanThrowsIAEOnNullMapTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:966;
   * 
   * @test_Strategy:java.lang.IllegalArgumentException - if the name-value map
   * or any of the names or values in the map is null.
   */
@Test
public void resolveTemplatesMapBooleanThrowsIAEOnNullMapTest() throws Fault {
    UriBuilder builder = UriBuilder.fromPath("").path("{a}/{b}");
    try {
        builder.resolveTemplates((Map<String, Object>) null, false);
        fault("IllegalArgumentException has not been thrown");
    } catch (IllegalArgumentException e) {
        logMsg("IllegalArgumentException has been thrown as expected", e);
    }
}
Also used : UriBuilder(jakarta.ws.rs.core.UriBuilder) Test(org.junit.jupiter.api.Test)

Example 9 with UriBuilder

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

the class JAXRSClientIT method resolveTemplateStringObjectBooleanThrowsIAEOnNullNameTest.

/*
   * @testName: resolveTemplateStringObjectBooleanThrowsIAEOnNullNameTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:959;
   * 
   * @test_Strategy: if the resolved template name or value is null.
   */
@Test
public void resolveTemplateStringObjectBooleanThrowsIAEOnNullNameTest() throws Fault {
    String template = "{v}/{w}/{x}/{y}/{w}";
    UriBuilder builder = UriBuilder.fromPath("").path(template);
    try {
        builder.resolveTemplate(null, "aaa", false);
        fault("No exception has been thrown");
    } catch (IllegalArgumentException e) {
        logMsg("IllegalArgumentException has been thrown as expected", e);
    }
}
Also used : UriBuilder(jakarta.ws.rs.core.UriBuilder) Test(org.junit.jupiter.api.Test)

Example 10 with UriBuilder

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

the class JAXRSClientIT method buildFromMapWithBooleanThrowsIAEWhenNoSuppliedValueTest.

/*
   * @testName: buildFromMapWithBooleanThrowsIAEWhenNoSuppliedValueTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:890;
   * 
   * @test_Strategy: java.lang.IllegalArgumentException - if there are any URI
   * template parameters without a supplied value
   */
@Test
public void buildFromMapWithBooleanThrowsIAEWhenNoSuppliedValueTest() throws Fault {
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("x", new StringBuilder("x%yz"));
    map.put("y", new StringBuffer("/path-absolute/test1"));
    map.put("w", "path-rootless/test2");
    UriBuilder builder = UriBuilder.fromPath("").path("{w}/{x}/{y}/{z}/{x}");
    try {
        uri = builder.buildFromMap(map, false);
        fault("No exception has been thrown");
    } catch (IllegalArgumentException e) {
        logMsg("IllegalArgumentException has been thrown as expected");
    }
}
Also used : HashMap(java.util.HashMap) UriBuilder(jakarta.ws.rs.core.UriBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

UriBuilder (jakarta.ws.rs.core.UriBuilder)48 Test (org.junit.jupiter.api.Test)45 HashMap (java.util.HashMap)18 URI (java.net.URI)8 Link (jakarta.ws.rs.core.Link)6 Builder (jakarta.ws.rs.core.Link.Builder)5 GET (jakarta.ws.rs.GET)3 Path (jakarta.ws.rs.Path)3 ClientBuilder (jakarta.ws.rs.client.ClientBuilder)2 JAXRSCommonClient (ee.jakarta.tck.ws.rs.common.JAXRSCommonClient)1 Configuration (jakarta.ws.rs.SeBootstrap.Configuration)1 Client (jakarta.ws.rs.client.Client)1 WebTarget (jakarta.ws.rs.client.WebTarget)1 UriBuilderException (jakarta.ws.rs.core.UriBuilderException)1 URISyntaxException (java.net.URISyntaxException)1