X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fio%2FFileLoaderTest.java;h=84bd7148850cc31f6f68bdf69a0cf8b40dca7892;hb=cfb79b69d9fa44595560659bd95d1d1cd27677ad;hp=0e21f6ef6b9ac8da5ba1f613533f0c1ebd2c5763;hpb=57d8917fc33ed24c51e1fbb585617bd6f7defb8d;p=jalview.git diff --git a/test/jalview/io/FileLoaderTest.java b/test/jalview/io/FileLoaderTest.java index 0e21f6e..84bd714 100644 --- a/test/jalview/io/FileLoaderTest.java +++ b/test/jalview/io/FileLoaderTest.java @@ -1,5 +1,9 @@ package jalview.io; +import static org.testng.Assert.assertEquals; + +import jalview.bin.Cache; + import org.junit.Assert; import org.testng.annotations.Test; @@ -14,11 +18,39 @@ public class FileLoaderTest fileLoader.LoadFileWaitTillLoaded(urlFile, DataSourceType.URL, FileFormat.PDB); Assert.assertNotNull(fileLoader.file); - // The FileLoader's file is expected to a temporary file different from the - // original URL. - Assert.assertNotEquals(urlFile, fileLoader.file); - // Data source type expected to be updated from DataSourceType.URL to - // DataSourceType.FILE - Assert.assertEquals(DataSourceType.FILE, fileLoader.protocol); + // The FileLoader's file is expected to be same as the original URL. + Assert.assertEquals(urlFile, fileLoader.file); + // Data source type expected to be DataSourceType.URL + Assert.assertEquals(DataSourceType.URL, fileLoader.protocol); + } + + @Test(groups = "Functional") + public void testUpdateRecentlyOpened() + { + // ensure properties file is read-only + Cache.loadProperties("test/jalview/io/testProps.jvprops"); + + String recent = "RECENT_FILE"; + Cache.removeProperty(recent); + + String prop = FileLoader.updateRecentlyOpened("a/b/c", + DataSourceType.FILE); + assertEquals(prop, "a/b/c"); + + prop = FileLoader.updateRecentlyOpened("d/e/f", DataSourceType.FILE); + assertEquals(prop, "d/e/f\ta/b/c"); + + // revisiting a file moves it to the top of the list + prop = FileLoader.updateRecentlyOpened("a/b/c", DataSourceType.FILE); + assertEquals(prop, "a/b/c\td/e/f"); + + // history list is limited to the most recent 11 items + for (int i = 0; i < 20; i++) + { + prop = FileLoader.updateRecentlyOpened(String.format("%d.fa", i), + DataSourceType.FILE); + } + assertEquals(prop, + "19.fa\t18.fa\t17.fa\t16.fa\t15.fa\t14.fa\t13.fa\t12.fa\t11.fa\t10.fa\t9.fa"); } }