1
2
3
4
5
6
7
8
9
10
11 package org.astrogrid.datacenter.deployed;
12
13 import java.io.IOException;
14 import java.io.InputStream;
15 import java.net.MalformedURLException;
16 import java.net.URISyntaxException;
17 import javax.xml.parsers.ParserConfigurationException;
18 import junit.framework.TestCase;
19 import junit.framework.TestSuite;
20 import org.astrogrid.applications.beans.v1.cea.castor.ExecutionSummaryType;
21 import org.astrogrid.applications.beans.v1.parameters.ParameterValue;
22 import org.astrogrid.applications.delegate.CEADelegateException;
23 import org.astrogrid.applications.delegate.CommonExecutionConnectorClient;
24 import org.astrogrid.applications.delegate.DelegateFactory;
25 import org.astrogrid.community.Account;
26 import org.astrogrid.config.SimpleConfig;
27 import org.astrogrid.datacenter.delegate.ConeSearcher;
28 import org.astrogrid.datacenter.delegate.DatacenterDelegateFactory;
29 import org.astrogrid.datacenter.delegate.DatacenterException;
30 import org.astrogrid.datacenter.query.Adql074Writer;
31 import org.astrogrid.datacenter.query.Query;
32 import org.astrogrid.datacenter.query.SimpleQueryMaker;
33 import org.astrogrid.jes.types.v1.cea.axis.JobIdentifierType;
34 import org.astrogrid.store.Ivorn;
35 import org.astrogrid.store.delegate.VoSpaceResolver;
36 import org.astrogrid.util.DomHelper;
37 import org.astrogrid.workflow.beans.v1.Input;
38 import org.astrogrid.workflow.beans.v1.Output;
39 import org.astrogrid.workflow.beans.v1.Tool;
40 import org.exolab.castor.xml.MarshalException;
41 import org.exolab.castor.xml.ValidationException;
42 import org.xml.sax.SAXException;
43
44 /***
45 * Tests to see if the real deployed services are up. This isn't really an
46 * integration test, but it seems a convenient place to have it run and notify
47 * us if services go down
48 *
49 */
50 public class DeployedServicesTest extends TestCase {
51
52 /*** Reads a file from myspace */
53 public void testMySpaceRead() throws URISyntaxException, IOException {
54 SimpleConfig.getSingleton().setProperty("org.astrogrid.sc2004/frog","astrogrid:store:myspace:http://twmbarlwm.roe.ac.uk:8080/astrogrid-mySpace-SNAPSHOT/services/Manager");
55
56 Ivorn file = new Ivorn("ivo://org.astrogrid.sc2004/frog#frog/queries/6df.q");
57
58 InputStream i = VoSpaceResolver.resolveInputStream(Account.ANONYMOUS.toUser(), file);
59 }
60
61
62 /*** Runs a CEA test */
63 public void doCea(String endpoint, String toolName, double ra, double dec, double radius) throws IOException, SAXException, IOException, ParserConfigurationException, CEADelegateException, MarshalException, ValidationException {
64
65 CommonExecutionConnectorClient client = DelegateFactory.createDelegate(endpoint);
66
67 Tool dsaTool = new Tool();
68 dsaTool.setName(toolName);
69 dsaTool.setInterface("adql");
70
71
72
73 ParameterValue query= new ParameterValue();
74 query.setName("Query");
75 query.setIndirect(false);
76 Query q = SimpleQueryMaker.makeConeQuery(ra,dec,radius);
77 query.setValue(Adql074Writer.makeAdql(q));
78
79
80 ParameterValue format= new ParameterValue();
81 format.setName("Format");
82 format.setIndirect(false);
83 format.setValue("VOTABLE");
84 ParameterValue result= new ParameterValue();
85 result.setName("Result");
86 result.setIndirect(false);
87
88 Input i = new Input();
89 i.addParameter(query);
90 i.addParameter(format);
91 Output o = new Output();
92 o.addParameter(result);
93
94 dsaTool.setInput(i);
95 dsaTool.setOutput(o);
96
97 String id = client.init(dsaTool, new JobIdentifierType("DeployedServicesTestJesID1"));
98 boolean success = client.execute(id);
99
100 ExecutionSummaryType summary = client.getExecutionSumary(id);
101 long start = System.currentTimeMillis();
102 while ((summary.getStatus().getType() < summary.getStatus().COMPLETED_TYPE) && (System.currentTimeMillis() < start+10000)) {
103 summary = client.getExecutionSumary(id);
104 }
105 java.io.StringWriter sw = new java.io.StringWriter();
106 summary.marshal(sw);
107 System.out.println(sw.toString());
108
109 assertTrue(success);
110 }
111
112 public void doCone(String endpoint, double ra, double dec, double radius) throws MalformedURLException, DatacenterException, IOException, IOException, ParserConfigurationException, SAXException {
113 ConeSearcher delegate = DatacenterDelegateFactory.makeConeSearcher(
114 Account.ANONYMOUS,
115 endpoint,
116 DatacenterDelegateFactory.ASTROGRID_WEB_SERVICE);
117
118 delegate.setTimeout(60000);
119 InputStream is = delegate.coneSearch(ra,dec,radius);
120 assertNotNull(is);
121 DomHelper.newDocument(is);
122 }
123
124 public void test6dfCea() throws IOException, MarshalException, CEADelegateException, ParserConfigurationException, ValidationException, SAXException {
125 doCea("http://grendel12.roe.ac.uk:8080/pal-6df/services/CommonExecutionConnectorService",
126 "roe.ac.uk/DSA_6dF/ceaApplication",
127 20,
128 20,
129 1);
130 }
131
132 public void testSsaCea() throws IOException, MarshalException, CEADelegateException, ParserConfigurationException, ValidationException, SAXException {
133 doCea("http://astrogrid.roe.ac.uk:8080/pal-ssa/services/CommonExecutionConnectorService",
134 "roe.ac.uk/DSA_SSA/ceaApplication",
135 20,
136 -20,
137 0.1);
138 }
139
140
141 /*** Runs a cone search on 6dF */
142 public void test6dFCone() throws IOException, SAXException, IOException, ParserConfigurationException {
143 doCone("http://grendel12.roe.ac.uk:8080/pal-6df/services/AxisDataService05",
144 10,
145 10,
146 2);
147 }
148
149 /*** Runs a simple adql search on SEC proxy on grendel12. No point in running
150 * a cone search - Solar Event Catalogues don't do cones
151 public void testGrendelSecProxy() throws IOException, SAXException, IOException, ParserConfigurationException, ServiceException {
152 QuerySearcher delegate = DatacenterDelegateFactory.makeQuerySearcher(
153 Account.ANONYMOUS,
154 "http://grendel12.roe.ac.uk:8080/pal-sec/services/AxisDataService05",
155 DatacenterDelegateFactory.ASTROGRID_WEB_SERVICE);
156 delegate.setTimeout(60000);
157
158 String adqls = "SELECT * FROM sgas_event AS s WHERE s.nar>9500 AND s.nar<9600";
159
160 Query query = SqlQueryMaker.makeQuery(adqls);
161 query.getResultsDef().setFormat(ReturnTable.VOTABLE);
162
163 InputStream is = delegate.askQuery(query);
164 assertNotNull(is);
165 DomHelper.newDocument(is);
166 }
167
168 /** Runs a cone search on Vizier proxy on grendel12
169 public void testGrendelVizierProxy() throws IOException, SAXException, IOException, ParserConfigurationException {
170 ConeSearcher delegate = DatacenterDelegateFactory.makeConeSearcher(
171 Account.ANONYMOUS,
172 "http://grendel12.roe.ac.uk:8080/pal-vizier/services/AxisDataService05",
173 DatacenterDelegateFactory.ASTROGRID_WEB_SERVICE);
174 delegate.setTimeout(60000);
175
176 InputStream is = delegate.coneSearch(10,10,2);
177 assertNotNull(is);
178 DomHelper.newDocument(is);
179 }
180
181 /** Runs a cone search on SSA
182 public void testSsaCone() throws IOException, SAXException, IOException, ParserConfigurationException {
183 ConeSearcher delegate = DatacenterDelegateFactory.makeConeSearcher(
184 Account.ANONYMOUS,
185 "http://astrogrid.roe.ac.uk:8080/pal-sss/services/AxisDataService05",
186 DatacenterDelegateFactory.ASTROGRID_WEB_SERVICE);
187 delegate.setTimeout(60000);
188
189 InputStream is = delegate.coneSearch(10,-10,0.1);
190 assertNotNull(is);
191 DomHelper.newDocument(is);
192 }
193
194 /** Runs a CEA test on SSA
195 public void testSsaCea() throws IOException, SAXException, IOException, ParserConfigurationException, CEADelegateException {
196
197 CommonExecutionConnectorClient client = DelegateFactory.createDelegate("http://astrogrid.roe.ac.uk:8080/pal-sss/services/CommonExecutionConnectorService");
198
199 Tool dsaTool = new Tool();
200 dsaTool.setName("DSA_SSA/ceaApplication");
201 dsaTool.setInterface("adql");
202 // ParameterValue query
203 // i.addParameter(new ParameterValue(
204
205 ParameterValue query= new ParameterValue();
206 query.setName("Query");
207 query.setIndirect(false);
208 Query q = SimpleQueryMaker.makeConeQuery(20,-10,0.1);
209 query.setValue(Adql074Writer.makeAdql(q));
210
211
212 ParameterValue format= new ParameterValue();
213 format.setName("Format");
214 format.setIndirect(false);
215 format.setValue("VOTABLE");// rely on default values.
216 ParameterValue result= new ParameterValue();
217 result.setName("Result");
218 result.setIndirect(false);
219
220 Input i = new Input();
221 i.addParameter(query);
222 i.addParameter(format);
223 Output o = new Output();
224 o.addParameter(result);
225
226 dsaTool.setInput(i);
227 dsaTool.setOutput(o);
228 // populateDsaTool(dsaTool);
229 String id = client.init(dsaTool, new JobIdentifierType("DeployedServicesTestJesID1"));
230 boolean success = client.execute(id);
231 client.getResults(id);
232
233 assertTrue(success);
234 }
235
236 public void populateDsaTool(Tool tool) throws IOException {
237
238 ParameterValue query= (ParameterValue)tool.findXPathValue("input/parameter[name='Query']");
239 query.setIndirect(false);
240
241 Query q = SimpleQueryMaker.makeConeQuery(20,-10,0.1);
242 query.setValue(Adql074Writer.makeAdql(q));
243
244
245 ParameterValue format= (ParameterValue)tool.findXPathValue("input/parameter[name='Format']");
246 format.setIndirect(false);
247 format.setValue("VOTABLE");// rely on default values.
248 ParameterValue target = (ParameterValue)tool.findXPathValue("output/parameter[name='Result']");
249 target.setIndirect(false);
250 }
251
252
253 /** Runs a cone search on INT-WFS
254 public void testIntWfs() throws IOException, SAXException, IOException, ParserConfigurationException {
255 ConeSearcher delegate = DatacenterDelegateFactory.makeConeSearcher(
256 Account.ANONYMOUS,
257 "http://ag01.ast.cam.ac.uk:8080/astrogrid-pal-Itn05_release/services/AxisDataService05",
258 DatacenterDelegateFactory.ASTROGRID_WEB_SERVICE);
259 delegate.setTimeout(60000);
260
261 InputStream is = delegate.coneSearch(10,10,2);
262 assertNotNull(is);
263 DomHelper.newDocument(is);
264 }
265 */
266
267 public static void main(String[] args) {
268 junit.textui.TestRunner.run(new TestSuite(DeployedServicesTest.class));
269 }
270 }
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315