From 760dedc94f18a8ec1919b2aa488b937e059c91fd Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Thu, 20 Feb 2014 15:15:40 +0000 Subject: [PATCH] JAL-1447 - more flexible testing for file format Identity detection --- test/jalview/io/FileIOTester.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/test/jalview/io/FileIOTester.java b/test/jalview/io/FileIOTester.java index 2b975a2..d438424 100644 --- a/test/jalview/io/FileIOTester.java +++ b/test/jalview/io/FileIOTester.java @@ -49,21 +49,23 @@ public class FileIOTester public static void tearDownAfterClass() throws Exception { } + // TODO: make a better/more comprehensive test harness for identify/io + 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) + private void assertValidFormat(String fmt, 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")); + assertTrue("Data from '"+src+"' Expected to be '"+fmt+"' identified as '"+type+"'",type.equalsIgnoreCase(fmt)); } @Test public void testGzipIo() throws IOException { String uri; FileParse fp = new FileParse(uri=ALIGN_FILE.getAbsoluteFile().toURI().toString(),AppletFormatAdapter.URL); - assertValidFasta(uri, fp); + assertValidFormat("FASTA", uri, fp); } @Test @@ -71,20 +73,20 @@ public class FileIOTester { String filepath; FileParse fp = new FileParse(filepath=ALIGN_FILE.getAbsoluteFile().toString(), AppletFormatAdapter.FILE); - assertValidFasta(filepath, fp); + assertValidFormat("FASTA",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); + assertValidFormat("FASTA",uri, fp); } @Test public void testNonGziplocalFileIO() throws IOException { String filepath; FileParse fp = new FileParse(filepath=NOTGZALIGN_FILE.getAbsoluteFile().toString(), AppletFormatAdapter.FILE); - assertValidFasta(filepath, fp); + assertValidFormat("FASTA",filepath, fp); } } -- 1.7.10.2