From fd64c343e17a21eb50bcbd1a4e6bf2021a3a81b1 Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Wed, 31 May 2017 11:08:24 +0100 Subject: [PATCH] Fixed failing tests --- src/jalview/io/AppletFormatAdapter.java | 17 +++++++-- test/jalview/ext/jmol/JmolViewerTest.java | 54 +---------------------------- test/jalview/io/FileLoaderTest.java | 10 +++--- 3 files changed, 19 insertions(+), 62 deletions(-) diff --git a/src/jalview/io/AppletFormatAdapter.java b/src/jalview/io/AppletFormatAdapter.java index c5a80e3..907ff46 100755 --- a/src/jalview/io/AppletFormatAdapter.java +++ b/src/jalview/io/AppletFormatAdapter.java @@ -407,15 +407,26 @@ public class AppletFormatAdapter return null; } - public static DataSourceType checkProtocol(String file) + /** + * Determines the protocol (i.e DataSourceType.{FILE|PASTE|URL}) for the input + * data + * + * @param data + * @return the protocol for the input data + */ + public static DataSourceType checkProtocol(String data) { - DataSourceType protocol = DataSourceType.FILE; - String ft = file.toLowerCase().trim(); + DataSourceType protocol = DataSourceType.PASTE; + String ft = data.toLowerCase().trim(); if (ft.indexOf("http:") == 0 || ft.indexOf("https:") == 0 || ft.indexOf("file:") == 0) { protocol = DataSourceType.URL; } + else if (new File(data).exists()) + { + protocol = DataSourceType.FILE; + } return protocol; } diff --git a/test/jalview/ext/jmol/JmolViewerTest.java b/test/jalview/ext/jmol/JmolViewerTest.java index 4a59044..792f7ad 100644 --- a/test/jalview/ext/jmol/JmolViewerTest.java +++ b/test/jalview/ext/jmol/JmolViewerTest.java @@ -33,7 +33,6 @@ 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; @@ -117,56 +116,5 @@ 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; - } - } - } + } diff --git a/test/jalview/io/FileLoaderTest.java b/test/jalview/io/FileLoaderTest.java index 0e21f6e..968901f 100644 --- a/test/jalview/io/FileLoaderTest.java +++ b/test/jalview/io/FileLoaderTest.java @@ -14,11 +14,9 @@ public class FileLoaderTest fileLoader.LoadFileWaitTillLoaded(urlFile, DataSourceType.URL, FileFormat.PDB); Assert.assertNotNull(fileLoader.file); - // The FileLoader's file is expected to a temporary file different from the - // original URL. - Assert.assertNotEquals(urlFile, fileLoader.file); - // Data source type expected to be updated from DataSourceType.URL to - // DataSourceType.FILE - Assert.assertEquals(DataSourceType.FILE, fileLoader.protocol); + // The FileLoader's file is expected to be same as the original URL. + Assert.assertEquals(urlFile, fileLoader.file); + // Data source type expected to be DataSourceType.URL + Assert.assertEquals(DataSourceType.URL, fileLoader.protocol); } } -- 1.7.10.2