Clover icon

Coverage Report

  1. Project Clover database Mon Sep 2 2024 17:57:51 BST
  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
1.0100%
 

Contributing tests

This file is covered by 3 tests. .

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