// Path: harahachibu/src/main/java/uk/co/flax/harahachibu/config/ProxyConfiguration.java
// public class ProxyConfiguration {
// 
// 	private int errorStatus = 503;
// 
// 	@NotNull
// 	private String destinationServer;
// 
// 	private List<String> checkUrls = new ArrayList<>();
// 
// 	public int getErrorStatus() {
// 		return errorStatus;
// 	}
// 
// 	public void setErrorStatus(int status) {
// 		this.errorStatus = status;
// 	}
// 
// 	public String getDestinationServer() {
// 		return destinationServer;
// 	}
// 
// 	public void setDestinationServer(String destinationServer) {
// 		this.destinationServer = destinationServer;
// 	}
// 
// 	public List<String> getCheckUrls() {
// 		return checkUrls;
// 	}
// 
// 	public void setCheckUrls(List<String> checkUrls) {
// 		this.checkUrls = checkUrls;
// 	}
// }
// 
// Path: harahachibu/src/main/java/uk/co/flax/harahachibu/services/DiskSpaceChecker.java
// public interface DiskSpaceChecker {
// 
// 	/**
// 	 * Check whether space is available on the disk or cluster of
// 	 * disks.
// 	 * @return {@code true} if space is available, {@code false} if not
// 	 * (including if server calls fail).
// 	 * @throws DiskSpaceCheckerException if problems occur checking the
// 	 * disks.
// 	 */
// 	boolean isSpaceAvailable() throws DiskSpaceCheckerException;
// 
// 	/**
// 	 * Pass configuration properties into the checker instance, for custom
// 	 * checkers.
// 	 * @param configuration a {@link Map} of configuration details.
// 	 * @throws DiskSpaceCheckerException if the configuration cannot be read.
// 	 */
// 	void configure(Map<String, Object> configuration) throws DiskSpaceCheckerException;
// 
// 	/**
// 	 * Does the implementation require an HTTP client for remote access?
// 	 * @return {@code true} if the checker requires HTTP access.
// 	 */
// 	boolean requiresHttpClient();
// 
// 	/**
// 	 * Set the HTTP client to use for remote access. This will be supplied and managed
// 	 * by DropWizard, avoiding the requirement to implement your own.
// 	 * @param httpClient the client to use.
// 	 */
// 	void setHttpClient(Client httpClient);
// 
// 	/**
// 	 * Set the disk space threshold to use to check for available space.
// 	 * @param threshold the threshold.
// 	 */
// 	void setThreshold(DiskSpaceThreshold threshold);
// 
// }
// 
// Path: harahachibu/src/main/java/uk/co/flax/harahachibu/services/DiskSpaceCheckerException.java
// public class DiskSpaceCheckerException extends Exception {
// 
// 	public DiskSpaceCheckerException() {
// 		super();
// 	}
// 
// 	public DiskSpaceCheckerException(String message) {
// 		super(message);
// 	}
// 
// 	public DiskSpaceCheckerException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// 
// 	public DiskSpaceCheckerException(Throwable cause) {
// 		super(cause);
// 	}
// 
// }


