Merge JAL-2136_phyre2_integration to develop
[jalview.git] / src / jalview / ws / sifts / SiftsClient.java
index 716a047..1328260 100644 (file)
@@ -73,6 +73,12 @@ import javax.xml.stream.XMLStreamReader;
 public class SiftsClient extends StructureMappingClient implements
         SiftsClientI
 {
+  /*
+   * for use in mocking out file fetch for tests only
+   * - reset to null after testing!
+   */
+  private static File mockSiftsFile;
+
   private Entry siftsEntry;
 
   private String pdbId;
@@ -182,6 +188,14 @@ public class SiftsClient extends StructureMappingClient implements
    */
   public static File getSiftsFile(String pdbId) throws SiftsException
   {
+    /*
+     * return mocked file if it has been set
+     */
+    if (mockSiftsFile != null)
+    {
+      return mockSiftsFile;
+    }
+
     String siftsFileName = SiftsSettings.getSiftDownloadDirectory()
             + pdbId.toLowerCase() + ".xml.gz";
     File siftsFile = new File(siftsFileName);
@@ -1033,4 +1047,9 @@ public class SiftsClient extends StructureMappingClient implements
     return siftsEntry.getDbVersion();
   }
 
+  public static void setMockSiftsFile(File file)
+  {
+    mockSiftsFile = file;
+  }
+
 }