Webservice which implements FoldWS and returns String. Parameters.xml file
[jabaws.git] / testsrc / compbio / ws / client / TestRNAalifoldWS.java
index 2d392f7..b061fcc 100644 (file)
@@ -1,5 +1,6 @@
 package compbio.ws.client;
 
+import compbio.metadata.AllTestSuit;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertNotNull;
 import static org.testng.Assert.fail;
@@ -17,10 +18,10 @@ import javax.xml.ws.WebServiceException;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 
+import compbio.data.msa.FoldWS;
 import compbio.data.msa.JABAService;
 import compbio.data.msa.SequenceAnnotation;
 import compbio.data.sequence.Alignment;
-import compbio.data.structure.FoldWS;
 import compbio.data.sequence.RNAstruct;
 import compbio.data.sequence.ClustalAlignmentUtil;
 import compbio.data.sequence.ConservationMethod;
@@ -37,47 +38,50 @@ 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.RNAalifoldWS;
 
+
 public class TestRNAalifoldWS {
        
        FoldWS<RNAalifoldWS> foldws;
        
-//     @BeforeTest(groups = {AllTestSuit.test_group_webservices})
-//     void initConnection() {
-//             
-//             try {
-//                     JABAService client = Jws2Client.connect(
-//                                     "http://localhost:8080/jabaws", Services.RNAalifoldWS);
-//                     foldws = (FoldWS<RNAalifoldWS>) client;
-//             } catch (ConnectException e) {
-//                     e.printStackTrace();
-//                     fail(e.getMessage());
-//             } catch (WebServiceException e) {
-//                     e.printStackTrace();
-//                     fail(e.getMessage());
-//             }
-//     }
+       @BeforeTest(groups = {AllTestSuit.test_group_webservices})
+       void initConnection() {
+               
+               try {
+                       JABAService client = Jws2Client.connect(
+                                       "http://localhost:8080/jabaws", Services.RNAalifoldWS);
+                       foldws = (FoldWS<RNAalifoldWS>) 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 testFold() throws FileNotFoundException, IOException,
                        UnknownFileFormatException {
                
-               String CURRENT_DIRECTORY = SysPrefs.getCurrentDirectory()
-                               + File.separator;
+//             String CURRENT_DIRECTORY = SysPrefs.getCurrentDirectory()
+//                             + File.separator;
                
                Alignment aln = ClustalAlignmentUtil.readClustalFile(new FileInputStream(
-                               CURRENT_DIRECTORY + "testsrc" + File.separator + "testdata"
-                                       + File.separator + "unfolded_RF00031.aln"));
+                               AllTestSuit.test_input_aln));
                
                try {
-                       String jobId = foldws.fold(aln);
+                       List<Option<RNAalifoldWS>> options  = new ArrayList<Option<RNAalifoldWS>>();
+                       options.add(foldws.getRunnerOptions().getArgumentByOptionName("--mis"));
+                       System.out.println("TestRNAalifoldWS: print options: " + options.toString());
+                       String jobId = foldws.customFold(aln, options);
                        System.out.println("J: " + jobId);
-                       RNAstruct result = foldws.getResult(jobId);
+                       String result = foldws.getResult(jobId);
+                       System.out.println("fold results: \n" + result);
                        assertNotNull(result);
                        
                } catch (UnsupportedRuntimeException e) {
@@ -92,7 +96,10 @@ public class TestRNAalifoldWS {
                } catch (ResultNotAvailableException e) {
                        e.printStackTrace();
                        fail(e.getMessage());
-               } 
+               } catch (WrongParameterException e) {
+                       e.printStackTrace();
+                       fail(e.getMessage());
+               }
        }
 }