Search in sources :

Example 11 with UriInfo

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

the class UriRoutingContextTest method testGetQueryParametersEmpty.

/**
     * Migrated Jersey 1.x {@code com.sun.jersey.impl.QueryParametersHttpRequestTest}.
     */
@Test
public void testGetQueryParametersEmpty() 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 12 with UriInfo

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

the class UriRoutingContextTest method testGetQueryParametersDecoded.

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

Example 13 with UriInfo

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

the class UriRoutingContextTest method testGetQueryParametersMultipleEmptyValues.

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

Example 14 with UriInfo

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

the class UriRoutingContextTest method testGetQueryParametersGeneral.

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

Example 15 with UriInfo

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

the class UriRoutingContextTest method testGetPathSegmentsGeneral.

/**
     * Migrated Jersey 1.x {@code com.sun.jersey.impl.PathSegmentsHttpRequestTest}.
     */
@Test
public void testGetPathSegmentsGeneral() {
    final UriInfo ui = createContext("/p1;x=1;y=1/p2;x=2;y=2/p3;x=3;y=3", "GET");
    List<PathSegment> segments = ui.getPathSegments();
    assertEquals(3, segments.size());
    final Iterator<PathSegment> psi = segments.iterator();
    PathSegment segment;
    segment = psi.next();
    assertEquals("p1", segment.getPath());
    MultivaluedMap<String, String> m = segment.getMatrixParameters();
    assertEquals("1", m.getFirst("x"));
    assertEquals("1", m.getFirst("y"));
    segment = psi.next();
    assertEquals("p2", segment.getPath());
    m = segment.getMatrixParameters();
    assertEquals("2", m.getFirst("x"));
    assertEquals("2", m.getFirst("y"));
    segment = psi.next();
    assertEquals("p3", segment.getPath());
    m = segment.getMatrixParameters();
    assertEquals("3", m.getFirst("x"));
    assertEquals("3", m.getFirst("y"));
}
Also used : PathSegment(javax.ws.rs.core.PathSegment) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.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