2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
24 import java.io.IOException;
25 import java.nio.file.Files;
26 import java.nio.file.StandardCopyOption;
28 import org.testng.Assert;
29 import org.testng.annotations.AfterClass;
30 import org.testng.annotations.BeforeClass;
31 import org.testng.annotations.Test;
33 import jalview.bin.Cache;
34 import jalview.datamodel.AlignmentI;
35 import jalview.gui.AlignFrame;
36 import jalview.gui.JvOptionPane;
39 * WindowsFileSaveTest simply opens an alignment file and then tries to save it.
40 * This failed in Windows from 2.11.0 to 2.11.1.6 due to a combination of the
41 * opening file handle being left open ad infinitum, causing the BackupFiles
42 * operation of moving the saved (temp) file onto the original filename to fail,
43 * but only in Windows. See: https://issues.jalview.org/browse/JAL-3628
44 * https://issues.jalview.org/browse/JAL-3703
45 * https://issues.jalview.org/browse/JAL-3935 These issues are really all fixed
46 * by JAL-3703 This test is to ensure it doesn't start again, but note that this
47 * test will only fail in Windows.
49 public class WindowsFileLoadAndSaveTest
52 private final static String fileName = "examples" + File.separator
55 private final static String testFileName = fileName + "-TEST";
57 @BeforeClass(alwaysRun = true)
58 public void setUpJvOptionPane()
60 JvOptionPane.setInteractiveMode(false);
61 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
65 * Test saving and re-reading in a specified format
69 @Test(groups = { "Functional" })
70 public void loadAndSaveAlignment() throws IOException
73 File file = new File(fileName);
74 File testFile = new File(testFileName);
75 Files.copy(file.toPath(), testFile.toPath(),
76 StandardCopyOption.REPLACE_EXISTING);
77 FormatAdapter fa = new FormatAdapter();
78 AlignmentI a = fa.readFile(fileName, DataSourceType.FILE,
81 AlignFrame af = new AlignFrame(a, 500, 500);
82 Assert.assertTrue(af.saveAlignment(testFileName, FileFormat.Fasta));
85 @AfterClass(alwaysRun = true)
86 private void cleanupTmpFiles()
88 BackupFilesPresetEntry bfpe = BackupFilesPresetEntry
89 .getSavedBackupEntry();
90 BackupFilesTest.cleanupTmpFiles(testFileName, bfpe.suffix, bfpe.digits);