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