JAL-1286 additional tests to ensure that non-GZ files with a .gz at end
authorJim Procter <jprocter@compbio.dundee.ac.uk>
Thu, 7 Nov 2013 13:49:15 +0000 (13:49 +0000)
committerJim Procter <jprocter@compbio.dundee.ac.uk>
Thu, 7 Nov 2013 13:49:15 +0000 (13:49 +0000)
are read in correctly

test/jalview/io/FileIOTester.java

index 20f6d0f..a2aa5da 100644 (file)
@@ -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);
   }
 }