From cac8a9f661bdfd7cf977782f31c85eec619875c8 Mon Sep 17 00:00:00 2001 From: pvtroshin Date: Tue, 20 Dec 2011 12:00:16 +0000 Subject: [PATCH] File puller tester 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 | 100 +++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/testsrc/compbio/ws/server/RegistryWSTester.java b/testsrc/compbio/ws/server/RegistryWSTester.java index 51bfa71..34f7b6c 100644 --- a/testsrc/compbio/ws/server/RegistryWSTester.java +++ b/testsrc/compbio/ws/server/RegistryWSTester.java @@ -4,15 +4,27 @@ import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; import java.net.ConnectException; import java.util.Arrays; +import java.util.List; import java.util.Set; import javax.xml.ws.WebServiceException; import org.testng.annotations.Test; +import compbio.data.msa.MsaWS; +import compbio.data.sequence.FastaSequence; +import compbio.data.sequence.SequenceUtil; import compbio.metadata.AllTestSuit; +import compbio.metadata.ChunkHolder; +import compbio.metadata.JobStatus; +import compbio.metadata.JobSubmissionException; +import compbio.metadata.ResultNotAvailableException; import compbio.ws.client.Jws2Client; import compbio.ws.client.Services; import compbio.ws.client.WSTesterTester; @@ -119,4 +131,92 @@ public class RegistryWSTester { fail(e.getLocalizedMessage()); } } + + @Test(groups = {AllTestSuit.test_group_webservices}) + public void testProgressReporting() { + MsaWS service = null; + try { + service = (MsaWS) Jws2Client.connect( + "http://www.compbio.dundee.ac.uk/jabaws", + // "http://webserv1.cluster.lifesci.dundee.ac.uk:8089/jabaws", + Services.ProbconsWS); + File input = new File(AllTestSuit.TEST_DATA_PATH_ABSOLUTE + + "200x500Protein.fasta"); + assertTrue(input.exists()); + List fs = SequenceUtil + .readFasta(new FileInputStream(input)); + String jobId = service.align(fs); + Thread.sleep(5000); + ChunkHolder pos = null; + while (service.getJobStatus(jobId) == JobStatus.RUNNING) { + if (pos == null) { + pos = service.pullExecStatistics(jobId, 0); + } else { + pos = service.pullExecStatistics(jobId, + pos.getNextPosition()); + } + Thread.sleep(10); + System.out.print(pos.getChunk()); + } + System.out.println(); + System.out.println(service.getResult(jobId)); + } catch (ConnectException e) { + e.printStackTrace(); + fail(e.getLocalizedMessage()); + } catch (WebServiceException e) { + e.printStackTrace(); + fail(e.getLocalizedMessage()); + } catch (ResultNotAvailableException e) { + e.printStackTrace(); + fail(e.getLocalizedMessage()); + } catch (FileNotFoundException e) { + e.printStackTrace(); + fail(e.getLocalizedMessage()); + } catch (IOException e) { + e.printStackTrace(); + fail(e.getLocalizedMessage()); + } catch (JobSubmissionException e) { + e.printStackTrace(); + fail(e.getLocalizedMessage()); + } catch (InterruptedException e) { + e.printStackTrace(); + fail(e.getLocalizedMessage()); + } + } + + @Test(groups = {AllTestSuit.test_group_webservices}) + public void testPullRunningJob() { + MsaWS service = null; + try { + service = (MsaWS) Jws2Client.connect( + "http://webserv1.cluster.lifesci.dundee.ac.uk:8089/jabaws", + Services.ProbconsWS); + String jobId = "@Probcons#158079030012566"; + ChunkHolder pos = null; + while (service.getJobStatus(jobId) == JobStatus.RUNNING) { + if (pos == null) { + pos = service.pullExecStatistics(jobId, 0); + } else { + pos = service.pullExecStatistics(jobId, + pos.getNextPosition()); + } + Thread.sleep(10); + System.out.print(pos.getChunk()); + } + System.out.println(); + System.out.println(service.getResult(jobId)); + } catch (ConnectException e) { + e.printStackTrace(); + fail(e.getLocalizedMessage()); + } catch (WebServiceException e) { + e.printStackTrace(); + fail(e.getLocalizedMessage()); + } catch (ResultNotAvailableException e) { + e.printStackTrace(); + fail(e.getLocalizedMessage()); + } catch (InterruptedException e) { + e.printStackTrace(); + fail(e.getLocalizedMessage()); + } + } } -- 1.7.10.2