A few minor changes to the test
[jabaws.git] / testsrc / compbio / data / msa / CategoryTester.java
1 package compbio.data.msa;\r
2 \r
3 import java.net.ConnectException;\r
4 import java.util.Set;\r
5 \r
6 import javax.xml.ws.WebServiceException;\r
7 \r
8 import org.testng.Assert;\r
9 import org.testng.annotations.BeforeTest;\r
10 import org.testng.annotations.Test;\r
11 \r
12 import compbio.metadata.AllTestSuit;\r
13 import compbio.ws.client.Jws2Client;\r
14 import compbio.ws.client.Services;\r
15 import compbio.ws.client.WSTesterTester;\r
16 \r
17 public class CategoryTester {\r
18 \r
19         // test category membership from string constants\r
20         RegistryWS registry = null;\r
21 \r
22         @BeforeTest(groups = AllTestSuit.test_group_webservices)\r
23         public void setupTest() {\r
24                 try {\r
25                         /*\r
26                          * registry = Jws2Client .connectToRegistry(\r
27                          * "http://webserv1.cluster.lifesci.dundee.ac.uk:8089/jaba");\r
28                          */\r
29                         registry = Jws2Client.connectToRegistry(WSTesterTester.SERVER);\r
30 \r
31                 } catch (ConnectException e) {\r
32                         e.printStackTrace();\r
33                         Assert.fail(e.getMessage());\r
34                 } catch (WebServiceException e) {\r
35                         e.printStackTrace();\r
36                         Assert.fail(e.getMessage());\r
37                 }\r
38 \r
39         }\r
40 \r
41         /*\r
42          * This test will FAIL unless a connection to a running JABAWS web server is\r
43          * made!\r
44          */\r
45         @Test(groups = AllTestSuit.test_group_webservices)\r
46         public void categoryTest() {\r
47                 Set<Category> servicecategories = registry.getServiceCategories();\r
48 \r
49                 boolean found = false;\r
50                 for (Category svccategory : servicecategories) {\r
51 \r
52                         Set<Services> catservices;\r
53 \r
54                         for (String category : new String[]{Category.CATEGORY_ALIGNMENT,\r
55                                         Category.CATEGORY_CONSERVATION, Category.CATEGORY_DISORDER}) {\r
56                                 if (category.equals(svccategory.name)) {\r
57                                         found = true;\r
58                                         catservices = svccategory.getServices();\r
59                                         System.out.println("Found " + catservices.size()\r
60                                                         + " services in category " + category\r
61                                                         + "(service category string " + svccategory + ")");\r
62                                 }\r
63                         }\r
64                 }\r
65                 if (!found) {\r
66                         Assert.fail("Could not match any category to one of the given category constants");\r
67                 }\r
68         }\r
69 \r
70 }\r