use of jakarta.ws.rs.core.UriBuilder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method toTemplateTest.
/*
* @testName: toTemplateTest
*
* @assertion_ids: JAXRS:JAVADOC:896;
*
* @test_Strategy: Get the URI template string represented by this URI
* builder.
*/
@Test
public void toTemplateTest() throws Fault {
String template = "{v}/{w}/{x}/{y}/{w}";
UriBuilder builder = UriBuilder.fromPath("").path(template);
assertEquals(template, builder.toTemplate(), "Given template", template, "differs from obtain", builder.toTemplate());
logMsg("Got expected template", template);
}
use of jakarta.ws.rs.core.UriBuilder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method buildFromMapTest5.
/*
* @testName: buildFromMapTest5
*
* @assertion_ids: JAXRS:JAVADOC:185;
*
* @test_Strategy: Create multiple URI instances from the same UriBuilder
* instance using the UriBuilder.buildFromMap(Map); Verify that the builder is
* not affected.
*/
@Test
public void buildFromMapTest5() throws Fault {
UriBuilder ub;
Map<String, String> maps = new HashMap<String, String>();
maps.put("x", "x%yz");
maps.put("y", "/path-absolute/%25test1");
maps.put("z", "fred@example.com");
maps.put("w", "path-rootless/test2");
Map<String, String> maps1 = new HashMap<String, String>();
maps1.put("x", "x%20yz");
maps1.put("y", "/path-absolute/test1");
maps1.put("z", "fred@example.com");
maps1.put("w", "path-rootless/test2");
Map<String, String> maps2 = new HashMap<String, String>();
maps2.put("x", "x%yz");
maps2.put("y", "/path-absolute/%25test1");
maps2.put("z", "fred@example.com");
maps2.put("w", "path-rootless/test2");
maps2.put("v", "xyz");
String expected_path_1 = "path-rootless%2Ftest2/x%2520yz/%2Fpath-absolute%2Ftest1/fred@example.com/x%2520yz";
try {
ub = UriBuilder.fromPath("").path("{w}/{x}/{y}/{z}/{x}");
uri = ub.buildFromMap(maps);
gotExpectedPass(uri.getRawPath(), ENCODED_EXPECTED_PATH);
uri = ub.buildFromMap(maps1);
gotExpectedPass(uri.getRawPath(), expected_path_1);
uri = ub.buildFromMap(maps2);
gotExpectedPass(uri.getRawPath(), ENCODED_EXPECTED_PATH);
} catch (Throwable ex) {
pass = false;
sb.append("Unexpected exception thrown: " + ex.getMessage() + newline);
}
assertPassAndLog();
}
use of jakarta.ws.rs.core.UriBuilder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method resolveTemplateFromEncodedThrowsNullOnNullNameTest.
/*
* @testName: resolveTemplateFromEncodedThrowsNullOnNullNameTest
*
* @assertion_ids: JAXRS:JAVADOC:961;
*
* @test_Strategy: java.lang.IllegalArgumentException - if the resolved
* template name or encoded value is null.
*/
@Test
public void resolveTemplateFromEncodedThrowsNullOnNullNameTest() throws Fault {
Object[] s = { "path-rootless%2Ftest2", new StringBuilder("x%25yz"), "%2Fpath-absolute%2F%2525test1", "fred@example.com" };
UriBuilder builder = UriBuilder.fromPath("").path("{v}/{w}/{x}/{y}/{w}");
try {
builder.resolveTemplateFromEncoded(null, s[0]);
fault("No exception has been thrown");
} catch (IllegalArgumentException e) {
logMsg("IllegalArgumentException thrown as expected", e);
}
}
use of jakarta.ws.rs.core.UriBuilder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method resolveTemplatesFromEncodedTest.
/*
* @testName: resolveTemplatesFromEncodedTest
*
* @assertion_ids: JAXRS:JAVADOC:967;
*
* @test_Strategy: Resolve one or more URI templates in this instance using
* supplied name-value pairs.
*/
@Test
public void resolveTemplatesFromEncodedTest() throws Fault {
Map<String, Object> map = new HashMap<String, Object>();
map.put("v", new StringBuilder("path-rootless%2Ftest2"));
map.put("w", new StringBuilder("x%25yz"));
map.put("x", new Object() {
public String toString() {
return "%2Fpath-absolute%2F%2525test1";
}
});
map.put("y", "fred@example.com");
UriBuilder builder = UriBuilder.fromPath("").path("{v}/{w}/{x}/{y}/{w}");
builder = builder.resolveTemplatesFromEncoded(map);
uri = builder.build();
gotExpectedPass(uri.getRawPath(), ENCODED_EXPECTED_PATH);
assertPassAndLog();
}
use of jakarta.ws.rs.core.UriBuilder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method checkCreatedUriBuilderTest.
/*
* @testName: checkCreatedUriBuilderTest
*
* @assertion_ids: JAXRS:JAVADOC:289;
*
* @test_Strategy: Check that RuntimeDelegate.createUriBuilder makes no
* exception and is not null
*
*/
@Test
public void checkCreatedUriBuilderTest() throws Fault {
UriBuilder builder = delegate.createUriBuilder();
assertTrue(builder != null, "UriBuilder has not been created");
}
Aggregations