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/commandsTest2.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 if (Desktop.instance != null)
55 Desktop.instance.closeAll_actionPerformed(null);
61 dataProvider = "structureOpeningArgsParams",
62 singleThreaded = true)
63 public void structureOpeningArgsTest(String cmdLine, int seqNum,
64 int annNum, int viewerNum)
66 String[] args = cmdLine.split("\\s+");
71 // sleep for slow build server to open annotations and viewer windows
72 Thread.sleep(seqNum * 100 + annNum * 200 + viewerNum * 1500);
73 } catch (InterruptedException e)
78 AlignFrame[] afs = Desktop.getAlignFrames();
79 Assert.assertNotNull(afs);
80 Assert.assertTrue(afs.length > 0);
82 AlignFrame af = afs[0];
83 Assert.assertNotNull(af);
85 AlignmentPanel ap = af.alignPanel;
86 Assert.assertNotNull(ap);
88 AlignmentI al = ap.getAlignment();
89 Assert.assertNotNull(al);
91 List<SequenceI> seqs = al.getSequences();
92 Assert.assertNotNull(seqs);
94 Assert.assertEquals(seqs.size(), seqNum, "Wrong number of sequences");
96 AlignViewportI av = ap.getAlignViewport();
97 Assert.assertNotNull(av);
99 AlignmentAnnotation[] aas = al.getAlignmentAnnotation();
102 for (AlignmentAnnotation aa : aas)
104 System.err.println("##### DIAGNOSIS: annotation " + ++dcount
105 + " is labelled '" + aa.label + "'");
106 System.err.println("# " + aa.annotationId + ": " + aa.toString());
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()
140 return new Object[][] {
144 { "--nonews --nosplash --debug " + "--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 { "--nonews --nosplash --debug " + "--append=examples/uniref50.fa "
151 + "--colour=gecos:flower "
152 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
153 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
154 + "--props=test/jalview/bin/commandsTest2.jvprops2 ",
156 { "--nonews --nosplash --debug " + "--append=examples/uniref50.fa "
157 + "--colour=gecos:flower "
158 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
159 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
160 + "--nossannotations "
161 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
163 { "--nonews --nosplash --debug " + "--append=examples/uniref50.fa "
164 + "--colour=gecos:flower "
165 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
166 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
168 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
170 { "--nonews --nosplash --debug " + "--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 + "--noannotations " + "--nossannotations "
175 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
177 { "--nonews --nosplash --debug " + "--append=examples/uniref50.fa "
178 + "--colour=gecos:flower "
179 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
180 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
181 + "--noannotations " + "--nossannotations "
182 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
184 { "--props=test/jalview/bin/commandsTest.jvprops --argfile=test/jalview/bin/commandsTest2.argfile1 ",
186 { "--props=test/jalview/bin/commandsTest.jvprops --argfile=test/jalview/bin/commandsTest2.argfile2 ",