use of javax.ws.rs.core.UriBuilder in project jersey by jersey.
the class JerseyUriBuilderTest method shouldOnlyRemoveMatrixInFinalSegment.
// Reproducer for JERSEY-2537
@Test
public void shouldOnlyRemoveMatrixInFinalSegment() {
final UriBuilder builder = UriBuilder.fromPath("/apples;order=random;color=blue/2006/bar;zot=baz").replaceMatrix(null);
final URI result = builder.build();
assertEquals("/apples;order=random;color=blue/2006/bar", result.toString());
}
use of javax.ws.rs.core.UriBuilder in project jersey by jersey.
the class JerseyUriBuilderTest method shouldKeepTrailingSlash.
// Reproducer for JERSEY-2537
@Test
public void shouldKeepTrailingSlash() throws MalformedURLException, URISyntaxException {
final URL url = new URL("http://example.com/authentications;email=joe@joe.com/");
final UriBuilder builder = UriBuilder.fromPath(url.getPath()).replaceMatrix(null);
final URI result = builder.build();
assertEquals("/authentications/", result.toString());
}
use of javax.ws.rs.core.UriBuilder in project jersey by jersey.
the class JerseyUriBuilderTest method testReplaceQueryParamsEncoded2.
@Test
public void testReplaceQueryParamsEncoded2() throws URISyntaxException {
final UriBuilder ubu = UriBuilder.fromUri(new URI("http://localhost")).replaceQuery("limit=10&sql=select+*+from+users");
ubu.replaceQueryParam("limit", 100);
final URI uri = ubu.build();
Assert.assertEquals(URI.create("http://localhost/?limit=100&sql=select+%2A+from+users"), uri);
}
use of javax.ws.rs.core.UriBuilder in project jersey by jersey.
the class JerseyUriBuilderTest method resolveTemplateTest.
@Test
public void resolveTemplateTest() {
final UriBuilder uriBuilder = UriBuilder.fromPath("http://localhost:8080").path("{a}").path("{b}").queryParam("query", "{q}");
uriBuilder.resolveTemplate("a", "param-a");
uriBuilder.resolveTemplate("q", "param-q");
final Map<String, Object> m = new HashMap<String, Object>();
m.put("a", "ignored-a");
m.put("b", "param-b");
m.put("q", "ignored-q");
Assert.assertEquals(URI.create("http://localhost:8080/param-a/param-b?query=param-q"), uriBuilder.buildFromMap(m));
}
use of javax.ws.rs.core.UriBuilder in project jersey by jersey.
the class JerseyUriBuilderTest method resolveTemplateFromEncodedTest.
@Test
public void resolveTemplateFromEncodedTest() {
final UriBuilder uriBuilder = UriBuilder.fromPath("http://localhost:8080").path("{a}").path("{b}").path("{c}").queryParam("query", "{q}");
uriBuilder.resolveTemplateFromEncoded("a", "x/y/z%3F%20");
uriBuilder.resolveTemplateFromEncoded("q", "q?%20%26");
uriBuilder.resolveTemplate("c", "paramc1/paramc2");
final Map<String, Object> m = new HashMap<String, Object>();
m.put("a", "ignored-a");
m.put("b", "param-b/aaa");
m.put("q", "ignored-q");
Assert.assertEquals("http://localhost:8080/x/y/z%3F%20/param-b/aaa/paramc1%2Fparamc2?query=q%3F%20%26", uriBuilder.buildFromEncodedMap(m).toString());
}
Aggregations