2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.ws.jabaws;
23 import static org.testng.AssertJUnit.assertNotNull;
24 import static org.testng.AssertJUnit.assertTrue;
26 import jalview.bin.Cache;
27 import jalview.datamodel.AlignmentAnnotation;
28 import jalview.datamodel.AlignmentI;
29 import jalview.gui.AlignFrame;
30 import jalview.gui.JvOptionPane;
31 import jalview.ws.api.ServiceWithParameters;
32 import jalview.ws.jws2.Jws2Discoverer;
33 import jalview.ws.jws2.SeqAnnotationServiceCalcWorker;
34 import jalview.ws.slivkaws.SlivkaWSDiscoverer;
36 import java.util.ArrayList;
37 import java.util.List;
39 import org.testng.annotations.AfterClass;
40 import org.testng.annotations.BeforeClass;
41 import org.testng.annotations.DataProvider;
42 import org.testng.annotations.Test;
45 * All methods in this class are set to the Network group because setUpBeforeClass will fail
46 * if there is no network.
48 @Test(singleThreaded = true)
49 public class AAConAnnotAndSettingsIO
52 @BeforeClass(alwaysRun = true)
53 public void setUpJvOptionPane()
55 JvOptionPane.setInteractiveMode(false);
56 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
59 public static String testseqs = "examples/uniref50.fa";
61 public static Jws2Discoverer disc;
63 public static List<ServiceWithParameters[]> aacon;
65 jalview.ws.jws2.SeqAnnotationServiceCalcWorker aaconClient;
67 public static jalview.gui.AlignFrame af = null;
69 @BeforeClass(alwaysRun = true)
70 public static void setUpBeforeClass() throws Exception
72 Cache.loadProperties("test/jalview/io/testProps.jvprops");
74 disc = JalviewJabawsTestUtils.getJabawsDiscoverer();
76 while (disc.isRunning())
78 // don't get services until discoverer has finished
83 aacon = new ArrayList<>();
84 for (ServiceWithParameters svc : disc.getServices())
86 if (svc.getNameURI().toLowerCase().contains("aacon"))
88 aacon.add(new ServiceWithParameters[] { svc });
92 for (ServiceWithParameters svc : SlivkaWSDiscoverer.getServices())
94 if (svc.getNameURI().toLowerCase().contains("aacon"))
96 aacon.add(new ServiceWithParameters[] { svc });
99 assertTrue("Couldn't discover any AACon services to use to test.",
103 @AfterClass(alwaysRun = true)
104 public static void tearDownAfterClass() throws Exception
108 af.setVisible(false);
114 @DataProvider(name = "aacons")
115 public Object[][] getAaconArray()
118 Object[][] rtn = new Object[aacon.size()][1];
120 for (ServiceWithParameters[] aa : aacon)
127 * Run AACon on an alignment with defaults and verify Just Shenkin annotation
130 @Test(groups = { "External", "Network" }, dataProvider = "aacons")
131 public void testAAConAnnotAndRecovery(ServiceWithParameters service)
133 jalview.io.FileLoader fl = new jalview.io.FileLoader(false);
134 AlignFrame _af = fl.LoadFileWaitTillLoaded(testseqs,
135 jalview.io.DataSourceType.FILE);
136 assertNotNull("Couldn't load test data ('" + testseqs + "')", _af);
140 testAAConClient(_af, service);
144 _af.setVisible(false);
152 * triggers the given aacon worker on the alignment, waits for 5s and gives up
153 * or verifies SHENKIN annotation is produced.
156 * - test data in an alignment frame
158 * - the service to test
160 static void testAAConClient(AlignFrame af, ServiceWithParameters aacon)
162 SeqAnnotationServiceCalcWorker aaconClient = new SeqAnnotationServiceCalcWorker(
165 long current = System.currentTimeMillis(), limit = 15;
166 af.getViewport().getCalcManager().startWorker(aaconClient);
172 } catch (InterruptedException x)
177 "Waited " + limit + "s for " + aacon.getHostURL()
179 (System.currentTimeMillis() - current) < limit * 1000);
180 } while (af.getViewport().getCalcManager().isWorking());
181 AlignmentI orig_alig = af.getViewport().getAlignment();
182 boolean foundShenkin = false;
183 Iterable<AlignmentAnnotation> _aa=orig_alig
184 .findAnnotation(aacon.getAlignAnalysisUI().getCalcId());
185 assertTrue("No annotation from service",
186 _aa != null && _aa.iterator().hasNext());
188 for (AlignmentAnnotation aa : _aa)
190 assertTrue("AACon annotation not marked as autocalculated!",
192 if ("shenkin".equals(aa.label.toLowerCase()))
198 assertTrue("Failed to locate 'SHENKIN' annotation row.", foundShenkin);