X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=webservices%2Fcompbio%2Fws%2Fclient%2FWSTester.java;h=883890377832fb70363ca9a33782a53cc1a7d108;hb=1e1c3681ba25ee1797a46f871b8c80f259afe2ca;hp=7091f02524fdf35c0346ea449ee01e5cb8adda4a;hpb=175c6382f4b2838916a98a2d87f1a4fff0103ea6;p=jabaws.git diff --git a/webservices/compbio/ws/client/WSTester.java b/webservices/compbio/ws/client/WSTester.java index 7091f02..8838903 100644 --- a/webservices/compbio/ws/client/WSTester.java +++ b/webservices/compbio/ws/client/WSTester.java @@ -1,6 +1,6 @@ -/* Copyright (c) 2009 Peter Troshin +/* Copyright (c) 2011 Peter Troshin * - * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0 + * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 2.0 * * This library is free software; you can redistribute it and/or modify it under the terms of the * Apache License version 2 as published by the Apache Software Foundation @@ -26,9 +26,12 @@ import java.io.ByteArrayInputStream; import java.io.Closeable; import java.io.IOException; import java.io.PrintWriter; +import java.net.ConnectException; import java.util.Arrays; import java.util.List; +import javax.xml.ws.WebServiceException; + import org.apache.log4j.Logger; import compbio.data.msa.JABAService; @@ -116,6 +119,15 @@ public class WSTester { private final PrintWriter writer; private final String hostname; + /** + * Construct an instance of JABAWS tester + * + * @param hostname + * - fully qualified host and context name of JABAWS e.g. + * http://nanna.cluster.lifesci.dundee.ac.uk:8080/jaba + * @param writer + * a PrintWriter instance to writer test log to. + */ public WSTester(String hostname, PrintWriter writer) { if (Util.isEmpty(hostname)) { throw new NullPointerException("Hostname must be provided!"); @@ -209,7 +221,7 @@ public class WSTester { * executable does not exists for a server platform */ @SuppressWarnings("unchecked") - private boolean checkService(JABAService wservice) { + private boolean checkService(JABAService wservice, Services service) { try { if (wservice == null) { throw new NullPointerException( @@ -219,7 +231,8 @@ public class WSTester { if (wservice instanceof MsaWS) { return testMsaWS((MsaWS) wservice); } else if (wservice instanceof SequenceAnnotation) { - return testSequenceAnnotationWS((SequenceAnnotation) wservice); + return testSequenceAnnotationWS( + (SequenceAnnotation) wservice, service); } else { throw new UnsupportedOperationException("The service: " + wservice.getClass() + " is not supported! "); @@ -230,11 +243,15 @@ public class WSTester { } } - private boolean testSequenceAnnotationWS(SequenceAnnotation wservice) - throws Exception { + private boolean testSequenceAnnotationWS( + SequenceAnnotation wservice, Services service) throws Exception { writer.print("Calling analyse........."); - boolean success = testDefaultAnalyse(loadAlignment(), wservice, null, - null); + + List input = loadSeqs(); + if (service == Services.AAConWS) { + input = loadAlignment(); + } + boolean success = testDefaultAnalyse(input, wservice, null, null); PresetManager presetman = wservice.getPresets(); if (presetman != null) { @@ -242,8 +259,7 @@ public class WSTester { if (presets != null && !presets.isEmpty()) { Preset preset = presets.get(0); writer.print("Calling analyse with Preset........."); - success = testDefaultAnalyse(loadAlignment(), wservice, preset, - null); + success = testDefaultAnalyse(input, wservice, preset, null); } } testMetadata(wservice); @@ -304,6 +320,7 @@ public class WSTester { LimitsManager limits = msaws.getLimits(); if (limits != null && limits.getLimits().size() > 0) { writer.println(OK); + // writer.println("Limits details: \n" + limits.toString()); } else { writer.println(UNSUPPORTED); } @@ -398,7 +415,17 @@ public class WSTester { } - public boolean checkService(Services service) { + /** + * Test JABA web service + * + * @param service + * the service to test + * @return true if the service works as expected, false otherwise + * @throws WebServiceException + * @throws ConnectException + */ + public boolean checkService(Services service) throws ConnectException, + WebServiceException { JABAService ws = Jws2Client.connect(hostname, service); if (ws == null) { writer.println("Cannot estabilish the connection to host " @@ -408,7 +435,7 @@ public class WSTester { boolean succeed = false; try { writer.println("Checking service " + service.toString()); - succeed = checkService(ws); + succeed = checkService(ws, service); } finally { FileUtil.closeSilently(((Closeable) ws)); }