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.
23 import static org.testng.Assert.assertEquals;
25 import jalview.bin.Cache;
27 import org.junit.Assert;
28 import org.testng.annotations.Test;
30 public class FileLoaderTest
33 @Test(groups = { "Network" })
34 public void testDownloadStructuresIfInputFromURL()
36 String urlFile = "http://www.jalview.org/builds/develop/examples/3W5V.pdb";
37 FileLoader fileLoader = new FileLoader();
38 fileLoader.LoadFileWaitTillLoaded(urlFile, DataSourceType.URL,
40 Assert.assertNotNull(fileLoader.file);
41 // The FileLoader's file is expected to be same as the original URL.
42 Assert.assertEquals(urlFile, fileLoader.file);
43 // Data source type expected to be DataSourceType.URL
44 Assert.assertEquals(DataSourceType.URL, fileLoader.protocol);
47 @Test(groups = "Functional")
48 public void testUpdateRecentlyOpened()
50 // ensure properties file is read-only
51 Cache.loadProperties("test/jalview/io/testProps.jvprops");
53 String recent = "RECENT_FILE";
54 Cache.removeProperty(recent);
56 String prop = FileLoader.updateRecentlyOpened("a/b/c",
58 assertEquals(prop, "a/b/c");
60 prop = FileLoader.updateRecentlyOpened("d/e/f", DataSourceType.FILE);
61 assertEquals(prop, "d/e/f\ta/b/c");
63 // revisiting a file moves it to the top of the list
64 prop = FileLoader.updateRecentlyOpened("a/b/c", DataSourceType.FILE);
65 assertEquals(prop, "a/b/c\td/e/f");
67 // history list is limited to the most recent 11 items
68 for (int i = 0; i < 20; i++)
70 prop = FileLoader.updateRecentlyOpened(String.format("%d.fa", i),
74 "19.fa\t18.fa\t17.fa\t16.fa\t15.fa\t14.fa\t13.fa\t12.fa\t11.fa\t10.fa\t9.fa");