JAL-2071 improvement to get column data files as InputStream
authortcofoegbu <tcnofoegbu@dundee.ac.uk>
Tue, 26 Apr 2016 12:00:43 +0000 (13:00 +0100)
committertcofoegbu <tcnofoegbu@dundee.ac.uk>
Tue, 26 Apr 2016 12:00:43 +0000 (13:00 +0100)
src/jalview/fts/core/FTSRestClient.java
src/jalview/fts/service/pdb/PDBFTSRestClient.java
src/jalview/fts/service/uniprot/UniProtFTSRestClient.java
test/jalview/fts/core/FTSRestClientTest.java

index f611d5b..0605fef 100644 (file)
@@ -5,8 +5,9 @@ import jalview.fts.api.FTSDataColumnI.FTSDataColumnGroupI;
 import jalview.fts.api.FTSRestClientI;
 
 import java.io.BufferedReader;
-import java.io.FileReader;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Objects;
@@ -43,7 +44,10 @@ public abstract class FTSRestClient implements FTSRestClientI
   public void parseDataColumnsConfigFile()
   {
     String fileName = getColumnDataConfigFileName();
-    try (BufferedReader br = new BufferedReader(new FileReader(fileName)))
+    
+    InputStream in = getClass().getResourceAsStream(fileName); 
+    
+    try (BufferedReader br = new BufferedReader(new InputStreamReader(in)))
     {
       String line;
       while ((line = br.readLine()) != null)
index 28e06d2..08803b0 100644 (file)
@@ -413,7 +413,7 @@ public class PDBFTSRestClient extends FTSRestClient
   @Override
   public String getColumnDataConfigFileName()
   {
-    return getResourceFile("/fts/pdb_data_columns.txt");
+    return "/fts/pdb_data_columns.txt";
   }
 
 
index 15c699e..c8e21e0 100644 (file)
@@ -217,7 +217,7 @@ public class UniProtFTSRestClient extends FTSRestClient
   @Override
   public String getColumnDataConfigFileName()
   {
-    return getResourceFile("/fts/uniprot_data_columns.txt");
+    return "/fts/uniprot_data_columns.txt";
   }
 
 }
index 4a90c4e..a5c6390 100644 (file)
@@ -24,7 +24,7 @@ public class FTSRestClientTest
       @Override
       public String getColumnDataConfigFileName()
       {
-        return "examples/testdata/test_fts_data_columns.conf";
+        return "/fts/uniprot_data_columns.txt";
       }
 
       @Override
@@ -272,7 +272,7 @@ public class FTSRestClientTest
     }
 
     String actualResourseFile = ftsRestClient
-            .getResourceFile("fts/uniprot_data_columns.conf");
+            .getResourceFile("/fts/uniprot_data_columns.txt");
     Assert.assertNotNull(actualResourseFile);
     Assert.assertTrue(actualResourseFile.length() > 31);
   }