Search in sources :

Example 36 with UriBuilder

use of javax.ws.rs.core.UriBuilder in project jersey by jersey.

the class JerseyUriBuilderTest method shouldLeaveURIUntouched.

// Reproducer for JERSEY-2537
@Test
public void shouldLeaveURIUntouched() {
    final UriBuilder builder = UriBuilder.fromPath("/apples;order=random;color=blue/2006").replaceMatrix(null);
    final URI result = builder.build();
    assertEquals("/apples;order=random;color=blue/2006", result.toString());
}
Also used : UriBuilder(javax.ws.rs.core.UriBuilder) URI(java.net.URI) Test(org.junit.Test)

Example 37 with UriBuilder

use of javax.ws.rs.core.UriBuilder in project jersey by jersey.

the class JerseyUriBuilderTest method resolveTemplatesFromNotEncodedTest.

@Test
public void resolveTemplatesFromNotEncodedTest() {
    final UriBuilder uriBuilder = UriBuilder.fromPath("http://localhost:8080").path("{a}").path("{b}").path("{c}").queryParam("query", "{q}");
    final Map<String, Object> resolveMap = new HashMap<String, Object>();
    resolveMap.put("a", "x/y/z%3F%20");
    resolveMap.put("q", "q?%20%26");
    resolveMap.put("c", "paramc1/paramc2");
    uriBuilder.resolveTemplates(resolveMap);
    final Map<String, Object> buildMap = new HashMap<String, Object>();
    buildMap.put("b", "param-b/aaa");
    Assert.assertEquals("http://localhost:8080/x%2Fy%2Fz%253F%2520/param-b%2Faaa/paramc1%2Fparamc2?query=q%3F%2520%2526", uriBuilder.buildFromMap(buildMap).toString());
}
Also used : HashMap(java.util.HashMap) UriBuilder(javax.ws.rs.core.UriBuilder) Test(org.junit.Test)

Example 38 with UriBuilder

use of javax.ws.rs.core.UriBuilder in project jersey by jersey.

the class JerseyUriBuilderTest method testQueryParamEncoded4.

@Test
public void testQueryParamEncoded4() {
    final UriBuilder uriBuilder = UriBuilder.fromUri("http://localhost:8080/path");
    uriBuilder.queryParam("query", "{param}");
    Assert.assertEquals("http://localhost:8080/path?query=%25test", uriBuilder.buildFromEncoded("%25test").toString());
}
Also used : UriBuilder(javax.ws.rs.core.UriBuilder) Test(org.junit.Test)

Example 39 with UriBuilder

use of javax.ws.rs.core.UriBuilder in project jersey by jersey.

the class JerseyUriBuilderTest method testReplaceQueryParamsEncoded1.

@Test
public void testReplaceQueryParamsEncoded1() 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);
}
Also used : UriBuilder(javax.ws.rs.core.UriBuilder) URI(java.net.URI) Test(org.junit.Test)

Example 40 with UriBuilder

use of javax.ws.rs.core.UriBuilder in project jersey by jersey.

the class JerseyUriBuilderTest method testReplaceMatrixParamWithNull.

@Test
public void testReplaceMatrixParamWithNull() {
    final UriBuilder builder = new JerseyUriBuilder().matrixParam("matrix", "param1", "param2");
    builder.replaceMatrixParam("matrix", (Object[]) null);
    assertEquals(builder.build().toString(), "");
}
Also used : UriBuilder(javax.ws.rs.core.UriBuilder) Test(org.junit.Test)

Aggregations

UriBuilder (javax.ws.rs.core.UriBuilder)167 URI (java.net.URI)78 Test (org.junit.Test)58 HashMap (java.util.HashMap)21 Consumes (javax.ws.rs.Consumes)15 Link (org.eclipse.che.api.core.rest.shared.dto.Link)15 IOException (java.io.IOException)12 Path (javax.ws.rs.Path)12 PUT (javax.ws.rs.PUT)11 Produces (javax.ws.rs.Produces)9 URL (java.net.URL)8 ArrayList (java.util.ArrayList)8 GET (javax.ws.rs.GET)8 LinksHelper.createLink (org.eclipse.che.api.core.util.LinksHelper.createLink)8 Timed (com.codahale.metrics.annotation.Timed)7 POST (javax.ws.rs.POST)7 Map (java.util.Map)6 Response (javax.ws.rs.core.Response)6 ServerException (org.eclipse.che.api.core.ServerException)6 List (java.util.List)5