JAL-1447 - more flexible testing for file format Identity detection
authorJim Procter <jprocter@compbio.dundee.ac.uk>
Thu, 20 Feb 2014 15:15:40 +0000 (15:15 +0000)
committerJim Procter <jprocter@compbio.dundee.ac.uk>
Thu, 20 Feb 2014 15:16:55 +0000 (15:16 +0000)
test/jalview/io/FileIOTester.java

index 2b975a2..d438424 100644 (file)
@@ -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);
   }
 }