Search in sources :

Example 96 with UriBuilder

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();
}
Also used : UriBuilder(javax.ws.rs.core.UriBuilder) Test(org.junit.Test)

Example 97 with UriBuilder

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());
}
Also used : UriBuilder(javax.ws.rs.core.UriBuilder) Test(org.junit.Test)

Example 98 with UriBuilder

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

Example 99 with UriBuilder

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());
}
Also used : HashMap(java.util.HashMap) JerseyUriBuilder(org.glassfish.jersey.uri.internal.JerseyUriBuilder) UriBuilder(javax.ws.rs.core.UriBuilder) Test(org.junit.Test)

Example 100 with UriBuilder

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());
}
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