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