2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
3 * Copyright (C) 2014 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 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
17 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 import static org.junit.Assert.*;
24 import java.io.IOException;
26 import org.junit.AfterClass;
27 import org.junit.BeforeClass;
28 import org.junit.Test;
34 public class FileIOTester
38 * @throws java.lang.Exception
41 public static void setUpBeforeClass() throws Exception
46 * @throws java.lang.Exception
49 public static void tearDownAfterClass() throws Exception
52 // TODO: make a better/more comprehensive test harness for identify/io
54 final static File ALIGN_FILE = new File("test/jalview/io/test_gz_fasta.gz");
55 final static File NOTGZALIGN_FILE = new File("test/jalview/io/test_gz_fasta_notgz.gz");
57 private void assertValidFormat(String fmt, String src, FileParse fp)
59 assertTrue("Couldn't resolve "+src+" as a valid file",fp.isValid());
60 String type = new IdentifyFile().Identify(fp);
61 assertTrue("Data from '"+src+"' Expected to be '"+fmt+"' identified as '"+type+"'",type.equalsIgnoreCase(fmt));
64 public void testGzipIo() throws IOException
67 FileParse fp = new FileParse(uri=ALIGN_FILE.getAbsoluteFile().toURI().toString(),AppletFormatAdapter.URL);
68 assertValidFormat("FASTA", uri, fp);
72 public void testGziplocalFileIO() throws IOException
75 FileParse fp = new FileParse(filepath=ALIGN_FILE.getAbsoluteFile().toString(), AppletFormatAdapter.FILE);
76 assertValidFormat("FASTA",filepath, fp);
79 public void testNonGzipURLIO() throws IOException
82 FileParse fp = new FileParse(uri=NOTGZALIGN_FILE.getAbsoluteFile().toURI().toString(),AppletFormatAdapter.URL);
83 assertValidFormat("FASTA",uri, fp);
86 public void testNonGziplocalFileIO() throws IOException
89 FileParse fp = new FileParse(filepath=NOTGZALIGN_FILE.getAbsoluteFile().toString(), AppletFormatAdapter.FILE);
90 assertValidFormat("FASTA",filepath, fp);