JAL-2422 test updated
[jalview.git] / test / jalview / ext / ensembl / EnsemblXrefTest.java
index 9ef2843..07f8892 100644 (file)
@@ -24,17 +24,27 @@ import static org.testng.AssertJUnit.assertEquals;
 import static org.testng.AssertJUnit.assertFalse;
 
 import jalview.datamodel.DBRefEntry;
+import jalview.gui.JvOptionPane;
+import jalview.util.JSONUtils;
 
-import java.io.BufferedReader;
 import java.io.IOException;
-import java.io.StringReader;
 import java.net.URL;
 import java.util.List;
 
+import org.json.simple.parser.ParseException;
+import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
 public class EnsemblXrefTest
 {
+
+  @BeforeClass(alwaysRun = true)
+  public void setUpJvOptionPane()
+  {
+    JvOptionPane.setInteractiveMode(false);
+    JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+  }
+
   //@formatter:off
   private static final String JSON = 
           "[{\"primary_id\":\"CCDS5863\",\"dbname\":\"CCDS\"}," +
@@ -51,12 +61,13 @@ public class EnsemblXrefTest
     EnsemblXref testee = new EnsemblXref("http://rest.ensembl.org", dbName,
             dbVers)
     {
-      @Override
-      protected BufferedReader getHttpResponse(URL url, List<String> ids)
-              throws IOException
-      {
-        return new BufferedReader(new StringReader(JSON));
-      }
+      @SuppressWarnings("unchecked")
+         @Override
+         protected Object getJSON(URL url, List<String> ids, int msDelay, int mode, String mapKey) throws IOException, ParseException 
+         {
+         return ((List<Object>)JSONUtils.parse(JSON)).iterator();
+         }
+
     };
 
     // synonyms and GO terms are not returned