Search in sources :

Example 91 with UriBuilder

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

the class JerseyUriBuilderTest method testBuildFromArrayNoSlashInUri.

// regression test for JERSEY-1114
@Test
public void testBuildFromArrayNoSlashInUri() {
    final UriBuilder builder = new JerseyUriBuilder().uri(URI.create("http://localhost:8080")).path("test");
    assertEquals("http://localhost:8080/test", builder.build("testing").toString());
}
Also used : UriBuilder(javax.ws.rs.core.UriBuilder) Test(org.junit.Test)

Example 92 with UriBuilder

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

the class JerseyUriBuilderTest method testBuildNoSlashUri.

// for completeness (added along with regression tests for JERSEY-1114)
@Test
public void testBuildNoSlashUri() {
    final UriBuilder builder = new JerseyUriBuilder().uri(URI.create("http://localhost:8080")).path("test");
    assertEquals("http://localhost:8080/test", builder.build().toString());
}
Also used : UriBuilder(javax.ws.rs.core.UriBuilder) Test(org.junit.Test)

Example 93 with UriBuilder

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

the class JerseyUriBuilderTest method shouldLeaveURIUntouchedAndKeepSlash.

// Reproducer for JERSEY-2537
@Test
public void shouldLeaveURIUntouchedAndKeepSlash() {
    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 94 with UriBuilder

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

the class JerseyUriBuilderTest method testBuildFromMapNoSlashInUri.

// regression test for JERSEY-1114
@Test
public void testBuildFromMapNoSlashInUri() {
    final UriBuilder builder = new JerseyUriBuilder().uri(URI.create("http://localhost:8080")).path("test");
    assertEquals("http://localhost:8080/test", builder.buildFromMap(new HashMap<String, Object>()).toString());
}
Also used : UriBuilder(javax.ws.rs.core.UriBuilder) Test(org.junit.Test)

Example 95 with UriBuilder

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

the class JerseyUriBuilderTest method resolveTemplateMultipleCall.

@Test
public void resolveTemplateMultipleCall() {
    final UriBuilder uriBuilder = UriBuilder.fromPath("http://localhost:8080").path("{start}").path("{a}").resolveTemplate("a", "first-a").path("{a}").resolveTemplate("a", "second-a").path("{a}/{a}").resolveTemplate("a", "twice-a");
    Assert.assertEquals(URI.create("http://localhost:8080/start-path/first-a/second-a/twice-a/twice-a"), uriBuilder.build("start-path"));
}
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