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
69 && Desktop.instance.operationsAreInProgress())
73 // sleep for slow build server to open annotations and viewer windows
74 Thread.sleep(viewerNum * 50);
75 } catch (InterruptedException e)
82 AlignFrame[] afs = Desktop.getAlignFrames();
83 Assert.assertNotNull(afs);
84 Assert.assertTrue(afs.length > 0);
86 AlignFrame af = afs[0];
87 Assert.assertNotNull(af);
89 AlignmentPanel ap = af.alignPanel;
90 Assert.assertNotNull(ap);
92 AlignmentI al = ap.getAlignment();
93 Assert.assertNotNull(al);
95 List<SequenceI> seqs = al.getSequences();
96 Assert.assertNotNull(seqs);
98 Assert.assertEquals(seqs.size(), seqNum, "Wrong number of sequences");
100 AlignViewportI av = ap.getAlignViewport();
101 Assert.assertNotNull(av);
103 AlignmentAnnotation[] aas = al.getAlignmentAnnotation();
106 for (AlignmentAnnotation aa : aas)
112 Assert.assertEquals(visibleAnn, annNum,
113 "Wrong number of visible annotations");
117 List<StructureViewerBase> openViewers = Desktop.instance
118 .getStructureViewers(ap, null);
119 Assert.assertNotNull(openViewers);
121 for (StructureViewerBase svb : openViewers)
126 Assert.assertEquals(count, viewerNum,
127 "Wrong number of structure viewers opened");
131 @DataProvider(name = "structureOpeningArgsParams")
132 public Object[][] structureOpeningArgsParams()
138 int structureViewerNum,
140 return new Object[][] {
144 { "--gui --nonews --nosplash --debug "
145 + "--append=examples/uniref50.fa "
146 + "--colour=gecos-flower "
147 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
148 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
149 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
151 { "--gui --nonews --nosplash --debug "
152 + "--append=examples/uniref50.fa "
153 + "--colour=gecos-flower "
154 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
155 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
156 + "--props=test/jalview/bin/commandsTest2.jvprops2 ",
158 { "--gui --nonews --nosplash --debug "
159 + "--append=examples/uniref50.fa "
160 + "--colour=gecos-flower "
161 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
162 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
163 + "--noshowssannotations "
164 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
166 { "--gui --nonews --nosplash --debug "
167 + "--append=examples/uniref50.fa "
168 + "--colour=gecos-flower "
169 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
170 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
171 + "--noshowannotations "
172 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
174 { "--gui --nonews --nosplash --debug "
175 + "--append=examples/uniref50.fa "
176 + "--colour=gecos-flower "
177 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
178 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
179 + "--noshowannotations " + "--noshowssannotations "
180 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
182 { "--gui --nonews --nosplash --debug "
183 + "--append=examples/uniref50.fa "
184 + "--colour=gecos-flower "
185 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
186 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
187 + "--noshowannotations " + "--noshowssannotations "
188 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
190 { "--gui --nonews --nosplash --debug --nowebservicediscovery --props=test/jalview/bin/commandsTest.jvprops --argfile=test/jalview/bin/commandsTest2.argfile1 ",
192 { "--gui --nonews --nosplash --debug --nowebservicediscovery --props=test/jalview/bin/commandsTest.jvprops --argfile=test/jalview/bin/commandsTest2.argfile2 ",
194 { "--gui --nonews --nosplash --debug --nowebservicediscovery --props=test/jalview/bin/commandsTest.jvprops --open=./examples/test_fab41.result/sample.a2m "
196 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb "
197 + "--structureviewer=none "
198 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_2_model_4.pdb "
199 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_3_model_2.pdb",
201 { "--gui --nonews --nosplash --debug --nowebservicediscovery --props=test/jalview/bin/commandsTest.jvprops --open=./examples/test_fab41.result/sample.a2m "
203 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb "
204 + "--noallstructures " + "--structureviewer=none "
205 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_2_model_4.pdb "
206 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_3_model_2.pdb",