import static org.testng.Assert.assertTrue;\r
import static org.testng.Assert.fail;\r
\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.io.FileNotFoundException;\r
+import java.io.IOException;\r
import java.net.ConnectException;\r
import java.util.Arrays;\r
+import java.util.List;\r
import java.util.Set;\r
\r
import javax.xml.ws.WebServiceException;\r
\r
import org.testng.annotations.Test;\r
\r
+import compbio.data.msa.MsaWS;\r
+import compbio.data.sequence.FastaSequence;\r
+import compbio.data.sequence.SequenceUtil;\r
import compbio.metadata.AllTestSuit;\r
+import compbio.metadata.ChunkHolder;\r
+import compbio.metadata.JobStatus;\r
+import compbio.metadata.JobSubmissionException;\r
+import compbio.metadata.ResultNotAvailableException;\r
import compbio.ws.client.Jws2Client;\r
import compbio.ws.client.Services;\r
import compbio.ws.client.WSTesterTester;\r
fail(e.getLocalizedMessage());\r
}\r
}\r
+\r
+ @Test(groups = {AllTestSuit.test_group_webservices})\r
+ public void testProgressReporting() {\r
+ MsaWS service = null;\r
+ try {\r
+ service = (MsaWS) Jws2Client.connect(\r
+ "http://www.compbio.dundee.ac.uk/jabaws",\r
+ // "http://webserv1.cluster.lifesci.dundee.ac.uk:8089/jabaws",\r
+ Services.ProbconsWS);\r
+ File input = new File(AllTestSuit.TEST_DATA_PATH_ABSOLUTE\r
+ + "200x500Protein.fasta");\r
+ assertTrue(input.exists());\r
+ List<FastaSequence> fs = SequenceUtil\r
+ .readFasta(new FileInputStream(input));\r
+ String jobId = service.align(fs);\r
+ Thread.sleep(5000);\r
+ ChunkHolder pos = null;\r
+ while (service.getJobStatus(jobId) == JobStatus.RUNNING) {\r
+ if (pos == null) {\r
+ pos = service.pullExecStatistics(jobId, 0);\r
+ } else {\r
+ pos = service.pullExecStatistics(jobId,\r
+ pos.getNextPosition());\r
+ }\r
+ Thread.sleep(10);\r
+ System.out.print(pos.getChunk());\r
+ }\r
+ System.out.println();\r
+ System.out.println(service.getResult(jobId));\r
+ } catch (ConnectException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ } catch (WebServiceException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ } catch (ResultNotAvailableException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ } catch (FileNotFoundException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ } catch (IOException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ } catch (JobSubmissionException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ } catch (InterruptedException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ }\r
+ }\r
+\r
+ @Test(groups = {AllTestSuit.test_group_webservices})\r
+ public void testPullRunningJob() {\r
+ MsaWS service = null;\r
+ try {\r
+ service = (MsaWS) Jws2Client.connect(\r
+ "http://webserv1.cluster.lifesci.dundee.ac.uk:8089/jabaws",\r
+ Services.ProbconsWS);\r
+ String jobId = "@Probcons#158079030012566";\r
+ ChunkHolder pos = null;\r
+ while (service.getJobStatus(jobId) == JobStatus.RUNNING) {\r
+ if (pos == null) {\r
+ pos = service.pullExecStatistics(jobId, 0);\r
+ } else {\r
+ pos = service.pullExecStatistics(jobId,\r
+ pos.getNextPosition());\r
+ }\r
+ Thread.sleep(10);\r
+ System.out.print(pos.getChunk());\r
+ }\r
+ System.out.println();\r
+ System.out.println(service.getResult(jobId));\r
+ } catch (ConnectException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ } catch (WebServiceException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ } catch (ResultNotAvailableException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ } catch (InterruptedException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ }\r
+ }\r
}\r