use of javax.ws.rs.core.UriBuilder in project jersey by jersey.
the class JerseyUriBuilderTest method resolveTemplateWithEncodedSlashTest.
@Test
public void resolveTemplateWithEncodedSlashTest() {
final UriBuilder uriBuilder = UriBuilder.fromPath("http://localhost:8080").path("{a}").path("{b}").queryParam("query", "{q}");
uriBuilder.resolveTemplate("a", "param-a/withSlash", false);
uriBuilder.resolveTemplate("b", "param-b/withEncodedSlash", true);
uriBuilder.resolveTemplate("q", "param-q", true);
Assert.assertEquals(URI.create("http://localhost:8080/param-a/withSlash/param-b%2FwithEncodedSlash?query=param-q"), uriBuilder.build());
uriBuilder.build();
}
use of javax.ws.rs.core.UriBuilder in project jersey by jersey.
the class JerseyUriBuilderTest method testMatrixParamsWithTheSameName.
@Test
public void testMatrixParamsWithTheSameName() {
UriBuilder first = UriBuilder.fromUri("http://www.com/").replaceMatrixParam("example", "one", "two");
first = first.path("/child");
first = first.replaceMatrixParam("example", "another");
Assert.assertEquals("http://www.com/;example=one;example=two/child;example=another", first.build().toString());
}
use of javax.ws.rs.core.UriBuilder in project jersey by jersey.
the class JerseyUriBuilderTest method shouldOnlyRemoveMatrixInFinalSegmentAndKeepSlash.
// Reproducer for JERSEY-2537
@Test
public void shouldOnlyRemoveMatrixInFinalSegmentAndKeepSlash() {
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 JerseyWebTargetTest method testGetUriBuilder.
@Test
public void testGetUriBuilder() {
final Map<String, Object> params = new HashMap<String, Object>(2);
params.put("a", "w1");
UriBuilder uriBuilder = target.path("{a}").resolveTemplate("a", "v1").resolveTemplates(params).getUriBuilder();
assertEquals("/v1", uriBuilder.build().toString());
}
use of javax.ws.rs.core.UriBuilder in project jersey by jersey.
the class JerseyUriBuilderTest method testMatrixParamsWithTheDifferentName.
@Test
public void testMatrixParamsWithTheDifferentName() {
UriBuilder first = UriBuilder.fromUri("http://www.com/").replaceMatrixParam("example", "one", "two");
first = first.path("/child");
first = first.replaceMatrixParam("other", "another");
Assert.assertEquals("http://www.com/;example=one;example=two/child;other=another", first.build().toString());
}
Aggregations