From: Jim Procter Date: Mon, 17 Feb 2020 16:08:40 +0000 (+0000) Subject: JAL-3536 failing test and test data X-Git-Tag: Develop-2_11_2_0-d20201215~105 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=a2f7344964ddf564fdb4f1bfcded3dfd6f794707;p=jalview.git JAL-3536 failing test and test data --- diff --git a/examples/testdata/CantShowEnsemblCrossrefsTwice.jvp b/examples/testdata/CantShowEnsemblCrossrefsTwice.jvp new file mode 100644 index 0000000..5e32d55 Binary files /dev/null and b/examples/testdata/CantShowEnsemblCrossrefsTwice.jvp differ diff --git a/test/jalview/io/CrossRef2xmlTests.java b/test/jalview/io/CrossRef2xmlTests.java index 53a0acb..ae5ed25 100644 --- a/test/jalview/io/CrossRef2xmlTests.java +++ b/test/jalview/io/CrossRef2xmlTests.java @@ -20,6 +20,10 @@ */ 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 source = new CrossRef(origAlig.getSequencesArray(), + origAlig.getDataset()).findXrefSourcesForSequences(true); + assertEquals(source.size(), 1, "Expected just one crossref to show."); + List 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) 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) 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() {