use of javax.ws.rs.core.UriInfo in project graylog2-server by Graylog2.
the class WebAppNotFoundResponseFilterTest method filterDoesNotFilterApplicationJson.
@Test
public void filterDoesNotFilterApplicationJson() throws Exception {
final UriInfo uriInfo = mock(UriInfo.class);
final List<MediaType> mediaTypes = Collections.singletonList(MediaType.APPLICATION_JSON_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, never()).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 filterDoesNotFilterRestApiPrefix.
@Test
public void filterDoesNotFilterRestApiPrefix() throws Exception {
final UriInfo uriInfo = mock(UriInfo.class);
final List<MediaType> mediaTypes = Collections.singletonList(MediaType.TEXT_HTML_TYPE);
when(uriInfo.getAbsolutePath()).thenReturn(URI.create("/api/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, never()).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 filterDoesNotFilterPostRequests.
@Test
public void filterDoesNotFilterPostRequests() 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/nonexisting"));
when(requestContext.getMethod()).thenReturn(CK_METHOD_POST);
when(requestContext.getUriInfo()).thenReturn(uriInfo);
when(requestContext.getAcceptableMediaTypes()).thenReturn(mediaTypes);
when(responseContext.getStatusInfo()).thenReturn(Response.Status.NOT_FOUND);
filter.filter(requestContext, responseContext);
verify(responseContext, never()).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 filterDoesFilterCompatibleAcceptMimeTypes.
@Test
public void filterDoesFilterCompatibleAcceptMimeTypes() throws Exception {
final UriInfo uriInfo = mock(UriInfo.class);
final List<MediaType> mediaTypes = Collections.singletonList(MediaType.WILDCARD_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 filterDoesNotFilterResponseStatusOk.
@Test
public void filterDoesNotFilterResponseStatusOk() 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.OK);
filter.filter(requestContext, responseContext);
verify(responseContext, never()).setEntity("index.html", new Annotation[0], MediaType.TEXT_HTML_TYPE);
}
Aggregations