JAL-3130 Attempting to fix 8 tests that pass on a Mac but not on linux (e.g. jv-bamboo)
authorBen Soares <bsoares@dundee.ac.uk>
Thu, 13 Dec 2018 09:27:46 +0000 (09:27 +0000)
committerBen Soares <bsoares@dundee.ac.uk>
Thu, 13 Dec 2018 09:27:46 +0000 (09:27 +0000)
src/jalview/gui/Desktop.java
src/jalview/io/FileLoader.java
test/jalview/ext/htsjdk/TestHtsContigDb.java
test/jalview/util/PlatformTest.java

index 9e8624a..874c619 100644 (file)
@@ -381,83 +381,84 @@ public class Desktop extends jalview.jbgui.GDesktop
       try
       {
 
-       if (Platform.isAMac())
-       {
-               if (desktopClass.getDeclaredMethod("setAboutHandler",
-                       new Class[]
-                       { AboutHandler.class }) != null)
-               {
-
-                 hdesktop.setAboutHandler(new AboutHandler()
-                 {
-                   @Override
-                   public void handleAbout(AboutEvent e)
-                   {
-                     aboutMenuItem_actionPerformed(null);
-                   }
-                 });
-
-               }
-
-               if (desktopClass.getDeclaredMethod("setPreferencesHandler",
-                       new Class[]
-                       { PreferencesHandler.class }) != null)
-               {
-
-                 hdesktop.setPreferencesHandler(new PreferencesHandler()
-                 {
-                   @Override
-                   public void handlePreferences(PreferencesEvent e)
-                   {
-                     preferences_actionPerformed(null);
-                   }
-                 });
-
-               }
-
-               if (desktopClass.getDeclaredMethod("setQuitHandler",
-                       new Class[]
-                       { QuitHandler.class }) != null)
-               {
-
-                 hdesktop.setQuitHandler(new QuitHandler()
-                 {
-                   @Override
-                   public void handleQuitRequestWith(QuitEvent e, QuitResponse r)
-                   {
-                     boolean confirmQuit = jalview.bin.Cache
-                             .getDefault(CONFIRM_KEYBOARD_QUIT, true);
-                     int n;
-                     if (confirmQuit)
-                     {
-                       n = JOptionPane.showConfirmDialog(null,
-                               MessageManager.getString("label.quit_jalview"),
-                               MessageManager.getString("action.quit"),
-                               JOptionPane.OK_CANCEL_OPTION,
-                               JOptionPane.PLAIN_MESSAGE, null);
-                     }
-                     else
-                     {
-                       n = JOptionPane.OK_OPTION;
-                     }
-                     if (n == JOptionPane.OK_OPTION)
-                     {
-                       System.out.println("Shortcut Quit confirmed by user");
-                       quit();
-                       r.performQuit(); // probably won't reach this line, but just in
-                                        // case
-                     }
-                     else
-                     {
-                       r.cancelQuit();
-                       System.out.println("Shortcut Quit cancelled by user");
-                     }
-                   }
-                 });
-                 hdesktop.setQuitStrategy(QuitStrategy.CLOSE_ALL_WINDOWS);
-
-               }
-       }
+        if (Platform.isAMac())
+        {
+          if (desktopClass.getDeclaredMethod("setAboutHandler",
+                  new Class[]
+                  { AboutHandler.class }) != null)
+          {
+
+            hdesktop.setAboutHandler(new AboutHandler()
+            {
+              @Override
+              public void handleAbout(AboutEvent e)
+              {
+                aboutMenuItem_actionPerformed(null);
+              }
+            });
+
+          }
+
+          if (desktopClass.getDeclaredMethod("setPreferencesHandler",
+                  new Class[]
+                  { PreferencesHandler.class }) != null)
+          {
+
+            hdesktop.setPreferencesHandler(new PreferencesHandler()
+            {
+              @Override
+              public void handlePreferences(PreferencesEvent e)
+              {
+                preferences_actionPerformed(null);
+              }
+            });
+
+          }
+
+          if (desktopClass.getDeclaredMethod("setQuitHandler",
+                  new Class[]
+                  { QuitHandler.class }) != null)
+          {
+
+            hdesktop.setQuitHandler(new QuitHandler()
+            {
+              @Override
+              public void handleQuitRequestWith(QuitEvent e, QuitResponse r)
+              {
+                boolean confirmQuit = jalview.bin.Cache
+                        .getDefault(CONFIRM_KEYBOARD_QUIT, true);
+                int n;
+                if (confirmQuit)
+                {
+                  n = JOptionPane.showConfirmDialog(null,
+                          MessageManager.getString("label.quit_jalview"),
+                          MessageManager.getString("action.quit"),
+                          JOptionPane.OK_CANCEL_OPTION,
+                          JOptionPane.PLAIN_MESSAGE, null);
+                }
+                else
+                {
+                  n = JOptionPane.OK_OPTION;
+                }
+                if (n == JOptionPane.OK_OPTION)
+                {
+                  System.out.println("Shortcut Quit confirmed by user");
+                  quit();
+                  r.performQuit(); // probably won't reach this line, but just
+                                   // in
+                                   // case
+                }
+                else
+                {
+                  r.cancelQuit();
+                  System.out.println("Shortcut Quit cancelled by user");
+                }
+              }
+            });
+            hdesktop.setQuitStrategy(QuitStrategy.CLOSE_ALL_WINDOWS);
+
+          }
+        }
 
       } catch (NoSuchMethodException e)
       {
@@ -1816,8 +1817,7 @@ public class Desktop extends jalview.jbgui.GDesktop
     final String[] desc = new String[] { "Jalview Project",
         "Jalview Project (old)" };
     JalviewFileChooser chooser = new JalviewFileChooser(
-            Cache.getProperty("LAST_DIRECTORY"), suffix,
-            desc,
+            Cache.getProperty("LAST_DIRECTORY"), suffix, desc,
             "Jalview Project");
     chooser.setFileView(new JalviewFileView());
     chooser.setDialogTitle(MessageManager.getString("label.restore_state"));
index 2a18b0b..78f646c 100755 (executable)
@@ -193,6 +193,9 @@ public class FileLoader implements Runnable
         Thread.sleep(500);
       } catch (Exception ex)
       {
+        System.out.println(
+                "Exception caught while waiting for FileLoader thread");
+        ex.printStackTrace();
       }
     }
 
