Search in sources :

Example 6 with UriInfo

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

the class UriRoutingContextTest method testGetPathSegmentsMultipleSlashmulitpleMatrix.

/**
     * Migrated Jersey 1.x {@code com.sun.jersey.impl.PathSegmentsHttpRequestTest}.
     */
@Test
public void testGetPathSegmentsMultipleSlashmulitpleMatrix() {
    final UriInfo ui = createContext("/;x=1;y=1/;x=2;y=2/;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();
    MultivaluedMap<String, String> m = segment.getMatrixParameters();
    assertEquals("1", m.getFirst("x"));
    assertEquals("1", m.getFirst("y"));
    segment = psi.next();
    m = segment.getMatrixParameters();
    assertEquals("2", m.getFirst("x"));
    assertEquals("2", m.getFirst("y"));
    segment = psi.next();
    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)

Example 7 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 8 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 9 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 10 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)

Aggregations

UriInfo (javax.ws.rs.core.UriInfo)86 Response (javax.ws.rs.core.Response)44 Test (org.junit.Test)43 URI (java.net.URI)31 Test (org.testng.annotations.Test)21 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 HttpServletRequest (javax.servlet.http.HttpServletRequest)11 ArrayList (java.util.ArrayList)10 Map (java.util.Map)10 MediaType (javax.ws.rs.core.MediaType)10 Api (io.swagger.annotations.Api)8 ApiOperation (io.swagger.annotations.ApiOperation)8 ApiParam (io.swagger.annotations.ApiParam)8 ApiResponse (io.swagger.annotations.ApiResponse)8 ApiResponses (io.swagger.annotations.ApiResponses)8 InputStream (java.io.InputStream)8