JAL-3536 failing test and test data
authorJim Procter <jprocter@issues.jalview.org>
Mon, 17 Feb 2020 16:08:40 +0000 (16:08 +0000)
committerJim Procter <jprocter@issues.jalview.org>
Mon, 17 Feb 2020 16:08:40 +0000 (16:08 +0000)
examples/testdata/CantShowEnsemblCrossrefsTwice.jvp [new file with mode: 0644]
test/jalview/io/CrossRef2xmlTests.java

diff --git a/examples/testdata/CantShowEnsemblCrossrefsTwice.jvp b/examples/testdata/CantShowEnsemblCrossrefsTwice.jvp
new file mode 100644 (file)
index 0000000..5e32d55
Binary files /dev/null and b/examples/testdata/CantShowEnsemblCrossrefsTwice.jvp differ
index 53a0acb..ae5ed25 100644 (file)
  */
 package jalview.io;
 
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
 import jalview.analysis.CrossRef;
 import jalview.api.AlignmentViewPanel;
 import jalview.datamodel.AlignedCodonFrame;
@@ -60,6 +64,51 @@ public class CrossRef2xmlTests extends Jalview2xmlBase
     JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
   }
 
+  @Test(groups = { "Functional" }, enabled = true)
+  public void openCrossrefsForEnsemblTwice()
+  {
+    AlignFrame af = new FileLoader(false).LoadFileWaitTillLoaded(
+            "examples/testdata/CantShowEnsemblCrossrefsTwice.jvp",
+            DataSourceType.FILE);
+    assertNotNull(af, "Couldn't load test's project.");
+    AlignmentI origAlig = af.getViewport().getAlignment();
+    List<String> source = new CrossRef(origAlig.getSequencesArray(),
+            origAlig.getDataset()).findXrefSourcesForSequences(true);
+    assertEquals(source.size(), 1, "Expected just one crossref to show.");
+    List<AlignmentViewPanel> views;
+    {
+      // try to show once - in a code block so handler is forgotten about
+      CrossRefAction xref1 = CrossRefAction.getHandlerFor(
+              origAlig.getSequencesArray(), true, source.get(0), af);
+      try
+      {
+        xref1.run();
+        views = (List<AlignmentViewPanel>) PA.getValue(xref1, "xrefViews");
+        assertTrue(views.size() > 0,
+                "Couldn't get cross ref on first attempt (SERIOUS FAIL).");
+      } catch (Exception ex)
+      {
+        Assert.fail("Unexpected Exception for first xref action", ex);
+      }
+    }
+
+    views = null;
+    // now just try it again
+    CrossRefAction xref2 = CrossRefAction.getHandlerFor(
+            origAlig.getSequencesArray(), true, source.get(0), af);
+    try
+    {
+      xref2.run();
+      views = (List<AlignmentViewPanel>) PA.getValue(xref2, "xrefViews");
+      assertTrue(views.size() > 0,
+              "Couldn't get cross ref on second attempt (SERIOUS FAIL).");
+    } catch (Exception ex)
+    {
+      Assert.fail("Unexpected Exception for second xref action", ex);
+    }
+    // TODO : check that both views contain the same data
+  }
+
   @DataProvider(name = "initialAccessions")
   static Object[][] getAccessions()
   {