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);
68 while (Desktop.instance!=null && Desktop.instance.operationsAreInProgress())
72 // sleep for slow build server to open annotations and viewer windows
73 Thread.sleep(viewerNum * 50);
74 } catch (InterruptedException e)
81 AlignFrame[] afs = Desktop.getAlignFrames();
82 Assert.assertNotNull(afs);
83 Assert.assertTrue(afs.length > 0);
85 AlignFrame af = afs[0];
86 Assert.assertNotNull(af);
88 AlignmentPanel ap = af.alignPanel;
89 Assert.assertNotNull(ap);
91 AlignmentI al = ap.getAlignment();
92 Assert.assertNotNull(al);
94 List<SequenceI> seqs = al.getSequences();
95 Assert.assertNotNull(seqs);
97 Assert.assertEquals(seqs.size(), seqNum, "Wrong number of sequences");
99 AlignViewportI av = ap.getAlignViewport();
100 Assert.assertNotNull(av);
102 AlignmentAnnotation[] aas = al.getAlignmentAnnotation();
105 for (AlignmentAnnotation aa : aas)
111 Assert.assertEquals(visibleAnn, annNum,
112 "Wrong number of visible annotations");
116 List<StructureViewerBase> openViewers = Desktop.instance
117 .getStructureViewers(ap, null);
118 Assert.assertNotNull(openViewers);
120 for (StructureViewerBase svb : openViewers)
125 Assert.assertEquals(count, viewerNum,
126 "Wrong number of structure viewers opened");
130 @DataProvider(name = "structureOpeningArgsParams")
131 public Object[][] structureOpeningArgsParams()
137 int structureViewerNum,
139 return new Object[][] {
143 { "--gui --nonews --nosplash --debug "
144 + "--append=examples/uniref50.fa "
145 + "--colour=gecos-flower "
146 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
147 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
148 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
150 { "--gui --nonews --nosplash --debug "
151 + "--append=examples/uniref50.fa "
152 + "--colour=gecos-flower "
153 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
154 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
155 + "--props=test/jalview/bin/commandsTest2.jvprops2 ",
157 { "--gui --nonews --nosplash --debug "
158 + "--append=examples/uniref50.fa "
159 + "--colour=gecos-flower "
160 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
161 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
162 + "--noshowssannotations "
163 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
165 { "--gui --nonews --nosplash --debug "
166 + "--append=examples/uniref50.fa "
167 + "--colour=gecos-flower "
168 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
169 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
170 + "--noshowannotations "
171 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
173 { "--gui --nonews --nosplash --debug "
174 + "--append=examples/uniref50.fa "
175 + "--colour=gecos-flower "
176 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
177 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
178 + "--noshowannotations " + "--noshowssannotations "
179 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
181 { "--gui --nonews --nosplash --debug "
182 + "--append=examples/uniref50.fa "
183 + "--colour=gecos-flower "
184 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
185 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
186 + "--noshowannotations " + "--noshowssannotations "
187 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
189 { "--gui --nonews --nosplash --debug --nowebservicediscovery --props=test/jalview/bin/commandsTest.jvprops --argfile=test/jalview/bin/commandsTest2.argfile1 ",
191 { "--gui --nonews --nosplash --debug --nowebservicediscovery --props=test/jalview/bin/commandsTest.jvprops --argfile=test/jalview/bin/commandsTest2.argfile2 ",
193 { "--gui --nonews --nosplash --debug --nowebservicediscovery --props=test/jalview/bin/commandsTest.jvprops --open=./examples/test_fab41.result/sample.a2m "
195 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb "
196 + "--structureviewer=none "
197 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_2_model_4.pdb "
198 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_3_model_2.pdb",
200 { "--gui --nonews --nosplash --debug --nowebservicediscovery --props=test/jalview/bin/commandsTest.jvprops --open=./examples/test_fab41.result/sample.a2m "
202 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb "
203 + "--noallstructures " + "--structureviewer=none "
204 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_2_model_4.pdb "
205 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_3_model_2.pdb",