test_class.declarator: checker = mock(DiskSpaceChecker.class)
test_class.modifier: private final
test_class.original_string: private final DiskSpaceChecker checker = mock(DiskSpaceChecker.class);
test_class.type: DiskSpaceChecker
test_class.var_name: checker
test_class.declarator: proxyConfig = mock(ProxyConfiguration.class)
test_class.modifier: private final
test_class.original_string: private final ProxyConfiguration proxyConfig = mock(ProxyConfiguration.class);
test_class.type: ProxyConfiguration
test_class.var_name: proxyConfig
test_class.declarator: checkUrls = Arrays.asList("/solr/update", "/solr/.*/update", "POST /solr/postUpdate")
test_class.modifier: private final
test_class.original_string: private final List<String> checkUrls = Arrays.asList("/solr/update", "/solr/.*/update", "POST /solr/postUpdate");
test_class.type: List<String>
test_class.var_name: checkUrls
test_class.declarator: localPaths = new String[]{ "/set" }
test_class.modifier: private final
test_class.original_string: private final String[] localPaths = new String[]{ "/set" };
test_class.type: String[]
test_class.var_name: localPaths
test_class.declarator: errorCode = 500
test_class.modifier: private final
test_class.original_string: private final int errorCode = 500;
test_class.type: int
test_class.var_name: errorCode
test_class.declarator: filter
test_class.modifier: private
test_class.original_string: private DiskSpaceFilter filter;
test_class.type: DiskSpaceFilter
test_class.var_name: filter
test_class.file: harahachibu/src/test/java/uk/co/flax/harahachibu/servlets/DiskSpaceFilterTest.java
test_class.identifier: DiskSpaceFilterTest
test_case.body: @Test
  	public void proxyWhenStateCheckPasses() throws Exception {
  		when(checker.isSpaceAvailable()).thenReturn(true);
  
  		final String requestUri = "/solr/banana/update";
  		final String requestQuery = "q=test";
  		final String proxiedUri = DiskSpaceProxyServlet.PROXY_PATH_PREFIX + requestUri + "?" + requestQuery;
  
  		final RequestDispatcher dispatcher = mock(RequestDispatcher.class);
  		final HttpServletRequest req = mock(HttpServletRequest.class);
  		when(req.getRequestURI()).thenReturn(requestUri);
  		when(req.getContextPath()).thenReturn("");
  		when(req.getQueryString()).thenReturn(requestQuery);
  		when(req.getRequestDispatcher(proxiedUri)).thenReturn(dispatcher);
  
  		final ServletResponse response = mock(ServletResponse.class);
  		final FilterChain chain = mock(FilterChain.class);
  
  		filter.doFilter(req, response, chain);
  
  		verify(req, atLeastOnce()).getRequestURI();
  		verify(req, atLeastOnce()).getQueryString();
  		verify(req).getRequestDispatcher(proxiedUri);
  		verify(dispatcher).forward(req, response);
  		verify(checker).isSpaceAvailable();
  	}
