JAL-4121 Added a NPE check caught in tests. Added --gui to relevant tests.
authorBen Soares <b.soares@dundee.ac.uk>
Sat, 27 May 2023 21:47:45 +0000 (22:47 +0100)
committerBen Soares <b.soares@dundee.ac.uk>
Sat, 27 May 2023 21:47:45 +0000 (22:47 +0100)
src/jalview/bin/Jalview.java
test/jalview/bin/CommandsTest.java
test/jalview/bin/CommandsTest2.java

index 159cf75..7535f60 100755 (executable)
@@ -451,11 +451,14 @@ public class Jalview
                 .getDefault("DEFAULT_CLOSE_EXTERNAL_VIEWERS", false)
                 || Cache.getDefault("ALWAYS_CLOSE_EXTERNAL_VIEWERS", false);
         StructureViewerBase.setQuitClose(closeExternal);
-        for (JInternalFrame frame : Desktop.desktop.getAllFrames())
+        if (desktop != null)
         {
-          if (frame instanceof StructureViewerBase)
+          for (JInternalFrame frame : Desktop.desktop.getAllFrames())
           {
-            ((StructureViewerBase) frame).closeViewer(closeExternal);
+            if (frame instanceof StructureViewerBase)
+            {
+              ((StructureViewerBase) frame).closeViewer(closeExternal);
+            }
           }
         }
 
