Commit 5d00d3ff2884cbe2615f5c534ea31d8cab91bcb9
1 parent
58950524
Exists in
master
#5 Add JUnit tests or EpnTapConnection.
Showing
3 changed files
with
223 additions
and
154 deletions
Show diff stats
pom.xml
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | 2 | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
3 | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | 3 | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
4 | - | 4 | + |
5 | <!-- Basic informations --> | 5 | <!-- Basic informations --> |
6 | <modelVersion>4.0.0</modelVersion> | 6 | <modelVersion>4.0.0</modelVersion> |
7 | <groupId>eu.omp.irap.vespa</groupId> | 7 | <groupId>eu.omp.irap.vespa</groupId> |
@@ -10,7 +10,7 @@ | @@ -10,7 +10,7 @@ | ||
10 | <name>epnTAPCLient</name> | 10 | <name>epnTAPCLient</name> |
11 | <description>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.</description> | 11 | <description>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.</description> |
12 | <url>http://cassis.irap.omp.eu/</url> | 12 | <url>http://cassis.irap.omp.eu/</url> |
13 | - | 13 | + |
14 | <!-- The developer of the library. --> | 14 | <!-- The developer of the library. --> |
15 | <developers> | 15 | <developers> |
16 | <developer> | 16 | <developer> |
@@ -22,16 +22,16 @@ | @@ -22,16 +22,16 @@ | ||
22 | </roles> | 22 | </roles> |
23 | </developer> | 23 | </developer> |
24 | </developers> | 24 | </developers> |
25 | - | 25 | + |
26 | <!-- The files encoding. --> | 26 | <!-- The files encoding. --> |
27 | <properties> | 27 | <properties> |
28 | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | 28 | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
29 | </properties> | 29 | </properties> |
30 | - | 30 | + |
31 | <build> | 31 | <build> |
32 | 32 | ||
33 | <plugins> | 33 | <plugins> |
34 | - | 34 | + |
35 | <!-- Tell to Maven wich Java version is used. --> | 35 | <!-- Tell to Maven wich Java version is used. --> |
36 | <plugin> | 36 | <plugin> |
37 | <artifactId>maven-compiler-plugin</artifactId> | 37 | <artifactId>maven-compiler-plugin</artifactId> |
@@ -41,7 +41,7 @@ | @@ -41,7 +41,7 @@ | ||
41 | <target>1.7</target> | 41 | <target>1.7</target> |
42 | </configuration> | 42 | </configuration> |
43 | </plugin> | 43 | </plugin> |
44 | - | 44 | + |
45 | <!-- Sign the jar in order to push it to cassis repository. --> | 45 | <!-- Sign the jar in order to push it to cassis repository. --> |
46 | <plugin> | 46 | <plugin> |
47 | <groupId>org.apache.maven.plugins</groupId> | 47 | <groupId>org.apache.maven.plugins</groupId> |
@@ -68,7 +68,7 @@ | @@ -68,7 +68,7 @@ | ||
68 | <verbose>true</verbose> | 68 | <verbose>true</verbose> |
69 | </configuration> | 69 | </configuration> |
70 | </plugin> | 70 | </plugin> |
71 | - | 71 | + |
72 | <!-- Generate model classes (voTable and voResource) from xsd schemas --> | 72 | <!-- Generate model classes (voTable and voResource) from xsd schemas --> |
73 | <plugin> | 73 | <plugin> |
74 | <groupId>org.jvnet.jaxb2.maven2</groupId> | 74 | <groupId>org.jvnet.jaxb2.maven2</groupId> |
@@ -84,20 +84,23 @@ | @@ -84,20 +84,23 @@ | ||
84 | <configuration> | 84 | <configuration> |
85 | <schemaDirectory>src/main/resources/xsd</schemaDirectory> | 85 | <schemaDirectory>src/main/resources/xsd</schemaDirectory> |
86 | <bindingDirectory>src/main/resources/xjb</bindingDirectory> | 86 | <bindingDirectory>src/main/resources/xjb</bindingDirectory> |
87 | - <!-- The xjb file tels to xjc which xsd file is associated to some Java package. --> | ||
88 | - <!-- It also modify voTable.xsd in order to rename the `Value`, which is a xjc keyword. --> | 87 | + <!-- The xjb file tels to xjc which xsd file is associated to some |
88 | + Java package. --> | ||
89 | + <!-- It also modify voTable.xsd in order to rename the `Value`, which | ||
90 | + is a xjc keyword. --> | ||
89 | </configuration> | 91 | </configuration> |
90 | </execution> | 92 | </execution> |
91 | </executions> | 93 | </executions> |
92 | </plugin> | 94 | </plugin> |
93 | <plugin> | 95 | <plugin> |
94 | - | 96 | + |
95 | <!-- Ant executions. --> | 97 | <!-- Ant executions. --> |
96 | <artifactId>maven-antrun-plugin</artifactId> | 98 | <artifactId>maven-antrun-plugin</artifactId> |
97 | <version>1.7</version> | 99 | <version>1.7</version> |
98 | <executions> | 100 | <executions> |
99 | <execution> | 101 | <execution> |
100 | - <!-- Add @SuppressWarnings annotations for each class of the generated code. --> | 102 | + <!-- Add @SuppressWarnings annotations for each class of the generated |
103 | + code. --> | ||
101 | <id>suppress-warning-generated</id> | 104 | <id>suppress-warning-generated</id> |
102 | <phase>process-sources</phase> | 105 | <phase>process-sources</phase> |
103 | <goals> | 106 | <goals> |
@@ -127,8 +130,9 @@ | @@ -127,8 +130,9 @@ | ||
127 | </executions> | 130 | </executions> |
128 | </plugin> | 131 | </plugin> |
129 | </plugins> | 132 | </plugins> |
130 | - | ||
131 | - <!-- Avoid Eclipse warnings "Plugin execution not covered by lifecycle configuration" --> | 133 | + |
134 | + <!-- Avoid Eclipse warnings "Plugin execution not covered by lifecycle | ||
135 | + configuration" --> | ||
132 | <pluginManagement> | 136 | <pluginManagement> |
133 | <plugins> | 137 | <plugins> |
134 | <plugin> | 138 | <plugin> |
@@ -158,10 +162,10 @@ | @@ -158,10 +162,10 @@ | ||
158 | </plugins> | 162 | </plugins> |
159 | </pluginManagement> | 163 | </pluginManagement> |
160 | </build> | 164 | </build> |
161 | - | 165 | + |
162 | <!-- The project dependencies --> | 166 | <!-- The project dependencies --> |
163 | <dependencies> | 167 | <dependencies> |
164 | - | 168 | + |
165 | <!-- A library to deal with JSON files --> | 169 | <!-- A library to deal with JSON files --> |
166 | <dependency> | 170 | <dependency> |
167 | <groupId>com.google.code.gson</groupId> | 171 | <groupId>com.google.code.gson</groupId> |
@@ -169,19 +173,24 @@ | @@ -169,19 +173,24 @@ | ||
169 | <version>2.2.2</version> | 173 | <version>2.2.2</version> |
170 | <scope>compile</scope> | 174 | <scope>compile</scope> |
171 | </dependency> | 175 | </dependency> |
172 | - | 176 | + |
173 | <!-- A library to deal with VOTables --> | 177 | <!-- A library to deal with VOTables --> |
174 | <dependency> | 178 | <dependency> |
175 | <groupId>eu.omp.irap.vespa</groupId> | 179 | <groupId>eu.omp.irap.vespa</groupId> |
176 | <artifactId>votable</artifactId> | 180 | <artifactId>votable</artifactId> |
177 | <version>0.0.1-SNAPSHOT</version> | 181 | <version>0.0.1-SNAPSHOT</version> |
178 | </dependency> | 182 | </dependency> |
179 | - | 183 | + <dependency> |
184 | + <groupId>junit</groupId> | ||
185 | + <artifactId>junit</artifactId> | ||
186 | + <version>4.12</version> | ||
187 | + <scope>test</scope> | ||
188 | + </dependency> | ||
180 | </dependencies> | 189 | </dependencies> |
181 | - | 190 | + |
182 | <profiles> | 191 | <profiles> |
183 | - <!-- This profile is activated by the "-P jenkins" switch when run on the build server by | ||
184 | - Jenkins (continuous integration) --> | 192 | + <!-- This profile is activated by the "-P jenkins" switch when run on the |
193 | + build server by Jenkins (continuous integration) --> | ||
185 | <profile> | 194 | <profile> |
186 | <id>jenkins</id> | 195 | <id>jenkins</id> |
187 | <build> | 196 | <build> |
@@ -210,7 +219,7 @@ | @@ -210,7 +219,7 @@ | ||
210 | </build> | 219 | </build> |
211 | </profile> | 220 | </profile> |
212 | </profiles> | 221 | </profiles> |
213 | - | 222 | + |
214 | <!-- The repository where to deploy the project. --> | 223 | <!-- The repository where to deploy the project. --> |
215 | <repositories> | 224 | <repositories> |
216 | <repository> | 225 | <repository> |
@@ -218,7 +227,7 @@ | @@ -218,7 +227,7 @@ | ||
218 | <url>https://nexus.irap.omp.eu/content/groups/public</url> | 227 | <url>https://nexus.irap.omp.eu/content/groups/public</url> |
219 | </repository> | 228 | </repository> |
220 | </repositories> | 229 | </repositories> |
221 | - | 230 | + |
222 | <!-- For using it, (with mvn deploy) it need the <server(s)> config on ~/m2/settings.xml | 231 | <!-- For using it, (with mvn deploy) it need the <server(s)> config on ~/m2/settings.xml |
223 | with the logins for nexus. --> | 232 | with the logins for nexus. --> |
224 | <distributionManagement> | 233 | <distributionManagement> |
src/test/java/eu/omp/irap/vespa/epntapclient/EpnTapConnectionTest.java
0 โ 100644
@@ -0,0 +1,192 @@ | @@ -0,0 +1,192 @@ | ||
1 | +/* | ||
2 | + * This file is a part of EpnTAPClient. | ||
3 | + * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. | ||
4 | + * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 | ||
5 | + * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planรฉtologie. | ||
6 | + * | ||
7 | + * This program is free software: you can | ||
8 | + * redistribute it and/or modify it under the terms of the GNU General Public License as published | ||
9 | + * by the Free Software Foundation, either version 3 of the License, or (at your option) any later | ||
10 | + * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY | ||
11 | + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | ||
12 | + * PURPOSE. See the GNU General Public License for more details. You should have received a copy of | ||
13 | + * the GNU General Public License along with this program. If not, see | ||
14 | + * <http://www.gnu.org/licenses/>. | ||
15 | + */ | ||
16 | + | ||
17 | +package eu.omp.irap.vespa.epntapclient; | ||
18 | + | ||
19 | +import static org.junit.Assert.assertEquals; | ||
20 | +import static org.junit.Assert.assertNotNull; | ||
21 | + | ||
22 | +import java.util.ArrayList; | ||
23 | +import java.util.HashMap; | ||
24 | +import java.util.List; | ||
25 | +import java.util.Map; | ||
26 | +import java.util.logging.Logger; | ||
27 | + | ||
28 | +import org.junit.Test; | ||
29 | + | ||
30 | +import eu.omp.irap.vespa.epntapclient.granule.Granule; | ||
31 | +import eu.omp.irap.vespa.epntapclient.voresource.VOResourceCtrl; | ||
32 | +import eu.omp.irap.vespa.epntapclient.voresource.VOResourceException; | ||
33 | +import eu.omp.irap.vespa.epntapclient.voresource.model.Resource; | ||
34 | +import eu.omp.irap.vespa.epntapclient.votable.model.Field; | ||
35 | +import eu.omp.irap.vespa.epntapclient.votable.model.Table; | ||
36 | +import eu.omp.irap.vespa.epntapclient.votable.model.VOTABLE; | ||
37 | +import eu.omp.irap.vespa.votable.controller.CantGetVOTableException; | ||
38 | + | ||
39 | +/** | ||
40 | + * @author N. Jourdane | ||
41 | + */ | ||
42 | +public class EpnTapConnectionTest { | ||
43 | + | ||
44 | + /** The logger for the class Main. */ | ||
45 | + private static final Logger logger = Logger.getLogger(EpnTapConnectionTest.class.getName()); | ||
46 | + | ||
47 | + | ||
48 | + @Test | ||
49 | + public void getVOResourceTest() throws VOResourceException { | ||
50 | + EpnTapConnection facade = new EpnTapConnection(); | ||
51 | + Resource resource = VOResourceCtrl.getVOresource("ivo://cdpp/amda"); | ||
52 | + | ||
53 | + assertEquals("AMDA", resource.getShortName()); | ||
54 | + assertEquals("CDPP AMDA DataBase", resource.getTitle()); | ||
55 | + assertEquals("Centre de Donnรฉes de la Physique des Plasmas", | ||
56 | + resource.getCuration().getCreator().get(0).getName().getValue()); | ||
57 | + } | ||
58 | + | ||
59 | + @Test | ||
60 | + public void getEPNVOResourcesTest() throws VOResourceException { | ||
61 | + EpnTapConnection facade = new EpnTapConnection(); | ||
62 | + List<Resource> resources = facade.getEPNVOResources(); | ||
63 | + | ||
64 | + assertEquals(13, resources.size()); | ||
65 | + for (Resource r : resources) { | ||
66 | + assertNotNull(r); | ||
67 | + } | ||
68 | + } | ||
69 | + | ||
70 | + @Test | ||
71 | + public void getEPNVOResourcesWithKeywordsTest() throws VOResourceException { | ||
72 | + EpnTapConnection facade = new EpnTapConnection(); | ||
73 | + final Map<String, String> keywords = new HashMap<>(); | ||
74 | + keywords.put("shortName", "IKS"); | ||
75 | + List<Resource> resources = facade.getEPNVOResources(); | ||
76 | + | ||
77 | + assertEquals(2, resources.size()); | ||
78 | + } | ||
79 | + | ||
80 | + @Test | ||
81 | + public void getEPNServiceTest() throws CantGetVOTableException { | ||
82 | + EpnTapConnection facade = new EpnTapConnection(); | ||
83 | + | ||
84 | + VOTABLE epnService = facade.getEPNService("ivo://cdpp/amda"); | ||
85 | + Table table = (Table) epnService.getRESOURCE().get(0).getLINKAndTABLEOrRESOURCE().get(0); | ||
86 | + String firstInfoVal = epnService.getRESOURCE().get(0).getINFO().get(0).getValueAttribute(); | ||
87 | + String firstFieldName = ((Field) table.getFIELDOrPARAMOrGROUP().get(0)).getID(); | ||
88 | + | ||
89 | + assertEquals("http://gavo.aip.de", firstInfoVal); | ||
90 | + assertEquals("short_name", firstFieldName); | ||
91 | + } | ||
92 | + | ||
93 | + @Test | ||
94 | + public void getEPNServiceWithAttributesTest() throws CantGetVOTableException { | ||
95 | + EpnTapConnection facade = new EpnTapConnection(); | ||
96 | + | ||
97 | + final List<String> serviceAttributes = new ArrayList<>(); | ||
98 | + serviceAttributes.add("target_name"); | ||
99 | + serviceAttributes.add("time_min"); | ||
100 | + serviceAttributes.add("time_max"); | ||
101 | + | ||
102 | + VOTABLE epnService = facade.getEPNService("ivo://cdpp/amda", serviceAttributes); | ||
103 | + Table table = (Table) epnService.getRESOURCE().get(0).getLINKAndTABLEOrRESOURCE().get(0); | ||
104 | + String firstInfoVal = epnService.getRESOURCE().get(0).getINFO().get(0).getValueAttribute(); | ||
105 | + String firstFieldName = ((Field) table.getFIELDOrPARAMOrGROUP().get(0)).getID(); | ||
106 | + | ||
107 | + assertEquals("http://cdpp-epntap.cesr.fr", firstInfoVal); | ||
108 | + assertEquals("short_name", firstFieldName); | ||
109 | + } | ||
110 | + | ||
111 | + @Test | ||
112 | + public void getEPNServicesTest() throws VOResourceException { | ||
113 | + EpnTapConnection facade = new EpnTapConnection(); | ||
114 | + List<VOTABLE> voTables = facade.getEPNServices(); | ||
115 | + assertEquals(11, voTables.size()); | ||
116 | + } | ||
117 | + | ||
118 | + @Test | ||
119 | + public void getEPNServicesWithAttributesTest() | ||
120 | + throws VOResourceException, CantGetVOTableException { | ||
121 | + final List<String> serviceAttributes = new ArrayList<>(); | ||
122 | + serviceAttributes.add("target_name"); | ||
123 | + serviceAttributes.add("time_min"); | ||
124 | + serviceAttributes.add("time_max"); | ||
125 | + | ||
126 | + EpnTapConnection facade = new EpnTapConnection(); | ||
127 | + List<VOTABLE> voTables = facade.getEPNServices(serviceAttributes); | ||
128 | + String firstInfoVal = voTables.get(0).getRESOURCE().get(0).getINFO().get(0) | ||
129 | + .getValueAttribute(); | ||
130 | + | ||
131 | + assertEquals("http://gavo.aip.de", firstInfoVal); | ||
132 | + } | ||
133 | + | ||
134 | + @Test | ||
135 | + public void getEPNServicesWithAttributesAndKeywordsTest() | ||
136 | + throws CantGetVOTableException, VOResourceException { | ||
137 | + final List<String> serviceAttributes = new ArrayList<>(); | ||
138 | + serviceAttributes.add("target_name"); | ||
139 | + serviceAttributes.add("time_min"); | ||
140 | + serviceAttributes.add("time_max"); | ||
141 | + | ||
142 | + final Map<String, String> keywords = new HashMap<>(); | ||
143 | + keywords.put("shortName", "IKS"); | ||
144 | + | ||
145 | + EpnTapConnection facade = new EpnTapConnection(); | ||
146 | + List<VOTABLE> voTables = facade.getEPNServices(keywords, serviceAttributes); | ||
147 | + String firstInfoVal = voTables.get(0).getRESOURCE().get(0).getINFO().get(0) | ||
148 | + .getValueAttribute(); | ||
149 | + assertEquals("http://gavo.aip.de", firstInfoVal); | ||
150 | + } | ||
151 | + | ||
152 | + @Test | ||
153 | + public void getEPNCoreTableNameTest() throws CantGetVOTableException { | ||
154 | + EpnTapConnection facade = new EpnTapConnection(); | ||
155 | + String epnCoreTableName = facade.getEPNCoreTableName("ivo://cdpp/amda"); | ||
156 | + assertEquals("?", epnCoreTableName); | ||
157 | + } | ||
158 | + | ||
159 | + @Test | ||
160 | + public void getTAPURLTest() throws CantGetVOTableException { | ||
161 | + EpnTapConnection facade = new EpnTapConnection(); | ||
162 | + String tapURL = facade.getTAPURL("ivo://cdpp/amda"); | ||
163 | + assertEquals("http://cdpp-epntap.cesr.fr/__system__/tap/run/tap", tapURL); | ||
164 | + } | ||
165 | + | ||
166 | + @Test | ||
167 | + public void sendADQLQueryTest() throws CantGetVOTableException { | ||
168 | + EpnTapConnection facade = new EpnTapConnection(); | ||
169 | + String tapURL = "http://voparis-tap-planeto.obspm.fr/__system__/tap/run/tap"; | ||
170 | + String query = "SELECT TOP 1 * FROM planets.epn_core"; | ||
171 | + List<Granule> granules = facade.sendADQLQuery(tapURL, query); | ||
172 | + | ||
173 | + assertEquals("?", granules.get(0).granuleUid); | ||
174 | + assertEquals("?", granules.get(0).timeMin); | ||
175 | + assertEquals("?", granules.get(0).processingLevel); | ||
176 | + assertEquals("?", granules.get(0).creationDate); | ||
177 | + } | ||
178 | + | ||
179 | + @Test | ||
180 | + public void sendADQLQueryWithSchemaNameTest() throws CantGetVOTableException { | ||
181 | + EpnTapConnection facade = new EpnTapConnection(); | ||
182 | + String tapURL = "http://voparis-tap-planeto.obspm.fr/__system__/tap/run/tap"; | ||
183 | + String schemaName = "amdadb.epn_core"; | ||
184 | + String query = "SELECT TOP 1 * FROM planets.epn_core"; | ||
185 | + List<Granule> granules = facade.sendQuery(tapURL, schemaName, query); | ||
186 | + | ||
187 | + assertEquals("?", granules.get(0).granuleUid); | ||
188 | + assertEquals("?", granules.get(0).timeMin); | ||
189 | + assertEquals("?", granules.get(0).processingLevel); | ||
190 | + assertEquals("?", granules.get(0).creationDate); | ||
191 | + } | ||
192 | +} |
src/test/java/eu/omp/irap/vespa/epntapclient/TestEpnTapConnection.java deleted
@@ -1,132 +0,0 @@ | @@ -1,132 +0,0 @@ | ||
1 | -/* | ||
2 | - * This file is a part of EpnTAPClient. | ||
3 | - * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. | ||
4 | - * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 | ||
5 | - * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planรฉtologie. | ||
6 | - * | ||
7 | - * This program is free software: you can | ||
8 | - * redistribute it and/or modify it under the terms of the GNU General Public License as published | ||
9 | - * by the Free Software Foundation, either version 3 of the License, or (at your option) any later | ||
10 | - * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY | ||
11 | - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | ||
12 | - * PURPOSE. See the GNU General Public License for more details. You should have received a copy of | ||
13 | - * the GNU General Public License along with this program. If not, see | ||
14 | - * <http://www.gnu.org/licenses/>. | ||
15 | - */ | ||
16 | - | ||
17 | -package eu.omp.irap.vespa.epntapclient; | ||
18 | - | ||
19 | -import java.util.ArrayList; | ||
20 | -import java.util.HashMap; | ||
21 | -import java.util.List; | ||
22 | -import java.util.Map; | ||
23 | -import java.util.logging.Logger; | ||
24 | - | ||
25 | -import eu.omp.irap.vespa.epntapclient.granule.Granule; | ||
26 | -import eu.omp.irap.vespa.epntapclient.voresource.VOResourceCtrl; | ||
27 | -import eu.omp.irap.vespa.epntapclient.voresource.VOResourceException; | ||
28 | -import eu.omp.irap.vespa.epntapclient.voresource.model.Resource; | ||
29 | -import eu.omp.irap.vespa.epntapclient.votable.model.VOTABLE; | ||
30 | -import eu.omp.irap.vespa.votable.controller.CantGetVOTableException; | ||
31 | -import eu.omp.irap.vespa.votable.utils.Debug; | ||
32 | -import eu.omp.irap.vespa.votable.utils.StringJoiner; | ||
33 | - | ||
34 | -/** | ||
35 | - * @author N. Jourdane | ||
36 | - */ | ||
37 | -public class TestEpnTapConnection { | ||
38 | - | ||
39 | - /** The logger for the class Main. */ | ||
40 | - private static final Logger logger = Logger.getLogger(TestEpnTapConnection.class.getName()); | ||
41 | - | ||
42 | - private static final String TEST_SERVICE_IVOID = "ivo://cdpp/amda"; | ||
43 | - | ||
44 | - private static final String TEST_SERVICE_URL = "http://voparis-tap-planeto.obspm.fr/__system__/tap/run/tap"; | ||
45 | - | ||
46 | - private static final String TEST_RESOURCE_IVOID = "ivo://vopdc.obspm/lesia/basecom/epn"; | ||
47 | - | ||
48 | - private static final String TEST_ADQL_QUERY = "SELECT TOP 1 * FROM planets.epn_core"; | ||
49 | - | ||
50 | - private static final String TEST_SCHEMA_NAME = "epn_core"; | ||
51 | - | ||
52 | - | ||
53 | - public static void main(String[] args) { | ||
54 | - EpnTapConnection facade = new EpnTapConnection(); | ||
55 | - | ||
56 | - final List<String> SERVICE_ATTRIBUTES = new ArrayList<>(); | ||
57 | - SERVICE_ATTRIBUTES.add("target_name"); | ||
58 | - SERVICE_ATTRIBUTES.add("time_min"); | ||
59 | - SERVICE_ATTRIBUTES.add("time_max"); | ||
60 | - String strServiceAttributes = "[" + StringJoiner.join(SERVICE_ATTRIBUTES) + "]"; | ||
61 | - | ||
62 | - final Map<String, String> KEYWORDS = new HashMap<>(); | ||
63 | - KEYWORDS.put("shortName", "IKS"); | ||
64 | - String strKeywords = "[shortName=IKS]"; | ||
65 | - | ||
66 | - try { | ||
67 | - System.out.println("\n*** 1. Resource ***\n"); | ||
68 | - | ||
69 | - Resource resource = VOResourceCtrl.getVOresource(TEST_RESOURCE_IVOID); | ||
70 | - System.out.println("1.1 getVOresource(\"" + TEST_RESOURCE_IVOID + "\")\n\t" | ||
71 | - + Debug.toJson(resource)); | ||
72 | - | ||
73 | - System.out.println("\n*** 2. Resources ***\n"); | ||
74 | - | ||
75 | - List<Resource> resources = facade.getEPNVOResources(); | ||
76 | - System.out.println("2.1 getEPNVOResources()\n\t" | ||
77 | - + Debug.toJson(resources)); | ||
78 | - | ||
79 | - List<Resource> resources2 = facade.getEPNVOResources(KEYWORDS); | ||
80 | - System.out.println("2.2 getEPNVOResources(" + strKeywords + ")\n\t" | ||
81 | - + Debug.toJson(resources2)); | ||
82 | - | ||
83 | - System.out.println("\n*** 3. Service ***\n"); | ||
84 | - | ||
85 | - VOTABLE epnService = facade.getEPNService(TEST_SERVICE_IVOID); | ||
86 | - System.out.println("3.1 getEPNService(\"" + TEST_SERVICE_IVOID + "\")\n\t" | ||
87 | - + Debug.toJson(epnService)); | ||
88 | - | ||
89 | - VOTABLE epnService2 = facade.getEPNService(TEST_SERVICE_IVOID, SERVICE_ATTRIBUTES); | ||
90 | - System.out.println("3.2 getEPNService(\"" + TEST_SERVICE_IVOID + "\", " | ||
91 | - + strServiceAttributes + ")\n\t" | ||
92 | - + Debug.toJson(epnService2)); | ||
93 | - | ||
94 | - System.out.println("\n*** 4. Services ***\n"); | ||
95 | - | ||
96 | - List<VOTABLE> epnServices = facade.getEPNServices(); | ||
97 | - System.out.println("4.1 getEPNServices()\n\t"); | ||
98 | - | ||
99 | - List<VOTABLE> epnServices2 = facade.getEPNServices(SERVICE_ATTRIBUTES); | ||
100 | - System.out.println("4.2 getEPNServices(" + strServiceAttributes + ")\n\t"); | ||
101 | - | ||
102 | - List<VOTABLE> epnServices3 = facade.getEPNServices(KEYWORDS, SERVICE_ATTRIBUTES); | ||
103 | - System.out.println("4.3 getEPNServices(" + strKeywords + ", " | ||
104 | - + strServiceAttributes + ")\n\t"); | ||
105 | - | ||
106 | - System.out.println("\n*** 5. Getters***\n"); | ||
107 | - | ||
108 | - String epnCoreTableName = facade.getEPNCoreTableName(TEST_SERVICE_IVOID); | ||
109 | - System.out.println("5.1 getEPNCoreTableName(\"" + TEST_SERVICE_IVOID + "\")\n\t" | ||
110 | - + epnCoreTableName); | ||
111 | - | ||
112 | - String tapURL = facade.getTAPURL(TEST_SERVICE_IVOID); | ||
113 | - System.out.println("5.2 getTAPURL(\"" + TEST_SERVICE_IVOID + "\")\n\t" + tapURL); | ||
114 | - | ||
115 | - System.out.println("\n*** 6. Queries ***\n"); | ||
116 | - | ||
117 | - List<Granule> granules = facade.sendADQLQuery(TEST_SERVICE_URL, TEST_ADQL_QUERY); | ||
118 | - System.out.println("6.1 sendADQLQuery(\"" + TEST_SERVICE_URL + "\", \"" | ||
119 | - + TEST_ADQL_QUERY + "\")\n\t" | ||
120 | - + Debug.toJson(granules)); | ||
121 | - | ||
122 | - List<Granule> granules2 = facade.sendQuery(TEST_SERVICE_URL, TEST_SCHEMA_NAME, | ||
123 | - TEST_ADQL_QUERY); | ||
124 | - System.out.println("6.2 sendQuery(\"" + TEST_SERVICE_URL + "\", \"" | ||
125 | - + TEST_SCHEMA_NAME + "\", \"" + TEST_ADQL_QUERY + "\")\n\t" | ||
126 | - + Debug.toJson(granules2)); | ||
127 | - | ||
128 | - } catch (CantGetVOTableException | VOResourceException e) { | ||
129 | - e.printStackTrace(); | ||
130 | - } | ||
131 | - } | ||
132 | -} |