6 import static org.junit.Assert.*;
9 import java.io.IOException;
11 import org.junit.AfterClass;
12 import org.junit.BeforeClass;
13 import org.junit.Test;
19 public class FileIOTester
23 * @throws java.lang.Exception
26 public static void setUpBeforeClass() throws Exception
31 * @throws java.lang.Exception
34 public static void tearDownAfterClass() throws Exception
37 final static File ALIGN_FILE = new File("test/jalview/io/test_gz_fasta.gz");
38 final static File NOTGZALIGN_FILE = new File("test/jalview/io/test_gz_fasta_notgz.gz");
40 private void assertValidFasta(String src, FileParse fp)
42 assertTrue("Couldn't resolve "+src+" as a valid file",fp.isValid());
43 String type = new IdentifyFile().Identify(fp);
44 assertTrue("Gzipped data from '"+src+"' identified as '"+type+"'",type.equalsIgnoreCase("FASTA"));
47 public void testGzipIo() throws IOException
50 FileParse fp = new FileParse(uri=ALIGN_FILE.getAbsoluteFile().toURI().toString(),AppletFormatAdapter.URL);
51 assertValidFasta(uri, fp);
55 public void testGziplocalFileIO() throws IOException
58 FileParse fp = new FileParse(filepath=ALIGN_FILE.getAbsoluteFile().toString(), AppletFormatAdapter.FILE);
59 assertValidFasta(filepath, fp);
62 public void testNonGzipURLIO() throws IOException
65 FileParse fp = new FileParse(uri=NOTGZALIGN_FILE.getAbsoluteFile().toURI().toString(),AppletFormatAdapter.URL);
66 assertValidFasta(uri, fp);
69 public void testNonGziplocalFileIO() throws IOException
72 FileParse fp = new FileParse(filepath=NOTGZALIGN_FILE.getAbsoluteFile().toString(), AppletFormatAdapter.FILE);
73 assertValidFasta(filepath, fp);