3 import static org.testng.Assert.assertEquals;
4 import static org.testng.Assert.assertNotNull;
5 import static org.testng.Assert.assertNotSame;
6 import static org.testng.Assert.assertNull;
7 import static org.testng.Assert.assertSame;
11 import javax.swing.ImageIcon;
13 import org.testng.annotations.Test;
15 public class JalviewFileViewTest
17 @Test(groups = "Functional")
18 public void testGetImageIcon()
20 JalviewFileView jfv = new JalviewFileView();
21 ImageIcon icon1 = jfv.getImageIcon("/images/file.png");
22 ImageIcon icon2 = jfv.getImageIcon("/images/file.png");
23 ImageIcon icon3 = jfv.getImageIcon("/images/dna.png");
24 ImageIcon icon4 = jfv.getImageIcon("/images/dna.png");
27 * verify a single image object is served per file path
30 assertSame(icon1, icon2);
32 assertSame(icon3, icon4);
33 assertNotSame(icon1, icon3);
35 assertNull(jfv.getImageIcon("/images/nosuchfile.png"));
36 assertNull(jfv.getImageIcon("images/file.png"));
39 @Test(groups = "Functional")
40 public void testGetExtension()
42 assertEquals(JalviewFileView.getExtension(new File("text.txt")), "txt");
43 assertEquals(JalviewFileView.getExtension(new File(
44 "/a/longer/file/path/text.png.TXT")), "txt");
45 assertNull(JalviewFileView.getExtension(new File(
46 "/a/longer/file/path/text.")));
47 assertNull(JalviewFileView.getExtension(new File(
48 "/a/longer/file/path/text")));
51 @Test(groups = "Functional")
52 public void testGetTypeDescription()
54 JalviewFileView jfw = new JalviewFileView();
55 assertEquals(jfw.getTypeDescription(new File("uniref50.fa")),
57 assertEquals(jfw.getTypeDescription(new File("uniref50.fasta")),
59 assertEquals(jfw.getTypeDescription(new File("uniref50.MFA")),
61 assertEquals(jfw.getTypeDescription(new File("uniref50.fastQ")),
63 assertEquals(jfw.getTypeDescription(new File("uniref50.pfam")),
65 assertEquals(jfw.getTypeDescription(new File("uniref50.stk")),
67 assertEquals(jfw.getTypeDescription(new File("uniref50.sto")),
69 assertEquals(jfw.getTypeDescription(new File("uniref50.pir")),
71 assertEquals(jfw.getTypeDescription(new File("uniref50.blc")),
73 assertEquals(jfw.getTypeDescription(new File("uniref50.amsa")),
75 assertEquals(jfw.getTypeDescription(new File("uniref50.html")),
77 assertNull(jfw.getTypeDescription(new File("uniref50.htm")));
78 assertEquals(jfw.getTypeDescription(new File("uniref50.xml")),
80 assertEquals(jfw.getTypeDescription(new File("uniref50.rnaml")),
82 assertEquals(jfw.getTypeDescription(new File("uniref50.json")),
84 assertEquals(jfw.getTypeDescription(new File("uniref50.pileup")),
86 assertEquals(jfw.getTypeDescription(new File("uniref50.msf")),
88 assertEquals(jfw.getTypeDescription(new File("uniref50.aln")),
90 assertEquals(jfw.getTypeDescription(new File("uniref50.phy")),
92 assertEquals(jfw.getTypeDescription(new File("uniref50.gff2")),
93 "GFF or Jalview features file");
94 assertEquals(jfw.getTypeDescription(new File("uniref50.gff3")),
95 "GFF or Jalview features file");
96 assertEquals(jfw.getTypeDescription(new File("uniref50.pdb")),
98 assertEquals(jfw.getTypeDescription(new File("uniref50.ent")),
100 assertEquals(jfw.getTypeDescription(new File("uniref50.cif")),
102 assertEquals(jfw.getTypeDescription(new File("uniref50.jvp")),
104 assertEquals(jfw.getTypeDescription(new File("uniref50.jar")),
105 "Jalview file (old)");