Exemplo n.º 1
0
  public void testDeleteAbstractSwapFile() throws IOException {
    SwapFile sf = SwapFile.get(new File(DIR_NAME), FILE_NAME);
    sf.spoolDone();

    // File on disk does not exist. It will not be removed from disk space.
    assertTrue("File should be deleted.", sf.delete());
  }
Exemplo n.º 2
0
 public void testGetSwapFile() throws IOException {
   // Get swap file is possible only in this way.
   SwapFile sf = SwapFile.get(new File(DIR_NAME), FILE_NAME);
   assertNotNull("File should be created.", sf);
   sf.spoolDone();
   sf.delete();
 }
Exemplo n.º 3
0
  public void testDeleteExistingSwapFile() throws IOException {
    SwapFile sf = SwapFile.get(new File(DIR_NAME), FILE_NAME);

    // write to file
    OutputStream out = new FileOutputStream(sf);
    byte[] outWrite = new byte[] {1, 2, 3};
    out.write(outWrite);
    out.close();
    sf.spoolDone();

    // File is present on the disk. It will be removed from disk space.
    assertTrue("File should be deleted.", sf.delete());
  }
Exemplo n.º 4
0
 public void testCreateTempFile() {
   // Not applicable creation.
   try {
     SwapFile.createTempFile("prefix", "suffix", new File(DIR_NAME));
     fail("IOException should have been thrown.");
   } catch (IOException e) {
     // Ok.
   }
 }
Exemplo n.º 5
0
 public void testIsSpooled() throws IOException {
   SwapFile sf = SwapFile.get(new File(DIR_NAME), FILE_NAME);
   assertFalse("Spool is not over.", sf.isSpooled());
   sf.spoolDone();
   assertTrue("Spool is over.", sf.isSpooled());
   sf.delete();
 }
Exemplo n.º 6
0
 public void testSpoolDone() throws IOException {
   SwapFile sf = SwapFile.get(new File(DIR_NAME), FILE_NAME);
   sf.spoolDone();
   assertTrue("Spool should be done.", sf.isSpooled());
   sf.delete();
 }