diff --git a/pom.xml b/pom.xml index d2bd1c4..0948c1b 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ - + 4.0.0 eu.omp.irap.vespa @@ -10,7 +10,7 @@ epnTAPCLient The Epn-TAP library aims to provide methods to manage resources, services and dataset wich implements the epn-TAP core, in order to get data and deal with it with any other software, ie. though a SAMP hub. It also comes with a GUI, initialy built to be integrated on the Cassis sofware, but it can be launch as standalone. http://cassis.irap.omp.eu/ - + @@ -22,16 +22,16 @@ - + UTF-8 - + - + maven-compiler-plugin @@ -41,7 +41,7 @@ 1.7 - + org.apache.maven.plugins @@ -68,7 +68,7 @@ true - + org.jvnet.jaxb2.maven2 @@ -84,20 +84,23 @@ src/main/resources/xsd src/main/resources/xjb - - + + - + maven-antrun-plugin 1.7 - + suppress-warning-generated process-sources @@ -127,8 +130,9 @@ - - + + @@ -158,10 +162,10 @@ - + - + com.google.code.gson @@ -169,19 +173,24 @@ 2.2.2 compile - + eu.omp.irap.vespa votable 0.0.1-SNAPSHOT - + + junit + junit + 4.12 + test + - + - + jenkins @@ -210,7 +219,7 @@ - + @@ -218,7 +227,7 @@ https://nexus.irap.omp.eu/content/groups/public - + diff --git a/src/test/java/eu/omp/irap/vespa/epntapclient/EpnTapConnectionTest.java b/src/test/java/eu/omp/irap/vespa/epntapclient/EpnTapConnectionTest.java new file mode 100644 index 0000000..b970129 --- /dev/null +++ b/src/test/java/eu/omp/irap/vespa/epntapclient/EpnTapConnectionTest.java @@ -0,0 +1,192 @@ +/* + * This file is a part of EpnTAPClient. + * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. + * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 + * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. + * + * This program is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public License as published + * by the Free Software Foundation, either version 3 of the License, or (at your option) any later + * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. You should have received a copy of + * the GNU General Public License along with this program. If not, see + * . + */ + +package eu.omp.irap.vespa.epntapclient; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.logging.Logger; + +import org.junit.Test; + +import eu.omp.irap.vespa.epntapclient.granule.Granule; +import eu.omp.irap.vespa.epntapclient.voresource.VOResourceCtrl; +import eu.omp.irap.vespa.epntapclient.voresource.VOResourceException; +import eu.omp.irap.vespa.epntapclient.voresource.model.Resource; +import eu.omp.irap.vespa.epntapclient.votable.model.Field; +import eu.omp.irap.vespa.epntapclient.votable.model.Table; +import eu.omp.irap.vespa.epntapclient.votable.model.VOTABLE; +import eu.omp.irap.vespa.votable.controller.CantGetVOTableException; + +/** + * @author N. Jourdane + */ +public class EpnTapConnectionTest { + + /** The logger for the class Main. */ + private static final Logger logger = Logger.getLogger(EpnTapConnectionTest.class.getName()); + + + @Test + public void getVOResourceTest() throws VOResourceException { + EpnTapConnection facade = new EpnTapConnection(); + Resource resource = VOResourceCtrl.getVOresource("ivo://cdpp/amda"); + + assertEquals("AMDA", resource.getShortName()); + assertEquals("CDPP AMDA DataBase", resource.getTitle()); + assertEquals("Centre de Données de la Physique des Plasmas", + resource.getCuration().getCreator().get(0).getName().getValue()); + } + + @Test + public void getEPNVOResourcesTest() throws VOResourceException { + EpnTapConnection facade = new EpnTapConnection(); + List resources = facade.getEPNVOResources(); + + assertEquals(13, resources.size()); + for (Resource r : resources) { + assertNotNull(r); + } + } + + @Test + public void getEPNVOResourcesWithKeywordsTest() throws VOResourceException { + EpnTapConnection facade = new EpnTapConnection(); + final Map keywords = new HashMap<>(); + keywords.put("shortName", "IKS"); + List resources = facade.getEPNVOResources(); + + assertEquals(2, resources.size()); + } + + @Test + public void getEPNServiceTest() throws CantGetVOTableException { + EpnTapConnection facade = new EpnTapConnection(); + + VOTABLE epnService = facade.getEPNService("ivo://cdpp/amda"); + Table table = (Table) epnService.getRESOURCE().get(0).getLINKAndTABLEOrRESOURCE().get(0); + String firstInfoVal = epnService.getRESOURCE().get(0).getINFO().get(0).getValueAttribute(); + String firstFieldName = ((Field) table.getFIELDOrPARAMOrGROUP().get(0)).getID(); + + assertEquals("http://gavo.aip.de", firstInfoVal); + assertEquals("short_name", firstFieldName); + } + + @Test + public void getEPNServiceWithAttributesTest() throws CantGetVOTableException { + EpnTapConnection facade = new EpnTapConnection(); + + final List serviceAttributes = new ArrayList<>(); + serviceAttributes.add("target_name"); + serviceAttributes.add("time_min"); + serviceAttributes.add("time_max"); + + VOTABLE epnService = facade.getEPNService("ivo://cdpp/amda", serviceAttributes); + Table table = (Table) epnService.getRESOURCE().get(0).getLINKAndTABLEOrRESOURCE().get(0); + String firstInfoVal = epnService.getRESOURCE().get(0).getINFO().get(0).getValueAttribute(); + String firstFieldName = ((Field) table.getFIELDOrPARAMOrGROUP().get(0)).getID(); + + assertEquals("http://cdpp-epntap.cesr.fr", firstInfoVal); + assertEquals("short_name", firstFieldName); + } + + @Test + public void getEPNServicesTest() throws VOResourceException { + EpnTapConnection facade = new EpnTapConnection(); + List voTables = facade.getEPNServices(); + assertEquals(11, voTables.size()); + } + + @Test + public void getEPNServicesWithAttributesTest() + throws VOResourceException, CantGetVOTableException { + final List serviceAttributes = new ArrayList<>(); + serviceAttributes.add("target_name"); + serviceAttributes.add("time_min"); + serviceAttributes.add("time_max"); + + EpnTapConnection facade = new EpnTapConnection(); + List voTables = facade.getEPNServices(serviceAttributes); + String firstInfoVal = voTables.get(0).getRESOURCE().get(0).getINFO().get(0) + .getValueAttribute(); + + assertEquals("http://gavo.aip.de", firstInfoVal); + } + + @Test + public void getEPNServicesWithAttributesAndKeywordsTest() + throws CantGetVOTableException, VOResourceException { + final List serviceAttributes = new ArrayList<>(); + serviceAttributes.add("target_name"); + serviceAttributes.add("time_min"); + serviceAttributes.add("time_max"); + + final Map keywords = new HashMap<>(); + keywords.put("shortName", "IKS"); + + EpnTapConnection facade = new EpnTapConnection(); + List voTables = facade.getEPNServices(keywords, serviceAttributes); + String firstInfoVal = voTables.get(0).getRESOURCE().get(0).getINFO().get(0) + .getValueAttribute(); + assertEquals("http://gavo.aip.de", firstInfoVal); + } + + @Test + public void getEPNCoreTableNameTest() throws CantGetVOTableException { + EpnTapConnection facade = new EpnTapConnection(); + String epnCoreTableName = facade.getEPNCoreTableName("ivo://cdpp/amda"); + assertEquals("?", epnCoreTableName); + } + + @Test + public void getTAPURLTest() throws CantGetVOTableException { + EpnTapConnection facade = new EpnTapConnection(); + String tapURL = facade.getTAPURL("ivo://cdpp/amda"); + assertEquals("http://cdpp-epntap.cesr.fr/__system__/tap/run/tap", tapURL); + } + + @Test + public void sendADQLQueryTest() throws CantGetVOTableException { + EpnTapConnection facade = new EpnTapConnection(); + String tapURL = "http://voparis-tap-planeto.obspm.fr/__system__/tap/run/tap"; + String query = "SELECT TOP 1 * FROM planets.epn_core"; + List granules = facade.sendADQLQuery(tapURL, query); + + assertEquals("?", granules.get(0).granuleUid); + assertEquals("?", granules.get(0).timeMin); + assertEquals("?", granules.get(0).processingLevel); + assertEquals("?", granules.get(0).creationDate); + } + + @Test + public void sendADQLQueryWithSchemaNameTest() throws CantGetVOTableException { + EpnTapConnection facade = new EpnTapConnection(); + String tapURL = "http://voparis-tap-planeto.obspm.fr/__system__/tap/run/tap"; + String schemaName = "amdadb.epn_core"; + String query = "SELECT TOP 1 * FROM planets.epn_core"; + List granules = facade.sendQuery(tapURL, schemaName, query); + + assertEquals("?", granules.get(0).granuleUid); + assertEquals("?", granules.get(0).timeMin); + assertEquals("?", granules.get(0).processingLevel); + assertEquals("?", granules.get(0).creationDate); + } +} diff --git a/src/test/java/eu/omp/irap/vespa/epntapclient/TestEpnTapConnection.java b/src/test/java/eu/omp/irap/vespa/epntapclient/TestEpnTapConnection.java deleted file mode 100644 index c4d58f4..0000000 --- a/src/test/java/eu/omp/irap/vespa/epntapclient/TestEpnTapConnection.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * This file is a part of EpnTAPClient. - * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. - * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 - * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. - * - * This program is free software: you can - * redistribute it and/or modify it under the terms of the GNU General Public License as published - * by the Free Software Foundation, either version 3 of the License, or (at your option) any later - * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. You should have received a copy of - * the GNU General Public License along with this program. If not, see - * . - */ - -package eu.omp.irap.vespa.epntapclient; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.logging.Logger; - -import eu.omp.irap.vespa.epntapclient.granule.Granule; -import eu.omp.irap.vespa.epntapclient.voresource.VOResourceCtrl; -import eu.omp.irap.vespa.epntapclient.voresource.VOResourceException; -import eu.omp.irap.vespa.epntapclient.voresource.model.Resource; -import eu.omp.irap.vespa.epntapclient.votable.model.VOTABLE; -import eu.omp.irap.vespa.votable.controller.CantGetVOTableException; -import eu.omp.irap.vespa.votable.utils.Debug; -import eu.omp.irap.vespa.votable.utils.StringJoiner; - -/** - * @author N. Jourdane - */ -public class TestEpnTapConnection { - - /** The logger for the class Main. */ - private static final Logger logger = Logger.getLogger(TestEpnTapConnection.class.getName()); - - private static final String TEST_SERVICE_IVOID = "ivo://cdpp/amda"; - - private static final String TEST_SERVICE_URL = "http://voparis-tap-planeto.obspm.fr/__system__/tap/run/tap"; - - private static final String TEST_RESOURCE_IVOID = "ivo://vopdc.obspm/lesia/basecom/epn"; - - private static final String TEST_ADQL_QUERY = "SELECT TOP 1 * FROM planets.epn_core"; - - private static final String TEST_SCHEMA_NAME = "epn_core"; - - - public static void main(String[] args) { - EpnTapConnection facade = new EpnTapConnection(); - - final List SERVICE_ATTRIBUTES = new ArrayList<>(); - SERVICE_ATTRIBUTES.add("target_name"); - SERVICE_ATTRIBUTES.add("time_min"); - SERVICE_ATTRIBUTES.add("time_max"); - String strServiceAttributes = "[" + StringJoiner.join(SERVICE_ATTRIBUTES) + "]"; - - final Map KEYWORDS = new HashMap<>(); - KEYWORDS.put("shortName", "IKS"); - String strKeywords = "[shortName=IKS]"; - - try { - System.out.println("\n*** 1. Resource ***\n"); - - Resource resource = VOResourceCtrl.getVOresource(TEST_RESOURCE_IVOID); - System.out.println("1.1 getVOresource(\"" + TEST_RESOURCE_IVOID + "\")\n\t" - + Debug.toJson(resource)); - - System.out.println("\n*** 2. Resources ***\n"); - - List resources = facade.getEPNVOResources(); - System.out.println("2.1 getEPNVOResources()\n\t" - + Debug.toJson(resources)); - - List resources2 = facade.getEPNVOResources(KEYWORDS); - System.out.println("2.2 getEPNVOResources(" + strKeywords + ")\n\t" - + Debug.toJson(resources2)); - - System.out.println("\n*** 3. Service ***\n"); - - VOTABLE epnService = facade.getEPNService(TEST_SERVICE_IVOID); - System.out.println("3.1 getEPNService(\"" + TEST_SERVICE_IVOID + "\")\n\t" - + Debug.toJson(epnService)); - - VOTABLE epnService2 = facade.getEPNService(TEST_SERVICE_IVOID, SERVICE_ATTRIBUTES); - System.out.println("3.2 getEPNService(\"" + TEST_SERVICE_IVOID + "\", " - + strServiceAttributes + ")\n\t" - + Debug.toJson(epnService2)); - - System.out.println("\n*** 4. Services ***\n"); - - List epnServices = facade.getEPNServices(); - System.out.println("4.1 getEPNServices()\n\t"); - - List epnServices2 = facade.getEPNServices(SERVICE_ATTRIBUTES); - System.out.println("4.2 getEPNServices(" + strServiceAttributes + ")\n\t"); - - List epnServices3 = facade.getEPNServices(KEYWORDS, SERVICE_ATTRIBUTES); - System.out.println("4.3 getEPNServices(" + strKeywords + ", " - + strServiceAttributes + ")\n\t"); - - System.out.println("\n*** 5. Getters***\n"); - - String epnCoreTableName = facade.getEPNCoreTableName(TEST_SERVICE_IVOID); - System.out.println("5.1 getEPNCoreTableName(\"" + TEST_SERVICE_IVOID + "\")\n\t" - + epnCoreTableName); - - String tapURL = facade.getTAPURL(TEST_SERVICE_IVOID); - System.out.println("5.2 getTAPURL(\"" + TEST_SERVICE_IVOID + "\")\n\t" + tapURL); - - System.out.println("\n*** 6. Queries ***\n"); - - List granules = facade.sendADQLQuery(TEST_SERVICE_URL, TEST_ADQL_QUERY); - System.out.println("6.1 sendADQLQuery(\"" + TEST_SERVICE_URL + "\", \"" - + TEST_ADQL_QUERY + "\")\n\t" - + Debug.toJson(granules)); - - List granules2 = facade.sendQuery(TEST_SERVICE_URL, TEST_SCHEMA_NAME, - TEST_ADQL_QUERY); - System.out.println("6.2 sendQuery(\"" + TEST_SERVICE_URL + "\", \"" - + TEST_SCHEMA_NAME + "\", \"" + TEST_ADQL_QUERY + "\")\n\t" - + Debug.toJson(granules2)); - - } catch (CantGetVOTableException | VOResourceException e) { - e.printStackTrace(); - } - } -} -- libgit2 0.21.2