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"));
}
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 pulsar by yahoo.
the class HttpDestinationLookupv2Test method testNotEnoughLookupPermits.
@Test
public void testNotEnoughLookupPermits() throws Exception {
BrokerService brokerService = pulsar.getBrokerService();
doReturn(new Semaphore(0)).when(brokerService).getLookupRequestSemaphore();
DestinationLookup destLookup = spy(new DestinationLookup());
doReturn(false).when(destLookup).isRequestHttps();
destLookup.setPulsar(pulsar);
doReturn("null").when(destLookup).clientAppId();
Field uriField = PulsarWebResource.class.getDeclaredField("uri");
uriField.setAccessible(true);
UriInfo uriInfo = mock(UriInfo.class);
uriField.set(destLookup, uriInfo);
URI uri = URI.create("http://localhost:8080/lookup/v2/destination/topic/myprop/usc/ns2/topic1");
doReturn(uri).when(uriInfo).getRequestUri();
doReturn(true).when(config).isAuthorizationEnabled();
AsyncResponse asyncResponse1 = mock(AsyncResponse.class);
destLookup.lookupDestinationAsync("myprop", "usc", "ns2", "topic1", false, asyncResponse1);
ArgumentCaptor<Throwable> arg = ArgumentCaptor.forClass(Throwable.class);
verify(asyncResponse1).resume(arg.capture());
assertEquals(arg.getValue().getClass(), WebApplicationException.class);
WebApplicationException wae = (WebApplicationException) arg.getValue();
assertEquals(wae.getResponse().getStatus(), Status.SERVICE_UNAVAILABLE.getStatusCode());
}
Aggregations