JAL-1988 JAL-3130 New jlinked JRE in jalview_java2 with modules. Still needs jaxws...
[jalview.git] / test / jalview / io / JalviewFileViewTest.java
1 package jalview.io;
2
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;
8
9 import java.io.File;
10
11 import javax.swing.ImageIcon;
12
13 import org.testng.annotations.Test;
14
15 public class JalviewFileViewTest
16 {
17   @Test(groups = "Functional")
18   public void testGetImageIcon()
19   {
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");
25
26     /*
27      * verify a single image object is served per file path
28      */
29     assertNotNull(icon1);
30     assertSame(icon1, icon2);
31     assertNotNull(icon3);
32     assertSame(icon3, icon4);
33     assertNotSame(icon1, icon3);
34
35     assertNull(jfv.getImageIcon("/images/nosuchfile.png"));
36     assertNull(jfv.getImageIcon("images/file.png"));
37   }
38
39   @Test(groups = "Functional")
40   public void testGetExtension()
41   {
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")));
49   }
50
51   @Test(groups = "Functional")
52   public void testGetTypeDescription()
53   {
54     JalviewFileView jfw = new JalviewFileView();
55     assertEquals(jfw.getTypeDescription(new File("uniref50.fa")),
56             "Fasta file");
57     assertEquals(jfw.getTypeDescription(new File("uniref50.fasta")),
58             "Fasta file");
59     assertEquals(jfw.getTypeDescription(new File("uniref50.MFA")),
60             "Fasta file");
61     assertEquals(jfw.getTypeDescription(new File("uniref50.fastQ")),
62             "Fasta file");
63     assertEquals(jfw.getTypeDescription(new File("uniref50.pfam")),
64             "PFAM file");
65     assertEquals(jfw.getTypeDescription(new File("uniref50.stk")),
66             "Stockholm file");
67     assertEquals(jfw.getTypeDescription(new File("uniref50.sto")),
68             "Stockholm file");
69     assertEquals(jfw.getTypeDescription(new File("uniref50.pir")),
70             "PIR file");
71     assertEquals(jfw.getTypeDescription(new File("uniref50.blc")),
72             "BLC file");
73     assertEquals(jfw.getTypeDescription(new File("uniref50.amsa")),
74             "AMSA file");
75     assertEquals(jfw.getTypeDescription(new File("uniref50.html")),
76             "HTML file");
77     assertNull(jfw.getTypeDescription(new File("uniref50.htm")));
78     assertEquals(jfw.getTypeDescription(new File("uniref50.xml")),
79             "RNAML file");
80     assertEquals(jfw.getTypeDescription(new File("uniref50.rnaml")),
81             "RNAML file");
82     assertEquals(jfw.getTypeDescription(new File("uniref50.json")),
83             "JSON file");
84     assertEquals(jfw.getTypeDescription(new File("uniref50.pileup")),
85             "PileUp file");
86     assertEquals(jfw.getTypeDescription(new File("uniref50.msf")),
87             "MSF file");
88     assertEquals(jfw.getTypeDescription(new File("uniref50.aln")),
89             "Clustal file");
90     assertEquals(jfw.getTypeDescription(new File("uniref50.phy")),
91             "PHYLIP file");
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")),
97             "PDB file");
98     assertEquals(jfw.getTypeDescription(new File("uniref50.ent")),
99             "PDB file");
100     assertEquals(jfw.getTypeDescription(new File("uniref50.cif")),
101             "mmCIF file");
102     assertEquals(jfw.getTypeDescription(new File("uniref50.jvp")),
103             "Jalview file");
104     assertEquals(jfw.getTypeDescription(new File("uniref50.jar")),
105             "Jalview file (old)");
106   }
107 }