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;
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;
31 import javax.swing.ImageIcon;
33 import org.testng.annotations.Test;
35 public class JalviewFileViewTest
37 @Test(groups = "Functional")
38 public void testGetImageIcon()
40 JalviewFileView jfv = new JalviewFileView();
41 ImageIcon icon1 = jfv.getImageIcon("/images/file.png");
42 ImageIcon icon2 = jfv.getImageIcon("/images/file.png");
43 ImageIcon icon3 = jfv.getImageIcon("/images/dna.png");
44 ImageIcon icon4 = jfv.getImageIcon("/images/dna.png");
47 * verify a single image object is served per file path
50 assertSame(icon1, icon2);
52 assertSame(icon3, icon4);
53 assertNotSame(icon1, icon3);
55 assertNull(jfv.getImageIcon("/images/nosuchfile.png"));
56 assertNull(jfv.getImageIcon("images/file.png"));
59 @Test(groups = "Functional")
60 public void testGetExtension()
62 assertEquals(JalviewFileView.getExtension(new File("text.txt")), "txt");
63 assertEquals(JalviewFileView.getExtension(
64 new File("/a/longer/file/path/text.png.TXT")), "txt");
65 assertNull(JalviewFileView
66 .getExtension(new File("/a/longer/file/path/text.")));
67 assertNull(JalviewFileView
68 .getExtension(new File("/a/longer/file/path/text")));
71 @Test(groups = "Functional")
72 public void testGetTypeDescription()
74 JalviewFileView jfw = new JalviewFileView();
75 assertEquals(jfw.getTypeDescription(new File("uniref50.fa")),
77 assertEquals(jfw.getTypeDescription(new File("uniref50.fasta")),
79 assertEquals(jfw.getTypeDescription(new File("uniref50.MFA")),
81 assertEquals(jfw.getTypeDescription(new File("uniref50.fastQ")),
83 assertEquals(jfw.getTypeDescription(new File("uniref50.pfam")),
85 assertEquals(jfw.getTypeDescription(new File("uniref50.stk")),
87 assertEquals(jfw.getTypeDescription(new File("uniref50.sto")),
89 assertEquals(jfw.getTypeDescription(new File("uniref50.pir")),
91 assertEquals(jfw.getTypeDescription(new File("uniref50.blc")),
93 assertEquals(jfw.getTypeDescription(new File("uniref50.amsa")),
95 assertEquals(jfw.getTypeDescription(new File("uniref50.html")),
97 assertNull(jfw.getTypeDescription(new File("uniref50.htm")));
98 assertEquals(jfw.getTypeDescription(new File("uniref50.xml")),
100 assertEquals(jfw.getTypeDescription(new File("uniref50.rnaml")),
102 assertEquals(jfw.getTypeDescription(new File("uniref50.json")),
104 assertEquals(jfw.getTypeDescription(new File("uniref50.pileup")),
106 assertEquals(jfw.getTypeDescription(new File("uniref50.msf")),
108 assertEquals(jfw.getTypeDescription(new File("uniref50.aln")),
110 assertEquals(jfw.getTypeDescription(new File("uniref50.phy")),
112 assertEquals(jfw.getTypeDescription(new File("uniref50.gff2")),
113 "GFF or Jalview features file");
114 assertEquals(jfw.getTypeDescription(new File("uniref50.gff3")),
115 "GFF or Jalview features file");
116 assertEquals(jfw.getTypeDescription(new File("uniref50.pdb")),
118 assertEquals(jfw.getTypeDescription(new File("uniref50.ent")),
120 assertEquals(jfw.getTypeDescription(new File("uniref50.cif")),
122 assertEquals(jfw.getTypeDescription(new File("uniref50.jvp")),
124 assertEquals(jfw.getTypeDescription(new File("uniref50.jar")),
125 "Jalview file (old)");