Search in sources :

Example 26 with UriBuilder

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

the class JerseyUriBuilderTest method resolveTemplatesTest.

@Test
public void resolveTemplatesTest() {
    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> buildMap = new HashMap<String, Object>();
    buildMap.put("a", "ignored-a");
    buildMap.put("b", "param-b");
    buildMap.put("q", "ignored-q");
    Assert.assertEquals(URI.create("http://localhost:8080/param-a/param-b?query=param-q"), uriBuilder.buildFromMap(buildMap));
}
Also used : HashMap(java.util.HashMap) UriBuilder(javax.ws.rs.core.UriBuilder) Test(org.junit.Test)

Example 27 with UriBuilder

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

the class JerseyUriBuilderTest method testQueryParamEncoded2.

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

Example 28 with UriBuilder

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

the class JerseyUriBuilderTest method resolveTemplateWithoutEncodedTest.

@Test
public void resolveTemplateWithoutEncodedTest() {
    final UriBuilder uriBuilder = UriBuilder.fromPath("http://localhost:8080").path("{a}").path("{b}").path("{c}").queryParam("query", "{q}");
    uriBuilder.resolveTemplate("a", "x/y/z%3F%20");
    uriBuilder.resolveTemplate("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%2Fy%2Fz%253F%2520/param-b%2Faaa/paramc1%2Fparamc2?query=q%3F%2520%2526", uriBuilder.buildFromMap(m).toString());
}
Also used : HashMap(java.util.HashMap) UriBuilder(javax.ws.rs.core.UriBuilder) Test(org.junit.Test)

Example 29 with UriBuilder

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

the class JerseyUriBuilderTest method testQueryParamEncoded.

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

Example 30 with UriBuilder

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

the class JerseyUriBuilderTest method testUriBuilderShouldLeaveRelativePathRelative.

// Reproducer for JERSEY-2753
@Test
public void testUriBuilderShouldLeaveRelativePathRelative() {
    final UriBuilder builder = JerseyUriBuilder.fromPath("");
    builder.scheme("http");
    builder.replacePath("path");
    assertEquals("http:path", builder.build().toString());
}
Also used : UriBuilder(javax.ws.rs.core.UriBuilder) Test(org.junit.Test)

Aggregations

UriBuilder (javax.ws.rs.core.UriBuilder)123 URI (java.net.URI)45 Test (org.junit.Test)42 HashMap (java.util.HashMap)15 Consumes (javax.ws.rs.Consumes)15 Link (org.eclipse.che.api.core.rest.shared.dto.Link)15 PUT (javax.ws.rs.PUT)11 IOException (java.io.IOException)10 Path (javax.ws.rs.Path)10 ArrayList (java.util.ArrayList)8 Produces (javax.ws.rs.Produces)8 LinksHelper.createLink (org.eclipse.che.api.core.util.LinksHelper.createLink)8 GET (javax.ws.rs.GET)7 URL (java.net.URL)6 ServerException (org.eclipse.che.api.core.ServerException)6 POST (javax.ws.rs.POST)5 ApiException (org.eclipse.che.api.core.ApiException)4 WorkspaceService (org.eclipse.che.api.workspace.server.WorkspaceService)4 ExternalTestContainerFactory (org.glassfish.jersey.test.external.ExternalTestContainerFactory)4 ExceptionMetered (com.codahale.metrics.annotation.ExceptionMetered)3