test_case.class_method_signature: DiskSpaceFilterTest.proxyWhenStateCheckPasses()
test_case.full_signature: @Test public void proxyWhenStateCheckPasses()
test_case.identifier: proxyWhenStateCheckPasses
test_case.invocations: thenReturn when isSpaceAvailable mock mock thenReturn when getRequestURI thenReturn when getContextPath thenReturn when getQueryString thenReturn when getRequestDispatcher mock mock doFilter getRequestURI verify atLeastOnce getQueryString verify atLeastOnce getRequestDispatcher verify forward verify isSpaceAvailable verify
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void proxyWhenStateCheckPasses()
focal_class.declarator: LOGGER = LoggerFactory.getLogger(DiskSpaceFilter.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOGGER = LoggerFactory.getLogger(DiskSpaceFilter.class);
focal_class.type: Logger
focal_class.var_name: LOGGER
focal_class.declarator: spaceChecker
focal_class.modifier: private final
focal_class.original_string: private final DiskSpaceChecker spaceChecker;
focal_class.type: DiskSpaceChecker
focal_class.var_name: spaceChecker
focal_class.declarator: proxyConfiguration
focal_class.modifier: private final
focal_class.original_string: private final ProxyConfiguration proxyConfiguration;
focal_class.type: ProxyConfiguration
focal_class.var_name: proxyConfiguration
focal_class.declarator: localPaths
focal_class.modifier: private final
focal_class.original_string: private final String[] localPaths;
focal_class.type: String[]
focal_class.var_name: localPaths
focal_class.file: harahachibu/src/main/java/uk/co/flax/harahachibu/servlets/DiskSpaceFilter.java
focal_class.identifier: DiskSpaceFilter
focal_class.interfaces: implements Filter
focal_class.class_method_signature: DiskSpaceFilter.DiskSpaceFilter(DiskSpaceChecker spaceChecker, ProxyConfiguration proxyConfiguration, String... localPaths)
focal_class.full_signature: public  DiskSpaceFilter(DiskSpaceChecker spaceChecker, ProxyConfiguration proxyConfiguration, String... localPaths)
focal_class.identifier: DiskSpaceFilter
focal_class.modifiers: public
focal_class.parameters: (DiskSpaceChecker spaceChecker, ProxyConfiguration proxyConfiguration, String... localPaths)
focal_class.signature:  DiskSpaceFilter(DiskSpaceChecker spaceChecker, ProxyConfiguration proxyConfiguration, String... localPaths)
focal_class.class_method_signature: DiskSpaceFilter.init(FilterConfig filterConfig)
focal_class.full_signature: @Override public void init(FilterConfig filterConfig)
focal_class.identifier: init
focal_class.modifiers: @Override public
focal_class.parameters: (FilterConfig filterConfig)
focal_class.return: void
focal_class.signature: void init(FilterConfig filterConfig)
focal_class.class_method_signature: DiskSpaceFilter.doFilter(ServletRequest request, ServletResponse response,
  						 FilterChain chain)
focal_class.full_signature: @Override public void doFilter(ServletRequest request, ServletResponse response,
  						 FilterChain chain)
focal_class.identifier: doFilter
focal_class.modifiers: @Override public
focal_class.parameters: (ServletRequest request, ServletResponse response,
  						 FilterChain chain)
focal_class.return: void
focal_class.signature: void doFilter(ServletRequest request, ServletResponse response,
  						 FilterChain chain)
focal_class.class_method_signature: DiskSpaceFilter.isUriInLocalPaths(HttpServletRequest request)
focal_class.full_signature: private boolean isUriInLocalPaths(HttpServletRequest request)
focal_class.identifier: isUriInLocalPaths
focal_class.modifiers: private
focal_class.parameters: (HttpServletRequest request)
focal_class.return: boolean
focal_class.signature: boolean isUriInLocalPaths(HttpServletRequest request)
focal_class.class_method_signature: DiskSpaceFilter.isUriInCheckPaths(HttpServletRequest request)
focal_class.full_signature: private boolean isUriInCheckPaths(HttpServletRequest request)
focal_class.identifier: isUriInCheckPaths
focal_class.modifiers: private
focal_class.parameters: (HttpServletRequest request)
focal_class.return: boolean
focal_class.signature: boolean isUriInCheckPaths(HttpServletRequest request)
focal_class.class_method_signature: DiskSpaceFilter.getProxyPath(HttpServletRequest request)
focal_class.full_signature: private String getProxyPath(HttpServletRequest request)
focal_class.identifier: getProxyPath
focal_class.modifiers: private
focal_class.parameters: (HttpServletRequest request)
focal_class.return: String
focal_class.signature: String getProxyPath(HttpServletRequest request)
focal_class.class_method_signature: DiskSpaceFilter.destroy()
focal_class.full_signature: @Override public void destroy()
focal_class.identifier: destroy
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void destroy()
focal_method.body: @Override
  	public void doFilter(ServletRequest request, ServletResponse response,
  						 FilterChain chain) throws IOException, ServletException {
  		final HttpServletRequest httpRequest = (HttpServletRequest) request;
  
  		if (isUriInLocalPaths(httpRequest)) {
  			// Ignore and pass through
  			LOGGER.debug("Passing through request for {}", httpRequest.getRequestURI());
  			chain.doFilter(request, response);
  		} else {
  			if (isUriInCheckPaths(httpRequest)) {
  				// Check the server state
  				try {
  					if (!spaceChecker.isSpaceAvailable()) {
  						((HttpServletResponse) response).sendError(proxyConfiguration.getErrorStatus());
  					}
  				} catch (DiskSpaceCheckerException e) {
  					LOGGER.error("Exception thrown by DiskSpaceChecker", e);
  					((HttpServletResponse) response).sendError(proxyConfiguration.getErrorStatus());
  				}
  			}
  
  			if (!response.isCommitted()) {
  				// Forward to proxy location
  				RequestDispatcher dispatcher = httpRequest.getRequestDispatcher(getProxyPath(httpRequest));
  				dispatcher.forward(request, response);
  			}
  		}
  	}
focal_method.class_method_signature: DiskSpaceFilter.doFilter(ServletRequest request, ServletResponse response,
  						 FilterChain chain)
focal_method.full_signature: @Override public void doFilter(ServletRequest request, ServletResponse response,
  						 FilterChain chain)
focal_method.identifier: doFilter
focal_method.invocations: isUriInLocalPaths debug getRequestURI doFilter isUriInCheckPaths isSpaceAvailable sendError getErrorStatus error sendError getErrorStatus isCommitted getRequestDispatcher getProxyPath forward
focal_method.modifiers: @Override public
focal_method.parameters: (ServletRequest request, ServletResponse response,
  						 FilterChain chain)
focal_method.return: void
focal_method.signature: void doFilter(ServletRequest request, ServletResponse response,
  						 FilterChain chain)