Search in sources :

Example 71 with UriInfo

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

the class UriRoutingContextTest method testGetQueryParametersMultipleAmpersand.

/**
     * Migrated Jersey 1.x {@code com.sun.jersey.impl.QueryParametersHttpRequestTest}.
     */
@Test
public void testGetQueryParametersMultipleAmpersand() throws Exception {
    final UriInfo ui = createContext("/widgets/10?&&%20=%20&&&", "GET");
    MultivaluedMap<String, String> p = ui.getQueryParameters();
    assertEquals(p.size(), 1);
}
Also used : UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Example 72 with UriInfo

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

the class UriRoutingContextTest method testGetQueryParametersSingleAmpersand.

/**
     * Migrated Jersey 1.x {@code com.sun.jersey.impl.QueryParametersHttpRequestTest}.
     */
@Test
public void testGetQueryParametersSingleAmpersand() throws Exception {
    final UriInfo ui = createContext("/widgets/10?&", "GET");
    MultivaluedMap<String, String> p = ui.getQueryParameters();
    assertEquals(p.size(), 0);
}
Also used : UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Example 73 with UriInfo

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

the class UriRoutingContextTest method testGetQueryParametersWhiteSpace.

/**
     * Migrated Jersey 1.x {@code com.sun.jersey.impl.QueryParametersHttpRequestTest}.
     */
@Test
public void testGetQueryParametersWhiteSpace() throws Exception {
    final UriInfo ui = createContext("/widgets/10?x+=+1%20&%20y+=+2", "GET");
    MultivaluedMap<String, String> p = ui.getQueryParameters();
    assertEquals(" 1 ", p.getFirst("x "));
    assertEquals(" 2", p.getFirst(" y "));
}
Also used : UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Example 74 with UriInfo

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

the class UriRoutingContextTest method testGetQueryParametersInterspersedAmpersand.

/**
     * Migrated Jersey 1.x {@code com.sun.jersey.impl.QueryParametersHttpRequestTest}.
     */
@Test
public void testGetQueryParametersInterspersedAmpersand() throws Exception {
    final UriInfo ui = createContext("/widgets/10?a=1&&b=2", "GET");
    MultivaluedMap<String, String> p = ui.getQueryParameters();
    assertEquals(p.size(), 2);
}
Also used : UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Example 75 with UriInfo

use of javax.ws.rs.core.UriInfo in project killbill by killbill.

the class TestBuildResponse method testUriBuilderWithoutPathLikeUrlAndNonRoot.

@Test(groups = "fast", description = "Tests Uri Builder with Full URL and non root Location")
public void testUriBuilderWithoutPathLikeUrlAndNonRoot() throws Exception {
    UUID objectId = UUID.randomUUID();
    final UriInfo uriInfo = mock(UriInfo.class);
    URI uri = URI.create("http://localhost:8080/killbill");
    when(uriInfo.getBaseUri()).thenReturn(uri);
    when(uriInfo.getAbsolutePath()).thenReturn(uri);
    JaxrsConfig jaxrsConfig = mock(JaxrsConfig.class);
    when(jaxrsConfig.isJaxrsLocationFullUrl()).thenReturn(true);
    JaxrsUriBuilder uriBuilder = new JaxrsUriBuilder(jaxrsConfig);
    Response response = uriBuilder.buildResponse(uriInfo, AccountResource.class, "getAccount", objectId, mockRequest(uriInfo));
    assertEquals(response.getStatus(), Status.CREATED.getStatusCode());
    assertEquals(response.getMetadata().get("Location").get(0).toString(), uri.toString() + "/1.0/kb/accounts/" + objectId.toString());
}
Also used : Response(javax.ws.rs.core.Response) UUID(java.util.UUID) JaxrsUriBuilder(org.killbill.billing.jaxrs.util.JaxrsUriBuilder) URI(java.net.URI) UriInfo(javax.ws.rs.core.UriInfo) JaxrsConfig(org.killbill.billing.util.config.definition.JaxrsConfig) Test(org.testng.annotations.Test)

Aggregations

UriInfo (javax.ws.rs.core.UriInfo)105 Response (javax.ws.rs.core.Response)50 Test (org.junit.Test)49 URI (java.net.URI)32 Test (org.testng.annotations.Test)21 Map (java.util.Map)15 MediaType (javax.ws.rs.core.MediaType)15 HttpServletRequest (javax.servlet.http.HttpServletRequest)12 GET (javax.ws.rs.GET)12 Path (javax.ws.rs.Path)12 Context (javax.ws.rs.core.Context)12 Request (org.apache.atlas.catalog.Request)12 ResourceProvider (org.apache.atlas.catalog.ResourceProvider)12 TaxonomyResourceProvider (org.apache.atlas.catalog.TaxonomyResourceProvider)12 MetadataService (org.apache.atlas.services.MetadataService)12 AtlasTypeDefStore (org.apache.atlas.store.AtlasTypeDefStore)12 PathParam (javax.ws.rs.PathParam)11 ArrayList (java.util.ArrayList)10 Api (io.swagger.annotations.Api)8 ApiOperation (io.swagger.annotations.ApiOperation)8