1 19 20 package org.netbeans.modules.refactoring.spi; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 import org.netbeans.junit.NbTestCase; 25 import org.openide.filesystems.FileObject; 26 import org.openide.filesystems.FileUtil; 27 28 32 public class BackupFacilityTest extends NbTestCase { 33 34 public BackupFacilityTest(String testName) { 35 super(testName); 36 } 37 38 protected void setUp() throws Exception { 39 super.setUp(); 40 f = FileUtil.toFileObject(getDataDir()).getFileObject("projects/default/src/defaultpkg/Main.java"); 41 } 42 43 protected void tearDown() throws Exception { 44 super.tearDown(); 45 } 46 47 public void testGetDefault() { 48 assertNotNull(BackupFacility.getDefault()); 49 } 50 51 static BackupFacility.Handle transactionId; 52 FileObject f; 53 public void testBackup() throws Exception { 54 transactionId = BackupFacility.getDefault().backup(f); 55 } 56 57 public void testRestore() throws Exception { 58 f.delete(); 59 assertFalse(f.isValid()); 60 transactionId.restore(); 61 FileObject newone = FileUtil.toFileObject(new File (f.getPath())); 62 assertTrue(newone.isValid()); 63 } 64 65 public void testClear() throws IOException { 66 BackupFacility.getDefault().clear(); 67 try { 68 transactionId.restore(); 69 } catch (IllegalArgumentException iae) { 70 return; 71 } 72 fail("clear failed"); 73 } 74 75 } 76 | Popular Tags |