use of javax.ws.rs.core.UriBuilder in project cxf by apache.
the class UriBuilderImplTest method testURIWithNonIntegerPort.
@Test
public void testURIWithNonIntegerPort() {
String url = "myscheme://not.really.a.host:port/";
UriBuilder builder = UriBuilder.fromUri(url);
URI uri = builder.build();
assertEquals(url, uri.toString());
}
use of javax.ws.rs.core.UriBuilder in project cxf by apache.
the class UriBuilderImplTest method testResolveTemplateFromEncodedMap.
@Test
public void testResolveTemplateFromEncodedMap() {
String expected = "path-rootless%2Ftest2/x%25yz/%2Fpath-absolute%2F%2525test1/fred@example.com/x%25yz";
Map<String, Object> map = new HashMap<>();
map.put("v", new StringBuilder("path-rootless%2Ftest2"));
map.put("w", new StringBuilder("x%yz"));
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 uri = builder.build();
assertEquals(expected, uri.getRawPath());
}
use of javax.ws.rs.core.UriBuilder in project cxf by apache.
the class UriBuilderImplTest method testResolveTemplatesMapBooleanSlashNotEncoded.
@Test
public void testResolveTemplatesMapBooleanSlashNotEncoded() throws Exception {
String expected = "path-rootless/test2/x%25yz//path-absolute/test1/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/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 uri = builder.resolveTemplates(map, false).build();
assertEquals(expected, uri.getRawPath());
}
use of javax.ws.rs.core.UriBuilder in project cxf by apache.
the class UriBuilderImplTest method testBuildWithNonEncodedSubstitutionValue4.
@Test
public void testBuildWithNonEncodedSubstitutionValue4() {
UriBuilder ub = UriBuilder.fromPath("/");
URI uri = ub.path("{a}").build("%");
assertEquals("/%25", uri.toString());
uri = ub.path("{token}").build("%", "{}");
assertEquals("/%25/%7B%7D", uri.toString());
}
use of javax.ws.rs.core.UriBuilder in project cxf by apache.
the class UriBuilderImplTest method testUriTemplate.
@Test
public void testUriTemplate() throws Exception {
UriBuilder builder = UriBuilder.fromUri("http://localhost:8080/{a}/{b}");
URI uri = builder.build("1", "2");
assertEquals("http://localhost:8080/1/2", uri.toString());
}
Aggregations