Пример #1
0
 public void test_doGet_noPathInfo() {
   TestUtil.writeFile("_test_", "Data for empty path.");
   servlet.prefix = "_test_";
   servlet.doGet(new ServletRequestFixture(null), response);
   TestUtil.deleteTree("_test_");
   assertEquals("information returned", "Data for empty path.", response.toString());
 }
Пример #2
0
 public void test_doGet_basics() {
   (new File("_test_")).mkdir();
   TestUtil.writeFile("_test_/abc", "Sample file to return.");
   servlet.prefix = "_test_/";
   servlet.doGet(new ServletRequestFixture("abc"), response);
   TestUtil.deleteTree("_test_");
   assertEquals("information returned", "Sample file to return.", response.toString());
 }
Пример #3
0
 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_");
 }
Пример #4
0
 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_");
 }
Пример #5
0
 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_");
 }
Пример #6
0
 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_");
 }
Пример #7
0
 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_");
 }
Пример #8
0
 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");
 }
Пример #9
0
 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");
 }