index 28c5cf0..ad9bf03 100644 (file)
@@ -44,12 +44,12 @@ public class TestHtsContigDb
   @Test(groups = "Functional")
   public final void testGetSequenceProxy() throws Exception
   {
-    String pathname = "test/jalview/ext/htsjdk/pgmb.fasta";
+    String pathname = "test/jalview/ext/htsjdk/pgmB.fasta";
     HtsContigDb db = new HtsContigDb("ADB", new File(pathname));
-    
+
     assertTrue(db.isValid());
     assertTrue(db.isIndexed()); // htsjdk opens the .fai file
-    
+
     SequenceI sq = db.getSequenceProxy("Deminut");
     assertNotNull(sq);
     assertEquals(sq.getLength(), 606);
@@ -60,7 +60,7 @@ public class TestHtsContigDb
     sq = db.getSequenceProxy("PPL_06716");
     assertNotNull(sq);
     assertEquals(sq.getLength(), 602);
-    
+
     // dict = db.getDictionary(f, truncate))
   }
 
@@ -73,7 +73,7 @@ public class TestHtsContigDb
     expectedExceptions = java.lang.IllegalArgumentException.class)
   public final void testGetSequenceProxy_indexed()
   {
-    String pathname = "test/jalview/ext/htsjdk/pgmb.fasta.fai";
+    String pathname = "test/jalview/ext/htsjdk/pgmB.fasta.fai";
     new HtsContigDb("ADB", new File(pathname));
     fail("Expected exception opening .fai file");
   }
@@ -92,16 +92,20 @@ public class TestHtsContigDb
   @Test(groups = "Functional")
   public void testCreateFastaSequenceIndex() throws IOException
   {
-    File fasta = new File("test/jalview/ext/htsjdk/pgmb.fasta");
-    
+    File fasta = new File("test/jalview/ext/htsjdk/pgmB.fasta");
+
     /*
      * create .fai with no overwrite fails if it exists
      */
-    try {
+    try
+    {
       HtsContigDb.createFastaSequenceIndex(fasta.toPath(), false);
       fail("Expected exception");
     } catch (IOException e)
     {
+      System.out.println(
+              "Caught IOException in testCreateFastaSequenceIndex");
+      e.printStackTrace();
       // expected
     }
 
index 307f450..470e64d 100644 (file)
@@ -26,7 +26,7 @@ import static org.testng.Assert.assertTrue;
 import jalview.gui.JvOptionPane;
 
 import java.awt.Button;
-import java.awt.Event;
+import java.awt.event.InputEvent;
 import java.awt.event.MouseEvent;
 
 import org.testng.annotations.BeforeClass;
@@ -61,11 +61,11 @@ public class PlatformTest
     assertFalse(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
             0, 0, clickCount, isPopupTrigger, buttonNo), mac));
 
-    mods = Event.CTRL_MASK;
+    mods = InputEvent.CTRL_DOWN_MASK;
     assertFalse(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
             0, 0, clickCount, isPopupTrigger, buttonNo), mac));
 
-    mods = Event.META_MASK;
+    mods = InputEvent.META_DOWN_MASK;
     assertTrue(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
             0, 0, clickCount, isPopupTrigger, buttonNo), mac));
 
@@ -97,11 +97,12 @@ public class PlatformTest
     assertFalse(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
             0, 0, clickCount, isPopupTrigger, buttonNo), mac));
 
-    mods = Event.CTRL_MASK;
+    mods = InputEvent.CTRL_DOWN_MASK;
     assertTrue(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
             0, 0, clickCount, isPopupTrigger, buttonNo), mac));
 
-    mods = Event.CTRL_MASK | Event.SHIFT_MASK | Event.ALT_MASK;
+    mods = InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK
+            | InputEvent.ALT_DOWN_MASK;
     clickCount = 2;
     buttonNo = 2;
     isPopupTrigger = true;