Clover icon

Coverage Report

  1. Project Clover database Thu Nov 7 2024 17:01:39 GMT
  2. Package jalview.io

File JalviewFileViewTest.java

 

Code metrics

0
43
3
1
127
95
3
0.07
14.33
3
1

Classes

Class Line # Actions
JalviewFileViewTest 35 43 3
0.00%
 

Contributing tests

No tests hitting this source file were found.

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    import static org.testng.Assert.assertNotNull;
25    import static org.testng.Assert.assertNotSame;
26    import static org.testng.Assert.assertNull;
27    import static org.testng.Assert.assertSame;
28   
29    import java.io.File;
30   
31    import javax.swing.ImageIcon;
32   
33    import org.testng.annotations.Test;
34   
 
35    public class JalviewFileViewTest
36    {
 
37  0 toggle @Test(groups = "Functional")
38    public void testGetImageIcon()
39    {
40  0 JalviewFileView jfv = new JalviewFileView();
41  0 ImageIcon icon1 = jfv.getImageIcon("/images/file.png");
42  0 ImageIcon icon2 = jfv.getImageIcon("/images/file.png");
43  0 ImageIcon icon3 = jfv.getImageIcon("/images/dna.png");
44  0 ImageIcon icon4 = jfv.getImageIcon("/images/dna.png");
45   
46    /*
47    * verify a single image object is served per file path
48    */
49  0 assertNotNull(icon1);
50  0 assertSame(icon1, icon2);
51  0 assertNotNull(icon3);
52  0 assertSame(icon3, icon4);
53  0 assertNotSame(icon1, icon3);
54   
55  0 assertNull(jfv.getImageIcon("/images/nosuchfile.png"));
56  0 assertNull(jfv.getImageIcon("images/file.png"));
57    }
58   
 
59  0 toggle @Test(groups = "Functional")
60    public void testGetExtension()
61    {
62  0 assertEquals(JalviewFileView.getExtension(new File("text.txt")), "txt");
63  0 assertEquals(JalviewFileView.getExtension(
64    new File("/a/longer/file/path/text.png.TXT")), "txt");
65  0 assertNull(JalviewFileView
66    .getExtension(new File("/a/longer/file/path/text.")));
67  0 assertNull(JalviewFileView
68    .getExtension(new File("/a/longer/file/path/text")));
69    }
70   
 
71  0 toggle @Test(groups = "Functional")
72    public void testGetTypeDescription()
73    {
74  0 JalviewFileView jfw = new JalviewFileView();
75  0 assertEquals(jfw.getTypeDescription(new File("uniref50.fa")),
76    "Fasta file");
77  0 assertEquals(jfw.getTypeDescription(new File("uniref50.fasta")),
78    "Fasta file");
79  0 assertEquals(jfw.getTypeDescription(new File("uniref50.MFA")),
80    "Fasta file");
81  0 assertEquals(jfw.getTypeDescription(new File("uniref50.fastQ")),
82    "Fasta file");
83  0 assertEquals(jfw.getTypeDescription(new File("uniref50.pfam")),
84    "PFAM file");
85  0 assertEquals(jfw.getTypeDescription(new File("uniref50.stk")),
86    "Stockholm file");
87  0 assertEquals(jfw.getTypeDescription(new File("uniref50.sto")),
88    "Stockholm file");
89  0 assertEquals(jfw.getTypeDescription(new File("uniref50.pir")),
90    "PIR file");
91  0 assertEquals(jfw.getTypeDescription(new File("uniref50.blc")),
92    "BLC file");
93  0 assertEquals(jfw.getTypeDescription(new File("uniref50.amsa")),
94    "AMSA file");
95  0 assertEquals(jfw.getTypeDescription(new File("uniref50.html")),
96    "HTML file");
97  0 assertNull(jfw.getTypeDescription(new File("uniref50.htm")));
98  0 assertEquals(jfw.getTypeDescription(new File("uniref50.xml")),
99    "RNAML file");
100  0 assertEquals(jfw.getTypeDescription(new File("uniref50.rnaml")),
101    "RNAML file");
102  0 assertEquals(jfw.getTypeDescription(new File("uniref50.json")),
103    "JSON file");
104  0 assertEquals(jfw.getTypeDescription(new File("uniref50.pileup")),
105    "PileUp file");
106  0 assertEquals(jfw.getTypeDescription(new File("uniref50.msf")),
107    "MSF file");
108  0 assertEquals(jfw.getTypeDescription(new File("uniref50.aln")),
109    "Clustal file");
110  0 assertEquals(jfw.getTypeDescription(new File("uniref50.phy")),
111    "PHYLIP file");
112  0 assertEquals(jfw.getTypeDescription(new File("uniref50.gff2")),
113    "GFF or Jalview features file");
114  0 assertEquals(jfw.getTypeDescription(new File("uniref50.gff3")),
115    "GFF or Jalview features file");
116  0 assertEquals(jfw.getTypeDescription(new File("uniref50.pdb")),
117    "PDB file");
118  0 assertEquals(jfw.getTypeDescription(new File("uniref50.ent")),
119    "PDB file");
120  0 assertEquals(jfw.getTypeDescription(new File("uniref50.cif")),
121    "mmCIF file");
122  0 assertEquals(jfw.getTypeDescription(new File("uniref50.jvp")),
123    "Jalview file");
124  0 assertEquals(jfw.getTypeDescription(new File("uniref50.jar")),
125    "Jalview file (old)");
126    }
127    }