File puller tester
authorpvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Tue, 20 Dec 2011 12:00:16 +0000 (12:00 +0000)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Tue, 15 May 2012 16:27:12 +0000 (17:27 +0100)
git-svn-id: link to svn.lifesci.dundee.ac.uk/svn/barton/ptroshin/JABA2@4832 e3abac25-378b-4346-85de-24260fe3988d

testsrc/compbio/ws/server/RegistryWSTester.java

index 51bfa71..34f7b6c 100644 (file)
@@ -4,15 +4,27 @@ import static org.testng.Assert.assertNotNull;
 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
@@ -119,4 +131,92 @@ public class RegistryWSTester {
                        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