JAL-3141 fixed test
[jalview.git] / test / jalview / io / BackupFilesTest.java
index a78936e..723279d 100644 (file)
@@ -108,27 +108,27 @@ public class BackupFilesTest
 
     // check 10 backup files
     HashMap correctindexmap = new HashMap();
-    correctindexmap.put(1, "backupfilestestTemp_BACKUPTEST-00000001.fa");
-    correctindexmap.put(2, "backupfilestestTemp_BACKUPTEST-00000002.fa");
-    correctindexmap.put(3, "backupfilestestTemp_BACKUPTEST-00000003.fa");
-    correctindexmap.put(4, "backupfilestestTemp_BACKUPTEST-00000004.fa");
-    correctindexmap.put(5, "backupfilestestTemp_BACKUPTEST-00000005.fa");
-    correctindexmap.put(6, "backupfilestestTemp_BACKUPTEST-00000006.fa");
-    correctindexmap.put(7, "backupfilestestTemp_BACKUPTEST-00000007.fa");
-    correctindexmap.put(8, "backupfilestestTemp_BACKUPTEST-00000008.fa");
-    correctindexmap.put(9, "backupfilestestTemp_BACKUPTEST-00000009.fa");
-    correctindexmap.put(10, "backupfilestestTemp_BACKUPTEST-00000010.fa");
+    correctindexmap.put(1, "backupfilestestTemp.fa_BACKUPTEST-00000001");
+    correctindexmap.put(2, "backupfilestestTemp.fa_BACKUPTEST-00000002");
+    correctindexmap.put(3, "backupfilestestTemp.fa_BACKUPTEST-00000003");
+    correctindexmap.put(4, "backupfilestestTemp.fa_BACKUPTEST-00000004");
+    correctindexmap.put(5, "backupfilestestTemp.fa_BACKUPTEST-00000005");
+    correctindexmap.put(6, "backupfilestestTemp.fa_BACKUPTEST-00000006");
+    correctindexmap.put(7, "backupfilestestTemp.fa_BACKUPTEST-00000007");
+    correctindexmap.put(8, "backupfilestestTemp.fa_BACKUPTEST-00000008");
+    correctindexmap.put(9, "backupfilestestTemp.fa_BACKUPTEST-00000009");
+    correctindexmap.put(10, "backupfilestestTemp.fa_BACKUPTEST-00000010");
     HashMap wrongindexmap = new HashMap();
-    wrongindexmap.put(1, "backupfilestestTemp_BACKUPTEST-1.fa");
-    wrongindexmap.put(2, "backupfilestestTemp_BACKUPTEST-00000002.fa");
-    wrongindexmap.put(3, "backupfilestestTemp_BACKUPTEST-00000003.fa");
-    wrongindexmap.put(4, "backupfilestestTemp_BACKUPTEST-00000004.fa");
-    wrongindexmap.put(5, "backupfilestestTemp_BACKUPTEST-00000005.fa");
-    wrongindexmap.put(6, "backupfilestestTemp_BACKUPTEST-00000006.fa");
-    wrongindexmap.put(7, "backupfilestestTemp_BACKUPTEST-00000007.fa");
-    wrongindexmap.put(8, "backupfilestestTemp_BACKUPTEST-00000008.fa");
-    wrongindexmap.put(9, "backupfilestestTemp_BACKUPTEST-00000009.fa");
-    wrongindexmap.put(10, "backupfilestestTemp_BACKUPTEST-00000010.fa");
+    wrongindexmap.put(1, "backupfilestestTemp.fa_BACKUPTEST-1");
+    wrongindexmap.put(2, "backupfilestestTemp.fa_BACKUPTEST-00000002");
+    wrongindexmap.put(3, "backupfilestestTemp.fa_BACKUPTEST-00000003");
+    wrongindexmap.put(4, "backupfilestestTemp.fa_BACKUPTEST-00000004");
+    wrongindexmap.put(5, "backupfilestestTemp.fa_BACKUPTEST-00000005");
+    wrongindexmap.put(6, "backupfilestestTemp.fa_BACKUPTEST-00000006");
+    wrongindexmap.put(7, "backupfilestestTemp.fa_BACKUPTEST-00000007");
+    wrongindexmap.put(8, "backupfilestestTemp.fa_BACKUPTEST-00000008");
+    wrongindexmap.put(9, "backupfilestestTemp.fa_BACKUPTEST-00000009");
+    wrongindexmap.put(10, "backupfilestestTemp.fa_BACKUPTEST-00000010");
     int[] indexes2 = { 3, 4, 5, 6, 7, 8, 9, 10 };
     int[] indexes3 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
     Assert.assertTrue(checkBackupFiles(correctindexmap));
