use of javax.ws.rs.core.UriBuilder in project cxf by apache.
the class UriBuilderImplTest method testBuildWithNonEncodedSubstitutionValue7.
@Test
public void testBuildWithNonEncodedSubstitutionValue7() {
UriBuilder ub = UriBuilder.fromPath("/");
URI uri = ub.replaceQueryParam("a", "%").buildFromEncoded();
assertEquals("/?a=%25", uri.toString());
uri = ub.replaceQueryParam("a2", "{token}").buildFromEncoded("{}");
assertEquals("/?a=%25&a2=%7B%7D", uri.toString());
}
use of javax.ws.rs.core.UriBuilder in project cxf by apache.
the class UriBuilderImplTest method testInvalidUriReplacement.
@Test
public void testInvalidUriReplacement() throws Exception {
UriBuilder builder = UriBuilder.fromUri(new URI("news:comp.lang.java"));
try {
builder.uri("").build();
fail("IAE exception is expected");
} catch (IllegalArgumentException e) {
// expected
}
}
use of javax.ws.rs.core.UriBuilder in project cxf by apache.
the class UriBuilderImplTest method testResolveTemplateFromMap2.
@Test
public void testResolveTemplateFromMap2() {
String expected = "path-rootless%2Ftest2/x%25yz/%2Fpath-absolute%2F%2525test1/fred@example.com/x%25yz";
Map<String, Object> map = new HashMap<>();
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 uri = builder.resolveTemplates(map).build();
assertEquals(expected, uri.getRawPath());
}
use of javax.ws.rs.core.UriBuilder in project cxf by apache.
the class UriBuilderImplTest method testFromUriRelativePath.
@Test
public void testFromUriRelativePath() throws Exception {
UriBuilder builder = UriBuilder.fromUri("path");
URI uri = builder.queryParam("a", "b").build();
assertEquals("path?a=b", uri.toString());
}
use of javax.ws.rs.core.UriBuilder in project cxf by apache.
the class UriBuilderImplTest method testBuildFromEncodedMapMultipleTimes.
@Test
public void testBuildFromEncodedMapMultipleTimes() throws Exception {
Map<String, Object> maps = new HashMap<>();
maps.put("x", "x%yz");
maps.put("y", "/path-absolute/test1");
maps.put("z", "fred@example.com");
maps.put("w", "path-rootless/test2");
Map<String, Object> maps1 = new HashMap<>();
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, Object> maps2 = new HashMap<>();
maps2.put("x", "x%yz");
maps2.put("y", "/path-absolute/test1");
maps2.put("z", "fred@example.com");
maps2.put("w", "path-rootless/test2");
maps2.put("v", "xyz");
String expectedPath = "path-rootless/test2/x%25yz//path-absolute/test1/fred@example.com/x%25yz";
String expectedPath1 = "path-rootless/test2/x%20yz//path-absolute/test1/fred@example.com/x%20yz";
String expectedPath2 = "path-rootless/test2/x%25yz//path-absolute/test1/fred@example.com/x%25yz";
UriBuilder ub = UriBuilder.fromPath("").path("{w}/{x}/{y}/{z}/{x}");
URI uri = ub.buildFromEncodedMap(maps);
assertEquals(expectedPath, uri.getRawPath());
uri = ub.buildFromEncodedMap(maps1);
assertEquals(expectedPath1, uri.getRawPath());
uri = ub.buildFromEncodedMap(maps2);
assertEquals(expectedPath2, uri.getRawPath());
}
Aggregations