further work on registry & WSTester nearly there
authorpvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Tue, 7 Jun 2011 16:47:05 +0000 (16:47 +0000)
committerpvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Tue, 7 Jun 2011 16:47:05 +0000 (16:47 +0000)
git-svn-id: link to svn.lifesci.dundee.ac.uk/svn/barton/ptroshin/JABA2@4229 e3abac25-378b-4346-85de-24260fe3988d

testsrc/compbio/metadata/AllTestSuit.java
testsrc/compbio/ws/client/WSTesterTester.java
testsrc/compbio/ws/server/RegistryWSTester.java
webservices/compbio/data/msa/RegistryWS.java
webservices/compbio/ws/client/WSTester.java
webservices/compbio/ws/server/RegistryWS.java

index c359d28..4ae260e 100644 (file)
@@ -52,6 +52,7 @@ public class AllTestSuit {
        public final static String test_group_cluster = "cluster";\r
        public final static String test_group_runner = "runner";\r
        public final static String test_group_non_windows = "non_windows";\r
+       public final static String test_group_windows_only = "windows_only";\r
        public final static String test_group_engine = "engine";\r
        public final static String test_group_long = "performance";\r
 \r
index 43204e5..5fe0a35 100644 (file)
@@ -6,7 +6,6 @@ import java.io.PrintWriter;
 \r
 import org.testng.annotations.Test;\r
 \r
-import compbio.data.msa.JABAService;\r
 import compbio.metadata.AllTestSuit;\r
 \r
 public class WSTesterTester {\r
@@ -15,18 +14,13 @@ public class WSTesterTester {
 \r
        @Test(groups = {AllTestSuit.test_group_runner})\r
        public void testAllWindowsWS() {\r
-               WSTester tester = new WSTester(new PrintWriter(System.out, true));\r
-               JABAService ws = Jws2Client.connect(SERVER, Services.AAConWS);\r
-               assertTrue(tester.checkService(ws));\r
+               WSTester tester = new WSTester(SERVER,\r
+                               new PrintWriter(System.out, true));\r
 \r
-               ws = Jws2Client.connect(SERVER, Services.JronnWS);\r
-               assertTrue(tester.checkService(ws));\r
-\r
-               ws = Jws2Client.connect(SERVER, Services.ClustalWS);\r
-               assertTrue(tester.checkService(ws));\r
-\r
-               ws = Jws2Client.connect(SERVER, Services.MuscleWS);\r
-               assertTrue(tester.checkService(ws));\r
+               assertTrue(tester.checkService(Services.AAConWS));\r
+               assertTrue(tester.checkService(Services.JronnWS));\r
+               assertTrue(tester.checkService(Services.ClustalWS));\r
+               assertTrue(tester.checkService(Services.MuscleWS));\r
 \r
                // Will throw UnsupportedRuntimeException on windows\r
                // ws = Jws2Client.connect(SERVER, Services.MafftWS);\r
@@ -36,11 +30,9 @@ public class WSTesterTester {
 \r
        @Test(groups = {AllTestSuit.test_group_non_windows})\r
        public void testAllWS() {\r
-               WSTester tester = new WSTester(new PrintWriter(System.out));\r
-\r
+               WSTester tester = new WSTester(SERVER, new PrintWriter(System.out));\r
                for (Services service : Services.values()) {\r
-                       JABAService ws = Jws2Client.connect(SERVER, service);\r
-                       assertTrue(tester.checkService(ws));\r
+                       assertTrue(tester.checkService(service));\r
                }\r
        }\r
 \r
index 4093626..91ee328 100644 (file)
@@ -1,25 +1,68 @@
 package compbio.ws.server;\r
 \r
+import static org.testng.Assert.assertEquals;\r
+import static org.testng.Assert.assertNotNull;\r
+import static org.testng.Assert.assertTrue;\r
+import static org.testng.Assert.fail;\r
+\r
+import java.util.EnumSet;\r
+\r
 import org.testng.annotations.Test;\r
 \r
+import compbio.metadata.AllTestSuit;\r
 import compbio.ws.client.Jws2Client;\r
 import compbio.ws.client.Services;\r
 import compbio.ws.client.WSTesterTester;\r
 \r
 public class RegistryWSTester {\r
 \r
-       @Test\r
+       @Test(groups = {AllTestSuit.test_group_windows_only})\r
        public void testGetSupportedServices() {\r
                compbio.data.msa.RegistryWS reg = Jws2Client\r
                                .connectToRegistry(WSTesterTester.SERVER);\r
-               System.out.println(reg.getSupportedServices());\r
+               assertEquals(EnumSet.of(Services.AAConWS, Services.JronnWS,\r
+                               Services.MuscleWS, Services.ClustalWS),\r
+                               reg.getSupportedServices());\r
        }\r
-\r
-       @Test\r
+       @Test()\r
        public void testTestService() {\r
                compbio.data.msa.RegistryWS reg = Jws2Client\r
                                .connectToRegistry(WSTesterTester.SERVER);\r
-               System.out.println(reg.testService(Services.AAConWS));\r
+               assertNotNull(reg.testService(Services.AAConWS));\r
+       }\r
+\r
+       @Test(dependsOnMethods = {"testTestService"})\r
+       public void testIsOperating() {\r
+               compbio.data.msa.RegistryWS reg = Jws2Client\r
+                               .connectToRegistry(WSTesterTester.SERVER);\r
+               assertTrue(reg.isOperating(Services.AAConWS));\r
+       }\r
+\r
+       @Test(dependsOnMethods = {"testTestService"})\r
+       public void testGetLastTestedOn() {\r
+               compbio.data.msa.RegistryWS reg = Jws2Client\r
+                               .connectToRegistry(WSTesterTester.SERVER);\r
+               assertNotNull(reg.getLastTestedOn(Services.AAConWS));\r
        }\r
 \r
+       @Test(dependsOnMethods = {"testTestService"})\r
+       public void testGetLastTested() {\r
+               try {\r
+                       Thread.sleep(1000);\r
+               } catch (InterruptedException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
+               }\r
+               compbio.data.msa.RegistryWS reg = Jws2Client\r
+                               .connectToRegistry(WSTesterTester.SERVER);\r
+               System.out.println(reg.getLastTested(Services.AAConWS));\r
+               assertTrue(reg.getLastTested(Services.AAConWS) > 0);\r
+       }\r
+\r
+       @Test()\r
+       public void testTestAllServices() {\r
+               compbio.data.msa.RegistryWS reg = Jws2Client\r
+                               .connectToRegistry(WSTesterTester.SERVER);\r
+               System.out.println(reg.testAllServices());\r
+       }\r
 }\r
index 3dd89b5..9f55ff9 100644 (file)
@@ -7,12 +7,60 @@ import javax.jws.WebService;
 \r
 import compbio.ws.client.Services;\r
 \r
+/**\r
+ * JABAWS services registry\r
+ * \r
+ * @author pvtroshin\r
+ * @version 1.0 June 2011\r
+ */\r
 @WebService(targetNamespace = "http://msa.data.compbio/01/12/2010/")\r
 public interface RegistryWS extends JABAService {\r
+\r
+       /**\r
+        * List of services that are functioning on the server. This function\r
+        * returns the results of testing performed some time ago by\r
+        * {@link #testAllServices} or {@link #testService(Services)} methods. The\r
+        * time of last check can be obtained from\r
+        * {@link #getLastTestedOn(Services)} method\r
+        * \r
+        * @return the Set of Services which are functioning on the server\r
+        * @see #testAllServices()\r
+        */\r
        Set<Services> getSupportedServices();\r
+       /**\r
+        * Number of seconds since the last test. Returns 0 if the service was not\r
+        * tested or tested less then a one second ago.\r
+        * \r
+        * @param service\r
+        * @return\r
+        */\r
+       int getLastTested(Services service);\r
+       /**\r
+        * The date and time the service has been verified to work last time\r
+        * \r
+        * @param service\r
+        * @return the Date and time on which the service was last tested\r
+        */\r
        Date getLastTestedOn(Services service);\r
+       /**\r
+        * Test all JABAWS services on the server\r
+        * \r
+        * @return the test log\r
+        */\r
        String testAllServices();\r
+       /**\r
+        * Test a particular service\r
+        * \r
+        * @param service\r
+        * @return the testing log\r
+        */\r
        String testService(Services service);\r
+       /**\r
+        * Check whether a particular web service is working on this server\r
+        * \r
+        * @param service\r
+        * @return true if the service was functioning in time of last testing.\r
+        */\r
        boolean isOperating(Services service);\r
 \r
 }\r
index 05bd0b8..a0e635b 100644 (file)
@@ -29,8 +29,6 @@ import java.io.PrintWriter;
 import java.util.Arrays;\r
 import java.util.List;\r
 \r
-import javax.xml.ws.WebServiceException;\r
-\r
 import org.apache.log4j.Logger;\r
 \r
 import compbio.data.msa.JABAService;\r
@@ -52,6 +50,8 @@ import compbio.metadata.ResultNotAvailableException;
 import compbio.metadata.RunnerConfig;\r
 import compbio.metadata.UnsupportedRuntimeException;\r
 import compbio.metadata.WrongParameterException;\r
+import compbio.util.FileUtil;\r
+import compbio.util.Util;\r
 \r
 /**\r
  * Class for testing web services\r
@@ -89,7 +89,7 @@ public class WSTester {
         * \r
         * @return List of FastaSequence records\r
         */\r
-       static List<FastaSequence> loadSeqs() {\r
+       private static List<FastaSequence> loadSeqs() {\r
                try {\r
                        return SequenceUtil.readFasta(new ByteArrayInputStream(fastaInput\r
                                        .getBytes()));\r
@@ -105,7 +105,7 @@ public class WSTester {
         * \r
         * @return List of FastaSequence records\r
         */\r
-       static List<FastaSequence> loadAlignment() {\r
+       private static List<FastaSequence> loadAlignment() {\r
                try {\r
                        return SequenceUtil.readFasta(new ByteArrayInputStream(\r
                                        fastaAlignment.getBytes()));\r
@@ -117,27 +117,34 @@ public class WSTester {
        }\r
 \r
        private final PrintWriter writer;\r
+       private final String hostname;\r
 \r
-       public WSTester(PrintWriter writer) {\r
+       public WSTester(String hostname, PrintWriter writer) {\r
+               if (Util.isEmpty(hostname)) {\r
+                       throw new NullPointerException("Hostname must be provided!");\r
+               }\r
+               this.hostname = hostname;\r
                this.writer = writer;\r
        }\r
 \r
        /**\r
         * Prints usage\r
         */\r
-       void printUsage() {\r
-               writer.println("Usage: <Class or Jar file name> " + hostkey\r
+       static void printUsage() {\r
+               System.out.println("Usage: <Class or Jar file name> " + hostkey\r
                                + pseparator + "host_and_context " + "<" + servicekey\r
                                + pseparator + "serviceName>");\r
-               writer.println();\r
-               writer.println(hostkey\r
-                               + pseparator\r
-                               + "<host_and_context> - a full URL to the JABAWS web server including context path e.g. http://10.31.1.159:8080/ws");\r
-               writer.println(servicekey\r
-                               + pseparator\r
-                               + "<ServiceName> - optional if unspecified all services are tested otherwise one of "\r
-                               + Arrays.toString(Services.values()));\r
-               writer.println();\r
+               System.out.println();\r
+               System.out\r
+                               .println(hostkey\r
+                                               + pseparator\r
+                                               + "<host_and_context> - a full URL to the JABAWS web server including context path e.g. http://10.31.1.159:8080/ws");\r
+               System.out\r
+                               .println(servicekey\r
+                                               + pseparator\r
+                                               + "<ServiceName> - optional if unspecified all services are tested otherwise one of "\r
+                                               + Arrays.toString(Services.values()));\r
+               System.out.println();\r
 \r
        }\r
 \r
@@ -150,7 +157,7 @@ public class WSTester {
         *            list of the Preset\r
         * @throws UnsupportedRuntimeException\r
         */\r
-       <T> boolean presetAlign(MsaWS<T> msaws, List<Preset<T>> presets)\r
+       private <T> boolean presetAlign(MsaWS<T> msaws, List<Preset<T>> presets)\r
                        throws UnsupportedRuntimeException {\r
                boolean succeed = false;\r
                for (Preset<T> preset : presets) {\r
@@ -196,9 +203,9 @@ public class WSTester {
 \r
        private <T> boolean testMsaWS(MsaWS<T> msaws)\r
                        throws UnsupportedRuntimeException {\r
+               assert msaws != null;\r
 \r
                boolean succeed = testDefaultAlignment(msaws);\r
-\r
                // If exception above is thrown than the tests below is not run\r
 \r
                PresetManager<T> pmanager = msaws.getPresets();\r
@@ -222,12 +229,13 @@ public class WSTester {
         *             executable does not exists for a server platform\r
         */\r
        @SuppressWarnings("unchecked")\r
-       public <T> boolean checkService(JABAService wservice) {\r
+       private <T> boolean checkService(JABAService wservice) {\r
                try {\r
                        if (wservice == null) {\r
                                throw new NullPointerException(\r
                                                "JABAService instance must be provided!");\r
                        }\r
+\r
                        if (wservice instanceof MsaWS) {\r
                                return testMsaWS((MsaWS<T>) wservice);\r
                        } else if (wservice instanceof SequenceAnnotation) {\r
@@ -245,13 +253,16 @@ public class WSTester {
 \r
        private <T> boolean testSequenceAnnotationWS(SequenceAnnotation<T> wservice)\r
                        throws UnsupportedRuntimeException {\r
+               writer.println("Calling analyse.........");\r
                boolean success = testDefaultAnalyse(loadAlignment(), wservice, null,\r
                                null);\r
+\r
                PresetManager<T> presetman = wservice.getPresets();\r
                if (presetman != null) {\r
                        List<Preset<T>> presets = presetman.getPresets();\r
                        if (presets != null && !presets.isEmpty()) {\r
                                Preset<T> preset = presets.get(0);\r
+                               writer.println("Calling analyse with Preset.........");\r
                                success = testDefaultAnalyse(loadAlignment(), wservice, preset,\r
                                                null);\r
                        }\r
@@ -260,7 +271,7 @@ public class WSTester {
                return success;\r
        }\r
 \r
-       <T> boolean testDefaultAnalyse(List<FastaSequence> fastalist,\r
+       private <T> boolean testDefaultAnalyse(List<FastaSequence> fastalist,\r
                        SequenceAnnotation<T> wsproxy, Preset<T> preset,\r
                        List<Option<T>> customOptions) throws UnsupportedRuntimeException {\r
 \r
@@ -274,7 +285,6 @@ public class WSTester {
                        } else {\r
                                jobId = wsproxy.analize(fastalist);\r
                        }\r
-                       writer.println("\n\ncalling analise.........");\r
                        Thread.sleep(1000);\r
                        scores = wsproxy.getAnnotation(jobId);\r
 \r
@@ -344,7 +354,7 @@ public class WSTester {
         * @param msaws\r
         * @throws UnsupportedRuntimeException\r
         */\r
-       public <T> boolean testDefaultAlignment(MsaWS<T> msaws)\r
+       private <T> boolean testDefaultAlignment(MsaWS<T> msaws)\r
                        throws UnsupportedRuntimeException {\r
                writer.print("Testing alignment with default parameters:");\r
                Alignment al = null;\r
@@ -361,20 +371,14 @@ public class WSTester {
                        writer.print("Retrieving results...");\r
                        al = msaws.getResult(taskId);\r
                        succeed = true;\r
-               } catch (ResultNotAvailableException e) {\r
-                       writer.println(FAILED);\r
-                       writer.println(e.getLocalizedMessage());\r
-                       e.printStackTrace(writer);\r
-               } catch (JobSubmissionException e) {\r
-                       writer.println(FAILED);\r
-                       writer.println();\r
-                       writer.println(e.getLocalizedMessage());\r
-                       e.printStackTrace(writer);\r
-               } catch (InterruptedException e) {\r
-                       writer.println(FAILED);\r
-                       writer.println();\r
-                       writer.println(e.getLocalizedMessage());\r
-                       e.printStackTrace(writer);\r
+               } catch (Exception e) {\r
+                       if (e instanceof UnsupportedRuntimeException) {\r
+                               throw (UnsupportedRuntimeException) e;\r
+                       } else {\r
+                               writer.println(FAILED);\r
+                               writer.println(e.getLocalizedMessage());\r
+                               e.printStackTrace(writer);\r
+                       }\r
                }\r
                if (al != null) {\r
                        writer.println(OK);\r
@@ -383,29 +387,6 @@ public class WSTester {
        }\r
 \r
        /**\r
-        * Connect to a WS using the host and the service name\r
-        * \r
-        * @param <T>\r
-        * @param host\r
-        * @param service\r
-        * @return\r
-        */\r
-       <T> JABAService connect(String host, Services service) {\r
-               JABAService jabaservice = null;\r
-               try {\r
-                       writer.print("Connecting to service " + service + " on " + host\r
-                                       + " ... ");\r
-                       jabaservice = Jws2Client.connect(host, service);\r
-                       writer.println(OK);\r
-               } catch (WebServiceException e) {\r
-                       writer.println(FAILED);\r
-                       writer.println(e.getLocalizedMessage());\r
-                       e.printStackTrace(writer);\r
-               }\r
-               return jabaservice;\r
-       }\r
-\r
-       /**\r
         * Test JWS2 web services\r
         * \r
         * @param <T>\r
@@ -419,20 +400,20 @@ public class WSTester {
         * @throws IOException\r
         */\r
        public static <T> void main(String[] args) throws IOException {\r
-               WSTester tester = new WSTester(new PrintWriter(System.out, true));\r
+\r
                if (args == null || args.length < 1) {\r
-                       tester.printUsage();\r
+                       WSTester.printUsage();\r
                        System.exit(0);\r
                }\r
                String host = CmdHelper.getHost(args);\r
                String serviceName = CmdHelper.getServiceName(args);\r
                if (!Jws2Client.validURL(host)) {\r
-                       tester.writer\r
+                       System.err\r
                                        .println("<host_and_context> parameter is not provided or is incorrect!");\r
                        System.exit(1);\r
                }\r
-               boolean succeed = false;\r
-               MsaWS<T> msaws = null;\r
+               WSTester tester = new WSTester(host, new PrintWriter(System.out, true));\r
+\r
                if (serviceName != null) {\r
                        Services service = Services.getService(serviceName);\r
                        if (service == null) {\r
@@ -440,21 +421,10 @@ public class WSTester {
                                                + "' is not supported. Valid values are: "\r
                                                + Arrays.toString(Services.values()));\r
                                tester.writer.println();\r
-                               tester.printUsage();\r
-                               System.exit(1);\r
-                       }\r
-\r
-                       msaws = (MsaWS<T>) tester.connect(host, service);\r
-                       if (msaws == null) {\r
+                               printUsage();\r
                                System.exit(1);\r
                        }\r
-                       try {\r
-                               succeed = tester.checkService(msaws);\r
-                       } finally {\r
-                               ((Closeable) msaws).close();\r
-                       }\r
-                       // TODO test results printing!\r
-                       tester.reportResults(service, succeed);\r
+                       tester.checkService(service);\r
                        System.exit(0);\r
                }\r
 \r
@@ -463,26 +433,36 @@ public class WSTester {
 \r
                for (Services serv : Services.values()) {\r
                        tester.writer.println();\r
-                       msaws = (MsaWS<T>) tester.connect(host, serv);\r
-                       if (msaws == null) {\r
-                               continue;\r
-                       }\r
-                       try {\r
-                               succeed = tester.checkService(msaws);\r
-                       } finally {\r
-                               ((Closeable) msaws).close();\r
-                       }\r
-                       tester.reportResults(serv, succeed);\r
+                       tester.checkService(serv);\r
                }\r
 \r
        }\r
+\r
+       public boolean checkService(Services service) {\r
+               JABAService ws = Jws2Client.connect(hostname, service);\r
+               if (ws == null) {\r
+                       writer.println("Cannot estabilish the connection to host "\r
+                                       + hostname + " with service " + service.toString());\r
+                       return false;\r
+               }\r
+               boolean succeed = false;\r
+               try {\r
+                       writer.println("Checking service " + service.toString());\r
+                       succeed = checkService(ws);\r
+               } finally {\r
+                       FileUtil.closeSilently(((Closeable) ws));\r
+               }\r
+               reportResults(service, succeed);\r
+               return succeed;\r
+       }\r
+\r
        private void reportResults(Services serv, boolean succeed) {\r
                if (succeed) {\r
                        writer.println("Check is completed. The Service " + serv\r
-                                       + " IS WORKING");\r
+                                       + " IS WORKING\n");\r
                } else {\r
                        writer.println("Check is completed. The Service " + serv\r
-                                       + " HAS SOME PROBLEMS");\r
+                                       + " HAS SOME PROBLEMS\n");\r
                }\r
        }\r
 }\r
index 869807b..dda265e 100644 (file)
@@ -17,12 +17,11 @@ import javax.xml.ws.handler.MessageContext;
 import org.apache.log4j.Logger;\r
 \r
 import compbio.data.msa.JABAService;\r
-import compbio.ws.client.Jws2Client;\r
 import compbio.ws.client.Services;\r
 import compbio.ws.client.WSTester;\r
 \r
 /**\r
- * TODO\r
+ * JABAWS services registry\r
  * \r
  * @author pvtroshin\r
  * \r
@@ -34,20 +33,10 @@ public class RegistryWS implements compbio.data.msa.RegistryWS, JABAService {
        @Resource\r
        WebServiceContext wsContext;\r
 \r
-       private static Logger statLog = Logger.getLogger("RegistryWS-stats");\r
        private static Logger log = Logger.getLogger(RegistryWS.class);\r
 \r
        private final static Map<Services, Date> operating = new ConcurrentHashMap<Services, Date>();\r
 \r
-       /**\r
-        * 1) Check that the actual executable is configured\r
-        * \r
-        * 2) Check whether the service is enabled?\r
-        * \r
-        * 3) Attempt to execute?\r
-        * \r
-        * @return\r
-        */\r
        @Override\r
        public Set<Services> getSupportedServices() {\r
                init();\r
@@ -55,28 +44,55 @@ public class RegistryWS implements compbio.data.msa.RegistryWS, JABAService {
        }\r
 \r
        private void init() {\r
-               // This can be run concurrently\r
+               // This should not be run concurrently\r
                if (operating.isEmpty()) {\r
-                       testAllServices();\r
+                       synchronized (operating) {\r
+                               if (operating.isEmpty()) {\r
+                                       testAllServices();\r
+                               }\r
+                       }\r
                }\r
        }\r
+\r
+       @Override\r
+       public int getLastTested(Services service) {\r
+               Date testedOn = getLastTestedOn(service);\r
+               if (testedOn != null) {\r
+                       return (int) ((System.currentTimeMillis() - testedOn.getTime()) / 1000);\r
+               }\r
+               return 0;\r
+       }\r
+\r
+       /**\r
+        * Can potentially return null if the service has not been tested yet.\r
+        */\r
        @Override\r
        public Date getLastTestedOn(Services service) {\r
-               return operating.get(service);\r
+               if (operating.containsKey(service)) {\r
+                       return operating.get(service);\r
+               }\r
+               return null;\r
        }\r
 \r
+       /**\r
+        * TODO improve reporting. stop testing service on unsupported runtime env\r
+        * exception\r
+        */\r
        @Override\r
        public String testAllServices() {\r
                Writer testlog = new StringWriter();\r
                PrintWriter writer = new PrintWriter(testlog, true);\r
-               WSTester tester = new WSTester(writer);\r
-\r
-               for (Services service : Services.values()) {\r
-                       JABAService ws = Jws2Client.connect(getServicePath(), service);\r
-                       if (tester.checkService(ws)) {\r
-                               operating.put(service, new Date());\r
+               WSTester tester = new WSTester(getServicePath(), writer);\r
+               // This is done deliberately to prevent malicious user from overloading\r
+               // the server\r
+               synchronized (operating) {\r
+                       for (Services service : Services.values()) {\r
+                               if (tester.checkService(service)) {\r
+                                       operating.put(service, new Date());\r
+                               }\r
                        }\r
                }\r
+               writer.close();\r
                return testlog.toString();\r
        }\r
 \r
@@ -96,27 +112,20 @@ public class RegistryWS implements compbio.data.msa.RegistryWS, JABAService {
                String server = getServicePath();\r
                Writer testlog = new StringWriter();\r
                PrintWriter writer = new PrintWriter(testlog, true);\r
-               WSTester tester = new WSTester(writer);\r
-               writer.println("Attempting to connect to the service " + service\r
-                               + " on the server " + server + "...");\r
-               JABAService ws = Jws2Client.connect(server, service);\r
-               writer.println("Connected successfully!");\r
+               WSTester tester = new WSTester(server, writer);\r
                try {\r
-                       boolean succeed = tester.checkService(ws);\r
-                       if (succeed) {\r
-                               // TODO extract messages (see WSTester main)\r
-                               writer.println("Check is completed. The Service "\r
-                                               + service.toString() + " IS WORKING");\r
-                               operating.put(service, new Date());\r
-                       } else {\r
-                               writer.println("Check is completed. The Service "\r
-                                               + service.toString() + " HAS SOME PROBLEMS");\r
+                       synchronized (operating) {\r
+                               boolean succeed = tester.checkService(service);\r
+                               if (succeed) {\r
+                                       operating.put(service, new Date());\r
+                               }\r
                        }\r
                } finally {\r
                        writer.close();\r
                }\r
                return testlog.toString();\r
        }\r
+\r
        @Override\r
        public boolean isOperating(Services service) {\r
                init();\r