@Override public void filter(ContainerRequestContext requestContext) throws IOException { try { underlying.filter(requestContext); } catch (WebApplicationException err) { // Pass through. } } }
final long filterTimestamp = tracingLogger.timestamp(filterEvent); try { filter.filter(request); } catch (Exception exception) { throw new MappableException(exception);
final long filterTimestamp = tracingLogger.timestamp(filterEvent); try { filter.filter(request); } catch (Exception exception) { throw new MappableException(exception);
@Override public void filter(ContainerRequestContext requestContext) throws IOException { try { underlying.filter(requestContext); } catch (WebApplicationException err) { // Pass through. } } }
final long filterTimestamp = tracingLogger.timestamp(filterEvent); try { filter.filter(request); } catch (Exception exception) { throw new MappableException(exception);
private void runRequestFilters(final MinijaxRequestContext context) throws IOException { for (final Class<? extends ContainerRequestFilter> filterClass : requestFilters) { final ContainerRequestFilter filter = getResource(filterClass); filter.filter(context); } }
inFilter = true; final long timestamp = tracingLogger.timestamp("REQUEST_FILTER"); filter.filter(this); tracingLogger.logDuration("REQUEST_FILTER", timestamp, filter);
public void filter(ContainerRequestContext requestContext) throws IOException { getDelegate().filter(requestContext); } }
public void filter(ContainerRequestContext requestContext) throws IOException { getDelegate().filter(requestContext); } }
@Test public void filter_NullAppConfigGiven_ShouldNotUpdateBaseUri() throws IOException { ContainerRequestContext reqContext = mockRequestContext(EXISTING_BASE_URI, REQUEST_URI); createApplicationPathFilter(null).filter(reqContext); verify(reqContext, never()).setRequestUri(any(), any()); verify(reqContext, never()).setRequestUri(any()); }
@Test public void filter_NoAppPathGiven_ShouldNotUpdateBaseUri() throws IOException { ContainerRequestContext reqContext = mockRequestContext(EXISTING_BASE_URI, REQUEST_URI); createApplicationPathFilter(new ApplicationWithoutPath()).filter(reqContext); verify(reqContext, never()).setRequestUri(any(), any()); verify(reqContext, never()).setRequestUri(any()); }
@Test public void filter_EmptyAppPathGiven_ShouldNotUpdateBaseUri() throws IOException { ContainerRequestContext reqContext = mockRequestContext(EXISTING_BASE_URI, REQUEST_URI); createApplicationPathFilter(new ApplicationPathEmpty()).filter(reqContext); verify(reqContext, never()).setRequestUri(any(), any()); verify(reqContext, never()).setRequestUri(any()); }
@Test public void filter_NoAppPathRootGiven_ShouldNotUpdateBaseUri() throws IOException { ContainerRequestContext reqContext = mockRequestContext(EXISTING_BASE_URI, REQUEST_URI); createApplicationPathFilter(new ApplicationPathRoot()).filter(reqContext); verify(reqContext, never()).setRequestUri(any(), any()); verify(reqContext, never()).setRequestUri(any()); }
@Test public void filter_AppPathWithMultiplePathsGiven_ShouldUpdateBaseUriWithAllPaths() throws IOException { ContainerRequestContext reqContext = mockRequestContext(EXISTING_BASE_URI, REQUEST_URI); createApplicationPathFilter(new ApplicationPath1AndPath2()).filter(reqContext); verify(reqContext, times(1)).setRequestUri(URI.create("existing-base-uri/path1/path2/"), REQUEST_URI); verify(reqContext, never()).setRequestUri(any()); }
@Test public void filter_AppPathWithSlashAsteriskGiven_ShouldUpdateBaseUriWithoutSlashesAsterisk() throws IOException { ContainerRequestContext reqContext = mockRequestContext(EXISTING_BASE_URI, REQUEST_URI); createApplicationPathFilter(new ApplicationPathTestSlashAsterisk()).filter(reqContext); verify(reqContext, times(1)).setRequestUri(TEST_UPDATED_BASE_URI, REQUEST_URI); verify(reqContext, never()).setRequestUri(any()); }
@Test public void filter_AppPathWithSlashGiven_ShouldUpdateBaseUriWithoutSlashes() throws IOException { ContainerRequestContext reqContext = mockRequestContext(EXISTING_BASE_URI, REQUEST_URI); createApplicationPathFilter(new ApplicationPathTestWithLeadingAndTrailingSlashes()).filter(reqContext); verify(reqContext, times(1)).setRequestUri(TEST_UPDATED_BASE_URI, REQUEST_URI); verify(reqContext, never()).setRequestUri(any()); }
@Test public void filter_AppPathGiven_ShouldUpdateBaseUri() throws IOException { ContainerRequestContext reqContext = mockRequestContext(EXISTING_BASE_URI, REQUEST_URI); createApplicationPathFilter(new ApplicationPathTest()).filter(reqContext); verify(reqContext, times(1)).setRequestUri(TEST_UPDATED_BASE_URI, REQUEST_URI); verify(reqContext, never()).setRequestUri(any()); }
@Test public void filter_NoAppPathGiven_ShouldAccessRequestContext() throws IOException { createApplicationPathFilter(new ApplicationWithoutPath()).filter(null); }
public static boolean runContainerRequestFilters(ServerProviderFactory pf, Message m, boolean preMatch, Set<String> names) throws IOException { List<ProviderInfo<ContainerRequestFilter>> containerFilters = preMatch ? pf.getPreMatchContainerRequestFilters() : pf.getPostMatchContainerRequestFilters(names); if (!containerFilters.isEmpty()) { ContainerRequestContext context = new ContainerRequestContextImpl(m, preMatch, false); for (ProviderInfo<ContainerRequestFilter> filter : containerFilters) { InjectionUtils.injectContexts(filter.getProvider(), filter, m); filter.getProvider().filter(context); Response response = m.getExchange().get(Response.class); if (response != null) { setMessageContentType(m, response); return true; } } } return false; }
@Test public void filter_AppPathGiven_ShouldAccessRequestContext() throws IOException { assertThrows(NullPointerException.class, () -> createApplicationPathFilter(new ApplicationPathTest()).filter(null)); }