index 7ed1ea3..b4c927b 100644 (file)
@@ -70,7 +70,7 @@ public class CommandsTest
   public void commandsOpenTest(String cmdLine, boolean cmdArgs,
           int numFrames, String[] sequences)
   {
-    String[] args = cmdLine.split("\\s+");
+    String[] args = (cmdLine + " --gui").split("\\s+");
     Jalview.main(args);
     Commands cmds = Jalview.getInstance().getCommands();
     Assert.assertNotNull(cmds);
@@ -110,7 +110,7 @@ public class CommandsTest
           throws IOException
   {
     cleanupFiles(filenames);
-    String[] args = cmdLine.split("\\s+");
+    String[] args = (cmdLine + " --gui").split("\\s+");
     Jalview.main(args);
     Commands cmds = Jalview.getInstance().getCommands();
     Assert.assertNotNull(cmds);
@@ -138,7 +138,7 @@ public class CommandsTest
           String[] filenames) throws IOException
   {
     cleanupFiles(filenames);
-    String[] args = cmdLine.split("\\s+");
+    String[] args = (cmdLine + " --gui").split("\\s+");
     Jalview.main(args);
     Commands cmds = Jalview.getInstance().getCommands();
     Assert.assertNotNull(cmds);
@@ -166,7 +166,7 @@ public class CommandsTest
   {
     return new Object[][] {
         //
-        { "--nonews --nosplash --open=./examples/test_fab41.result/sample.a2m "
+        { "--gui --nonews --nosplash --open=./examples/test_fab41.result/sample.a2m "
                 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb "
                 + "--structureimage=" + testfiles + "/structureimage1.png "
                 + "--open=./examples/test_fab41.result/sample.a2m "
@@ -208,18 +208,18 @@ public class CommandsTest
   {
     return new Object[][] {
         //
-        { "--argfile=" + testfiles + "/**/*.txt", new String[]
+        { "--gui --argfile=" + testfiles + "/**/*.txt", new String[]
         { testfiles + "/dir1/test1.png", testfiles + "/dir2/test1.png",
             testfiles + "/dir3/subdir/test0.png" } },
-        { "--argfile=" + testfiles + "/**/argfile.txt", new String[]
+        { "--gui --argfile=" + testfiles + "/**/argfile.txt", new String[]
         { testfiles + "/dir1/test1.png", testfiles + "/dir2/test1.png" } },
-        { "--argfile=" + testfiles + "/dir*/argfile.txt", new String[]
+        { "--gui --argfile=" + testfiles + "/dir*/argfile.txt", new String[]
         { testfiles + "/dir1/test1.png", testfiles + "/dir2/test1.png" } },
-        { "--initsubstitutions --append examples/uniref50.fa --image "
+        { "--gui --initsubstitutions --append examples/uniref50.fa --image "
                 + testfiles + "/{basename}.png",
             new String[]
             { testfiles + "/uniref50.png" } },
-        { "--append examples/uniref50.fa --nosubstitutions --image "
+        { "--gui --append examples/uniref50.fa --nosubstitutions --image "
                 + testfiles + "/{basename}.png",
             new String[]
             { testfiles + "/{basename}.png" } }
@@ -252,11 +252,11 @@ public class CommandsTest
         { "examples/uniref50.fa " + testfiles + "/test1.fa", true, 2,
             ArrayUtils.concatArrays(someUniref50Seqs, t1) },
         { "examples/uniref50.fa " + testfiles + "/test1.fa", true, 2, t1 },
-        { "--argfile=" + testfiles + "/argfile0.txt", true, 1,
+        { "--gui --argfile=" + testfiles + "/argfile0.txt", true, 1,
             ArrayUtils.concatArrays(t1, t3) },
-        { "--argfile=" + testfiles + "/argfile*.txt", true, 5,
+        { "--gui --argfile=" + testfiles + "/argfile*.txt", true, 5,
             ArrayUtils.concatArrays(t1, t2, t3) },
-        { "--argfile=" + testfiles + "/argfile.autocounter", true, 3,
+        { "--gui --argfile=" + testfiles + "/argfile.autocounter", true, 3,
             ArrayUtils.concatArrays(t1, t2) } };
 
   }
@@ -296,7 +296,7 @@ public class CommandsTest
   public void allLinkedIdsTest(String cmdLine, String[] filenames,
           String[] nonfilenames)
   {
-    String[] args = cmdLine.split("\\s+");
+    String[] args = (cmdLine + " --gui").split("\\s+");
     Jalview.main(args);
     Commands cmds = Jalview.getInstance().getCommands();
     Assert.assertNotNull(cmds);
@@ -324,19 +324,19 @@ public class CommandsTest
         //
         /*
          */
-        { "--open=test/jalview/bin/argparser/testfiles/*.fa --substitutions --all --output={dirname}/{basename}.stk --close",
+        { "--gui --open=test/jalview/bin/argparser/testfiles/*.fa --substitutions --all --output={dirname}/{basename}.stk --close",
             new String[]
             { "test/jalview/bin/argparser/testfiles/test1.stk",
                 "test/jalview/bin/argparser/testfiles/test2.stk",
                 "test/jalview/bin/argparser/testfiles/test3.stk", },
             null },
-        { "--open=test/jalview/bin/argparser/testfiles/*.fa --substitutions --all --image={dirname}/{basename}.png --close",
+        { "--gui --open=test/jalview/bin/argparser/testfiles/*.fa --substitutions --all --image={dirname}/{basename}.png --close",
             new String[]
             { "test/jalview/bin/argparser/testfiles/test1.png",
                 "test/jalview/bin/argparser/testfiles/test2.png",
                 "test/jalview/bin/argparser/testfiles/test3.png", },
             null },
-        { "--open=test/jalview/bin/argparser/testfiles/*.fa --all --output={dirname}/{basename}.stk --close",
+        { "--gui --open=test/jalview/bin/argparser/testfiles/*.fa --all --output={dirname}/{basename}.stk --close",
             new String[]
             { "test/jalview/bin/argparser/testfiles/test1.stk",
                 "test/jalview/bin/argparser/testfiles/test2.stk",
@@ -351,7 +351,7 @@ public class CommandsTest
                 "test/jalview/bin/argparser/testfiles/dir3/subdir/test1.stk",
                 "test/jalview/bin/argparser/testfiles/dir3/subdir/test2.stk",
                 "test/jalview/bin/argparser/testfiles/dir3/subdir/test3.stk", }, },
-        { "--open=test/jalview/bin/argparser/**/*.fa --all --output={dirname}/{basename}.stk --close",
+        { "--gui --open=test/jalview/bin/argparser/**/*.fa --all --output={dirname}/{basename}.stk --close",
             new String[]
             { "test/jalview/bin/argparser/testfiles/test1.stk",
                 "test/jalview/bin/argparser/testfiles/test2.stk",
@@ -366,7 +366,7 @@ public class CommandsTest
                 "test/jalview/bin/argparser/testfiles/dir3/subdir/test2.stk",
                 "test/jalview/bin/argparser/testfiles/dir3/subdir/test3.stk", },
             null },
-        { "--open=test/jalview/bin/argparser/**/*.fa --output=*.stk --close",
+        { "--gui --open=test/jalview/bin/argparser/**/*.fa --output=*.stk --close",
             new String[]
             { "test/jalview/bin/argparser/testfiles/test1.stk",
                 "test/jalview/bin/argparser/testfiles/test2.stk",
@@ -381,7 +381,7 @@ public class CommandsTest
                 "test/jalview/bin/argparser/testfiles/dir3/subdir/test2.stk",
                 "test/jalview/bin/argparser/testfiles/dir3/subdir/test3.stk", },
             null },
-        { "--open=test/jalview/bin/argparser/testfiles/dir1/*.fa --open=test/jalview/bin/argparser/testfiles/dir2/*.fa --output=*.stk --close",
+        { "--gui --open=test/jalview/bin/argparser/testfiles/dir1/*.fa --open=test/jalview/bin/argparser/testfiles/dir2/*.fa --output=*.stk --close",
             new String[]
             { "test/jalview/bin/argparser/testfiles/dir1/test1.stk",
                 "test/jalview/bin/argparser/testfiles/dir1/test2.stk",
@@ -396,7 +396,7 @@ public class CommandsTest
                 "test/jalview/bin/argparser/testfiles/dir3/subdir/test1.stk",
                 "test/jalview/bin/argparser/testfiles/dir3/subdir/test2.stk",
                 "test/jalview/bin/argparser/testfiles/dir3/subdir/test3.stk", }, },
-        { "--open=test/jalview/bin/argparser/testfiles/dir1/*.fa --open=test/jalview/bin/argparser/testfiles/dir2/*.fa --output=open*.stk --close",
+        { "--gui --open=test/jalview/bin/argparser/testfiles/dir1/*.fa --open=test/jalview/bin/argparser/testfiles/dir2/*.fa --output=open*.stk --close",
             new String[]
             { "test/jalview/bin/argparser/testfiles/dir2/test1.stk",
                 "test/jalview/bin/argparser/testfiles/dir2/test2.stk",
@@ -411,7 +411,7 @@ public class CommandsTest
                 "test/jalview/bin/argparser/testfiles/dir3/subdir/test1.stk",
                 "test/jalview/bin/argparser/testfiles/dir3/subdir/test2.stk",
                 "test/jalview/bin/argparser/testfiles/dir3/subdir/test3.stk", }, },
-        { "--open=test/jalview/bin/argparser/testfiles/dir1/*.fa --open=test/jalview/bin/argparser/testfiles/dir2/*.fa --opened --output={dirname}/{basename}.stk --close",
+        { "--gui --open=test/jalview/bin/argparser/testfiles/dir1/*.fa --open=test/jalview/bin/argparser/testfiles/dir2/*.fa --opened --output={dirname}/{basename}.stk --close",
             new String[]
             { "test/jalview/bin/argparser/testfiles/dir2/test1.stk",
                 "test/jalview/bin/argparser/testfiles/dir2/test2.stk",
@@ -426,7 +426,7 @@ public class CommandsTest
                 "test/jalview/bin/argparser/testfiles/dir3/subdir/test1.stk",
                 "test/jalview/bin/argparser/testfiles/dir3/subdir/test2.stk",
                 "test/jalview/bin/argparser/testfiles/dir3/subdir/test3.stk", }, },
-        { "--open=test/jalview/bin/argparser/testfiles/dir1/*.fa --output open*.stk --open=test/jalview/bin/argparser/testfiles/dir2/*.fa --output=open*.aln --close",
+        { "--gui --open=test/jalview/bin/argparser/testfiles/dir1/*.fa --output open*.stk --open=test/jalview/bin/argparser/testfiles/dir2/*.fa --output=open*.aln --close",
             new String[]
             { "test/jalview/bin/argparser/testfiles/dir1/test1.stk",
                 "test/jalview/bin/argparser/testfiles/dir1/test2.stk",
index a31b77d..0a47700 100644 (file)
@@ -137,58 +137,64 @@ public class CommandsTest2
         //
         /*
          */
-        { "--nonews --nosplash --debug " + "--append=examples/uniref50.fa "
+        { "--gui --nonews --nosplash --debug "
+                + "--append=examples/uniref50.fa "
                 + "--colour=gecos-flower "
                 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
                 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
                 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
             15, 7, 1 },
-        { "--nonews --nosplash --debug " + "--append=examples/uniref50.fa "
+        { "--gui --nonews --nosplash --debug "
+                + "--append=examples/uniref50.fa "
                 + "--colour=gecos-flower "
                 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
                 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
                 + "--props=test/jalview/bin/commandsTest2.jvprops2 ",
             15, 4, 1 },
-        { "--nonews --nosplash --debug " + "--append=examples/uniref50.fa "
+        { "--gui --nonews --nosplash --debug "
+                + "--append=examples/uniref50.fa "
                 + "--colour=gecos-flower "
                 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
                 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
                 + "--noshowssannotations "
                 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
             15, 4, 1 },
-        { "--nonews --nosplash --debug " + "--append=examples/uniref50.fa "
+        { "--gui --nonews --nosplash --debug "
+                + "--append=examples/uniref50.fa "
                 + "--colour=gecos-flower "
                 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
                 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
                 + "--noshowannotations "
                 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
             15, 3, 1 },
-        { "--nonews --nosplash --debug " + "--append=examples/uniref50.fa "
+        { "--gui --nonews --nosplash --debug "
+                + "--append=examples/uniref50.fa "
                 + "--colour=gecos-flower "
                 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
                 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
                 + "--noshowannotations " + "--noshowssannotations "
                 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
             15, 0, 1 },
-        { "--nonews --nosplash --debug " + "--append=examples/uniref50.fa "
+        { "--gui --nonews --nosplash --debug "
+                + "--append=examples/uniref50.fa "
                 + "--colour=gecos-flower "
                 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
                 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
                 + "--noshowannotations " + "--noshowssannotations "
                 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
             15, 0, 1 },
-        { "--nonews --nosplash --debug --nowebservicediscovery --props=test/jalview/bin/commandsTest.jvprops --argfile=test/jalview/bin/commandsTest2.argfile1 ",
+        { "--gui --nonews --nosplash --debug --nowebservicediscovery --props=test/jalview/bin/commandsTest.jvprops --argfile=test/jalview/bin/commandsTest2.argfile1 ",
             16, 19, 3 },
-        { "--nonews --nosplash --debug --nowebservicediscovery --props=test/jalview/bin/commandsTest.jvprops --argfile=test/jalview/bin/commandsTest2.argfile2 ",
+        { "--gui --nonews --nosplash --debug --nowebservicediscovery --props=test/jalview/bin/commandsTest.jvprops --argfile=test/jalview/bin/commandsTest2.argfile2 ",
             16, 0, 2 },
-        { "--nonews --nosplash --debug --nowebservicediscovery --props=test/jalview/bin/commandsTest.jvprops --open=./examples/test_fab41.result/sample.a2m "
+        { "--gui --nonews --nosplash --debug --nowebservicediscovery --props=test/jalview/bin/commandsTest.jvprops --open=./examples/test_fab41.result/sample.a2m "
                 + "--allstructures "
                 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb "
                 + "--structureviewer=none "
                 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_2_model_4.pdb "
                 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_3_model_2.pdb",
             16, 10, 0 },
-        { "--nonews --nosplash --debug --nowebservicediscovery --props=test/jalview/bin/commandsTest.jvprops --open=./examples/test_fab41.result/sample.a2m "
+        { "--gui --nonews --nosplash --debug --nowebservicediscovery --props=test/jalview/bin/commandsTest.jvprops --open=./examples/test_fab41.result/sample.a2m "
                 + "--allstructures "
                 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb "
                 + "--noallstructures " + "--structureviewer=none "