CheckRefererFilter implements Filter, InitializingBean { public void init( FilterConfig filterConfig ) throws ServletException { String pfx = filterConfig.getInitParameter( "refererPrefix" ); String redirect = filterConfig.getInitParameter( "redirectTo" ); if ( !( StringUtils.isBlank( pfx ) ) ) { this.setRefererPrefix( pfx ); } if ( !( StringUtils.isBlank( redirect ) ) ) { this.setRedirectTo( redirect ); } if ( !checked ) { try { afterPropertiesSet(); } catch ( Exception e ) { throw new ServletException( e ); } } }  void afterPropertiesSet(); void setRefererPrefix( String value ); void setRedirectTo( String value ); void doFilter( ServletRequest request, ServletResponse response, FilterChain chain ); void destroy(); void init( FilterConfig filterConfig );  }
@Test(expected = ServletException.class) public void blankReferrerPrefixCausesException() throws Exception { MockFilterConfig cfg = new MockFilterConfig(); cfg.addInitParameter( "refererPrefix", "" ); cfg.addInitParameter( "redirectTo", "qwerty" ); CheckRefererFilter filter = new CheckRefererFilter(); filter.init( cfg ); }
@Test(expected = ServletException.class) public void blankRedirectToCausesException() throws Exception { MockFilterConfig cfg = new MockFilterConfig(); cfg.addInitParameter( "refererPrefix", "qwerty" ); cfg.addInitParameter( "redirectTo", "" ); CheckRefererFilter filter = new CheckRefererFilter(); filter.init( cfg ); }