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"));
}
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);
}
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"));
}
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), "");
}
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);
}
Aggregations