Clover icon

Coverage Report

  1. Project Clover database Wed Dec 3 2025 17:03:17 GMT
  2. Package jalview.io

File FileLoaderTest.java

 

Code metrics

2
18
2
1
76
40
3
0.17
9
2
1.5

Classes

Class Line # Actions
FileLoaderTest 30 18 3
0.681818268.2%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
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.
11    *
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.
16    *
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.
20    */
21    package jalview.io;
22   
23    import static org.testng.Assert.assertEquals;
24   
25    import jalview.bin.Cache;
26   
27    import org.junit.Assert;
28    import org.testng.annotations.Test;
29   
 
30    public class FileLoaderTest
31    {
32   
 
33  0 toggle @Test(groups = { "Network" })
34    public void testDownloadStructuresIfInputFromURL()
35    {
36  0 String urlFile = "http://www.jalview.org/builds/develop/examples/3W5V.pdb";
37  0 FileLoader fileLoader = new FileLoader();
38  0 fileLoader.LoadFileWaitTillLoaded(urlFile, DataSourceType.URL,
39    FileFormat.PDB);
40  0 Assert.assertNotNull(fileLoader.file);
41    // The FileLoader's file is expected to be same as the original URL.
42  0 Assert.assertEquals(urlFile, fileLoader.file);
43    // Data source type expected to be DataSourceType.URL
44  0 Assert.assertEquals(DataSourceType.URL, fileLoader.protocol);
45    }
46   
 
47  1 toggle @Test(groups = "Functional")
48    public void testUpdateRecentlyOpened()
49    {
50    // ensure properties file is read-only
51  1 Cache.loadProperties("test/jalview/io/testProps.jvprops");
52   
53  1 String recent = "RECENT_FILE";
54  1 Cache.removeProperty(recent);
55   
56  1 String prop = FileLoader.updateRecentlyOpened("a/b/c",
57    DataSourceType.FILE);
58  1 assertEquals(prop, "a/b/c");
59   
60  1 prop = FileLoader.updateRecentlyOpened("d/e/f", DataSourceType.FILE);
61  1 assertEquals(prop, "d/e/f\ta/b/c");
62   
63    // revisiting a file moves it to the top of the list
64  1 prop = FileLoader.updateRecentlyOpened("a/b/c", DataSourceType.FILE);
65  1 assertEquals(prop, "a/b/c\td/e/f");
66   
67    // history list is limited to the most recent 11 items
68  21 for (int i = 0; i < 20; i++)
69    {
70  20 prop = FileLoader.updateRecentlyOpened(String.format("%d.fa", i),
71    DataSourceType.FILE);
72    }
73  1 assertEquals(prop,
74    "19.fa\t18.fa\t17.fa\t16.fa\t15.fa\t14.fa\t13.fa\t12.fa\t11.fa\t10.fa\t9.fa");
75    }
76    }