import org.junit.Before;
import org.junit.Test;
import uk.co.flax.harahachibu.config.ProxyConfiguration;
import uk.co.flax.harahachibu.services.DiskSpaceChecker;
import uk.co.flax.harahachibu.services.DiskSpaceCheckerException;
import javax.servlet.FilterChain;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;
import static org.mockito.Mockito.*;

	@Test
	public void returnErrorWhenDiskCheckFails() throws Exception {
		when(checker.isSpaceAvailable()).thenThrow(new DiskSpaceCheckerException("Error"));

		final String requestUri = "/solr/update";
		final HttpServletRequest req = mock(HttpServletRequest.class);
		when(req.getRequestURI()).thenReturn(requestUri);
		when(req.getContextPath()).thenReturn("");
		when(req.getQueryString()).thenReturn(null);

		final HttpServletResponse response = mock(HttpServletResponse.class);
		when(response.isCommitted()).thenReturn(true);
		final FilterChain chain = mock(FilterChain.class);

		filter.doFilter(req, response, chain);

		verify(req, atLeastOnce()).getRequestURI();
		verify(response).sendError(errorCode);
		verify(checker).isSpaceAvailable();
	}

	@Test
	public void returnErrorWhenDiskFull() throws Exception {
		when(checker.isSpaceAvailable()).thenReturn(false);

		final String requestUri = "/solr/update";
		final HttpServletRequest req = mock(HttpServletRequest.class);
		when(req.getRequestURI()).thenReturn(requestUri);
		when(req.getContextPath()).thenReturn("");
// Path: harahachibu/src/main/java/uk/co/flax/harahachibu/config/ProxyConfiguration.java
// public class ProxyConfiguration {
// 
// 	private int errorStatus = 503;
// 
// 	@NotNull
// 	private String destinationServer;
// 
// 	private List<String> checkUrls = new ArrayList<>();
// 
// 	public int getErrorStatus() {
// 		return errorStatus;
// 	}
// 
// 	public void setErrorStatus(int status) {
// 		this.errorStatus = status;
// 	}
// 
// 	public String getDestinationServer() {
// 		return destinationServer;
// 	}
// 
// 	public void setDestinationServer(String destinationServer) {
// 		this.destinationServer = destinationServer;
// 	}
// 
// 	public List<String> getCheckUrls() {
// 		return checkUrls;
// 	}
// 
// 	public void setCheckUrls(List<String> checkUrls) {
// 		this.checkUrls = checkUrls;
// 	}
// }
// 
// Path: harahachibu/src/main/java/uk/co/flax/harahachibu/services/DiskSpaceChecker.java
// public interface DiskSpaceChecker {
// 
// 	/**
// 	 * Check whether space is available on the disk or cluster of
// 	 * disks.
// 	 * @return {@code true} if space is available, {@code false} if not
// 	 * (including if server calls fail).
// 	 * @throws DiskSpaceCheckerException if problems occur checking the
// 	 * disks.
// 	 */
// 	boolean isSpaceAvailable() throws DiskSpaceCheckerException;
// 
// 	/**
// 	 * Pass configuration properties into the checker instance, for custom
// 	 * checkers.
// 	 * @param configuration a {@link Map} of configuration details.
// 	 * @throws DiskSpaceCheckerException if the configuration cannot be read.
// 	 */
// 	void configure(Map<String, Object> configuration) throws DiskSpaceCheckerException;
// 
// 	/**
// 	 * Does the implementation require an HTTP client for remote access?
// 	 * @return {@code true} if the checker requires HTTP access.
// 	 */
// 	boolean requiresHttpClient();
// 
// 	/**
// 	 * Set the HTTP client to use for remote access. This will be supplied and managed
// 	 * by DropWizard, avoiding the requirement to implement your own.
// 	 * @param httpClient the client to use.
// 	 */
// 	void setHttpClient(Client httpClient);
// 
// 	/**
// 	 * Set the disk space threshold to use to check for available space.
// 	 * @param threshold the threshold.
// 	 */
// 	void setThreshold(DiskSpaceThreshold threshold);
// 
// }
// 
// Path: harahachibu/src/main/java/uk/co/flax/harahachibu/services/DiskSpaceCheckerException.java
// public class DiskSpaceCheckerException extends Exception {
// 
// 	public DiskSpaceCheckerException() {
// 		super();
// 	}
// 
// 	public DiskSpaceCheckerException(String message) {
// 		super(message);
// 	}
// 
// 	public DiskSpaceCheckerException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// 
// 	public DiskSpaceCheckerException(Throwable cause) {
// 		super(cause);
// 	}
// 
// }


// Path: harahachibu/src/test/java/uk/co/flax/harahachibu/servlets/DiskSpaceFilterTest.java
import org.junit.Before;
import org.junit.Test;
import uk.co.flax.harahachibu.config.ProxyConfiguration;
import uk.co.flax.harahachibu.services.DiskSpaceChecker;
import uk.co.flax.harahachibu.services.DiskSpaceCheckerException;
import javax.servlet.FilterChain;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;
import static org.mockito.Mockito.*;


	@Test
	public void returnErrorWhenDiskCheckFails() throws Exception {
		when(checker.isSpaceAvailable()).thenThrow(new DiskSpaceCheckerException("Error"));

		final String requestUri = "/solr/update";
		final HttpServletRequest req = mock(HttpServletRequest.class);
		when(req.getRequestURI()).thenReturn(requestUri);
		when(req.getContextPath()).thenReturn("");
		when(req.getQueryString()).thenReturn(null);

		final HttpServletResponse response = mock(HttpServletResponse.class);
		when(response.isCommitted()).thenReturn(true);
		final FilterChain chain = mock(FilterChain.class);

		filter.doFilter(req, response, chain);

		verify(req, atLeastOnce()).getRequestURI();
		verify(response).sendError(errorCode);
		verify(checker).isSpaceAvailable();
	}

	@Test
	public void returnErrorWhenDiskFull() throws Exception {
		when(checker.isSpaceAvailable()).thenReturn(false);

		final String requestUri = "/solr/update";
		final HttpServletRequest req = mock(HttpServletRequest.class);
		when(req.getRequestURI()).thenReturn(requestUri);
		when(req.getContextPath()).thenReturn("");
		when(req.getQueryString()).thenReturn(null);