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.datamodel.AlignmentI;
34 import jalview.gui.AlignFrame;
35 import jalview.gui.JvOptionPane;
38 * WindowsFileSaveTest simply opens an alignment file and then tries to save it.
39 * This failed in Windows from 2.11.0 to 2.11.1.6 due to a combination of the
40 * opening file handle being left open ad infinitum, causing the BackupFiles
41 * operation of moving the saved (temp) file onto the original filename to fail,
42 * but only in Windows. See: https://issues.jalview.org/browse/JAL-3628
43 * https://issues.jalview.org/browse/JAL-3703
44 * https://issues.jalview.org/browse/JAL-3935 These issues are really all fixed
45 * by JAL-3703 This test is to ensure it doesn't start again, but note that this
46 * test will only fail in Windows.
48 public class WindowsFileLoadAndSaveTest
51 private final static String fileName = "examples" + File.separator
54 private final static String testFileName = fileName + "-TEST";
56 @BeforeClass(alwaysRun = true)
57 public void setUpJvOptionPane()
59 JvOptionPane.setInteractiveMode(false);
60 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
64 * Test saving and re-reading in a specified format
68 @Test(groups = { "Functional" })
69 public void loadAndSaveAlignment() throws IOException
71 File file = new File(fileName);
72 File testFile = new File(testFileName);
73 Files.copy(file.toPath(), testFile.toPath(),
74 StandardCopyOption.REPLACE_EXISTING);
75 FormatAdapter fa = new FormatAdapter();
76 AlignmentI a = fa.readFile(testFile, DataSourceType.FILE,
79 AlignFrame af = new AlignFrame(a, 500, 500);
80 af.saveAlignment(testFileName, FileFormat.Fasta);
82 Assert.assertTrue(af.isSaveAlignmentSuccessful());
85 @AfterClass(alwaysRun = true)
86 private void cleanupTmpFiles()
88 BackupFilesPresetEntry bfpe = BackupFilesPresetEntry
89 .getSavedBackupEntry();
90 BackupFilesTest.cleanupTmpFiles(testFileName, bfpe.suffix, bfpe.digits);