public void test_returnFile_errorFlushingOutputStream() {
   TestUtil.writeFile("_test_", "Sample file to return.");
   response.stream.setFlushError();
   StaticServlet.returnFile("_test_", context, response);
   assertEquals(
       "log4j log output",
       "I/O error flushing output stream in StaticServlet." + "returnFile: error during flush",
       log4jLog.log.toString());
   TestUtil.deleteTree("_test_");
 }
 public void test_returnFile_errorSendingFileData() {
   TestUtil.writeFile("_test_", "Sample file to return.");
   response.stream.setWriteError();
   StaticServlet.returnFile("_test_", context, response);
   assertEquals(
       "log4j log output",
       "I/O error sending response in StaticServlet.returnFile: " + "error during write",
       log4jLog.log.toString());
   TestUtil.deleteTree("_test_");
 }
 public void test_returnFile_cantOpenOutputStream() throws ServletException {
   TestUtil.writeFile("_test_", "Sample file to return.");
   response.getOutputStreamException = true;
   StaticServlet.returnFile("_test_", context, response);
   assertEquals(
       "log4j log output",
       "I/O error retrieving response output stream in "
           + "StaticServlet.returnFile: getOutputStream failed",
       log4jLog.log.toString());
   TestUtil.deleteTree("_test_");
 }
 public void test_returnFile_contentDispositionHeader() {
   TestUtil.writeFile("_test_", "Sample file to return.");
   StaticServlet.returnFile("_test_", context, response);
   assertEquals(
       "log info about headers",
       "getOutputStream; setContentType(\"application/octet-"
           + "stream\"); setHeader(\"Content-Disposition\", "
           + "\"filename=\"_test_\"\")",
       response.log.toString());
   TestUtil.deleteTree("_test_");
 }
 public void test_returnFile_badFileName() throws ServletException {
   StaticServlet.returnFile("bogus/x/y/z", context, response);
   assertEquals("response log", "sendError(404)", response.log.toString());
 }
 public void test_returnFile_sendFileData() {
   TestUtil.writeFile("_test_", "Sample file to return.");
   StaticServlet.returnFile("_test_", context, response);
   assertEquals("information returned", "Sample file to return.", response.toString());
   TestUtil.deleteTree("_test_");
 }
 public void test_returnFile_defaultMimeType() {
   TestUtil.writeFile("_test_.xxx", "Sample file to return.");
   StaticServlet.returnFile("_test_.xxx", context, response);
   assertEquals("content type for response", "application/octet-stream", response.contentType);
   TestUtil.deleteTree("_test_.xxx");
 }
 public void test_returnFile_setMimeType() {
   TestUtil.writeFile("_test_.xls", "Sample file to return.");
   StaticServlet.returnFile("_test_.xls", context, response);
   assertEquals("content type for response", "application/vnd.ms-excel", response.contentType);
   TestUtil.deleteTree("_test_.xls");
 }