@@ -159,8 +159,8 @@ public class BackupFilesTest
     // check there are "rollMax" backup files and they are all saved correctly
     // check 10 backup files
     HashMap correctindexmap = new HashMap();
-    correctindexmap.put(9, "backupfilestestTemp_BACKUPTEST-00000009.fa");
-    correctindexmap.put(10, "backupfilestestTemp_BACKUPTEST-00000010.fa");
+    correctindexmap.put(9, "backupfilestestTemp.fa_BACKUPTEST-00000009");
+    correctindexmap.put(10, "backupfilestestTemp.fa_BACKUPTEST-00000010");
     int[] indexes2 = { 10 };
     int[] indexes3 = { 8, 9, 10 };
     Assert.assertTrue(checkBackupFiles(correctindexmap));
@@ -190,8 +190,8 @@ public class BackupFilesTest
     // check there are "rollMax" backup files and they are all saved correctly
     // check 10 backup files
     HashMap correctindexmap = new HashMap();
-    correctindexmap.put(1, "backupfilestestTemp_BACKUPTEST-00000001.fa");
-    correctindexmap.put(2, "backupfilestestTemp_BACKUPTEST-00000002.fa");
+    correctindexmap.put(1, "backupfilestestTemp.fa_BACKUPTEST-00000001");
+    correctindexmap.put(2, "backupfilestestTemp.fa_BACKUPTEST-00000002");
     int[] indexes2 = { 1 };
     int[] indexes3 = { 1, 2, 3 };
     Assert.assertTrue(checkBackupFiles(correctindexmap));
@@ -272,7 +272,7 @@ public class BackupFilesTest
     {
       newfile.delete();
     }
-    File[] tmpFiles = BackupFiles.lsBackupFiles(newFile, suffix, digits);
+    File[] tmpFiles = getBackupFiles(newFile, suffix, digits);
     for (int i = 0; i < tmpFiles.length; i++)
     {
       if (actuallyDeleteTmpFiles)
@@ -286,15 +286,24 @@ public class BackupFilesTest
     }
   }
 
+  private static File[] getBackupFiles(String f, String s, int i)
+  {
+    TreeMap<Integer, File> bfTreeMap = BackupFiles.getBackupFilesAsTreeMap(f,
+            s, i);
+    File[] backupFiles = new File[bfTreeMap.size()];
+    bfTreeMap.values().toArray(backupFiles);
+    return backupFiles;
+  }
+
   private static File[] getBackupFiles()
   {
-    return BackupFiles.lsBackupFiles(newFile, suffix, digits);
+    return getBackupFiles(newFile, suffix, digits);
   }
 
   private static boolean checkBackupFiles(HashMap<Integer, String> indexmap)
           throws IOException
   {
-    TreeMap<Integer, File> map = BackupFiles.lsBackupFilesAsTreeMap(newFile,
+    TreeMap<Integer, File> map = BackupFiles.getBackupFilesAsTreeMap(newFile,
             suffix, digits);
     Enumeration<Integer> indexesenum = Collections
             .enumeration(indexmap.keySet());
@@ -332,7 +341,7 @@ public class BackupFilesTest
 
   private static boolean checkBackupFiles(int[] indexes) throws IOException
   {
-    TreeMap<Integer, File> map = BackupFiles.lsBackupFilesAsTreeMap(newFile,
+    TreeMap<Integer, File> map = BackupFiles.getBackupFilesAsTreeMap(newFile,
             suffix, digits);
     for (int m = 0; m < indexes.length; m++)
     {
@@ -352,8 +361,8 @@ public class BackupFilesTest
         return false;
       }
       // check the filename -- although this uses the same code to forumulate the filename so not much of a test!
-      String filename = BackupFilenameFilter.getBackupFilename(i,
-              newBasename, suffix, digits, testExt);
+      String filename = BackupFilenameParts.getBackupFilename(i,
+              newBasename + testExt, suffix, digits);
       if (!filename.equals(f.getName()))
       {
         System.out.println("Supposed filename '" + filename
@@ -372,7 +381,7 @@ public class BackupFilesTest
 
   private static String[] getBackupFilesAsStrings()
   {
-    File[] files = BackupFiles.lsBackupFiles(newFile, suffix, digits);
+    File[] files = getBackupFiles(newFile, suffix, digits);
     String[] filenames = new String[files.length];
     for (int i = 0; i < files.length; i++)
     {