use of jakarta.ws.rs.core.UriBuilder in project jaxrs-api by eclipse-ee4j.
the class URIInfoTest method apathTest.
@GET
@Path("/apath")
public String apathTest(@Context UriInfo info) {
StringBuilder sb = new StringBuilder();
URI uri = info.getAbsolutePath();
UriBuilder urib = info.getAbsolutePathBuilder();
sb.append(uri.toString());
if (!uri.toString().equals(urib.build().toString())) {
sb.append("Got unexpected = " + urib.build().toString());
sb.append("FAILED");
}
return sb.toString();
}
use of jakarta.ws.rs.core.UriBuilder in project jaxrs-api by eclipse-ee4j.
the class URIInfoTest method baseUriTest.
@GET
@Path("/baseuri")
public String baseUriTest(@Context UriInfo info) {
StringBuilder sb = new StringBuilder();
URI uri = info.getBaseUri();
UriBuilder urib = info.getBaseUriBuilder();
sb.append(uri.toString());
if (!uri.toString().equals(urib.build().toString())) {
sb.append("Got unexpected = " + urib.build().toString());
sb.append("FAILED");
}
return sb.toString();
}
use of jakarta.ws.rs.core.UriBuilder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method resolveTemplatesMapBooleanSlashNotEncodedTest.
/*
* @testName: resolveTemplatesMapBooleanSlashNotEncodedTest
*
* @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 resolveTemplatesMapBooleanSlashNotEncodedTest() 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", 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, false).build();
gotExpectedPass(uri.getRawPath(), EXPECTED_PATH);
assertPassAndLog();
}
use of jakarta.ws.rs.core.UriBuilder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method resolveTemplatesMapTest.
/*
* @testName: resolveTemplatesMapTest
*
* @assertion_ids: JAXRS:JAVADOC:963;
*
* @test_Strategy: Resolve one or more URI templates in this UriBuilder
* instance using supplied name-value pairs.
*/
@Test
public void resolveTemplatesMapTest() 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).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 cloneTest1.
/*
* @testName: cloneTest1
*
* @assertion_ids: JAXRS:JAVADOC:188;
*
* @test_Strategy: Create an UriBuilder instance using
* UriBuilder.fromPath(String); Create another UriBuilder instance using
* UriBuilder.clone(); Verify that both are created correctly.
*/
@Test
public void cloneTest1() throws Fault {
UriBuilder ub, ub1;
URI uri1;
String path1 = "test";
String frag = "xyz";
String expected_path_1 = "test#xyz";
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");
String expected_path_2 = "test/" + ENCODED_EXPECTED_PATH + "#xyz";
try {
ub = UriBuilder.fromPath(path1).fragment(frag);
ub1 = ub.clone();
uri = ub.build();
gotExpectedPass(uri.toString(), expected_path_1);
uri1 = ub1.path("{w}/{x}/{y}/{z}/{x}").buildFromMap(maps);
gotExpectedPass(uri1.toString(), expected_path_2);
} catch (Exception ex) {
pass = false;
sb.append("Unexpected exception thrown: " + ex.getMessage());
}
assertPassAndLog();
}
Aggregations