From: Jim Procter Date: Thu, 7 Nov 2013 13:49:15 +0000 (+0000) Subject: JAL-1286 additional tests to ensure that non-GZ files with a .gz at end X-Git-Tag: Jalview_2_9~215^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=9809e9cda7fea9968e6e50696b215a591f6172d3;p=jalview.git JAL-1286 additional tests to ensure that non-GZ files with a .gz at end are read in correctly --- diff --git a/test/jalview/io/FileIOTester.java b/test/jalview/io/FileIOTester.java index 20f6d0f..a2aa5da 100644 --- a/test/jalview/io/FileIOTester.java +++ b/test/jalview/io/FileIOTester.java @@ -34,16 +34,21 @@ public class FileIOTester public static void tearDownAfterClass() throws Exception { } -final static File ALIGN_FILE = new File("test/jalview/io/test_gz_fasta.gz"); + final static File ALIGN_FILE = new File("test/jalview/io/test_gz_fasta.gz"); + final static File NOTGZALIGN_FILE = new File("test/jalview/io/test_gz_fasta_notgz.gz"); + private void assertValidFasta(String src, FileParse fp) + { + assertTrue("Couldn't resolve "+src+" as a valid file",fp.isValid()); + String type = new IdentifyFile().Identify(fp); + assertTrue("Gzipped data from '"+src+"' identified as '"+type+"'",type.equalsIgnoreCase("FASTA")); + } @Test public void testGzipIo() throws IOException { String uri; FileParse fp = new FileParse(uri=ALIGN_FILE.getAbsoluteFile().toURI().toString(),AppletFormatAdapter.URL); - assertTrue("Couldn't resolve "+uri+" as a valid file",fp.isValid()); - String type = new IdentifyFile().Identify(fp); - assertTrue("Gzipped data from '"+uri+"' identified as '"+type+"'",type.equalsIgnoreCase("FASTA")); + assertValidFasta(uri, fp); } @Test @@ -51,9 +56,20 @@ final static File ALIGN_FILE = new File("test/jalview/io/test_gz_fasta.gz"); { String filepath; FileParse fp = new FileParse(filepath=ALIGN_FILE.getAbsoluteFile().toString(), AppletFormatAdapter.FILE); - assertTrue("Couldn't resolve " + filepath + " as a valid file", fp.isValid()); - String type = new IdentifyFile().Identify(fp); - assertTrue("Gzipped data from '" + filepath + "' identified as '" + type - + "'", type.equalsIgnoreCase("FASTA")); + assertValidFasta(filepath, fp); + } + @Test + public void testNonGzipURLIO() throws IOException + { + String uri; + FileParse fp = new FileParse(uri=NOTGZALIGN_FILE.getAbsoluteFile().toURI().toString(),AppletFormatAdapter.URL); + assertValidFasta(uri, fp); + } + @Test + public void testNonGziplocalFileIO() throws IOException + { + String filepath; + FileParse fp = new FileParse(filepath=NOTGZALIGN_FILE.getAbsoluteFile().toString(), AppletFormatAdapter.FILE); + assertValidFasta(filepath, fp); } }