X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=webservices%2Fcompbio%2Fws%2Fclient%2FWSTester.java;h=2f33cb1dd4a3d4166128722ec99eaa949141cdac;hb=652864eebc0ecdeb6f8bfef1700e3b365a0d7227;hp=883890377832fb70363ca9a33782a53cc1a7d108;hpb=1e1c3681ba25ee1797a46f871b8c80f259afe2ca;p=jabaws.git diff --git a/webservices/compbio/ws/client/WSTester.java b/webservices/compbio/ws/client/WSTester.java index 8838903..2f33cb1 100644 --- a/webservices/compbio/ws/client/WSTester.java +++ b/webservices/compbio/ws/client/WSTester.java @@ -32,8 +32,6 @@ import java.util.List; import javax.xml.ws.WebServiceException; -import org.apache.log4j.Logger; - import compbio.data.msa.JABAService; import compbio.data.msa.Metadata; import compbio.data.msa.MsaWS; @@ -62,22 +60,24 @@ import compbio.util.Util; */ public class WSTester { - private static Logger log = Logger.getLogger(WSTester.class); /** * Sequences to be used as input for all WS */ - static final String fastaInput = ">Foo\n" + public static final String fastaInput2records = ">Foo\n" + "MTADGPRELLQLRAAVRHRPQDFVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAV" + "\n>Bar\n" - + "ASDAAPEHPGIALWLHALEDAGQAEAAAAYTRAHQLLPEEPYITAQLLNAVA"; + + "ASDAAPEHPGIALWLHALEDAGQAEAAAAYTRAHQLLPEEPYITAQLLNAVA\n"; + public static final String fastaInput1record = ">Foo\n" + + "MTADGPRELLQLRAAVRHRPQDFVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAV" + + "\n"; - static final String fastaAlignment = ">Foo\r\n" - + "MTADGPRELLQLRAAVRHRPQDFVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAV--------\r\n" - + ">Bar\r\n" - + "ASDAAPEH------------PGIALWLHALE-DAGQAEAAA---AYTRAHQLLPEEPYITAQLLNAVA\r\n" + public static final String fastaAlignment = ">Foo\n" + + "MTADGPRELLQLRAAVRHRPQDFVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAV--------\n" + + ">Bar\n" + + "ASDAAPEH------------PGIALWLHALE-DAGQAEAAA---AYTRAHQLLPEEPYITAQLLNAVA\n" + ""; - static final List seqs = loadSeqs(); + static final List seqs = loadSeqs(2); private static final String FAILED = "FAILED"; private static final String OK = "OK"; @@ -89,10 +89,12 @@ public class WSTester { * * @return List of FastaSequence records */ - private static List loadSeqs() { + private static List loadSeqs(int nLines) { try { - return SequenceUtil.readFasta(new ByteArrayInputStream(fastaInput - .getBytes())); + if (nLines == 1) { + return SequenceUtil.readFasta(new ByteArrayInputStream(fastaInput1record.getBytes())); + } + return SequenceUtil.readFasta(new ByteArrayInputStream(fastaInput2records.getBytes())); } catch (IOException ignored) { // Should not happen as a source is not a external stream ignored.printStackTrace(); @@ -144,12 +146,10 @@ public class WSTester { + pseparator + "host_and_context " + "<" + servicekey + pseparator + "serviceName>"); System.out.println(); - System.out - .println(hostkey + System.out.println(hostkey + pseparator + " - a full URL to the JABAWS web server including context path e.g. http://10.31.1.159:8080/ws"); - System.out - .println(servicekey + System.out.println(servicekey + pseparator + " - optional if unspecified all services are tested otherwise one of " + Arrays.toString(Services.values())); @@ -224,8 +224,7 @@ public class WSTester { private boolean checkService(JABAService wservice, Services service) { try { if (wservice == null) { - throw new NullPointerException( - "JABAService instance must be provided!"); + throw new NullPointerException("JABAService instance must be provided!"); } if (wservice instanceof MsaWS) { @@ -234,8 +233,7 @@ public class WSTester { return testSequenceAnnotationWS( (SequenceAnnotation) wservice, service); } else { - throw new UnsupportedOperationException("The service: " - + wservice.getClass() + " is not supported! "); + throw new UnsupportedOperationException("The service: " + wservice.getClass() + " is not supported! "); } } catch (Exception e) { reportException(e); @@ -247,10 +245,13 @@ public class WSTester { SequenceAnnotation wservice, Services service) throws Exception { writer.print("Calling analyse........."); - List input = loadSeqs(); + List input = loadSeqs(2); if (service == Services.AAConWS) { input = loadAlignment(); } + if (service == Services.JpredWS) { + input = loadSeqs(1); + } boolean success = testDefaultAnalyse(input, wservice, null, null); PresetManager presetman = wservice.getPresets(); @@ -385,8 +386,7 @@ public class WSTester { String host = CmdHelper.getHost(args); String serviceName = CmdHelper.getServiceName(args); if (!Jws2Client.validURL(host)) { - System.err - .println(" parameter is not provided or is incorrect!"); + System.err.println(" parameter is not provided or is incorrect!"); System.exit(1); } WSTester tester = new WSTester(host, new PrintWriter(System.out, true)); @@ -394,8 +394,7 @@ public class WSTester { if (serviceName != null) { Services service = Services.getService(serviceName); if (service == null) { - tester.writer.println("Service '" + serviceName - + "' is not supported. Valid values are: " + tester.writer.println("Service '" + serviceName + "' is not supported. Valid values are: " + Arrays.toString(Services.values())); tester.writer.println(); printUsage(); @@ -405,8 +404,7 @@ public class WSTester { System.exit(0); } - tester.writer - .println(" is not provided checking all known services..."); + tester.writer.println(" is not provided checking all known services..."); for (Services serv : Services.values()) { tester.writer.println(); @@ -428,8 +426,8 @@ public class WSTester { WebServiceException { JABAService ws = Jws2Client.connect(hostname, service); if (ws == null) { - writer.println("Cannot estabilish the connection to host " - + hostname + " with service " + service.toString()); + String line = "Cannot estabilish the connection to host " + hostname + " with service "; + writer.println(line + service.toString()); return false; } boolean succeed = false; @@ -445,11 +443,9 @@ public class WSTester { private void reportResults(Services serv, boolean succeed) { if (succeed) { - writer.println("Check is completed. The Service " + serv - + " IS WORKING\n"); + writer.println("Check is completed. The Service " + serv + " IS WORKING\n"); } else { - writer.println("Check is aborted. The Service " + serv - + " HAS SOME PROBLEMS\n"); + writer.println("Check is aborted. The Service " + serv + " HAS SOME PROBLEMS\n"); } } }