JWS-47 new customAnalize test for IUPredWS - with several unaligned sequences of...
authorjprocter <jprocter@compbio.dundee.ac.uk>
Thu, 2 Aug 2012 11:46:51 +0000 (12:46 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Thu, 2 Aug 2012 13:54:59 +0000 (14:54 +0100)
testsrc/compbio/ws/client/TestIUPredWS.java [new file with mode: 0644]

diff --git a/testsrc/compbio/ws/client/TestIUPredWS.java b/testsrc/compbio/ws/client/TestIUPredWS.java
new file mode 100644 (file)
index 0000000..56533fa
--- /dev/null
@@ -0,0 +1,105 @@
+package compbio.ws.client;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+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.ArrayList;
+import java.util.List;
+
+import javax.xml.ws.WebServiceException;
+
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import compbio.data.msa.JABAService;
+import compbio.data.msa.SequenceAnnotation;
+import compbio.data.sequence.ConservationMethod;
+import compbio.data.sequence.FastaSequence;
+import compbio.data.sequence.ScoreManager;
+import compbio.data.sequence.SequenceUtil;
+import compbio.metadata.AllTestSuit;
+import compbio.metadata.JobSubmissionException;
+import compbio.metadata.LimitExceededException;
+import compbio.metadata.Option;
+import compbio.metadata.PresetManager;
+import compbio.metadata.ResultNotAvailableException;
+import compbio.metadata.RunnerConfig;
+import compbio.metadata.UnsupportedRuntimeException;
+import compbio.metadata.WrongParameterException;
+import compbio.runner.conservation.AACon;
+import compbio.util.SysPrefs;
+import compbio.ws.server.IUPredWS;
+
+public class TestIUPredWS {
+
+       SequenceAnnotation<IUPredWS> msaws;
+
+       @BeforeTest(groups = {AllTestSuit.test_group_webservices})
+       void initConnection() {
+               /*
+                * URL url = null; try { url = new
+                * URL("http://localhost:8080/jabaws/AAConWS?wsdl"); } catch
+                * (MalformedURLException e) { e.printStackTrace();
+                * fail(e.getLocalizedMessage()); } String namespace =
+                * "http://msa.data.compbio/01/12/2010/"; QName qname = new
+                * QName(namespace, "AAConWS"); Service serv = Service.create(url,
+                * qname); msaws = serv.getPort(new QName(namespace, "AAConWSPort"),
+                * Annotation.class);
+                */try {
+                       JABAService client = Jws2Client.connect(
+                                       "http://localhost:18080/jaba", Services.IUPredWS);
+                       msaws = (SequenceAnnotation<IUPredWS>) client;
+               } catch (ConnectException e) {
+                       e.printStackTrace();
+                       fail(e.getMessage());
+               } catch (WebServiceException e) {
+                       e.printStackTrace();
+                       fail(e.getMessage());
+               }
+       }
+
+       @Test(groups = {AllTestSuit.test_group_webservices})
+       public void testCustomAnalize() throws FileNotFoundException, IOException {
+
+               String CURRENT_DIRECTORY = SysPrefs.getCurrentDirectory()
+                               + File.separator;
+
+               List<FastaSequence> fsl = SequenceUtil.readFasta(new FileInputStream(
+                               CURRENT_DIRECTORY + "testsrc" + File.separator + "testdata"
+                                               + File.separator + "TO1381.fasta"));
+
+               try {
+                       List<Option<IUPredWS>> opts=new ArrayList<Option<IUPredWS>>();
+                       opts.add(msaws.getRunnerOptions().getArgumentByOptionName("Long"));
+                       
+                       String jobId = msaws.customAnalize(fsl,opts);
+                       System.out.println("J: " + jobId);
+                       ScoreManager result = msaws.getAnnotation(jobId);
+                       assertNotNull(result);
+//                     assertEquals(result.asSet().size(), 1);
+
+               } catch (UnsupportedRuntimeException e) {
+                       e.printStackTrace();
+                       fail(e.getMessage());
+               } catch (LimitExceededException e) {
+                       e.printStackTrace();
+                       fail(e.getMessage());
+               } catch (JobSubmissionException e) {
+                       e.printStackTrace();
+                       fail(e.getMessage());
+               } catch (ResultNotAvailableException e) {
+                       e.printStackTrace();
+                       fail(e.getMessage());
+               } catch (WrongParameterException e) {
+                       e.printStackTrace();
+                       fail(e.getMessage());
+               }
+
+       }
+}