test that methods and fields of Category are publicly accessible
authorjprocter <jprocter@e3abac25-378b-4346-85de-24260fe3988d>
Wed, 2 Nov 2011 17:34:40 +0000 (17:34 +0000)
committerjprocter <jprocter@e3abac25-378b-4346-85de-24260fe3988d>
Wed, 2 Nov 2011 17:34:40 +0000 (17:34 +0000)
git-svn-id: link to svn.lifesci.dundee.ac.uk/svn/barton/ptroshin/JABA2@4707 e3abac25-378b-4346-85de-24260fe3988d

testsrc/compbio/test/CategoryTester.java [new file with mode: 0644]
webservices/compbio/data/msa/Category.java

diff --git a/testsrc/compbio/test/CategoryTester.java b/testsrc/compbio/test/CategoryTester.java
new file mode 100644 (file)
index 0000000..83f9cd7
--- /dev/null
@@ -0,0 +1,72 @@
+package compbio.test;\r
+\r
+import java.net.ConnectException;\r
+import java.util.Set;\r
+\r
+import javax.xml.ws.WebServiceException;\r
+\r
+import org.testng.Assert;\r
+import org.testng.annotations.BeforeTest;\r
+import org.testng.annotations.Test;\r
+\r
+import compbio.data.msa.Category;\r
+import compbio.data.msa.RegistryWS;\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 CategoryTester {\r
+\r
+       // test category membership from string constants\r
+       RegistryWS registry = null;\r
+\r
+       @BeforeTest(groups = AllTestSuit.test_group_webservices)\r
+       public void setupTest() {\r
+               try {\r
+                       /*\r
+                        * registry = Jws2Client .connectToRegistry(\r
+                        * "http://webserv1.cluster.lifesci.dundee.ac.uk:8089/jaba");\r
+                        */\r
+                       registry = Jws2Client.connectToRegistry(WSTesterTester.SERVER);\r
+\r
+               } catch (ConnectException e) {\r
+                       e.printStackTrace();\r
+                       Assert.fail(e.getMessage());\r
+               } catch (WebServiceException e) {\r
+                       e.printStackTrace();\r
+                       Assert.fail(e.getMessage());\r
+               }\r
+\r
+       }\r
+\r
+       /*\r
+        * This test will FAIL unless a connection to a running JABAWS web server is\r
+        * made!\r
+        */\r
+       @Test(groups = AllTestSuit.test_group_webservices)\r
+       public void categoryTest() {\r
+               Set<Category> servicecategories = registry.getServiceCategories();\r
+\r
+               boolean found = false;\r
+               for (Category svccategory : servicecategories) {\r
+\r
+                       Set<Services> catservices;\r
+\r
+                       for (String category : new String[]{Category.CATEGORY_ALIGNMENT,\r
+                                       Category.CATEGORY_CONSERVATION, Category.CATEGORY_DISORDER}) {\r
+                               if (category.equals(svccategory.name)) {\r
+                                       found = true;\r
+                                       catservices = svccategory.getServices();\r
+                                       System.out.println("Found " + catservices.size()\r
+                                                       + " services in category " + category\r
+                                                       + "(service category string " + svccategory + ")");\r
+                               }\r
+                       }\r
+               }\r
+               if (!found) {\r
+                       Assert.fail("Could not match any category to one of the given category constants");\r
+               }\r
+       }\r
+\r
+}\r
index 05e6873..56bf1de 100644 (file)
@@ -35,7 +35,7 @@ public class Category {
        public static final String CATEGORY_DISORDER = "Protein Disorder";\r
        public static final String CATEGORY_CONSERVATION = "Conservation";\r
 \r
-       String name;\r
+       public String name;\r
        Set<Services> services;\r
 \r
        private Category(String name, Set<Services> services) {\r
@@ -47,7 +47,7 @@ public class Category {
                // Default constructor for JAXB\r
        }\r
 \r
-       Set<Services> getServices() {\r
+       public Set<Services> getServices() {\r
                return new TreeSet<Services>(services);\r
        }\r
 \r