PagedRequestServletFilter implements Filter { @Override public void init(final FilterConfig config) throws ServletException { ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(config.getServletContext()); Environment environment = ctx.getEnvironment(); this.maxPaginationCount = environment.getProperty(MAX_PAGINATION_COUNT, Integer.class, DEFAULT_PAGINATION_COUNT); }  @Override void doFilter(final ServletRequest req, final ServletResponse response, final FilterChain chain); @Override void destroy(); @Override void init(final FilterConfig config); void setMaxPaginationCount(final Integer maxPaginationCount);  }
@Test public void testInit() throws Exception { when(config.getServletContext()).thenReturn(context); when(context.getAttribute(WebApplicationContext.class.getName() + ".ROOT")).thenReturn(webApplicationContext); when(webApplicationContext.getEnvironment()).thenReturn(env); when(env.getProperty(MAX_PAGINATION_COUNT, Integer.class, DEFAULT_PAGINATION_COUNT)).thenReturn(maxPaginationCount); unit.init(config); verify(config).getServletContext(); verify(context).getAttribute(WebApplicationContext.class.getName() + ".ROOT"); verify(webApplicationContext).getEnvironment(); verify(env).getProperty(MAX_PAGINATION_COUNT, Integer.class, DEFAULT_PAGINATION_COUNT); }