| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.ws.jabaws; |
| 22 |
|
|
| 23 |
|
import static org.testng.AssertJUnit.assertNotNull; |
| 24 |
|
import static org.testng.AssertJUnit.assertTrue; |
| 25 |
|
|
| 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; |
| 35 |
|
|
| 36 |
|
import java.util.ArrayList; |
| 37 |
|
import java.util.List; |
| 38 |
|
|
| 39 |
|
import org.testng.annotations.AfterClass; |
| 40 |
|
import org.testng.annotations.BeforeClass; |
| 41 |
|
import org.testng.annotations.DataProvider; |
| 42 |
|
import org.testng.annotations.Test; |
| 43 |
|
|
| 44 |
|
|
| 45 |
|
|
| 46 |
|
|
| 47 |
|
|
| 48 |
|
@Test(singleThreaded = true) |
| |
|
| 0% |
Uncovered Elements: 69 (69) |
Complexity: 13 |
Complexity Density: 0.25 |
|
| 49 |
|
public class AAConAnnotAndSettingsIO |
| 50 |
|
{ |
| 51 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 52 |
0 |
@BeforeClass(alwaysRun = true)... |
| 53 |
|
public void setUpJvOptionPane() |
| 54 |
|
{ |
| 55 |
0 |
JvOptionPane.setInteractiveMode(false); |
| 56 |
0 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
| 57 |
|
} |
| 58 |
|
|
| 59 |
|
public static String testseqs = "examples/uniref50.fa"; |
| 60 |
|
|
| 61 |
|
public static Jws2Discoverer disc; |
| 62 |
|
|
| 63 |
|
public static List<ServiceWithParameters[]> aacon; |
| 64 |
|
|
| 65 |
|
jalview.ws.jws2.SeqAnnotationServiceCalcWorker aaconClient; |
| 66 |
|
|
| 67 |
|
public static jalview.gui.AlignFrame af = null; |
| 68 |
|
|
| |
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 4 |
Complexity Density: 0.33 |
|
| 69 |
0 |
@BeforeClass(alwaysRun = true)... |
| 70 |
|
public static void setUpBeforeClass() throws Exception |
| 71 |
|
{ |
| 72 |
0 |
Cache.loadProperties("test/jalview/io/testProps.jvprops"); |
| 73 |
0 |
disc = JalviewJabawsTestUtils.getJabawsDiscoverer(); |
| 74 |
|
|
| 75 |
0 |
while (disc.isRunning()) |
| 76 |
|
{ |
| 77 |
|
|
| 78 |
0 |
Thread.sleep(100); |
| 79 |
|
} |
| 80 |
|
|
| 81 |
|
|
| 82 |
0 |
aacon = new ArrayList<>(); |
| 83 |
0 |
for (ServiceWithParameters svc : disc.getServices()) |
| 84 |
|
{ |
| 85 |
0 |
if (svc.getNameURI().toLowerCase().contains("aacon")) |
| 86 |
|
{ |
| 87 |
0 |
aacon.add(new ServiceWithParameters[] { svc }); |
| 88 |
|
} |
| 89 |
|
} |
| 90 |
|
|
| 91 |
0 |
for (ServiceWithParameters svc : SlivkaWSDiscoverer.getInstance() |
| 92 |
|
.getServices()) |
| 93 |
|
{ |
| 94 |
0 |
if (svc.getNameURI().toLowerCase().contains("aacon")) |
| 95 |
|
{ |
| 96 |
0 |
aacon.add(new ServiceWithParameters[] { svc }); |
| 97 |
|
} |
| 98 |
|
} |
| 99 |
0 |
assertTrue("Couldn't discover any AACon services to use to test.", |
| 100 |
|
aacon.size() > 0); |
| 101 |
|
} |
| 102 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 103 |
0 |
@AfterClass(alwaysRun = true)... |
| 104 |
|
public static void tearDownAfterClass() throws Exception |
| 105 |
|
{ |
| 106 |
0 |
if (af != null) |
| 107 |
|
{ |
| 108 |
0 |
af.setVisible(false); |
| 109 |
0 |
af.dispose(); |
| 110 |
0 |
af = null; |
| 111 |
|
} |
| 112 |
|
} |
| 113 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 114 |
0 |
@DataProvider(name = "aacons")... |
| 115 |
|
public Object[][] getAaconArray() |
| 116 |
|
{ |
| 117 |
|
|
| 118 |
0 |
Object[][] rtn = new Object[aacon.size()][1]; |
| 119 |
0 |
int i = 0; |
| 120 |
0 |
for (ServiceWithParameters[] aa : aacon) |
| 121 |
|
{ |
| 122 |
0 |
rtn[i++] = aa; |
| 123 |
|
} |
| 124 |
0 |
return rtn; |
| 125 |
|
} |
| 126 |
|
|
| 127 |
|
|
| 128 |
|
|
| 129 |
|
|
| |
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
4-
|
|
| 130 |
0 |
@Test(groups = { "External", "Network" }, dataProvider = "aacons")... |
| 131 |
|
public void testAAConAnnotAndRecovery(ServiceWithParameters service) |
| 132 |
|
{ |
| 133 |
0 |
jalview.io.FileLoader fl = new jalview.io.FileLoader(false); |
| 134 |
0 |
AlignFrame _af = fl.LoadFileWaitTillLoaded(testseqs, |
| 135 |
|
jalview.io.DataSourceType.FILE); |
| 136 |
0 |
assertNotNull("Couldn't load test data ('" + testseqs + "')", _af); |
| 137 |
0 |
af = _af; |
| 138 |
0 |
try |
| 139 |
|
{ |
| 140 |
0 |
testAAConClient(_af, service); |
| 141 |
|
} finally |
| 142 |
|
{ |
| 143 |
0 |
af = null; |
| 144 |
0 |
_af.setVisible(false); |
| 145 |
0 |
_af.dispose(); |
| 146 |
0 |
_af = null; |
| 147 |
|
|
| 148 |
|
} |
| 149 |
|
} |
| 150 |
|
|
| 151 |
|
|
| 152 |
|
|
| 153 |
|
|
| 154 |
|
|
| 155 |
|
@param |
| 156 |
|
|
| 157 |
|
@param |
| 158 |
|
|
| 159 |
|
|
| |
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 4 |
Complexity Density: 0.22 |
|
| 160 |
0 |
static void testAAConClient(AlignFrame af, ServiceWithParameters aacon)... |
| 161 |
|
{ |
| 162 |
0 |
SeqAnnotationServiceCalcWorker aaconClient = new SeqAnnotationServiceCalcWorker( |
| 163 |
|
aacon, af, null, |
| 164 |
|
null); |
| 165 |
0 |
long current = System.currentTimeMillis(), limit = 15; |
| 166 |
0 |
af.getViewport().getCalcManager().startWorker(aaconClient); |
| 167 |
0 |
do |
| 168 |
|
{ |
| 169 |
0 |
try |
| 170 |
|
{ |
| 171 |
0 |
Thread.sleep(50); |
| 172 |
|
} catch (InterruptedException x) |
| 173 |
|
{ |
| 174 |
|
} |
| 175 |
0 |
; |
| 176 |
0 |
assertTrue( |
| 177 |
|
"Waited " + limit + "s for " + aacon.getHostURL() |
| 178 |
|
+ " - giving up.", |
| 179 |
|
(System.currentTimeMillis() - current) < limit * 1000); |
| 180 |
0 |
} while (af.getViewport().getCalcManager().isWorking()); |
| 181 |
0 |
AlignmentI orig_alig = af.getViewport().getAlignment(); |
| 182 |
0 |
boolean foundShenkin = false; |
| 183 |
0 |
Iterable<AlignmentAnnotation> _aa=orig_alig |
| 184 |
|
.findAnnotation(aacon.getAlignAnalysisUI().getCalcId()); |
| 185 |
0 |
assertTrue("No annotation from service", |
| 186 |
|
_aa != null && _aa.iterator().hasNext()); |
| 187 |
|
|
| 188 |
0 |
for (AlignmentAnnotation aa : _aa) |
| 189 |
|
{ |
| 190 |
0 |
assertTrue("AACon annotation not marked as autocalculated!", |
| 191 |
|
aa.autoCalculated); |
| 192 |
0 |
if ("shenkin".equals(aa.label.toLowerCase())) |
| 193 |
|
{ |
| 194 |
0 |
foundShenkin = true; |
| 195 |
0 |
break; |
| 196 |
|
} |
| 197 |
|
} |
| 198 |
0 |
assertTrue("Failed to locate 'SHENKIN' annotation row.", foundShenkin); |
| 199 |
|
} |
| 200 |
|
} |