6 import org.testng.Assert;
7 import org.testng.annotations.AfterClass;
8 import org.testng.annotations.AfterMethod;
9 import org.testng.annotations.BeforeClass;
10 import org.testng.annotations.DataProvider;
11 import org.testng.annotations.Test;
13 import jalview.api.AlignViewportI;
14 import jalview.datamodel.AlignmentAnnotation;
15 import jalview.datamodel.AlignmentI;
16 import jalview.datamodel.SequenceI;
17 import jalview.gui.AlignFrame;
18 import jalview.gui.AlignmentPanel;
19 import jalview.gui.Desktop;
20 import jalview.gui.JvOptionPane;
21 import jalview.gui.StructureViewerBase;
24 public class CommandsTest2
26 @BeforeClass(alwaysRun = true)
27 public static void setUpBeforeClass() throws Exception
29 Cache.loadProperties("test/jalview/bin/commandsTest.jvprops");
30 Date oneHourFromNow = new Date(
31 System.currentTimeMillis() + 3600 * 1000);
32 Cache.setDateProperty("JALVIEW_NEWS_RSS_LASTMODIFIED", oneHourFromNow);
33 if (Desktop.instance != null)
34 Desktop.instance.closeAll_actionPerformed(null);
38 @AfterClass(alwaysRun = true)
39 public static void resetProps()
41 Cache.loadProperties("test/jalview/testProps.jvprops");
44 @BeforeClass(alwaysRun = true)
45 public void setUpJvOptionPane()
47 JvOptionPane.setInteractiveMode(false);
48 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
51 @AfterMethod(alwaysRun = true)
52 public void tearDown()
54 Desktop.closeDesktop();
59 { "Functional", "testTask1" },
60 dataProvider = "structureOpeningArgsParams",
61 singleThreaded = true)
62 public void structureOpeningArgsTest(String cmdLine, int seqNum,
63 int annNum, int viewerNum)
65 String[] args = cmdLine.split("\\s+");
67 CommandsTest.callJalviewMain(args);
70 // sleep for slow build server to open annotations and viewer windows
71 Thread.sleep(seqNum * 50 + annNum * 50 + viewerNum * 500);
72 } catch (InterruptedException e)
77 AlignFrame[] afs = Desktop.getAlignFrames();
78 Assert.assertNotNull(afs);
79 Assert.assertTrue(afs.length > 0);
81 AlignFrame af = afs[0];
82 Assert.assertNotNull(af);
84 AlignmentPanel ap = af.alignPanel;
85 Assert.assertNotNull(ap);
87 AlignmentI al = ap.getAlignment();
88 Assert.assertNotNull(al);
90 List<SequenceI> seqs = al.getSequences();
91 Assert.assertNotNull(seqs);
93 Assert.assertEquals(seqs.size(), seqNum, "Wrong number of sequences");
95 AlignViewportI av = ap.getAlignViewport();
96 Assert.assertNotNull(av);
98 AlignmentAnnotation[] aas = al.getAlignmentAnnotation();
101 for (AlignmentAnnotation aa : aas)
107 Assert.assertEquals(visibleAnn, annNum,
108 "Wrong number of visible annotations");
112 List<StructureViewerBase> openViewers = Desktop.instance
113 .getStructureViewers(ap, null);
114 Assert.assertNotNull(openViewers);
116 for (StructureViewerBase svb : openViewers)
121 Assert.assertEquals(count, viewerNum,
122 "Wrong number of structure viewers opened");
126 @DataProvider(name = "structureOpeningArgsParams")
127 public Object[][] structureOpeningArgsParams()
133 int structureViewerNum,
135 return new Object[][] {
139 { "--gui --nonews --nosplash --debug "
140 + "--append=examples/uniref50.fa "
141 + "--colour=gecos-flower "
142 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
143 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
144 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
146 { "--gui --nonews --nosplash --debug "
147 + "--append=examples/uniref50.fa "
148 + "--colour=gecos-flower "
149 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
150 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
151 + "--props=test/jalview/bin/commandsTest2.jvprops2 ",
153 { "--gui --nonews --nosplash --debug "
154 + "--append=examples/uniref50.fa "
155 + "--colour=gecos-flower "
156 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
157 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
158 + "--noshowssannotations "
159 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
161 { "--gui --nonews --nosplash --debug "
162 + "--append=examples/uniref50.fa "
163 + "--colour=gecos-flower "
164 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
165 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
166 + "--noshowannotations "
167 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
169 { "--gui --nonews --nosplash --debug "
170 + "--append=examples/uniref50.fa "
171 + "--colour=gecos-flower "
172 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
173 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
174 + "--noshowannotations " + "--noshowssannotations "
175 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
177 { "--gui --nonews --nosplash --debug "
178 + "--append=examples/uniref50.fa "
179 + "--colour=gecos-flower "
180 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
181 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
182 + "--noshowannotations " + "--noshowssannotations "
183 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
185 { "--gui --nonews --nosplash --debug --nowebservicediscovery --props=test/jalview/bin/commandsTest.jvprops --argfile=test/jalview/bin/commandsTest2.argfile1 ",
187 { "--gui --nonews --nosplash --debug --nowebservicediscovery --props=test/jalview/bin/commandsTest.jvprops --argfile=test/jalview/bin/commandsTest2.argfile2 ",
189 { "--gui --nonews --nosplash --debug --nowebservicediscovery --props=test/jalview/bin/commandsTest.jvprops --open=./examples/test_fab41.result/sample.a2m "
191 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb "
192 + "--structureviewer=none "
193 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_2_model_4.pdb "
194 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_3_model_2.pdb",
196 { "--gui --nonews --nosplash --debug --nowebservicediscovery --props=test/jalview/bin/commandsTest.jvprops --open=./examples/test_fab41.result/sample.a2m "
198 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb "
199 + "--noallstructures " + "--structureviewer=none "
200 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_2_model_4.pdb "
201 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_3_model_2.pdb",