From dc907895da88980fabf5df80a8967bc6332fe883 Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Tue, 28 Mar 2017 18:04:46 +0100 Subject: [PATCH] JAL-2465 unit test for bugfix --- test/jalview/ext/jmol/JmolViewerTest.java | 54 +++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/test/jalview/ext/jmol/JmolViewerTest.java b/test/jalview/ext/jmol/JmolViewerTest.java index 995b099..8f616de 100644 --- a/test/jalview/ext/jmol/JmolViewerTest.java +++ b/test/jalview/ext/jmol/JmolViewerTest.java @@ -33,6 +33,7 @@ import jalview.gui.StructureViewer; import jalview.gui.StructureViewer.ViewerType; import jalview.io.DataSourceType; +import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -115,4 +116,57 @@ public class JmolViewerTest } } } + + @Test(groups = { "Functional, Network" }) + public void testStructureLoadingViaURL() + { + Cache.setProperty(Preferences.STRUCTURE_DISPLAY, ViewerType.JMOL.name()); + String inFile = "http://www.jalview.org/builds/develop/examples/3W5V.pdb"; + AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded( + inFile, DataSourceType.URL); + assertTrue("Didn't read input file " + inFile, af != null); + for (SequenceI sq : af.getViewport().getAlignment().getSequences()) + { + SequenceI dsq = sq.getDatasetSequence(); + while (dsq.getDatasetSequence() != null) + { + dsq = dsq.getDatasetSequence(); + } + if (dsq.getAllPDBEntries() != null + && dsq.getAllPDBEntries().size() > 0) + { + for (int q = 0; q < dsq.getAllPDBEntries().size(); q++) + { + final StructureViewer structureViewer = new StructureViewer(af + .getViewport().getStructureSelectionManager()); + structureViewer.setViewerType(ViewerType.JMOL); + JalviewStructureDisplayI jmolViewer = structureViewer + .viewStructures(dsq.getAllPDBEntries().elementAt(q), + new SequenceI[] { sq }, af.getCurrentView() + .getAlignPanel()); + /* + * Wait for viewer load thread to complete + */ + try + { + while (!jmolViewer.getBinding().isFinishedInit()) + { + Thread.sleep(500); + } + } catch (InterruptedException e) + { + } + // System.out.println(">>>>>>>>>>>>>>>>> " + // + jmolViewer.getBinding().getPdbFile()); + String[] expectedModelFiles = new String[] { "http://www.jalview.org/builds/develop/examples/3W5V.pdb" }; + String[] actualModelFiles = jmolViewer.getBinding().getStructureFiles(); + Assert.assertEqualsNoOrder(actualModelFiles, expectedModelFiles); + jmolViewer.closeViewer(true); + // todo: break here means only once through this loop? + break; + } + break; + } + } + } } -- 1.7.10.2