From 6f9b0cd13d25cf041aed033652e87f2d547cba52 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Mon, 22 Aug 2016 16:42:53 +0100 Subject: [PATCH] JAL-2154 - rejig test pass code for breadth-first (or top down) repetition of fetch/fetch crossref/fetch crossref. * First iteration, all pass counters at zero, process through all crossrefs. * Next iteration, pass1=1 - recover, process through all crossers * Next iteration, pass2=1 - recover each first crossref result and process through * Last iteration, pass3=1 - recover each second crossref result and process. --- test/jalview/io/CrossRef2xmlTests.java | 43 ++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/test/jalview/io/CrossRef2xmlTests.java b/test/jalview/io/CrossRef2xmlTests.java index 64c800b..20a95d0 100644 --- a/test/jalview/io/CrossRef2xmlTests.java +++ b/test/jalview/io/CrossRef2xmlTests.java @@ -20,8 +20,6 @@ */ package jalview.io; -import static org.testng.AssertJUnit.assertTrue; - import jalview.analysis.CrossRef; import jalview.api.AlignmentViewPanel; import jalview.datamodel.AlignedCodonFrame; @@ -100,7 +98,7 @@ public class CrossRef2xmlTests extends Jalview2xmlBase af = jalview.gui.SequenceFetcher.fetchAndShow(did[0], did[1]) .get(0); - assertTrue("Didn't retrieve " + first, af != null); + Assert.assertTrue(af != null, "Didn't retrieve " + first); // verify references for retrieved data AlignmentTest.assertAlignmentDatasetRefs(af.getViewport() @@ -140,8 +138,7 @@ public class CrossRef2xmlTests extends Jalview2xmlBase // start of pass2: retrieve each cross-ref for fetched or restored // project. - pass2 = 0; - do // second cross ref and recover crossref loop + do // first cross ref and recover crossref loop { for (String db : ptypes) @@ -153,6 +150,7 @@ public class CrossRef2xmlTests extends Jalview2xmlBase // perform crossref action, or retrieve stored project List cra_views = new ArrayList(); CrossRefAction cra = null; + if (pass2 == 0) { // retrieve and show cross-refs in this thread cra = new CrossRefAction(af, seqs, dna, db); @@ -164,6 +162,7 @@ public class CrossRef2xmlTests extends Jalview2xmlBase else { Desktop.instance.closeAll_actionPerformed(null); + pass3 = 0; // recover stored project AlignFrame af2 = new FileLoader(false) .LoadFileWaitTillLoaded(savedProjects.get(nextxref) @@ -213,11 +212,10 @@ public class CrossRef2xmlTests extends Jalview2xmlBase xrptypes.put(nextxref, _xrptypes); } - // now do the next xref pass starting from either saved or just + + // now do the second xref pass starting from either saved or just // recovered split pane, in sequence - pass3 = 0; - do // 3rd cross ref and recover crossref loop, for each view from - // second xref view set or recover viewset + do // retrieve second set of cross refs or recover and verify { firstcr_ap = 0; for (AlignmentViewPanel avp : cra_views) @@ -302,20 +300,39 @@ public class CrossRef2xmlTests extends Jalview2xmlBase } // end of loop around showing all xrefdb for crossrf2 } // end of loop around all viewpanels from crossrf1 - } while (pass3++ < 2 && pass2 < 1); + } while (pass2 == 2 && pass3++ < 2); // fetchdb->crossref1->crossref-2->verify for xrefs we // either loop twice when pass2=0, or just once when pass2=1 // (recovered project from previous crossref) - } + } // end of loop over db-xrefs for crossref-2 + // fetchdb-->crossref1 // for each xref we try to retrieve xref, store and verify when // pass1=0, or just retrieve and verify when pass1=1 - } while (pass2++ < 2 && pass1 < 1); + } while (pass1 == 1 && pass2++ < 2); // fetchdb // for each ref we // loop twice: first, do the retrieve, second recover from saved project - } while (pass1++ < 2); + + // increment pass counters, so we repeat traversal starting from the + // oldest saved project first. + if (pass1 == 0) + { + // verify stored projects for first set of cross references + pass1 = 1; + // and verify cross-references retrieved from stored projects + pass2 = 0; + pass3 = 0; + } + else + { + // verify stored projects for second set of cross references + pass2 = 1; + // and verify cross-references retrievable from those stored projects. + pass3 = 0; + } + } while (pass3 < 2); } } -- 1.7.10.2