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());
}
use of javax.ws.rs.core.UriInfo in project neo4j by neo4j.
the class DiscoveryServiceTest method uriInfo.
private UriInfo uriInfo(String host) {
URI uri = URI.create(host);
UriInfo uriInfo = mock(UriInfo.class);
when(uriInfo.getBaseUri()).thenReturn(uri);
return uriInfo;
}
use of javax.ws.rs.core.UriInfo in project graylog2-server by Graylog2.
the class WebAppNotFoundResponseFilterTest method filterDoesFilterApplicationXhtml.
@Test
public void filterDoesFilterApplicationXhtml() throws Exception {
final UriInfo uriInfo = mock(UriInfo.class);
final List<MediaType> mediaTypes = Collections.singletonList(MediaType.APPLICATION_XHTML_XML_TYPE);
when(uriInfo.getAbsolutePath()).thenReturn(URI.create("/web/search"));
when(requestContext.getMethod()).thenReturn(CK_METHOD_GET);
when(requestContext.getUriInfo()).thenReturn(uriInfo);
when(requestContext.getAcceptableMediaTypes()).thenReturn(mediaTypes);
when(responseContext.getStatusInfo()).thenReturn(Response.Status.NOT_FOUND);
filter.filter(requestContext, responseContext);
verify(responseContext, times(1)).setEntity("index.html", new Annotation[0], MediaType.TEXT_HTML_TYPE);
}
use of javax.ws.rs.core.UriInfo in project graylog2-server by Graylog2.
the class WebAppNotFoundResponseFilterTest method filterDoesFilterTextHtml.
@Test
public void filterDoesFilterTextHtml() throws Exception {
final UriInfo uriInfo = mock(UriInfo.class);
final List<MediaType> mediaTypes = Collections.singletonList(MediaType.TEXT_HTML_TYPE);
when(uriInfo.getAbsolutePath()).thenReturn(URI.create("/web/search"));
when(requestContext.getMethod()).thenReturn(CK_METHOD_GET);
when(requestContext.getUriInfo()).thenReturn(uriInfo);
when(requestContext.getAcceptableMediaTypes()).thenReturn(mediaTypes);
when(responseContext.getStatusInfo()).thenReturn(Response.Status.NOT_FOUND);
filter.filter(requestContext, responseContext);
verify(responseContext, times(1)).setEntity("index.html", new Annotation[0], MediaType.TEXT_HTML_TYPE);
}
use of javax.ws.rs.core.UriInfo in project graylog2-server by Graylog2.
the class WebAppNotFoundResponseFilterTest method filterAddsUserAgentResponseHeader.
@Test
public void filterAddsUserAgentResponseHeader() throws Exception {
final UriInfo uriInfo = mock(UriInfo.class);
final List<MediaType> mediaTypes = Collections.singletonList(MediaType.TEXT_HTML_TYPE);
when(uriInfo.getAbsolutePath()).thenReturn(URI.create("/web/search"));
when(requestContext.getMethod()).thenReturn(CK_METHOD_GET);
when(requestContext.getUriInfo()).thenReturn(uriInfo);
when(requestContext.getAcceptableMediaTypes()).thenReturn(mediaTypes);
when(responseContext.getStatusInfo()).thenReturn(Response.Status.NOT_FOUND);
filter.filter(requestContext, responseContext);
assertThat(responseHeaders).containsEntry("X-UA-Compatible", Collections.singletonList("IE=edge"));
}
Aggregations