Blame view

src/test/java/eu/omp/irap/vespa/epntapclient/EpnTapConnectionTest.java 13.9 KB
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
 * 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
 * <http://www.gnu.org/licenses/>.
 */

package eu.omp.irap.vespa.epntapclient;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
35daa117   Nathanael Jourdane   Improve JUnits te...
21
import static org.junit.Assert.assertTrue;
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
22
23

import java.util.ArrayList;
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
24
25
26
27
28
29
30
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;
2e350611   Nathanael Jourdane   Check Services pa...
31
import eu.omp.irap.vespa.epntapclient.service.Service;
35daa117   Nathanael Jourdane   Improve JUnits te...
32
import eu.omp.irap.vespa.epntapclient.service.ServiceCtrl;
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
33
34
import eu.omp.irap.vespa.epntapclient.voresource.VOResourceException;
import eu.omp.irap.vespa.epntapclient.voresource.model.Resource;
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
35
import eu.omp.irap.vespa.epntapclient.votable.model.VOTABLE;
e669c5d3   Nathanael Jourdane   Improve Javadoc.
36
import eu.omp.irap.vespa.votable.controller.VOTableException;
35daa117   Nathanael Jourdane   Improve JUnits te...
37
import eu.omp.irap.vespa.votable.votabledata.VOTableData;
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
38
39
40
41

/**
 * @author N. Jourdane
 */
330431b5   Nathanael Jourdane   Fix a Junit test ...
42
@SuppressWarnings("static-method")
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
43
44
45
public class EpnTapConnectionTest {

	/** The logger for the class Main. */
fd93317f   Nathanael Jourdane   Solve Sonar/Eclip...
46
	private static final Logger LOGGER = Logger.getLogger(EpnTapConnectionTest.class.getName());
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
47

330431b5   Nathanael Jourdane   Fix a Junit test ...
48
	/** The AMDA ivoid, for testing purposes. */
35daa117   Nathanael Jourdane   Improve JUnits te...
49
50
	private static final String AMDA_IVOID = "ivo://cdpp/amda";

330431b5   Nathanael Jourdane   Fix a Junit test ...
51
	/** The AMDA short name (to compare with the returned value), for testing purposes. */
35daa117   Nathanael Jourdane   Improve JUnits te...
52
53
	private static final String AMDA_SHORT_NAME = "AMDA";

330431b5   Nathanael Jourdane   Fix a Junit test ...
54
	/** The AMDA access URL, for testing purposes. */
35daa117   Nathanael Jourdane   Improve JUnits te...
55
56
	private static final String AMDA_ACCESS_URL = "http://cdpp-epntap.cesr.fr/__system__/tap/run/tap";

330431b5   Nathanael Jourdane   Fix a Junit test ...
57
	/** A subject associated with the AMDA service, for testing purposes. */
35daa117   Nathanael Jourdane   Improve JUnits te...
58
59
	private static final String AMDA_SUBJECT = "Space plasmas";

330431b5   Nathanael Jourdane   Fix a Junit test ...
60
	/** The API ivoid, for testing purposes. */
35daa117   Nathanael Jourdane   Improve JUnits te...
61
62
	private static final String APIS_IVOID = "ivo://vopdc.obspm/lesia/apis/epn";

330431b5   Nathanael Jourdane   Fix a Junit test ...
63
	/** The APIS short name (to compare with the returned value), for testing purposes. */
35daa117   Nathanael Jourdane   Improve JUnits te...
64
65
	private static final String APIS_SHORT_NAME = "APIS";

330431b5   Nathanael Jourdane   Fix a Junit test ...
66
	/** The URL access of a service implementing the EpnCorev2, for testing purposes. */
99642cfe   Nathanael Jourdane   Improve unit test...
67
68
	private static final String SERVICE_EPNCOREV2_ACCESS_URL = "http://voparis-tap-planeto.obspm.fr/__system__/tap/run/tap";

330431b5   Nathanael Jourdane   Fix a Junit test ...
69
	/** A query to send to a service implementing the EpnCorev2, for testing purposes */
99642cfe   Nathanael Jourdane   Improve unit test...
70
71
	private static final String SERVICE_EPNCOREV2_QUERY = "SELECT * FROM planets.epn_core";

330431b5   Nathanael Jourdane   Fix a Junit test ...
72
	/** The table name of a service implementing the EpnCorev2, for testing purposes. */
99642cfe   Nathanael Jourdane   Improve unit test...
73
	private static final String SERVICE_EPNCOREV2_TABLE_NAME = "planets.epn_core";
35daa117   Nathanael Jourdane   Improve JUnits te...
74
75
	// *** VOResources ***

5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
76

330431b5   Nathanael Jourdane   Fix a Junit test ...
77
78
79
80
81
	/**
	 * Unit test for the class {@link EpnTapConnection#getEPNVOresource(String)}.
	 *
	 * @throws VOResourceException Can not get the VOresource.
	 */
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
82
83
	@Test
	public void getVOResourceTest() throws VOResourceException {
fd93317f   Nathanael Jourdane   Solve Sonar/Eclip...
84
		LOGGER.info("getVOResourceTest");
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
85
		EpnTapConnection facade = new EpnTapConnection();
35daa117   Nathanael Jourdane   Improve JUnits te...
86

330431b5   Nathanael Jourdane   Fix a Junit test ...
87
		Resource resource = facade.getEPNVOresource(AMDA_IVOID);
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
88
89
90
91
92
93
94

		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());
	}

330431b5   Nathanael Jourdane   Fix a Junit test ...
95
96
97
98
99
	/**
	 * Unit test for the class {@link EpnTapConnection#getEPNVOResources()}.
	 *
	 * @throws VOResourceException Can not get the VOresource.
	 */
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
100
101
	@Test
	public void getEPNVOResourcesTest() throws VOResourceException {
fd93317f   Nathanael Jourdane   Solve Sonar/Eclip...
102
		LOGGER.info("getEPNVOResourcesTest");
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
103
		EpnTapConnection facade = new EpnTapConnection();
35daa117   Nathanael Jourdane   Improve JUnits te...
104

5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
105
106
		List<Resource> resources = facade.getEPNVOResources();

35daa117   Nathanael Jourdane   Improve JUnits te...
107
108
109
110
111
112
113
114
115
116
117
118
		int nbResources = resources.size();
		assertTrue(nbResources + " ∉ [13;20]", nbResources >= 13 && nbResources <= 20);

		Resource amda = null;
		Resource apis = null;
		for (Resource resource : resources) {
			if (AMDA_IVOID.equals(resource.getIdentifier())) {
				amda = resource;
			}
			if (APIS_IVOID.equals(resource.getIdentifier())) {
				apis = resource;
			}
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
119
		}
35daa117   Nathanael Jourdane   Improve JUnits te...
120
121
122
123
		assertNotNull("AMDA resource should be present.", amda);
		assertNotNull("APIS resource should be present.", apis);
		assertEquals(AMDA_SHORT_NAME, amda.getShortName());
		assertEquals(APIS_SHORT_NAME, apis.getShortName());
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
124
125
	}

330431b5   Nathanael Jourdane   Fix a Junit test ...
126
127
128
129
130
	/**
	 * Unit test for the class {@link EpnTapConnection#getEPNVOResources(List)}.
	 *
	 * @throws VOResourceException Can not get the VOresource.
	 */
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
131
132
	@Test
	public void getEPNVOResourcesWithKeywordsTest() throws VOResourceException {
fd93317f   Nathanael Jourdane   Solve Sonar/Eclip...
133
		LOGGER.info("getEPNVOResourcesWithKeywordsTest");
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
134
		EpnTapConnection facade = new EpnTapConnection();
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
135

35daa117   Nathanael Jourdane   Improve JUnits te...
136
137
138
139
140
141
142
143
		final List<String> keywords = new ArrayList<>();
		keywords.add(AMDA_SUBJECT);
		List<Resource> resources = facade.getEPNVOResources(keywords);

		assertEquals(resources.size(), 1);

		Resource amda = null;
		for (Resource resource : resources) {
35daa117   Nathanael Jourdane   Improve JUnits te...
144
145
146
147
148
			if (AMDA_IVOID.equals(resource.getIdentifier())) {
				amda = resource;
			}
		}
		assertNotNull("AMDA resource should be present.", amda);
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
149
150
	}

35daa117   Nathanael Jourdane   Improve JUnits te...
151
152
	// *** Services ***

330431b5   Nathanael Jourdane   Fix a Junit test ...
153
154
155
	/**
	 * Unit test for the class {@link EpnTapConnection#getEPNService(String)}.
	 *
e669c5d3   Nathanael Jourdane   Improve Javadoc.
156
	 * @throws VOTableException Can not get the VOTable corresponding to the service.
330431b5   Nathanael Jourdane   Fix a Junit test ...
157
	 */
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
158
	@Test
e669c5d3   Nathanael Jourdane   Improve Javadoc.
159
	public void getEPNServiceTest() throws VOTableException {
fd93317f   Nathanael Jourdane   Solve Sonar/Eclip...
160
		LOGGER.info("getEPNServiceTest");
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
161
162
		EpnTapConnection facade = new EpnTapConnection();

330431b5   Nathanael Jourdane   Fix a Junit test ...
163
		VOTABLE voTable = facade.getEPNService(AMDA_IVOID);
35daa117   Nathanael Jourdane   Improve JUnits te...
164
		VOTableData data = ServiceCtrl.getVoTableData(voTable);
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
165

35daa117   Nathanael Jourdane   Improve JUnits te...
166
167
168
169
170
171
172
		assertEquals(1, data.getNbRows());
		assertTrue("Column name ivoid not found.", data.isContainingColumnName("ivoid"));
		assertTrue("Column name short_name not found.", data.isContainingColumnName("access_url"));
		assertTrue("Column name short_name not found.", data.isContainingColumnName("short_name"));
		assertEquals(AMDA_IVOID, data.getCell(0, "ivoid"));
		assertEquals(AMDA_ACCESS_URL, data.getCell(0, "access_url"));
		assertEquals(AMDA_SHORT_NAME, data.getCell(0, "short_name"));
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
173
174
	}

330431b5   Nathanael Jourdane   Fix a Junit test ...
175
176
177
	/**
	 * Unit test for the class {@link EpnTapConnection#getEPNService(String, List)}.
	 *
e669c5d3   Nathanael Jourdane   Improve Javadoc.
178
	 * @throws VOTableException Can not get the VOTable corresponding to the service.
330431b5   Nathanael Jourdane   Fix a Junit test ...
179
	 */
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
180
	@Test
e669c5d3   Nathanael Jourdane   Improve Javadoc.
181
	public void getEPNServiceWithAttributesTest() throws VOTableException {
fd93317f   Nathanael Jourdane   Solve Sonar/Eclip...
182
		LOGGER.info("getEPNServiceWithAttributesTest");
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
183
184
		EpnTapConnection facade = new EpnTapConnection();

35daa117   Nathanael Jourdane   Improve JUnits te...
185
186
187
		final List<String> attributes = new ArrayList<>();
		attributes.add("access_url");
		attributes.add("short_name");
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
188

330431b5   Nathanael Jourdane   Fix a Junit test ...
189
		VOTABLE voTable = facade.getEPNService(AMDA_IVOID, attributes);
35daa117   Nathanael Jourdane   Improve JUnits te...
190
		VOTableData data = ServiceCtrl.getVoTableData(voTable);
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
191

35daa117   Nathanael Jourdane   Improve JUnits te...
192
193
194
195
196
197
		assertEquals(1, data.getNbRows());
		assertEquals(2, data.getNbColumns());
		assertTrue("Column name short_name not found.", data.isContainingColumnName("access_url"));
		assertTrue("Column name short_name not found.", data.isContainingColumnName("short_name"));
		assertEquals(AMDA_ACCESS_URL, data.getCell(0, "access_url"));
		assertEquals(AMDA_SHORT_NAME, data.getCell(0, "short_name"));
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
198
199
	}

330431b5   Nathanael Jourdane   Fix a Junit test ...
200
201
202
	/**
	 * Unit test for the class {@link EpnTapConnection#getEPNServices()}.
	 *
e669c5d3   Nathanael Jourdane   Improve Javadoc.
203
	 * @throws VOTableException Can not get the VOTable corresponding to the service.
330431b5   Nathanael Jourdane   Fix a Junit test ...
204
	 */
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
205
	@Test
e669c5d3   Nathanael Jourdane   Improve Javadoc.
206
	public void getEPNServicesTest() throws VOTableException {
fd93317f   Nathanael Jourdane   Solve Sonar/Eclip...
207
		LOGGER.info("getEPNServicesTest");
35daa117   Nathanael Jourdane   Improve JUnits te...
208

2e350611   Nathanael Jourdane   Check Services pa...
209
		EpnTapConnection facade = new EpnTapConnection();
35daa117   Nathanael Jourdane   Improve JUnits te...
210
211
		VOTABLE voTable = facade.getEPNServices();
		VOTableData data = ServiceCtrl.getVoTableData(voTable);
2e350611   Nathanael Jourdane   Check Services pa...
212
213
214
215
216
217
218
219
220
221
222
		List<Service> services = ServiceCtrl.getServices(data);
		boolean foundAMDAIvoid = false;

		for (Service service : services) {
			if (AMDA_IVOID.equals(service.getIvoid())) {
				foundAMDAIvoid = true;
				assertEquals(AMDA_SHORT_NAME, service.getShortName());
			}
		}
		assertTrue("AMDA service is not found.", foundAMDAIvoid);

35daa117   Nathanael Jourdane   Improve JUnits te...
223
224
		int nbServices = data.getNbRows();
		assertTrue(nbServices + " ∉ [13;20].", nbServices >= 13 && nbServices <= 20);
2e350611   Nathanael Jourdane   Check Services pa...
225
226
		assertTrue("Column name short_name not found.",
				data.isContainingColumnName("short_name"));
35daa117   Nathanael Jourdane   Improve JUnits te...
227
228
		assertTrue("AMDA ivoid not found.", data.isColumnContainingValue("ivoid", AMDA_IVOID));
		Map<String, Object> amda = data.getRowMapByValue("ivoid", AMDA_IVOID);
330431b5   Nathanael Jourdane   Fix a Junit test ...
229
230
231

		assertEquals(AMDA_ACCESS_URL, amda.get("access_url"));
		assertEquals(AMDA_SHORT_NAME, amda.get("short_name"));
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
232
233
	}

330431b5   Nathanael Jourdane   Fix a Junit test ...
234
235
236
	/**
	 * Unit test for the class {@link EpnTapConnection#getEPNServices(List)}.
	 *
e669c5d3   Nathanael Jourdane   Improve Javadoc.
237
	 * @throws VOTableException Can not get the VOTable corresponding to the service.
330431b5   Nathanael Jourdane   Fix a Junit test ...
238
	 */
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
239
240
	@Test
	public void getEPNServicesWithAttributesTest()
e669c5d3   Nathanael Jourdane   Improve Javadoc.
241
			throws VOTableException {
fd93317f   Nathanael Jourdane   Solve Sonar/Eclip...
242
		LOGGER.info("getEPNServicesWithAttributesTest");
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
243
		EpnTapConnection facade = new EpnTapConnection();
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
244

35daa117   Nathanael Jourdane   Improve JUnits te...
245
246
247
248
		final List<String> attributes = new ArrayList<>();
		attributes.add("access_url");
		attributes.add("short_name");

330431b5   Nathanael Jourdane   Fix a Junit test ...
249
		VOTABLE voTable = facade.getEPNServices(attributes);
35daa117   Nathanael Jourdane   Improve JUnits te...
250
251
252
		VOTableData data = ServiceCtrl.getVoTableData(voTable);

		assertEquals(2, data.getNbColumns());
330431b5   Nathanael Jourdane   Fix a Junit test ...
253
254
255
256
257
258
259
260
261
262
		assertTrue("Column name access_url not found.", data.isContainingColumnName("access_url"));
		assertTrue("Column name short_name not found.", data.isContainingColumnName("short_name"));
		assertTrue("AMDA short_name not found.",
				data.isColumnContainingValue("short_name", AMDA_SHORT_NAME));
		assertTrue("AMDA access_url not found.",
				data.isColumnContainingValue("access_url", AMDA_ACCESS_URL));

		Map<String, Object> amda = data.getRowMapByValue("short_name", AMDA_SHORT_NAME);
		assertEquals(AMDA_ACCESS_URL, amda.get("access_url"));
		assertEquals(AMDA_SHORT_NAME, amda.get("short_name"));
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
263
264
	}

330431b5   Nathanael Jourdane   Fix a Junit test ...
265
266
267
	/**
	 * Unit test for the class {@link EpnTapConnection#getEPNServices(List, List)}.
	 *
e669c5d3   Nathanael Jourdane   Improve Javadoc.
268
	 * @throws VOTableException Can not get the VOTable corresponding to the service.
330431b5   Nathanael Jourdane   Fix a Junit test ...
269
270
	 * @throws VOResourceException Can not get the VOresource.
	 */
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
271
	@Test
330431b5   Nathanael Jourdane   Fix a Junit test ...
272
	public void getEPNServicesWithKeywordsAndAttributesTest()
e669c5d3   Nathanael Jourdane   Improve Javadoc.
273
			throws VOTableException, VOResourceException {
fd93317f   Nathanael Jourdane   Solve Sonar/Eclip...
274
		LOGGER.info("getEPNServicesWithKeywordsAndAttributesTest");
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
275
		EpnTapConnection facade = new EpnTapConnection();
35daa117   Nathanael Jourdane   Improve JUnits te...
276

330431b5   Nathanael Jourdane   Fix a Junit test ...
277
278
279
		final List<String> keywords = new ArrayList<>();
		keywords.add(AMDA_SUBJECT);

35daa117   Nathanael Jourdane   Improve JUnits te...
280
281
282
283
		final List<String> attributes = new ArrayList<>();
		attributes.add("access_url");
		attributes.add("short_name");

35daa117   Nathanael Jourdane   Improve JUnits te...
284
285
286
287
		VOTABLE voTable = facade.getEPNServices(keywords, attributes);
		VOTableData data = ServiceCtrl.getVoTableData(voTable);

		assertEquals(3, data.getNbColumns());
330431b5   Nathanael Jourdane   Fix a Junit test ...
288
		assertEquals(1, data.getNbRows());
35daa117   Nathanael Jourdane   Improve JUnits te...
289
290
291
292
293
294
295
296
		assertTrue("Column name access_url not found.", data.isContainingColumnName("access_url"));
		assertTrue("Column name short_name not found.", data.isContainingColumnName("short_name"));
		assertTrue("AMDA short_name not found.",
				data.isColumnContainingValue("short_name", AMDA_SHORT_NAME));
		assertTrue("AMDA access_url not found.",
				data.isColumnContainingValue("access_url", AMDA_ACCESS_URL));
		assertEquals(AMDA_SHORT_NAME, data.getCell(0, "short_name"));
		assertEquals(AMDA_ACCESS_URL, data.getCell(0, "access_url"));
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
297
298
	}

35daa117   Nathanael Jourdane   Improve JUnits te...
299
300
	// *** Getters ***

330431b5   Nathanael Jourdane   Fix a Junit test ...
301
302
303
	/**
	 * Unit test for the class {@link EpnTapConnection#getEPNCoreTableName(String)}.
	 *
e669c5d3   Nathanael Jourdane   Improve Javadoc.
304
	 * @throws VOTableException Can not get the VOTable corresponding to the service.
330431b5   Nathanael Jourdane   Fix a Junit test ...
305
	 */
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
306
	@Test
e669c5d3   Nathanael Jourdane   Improve Javadoc.
307
	public void getEPNCoreTableNameTest() throws VOTableException {
fd93317f   Nathanael Jourdane   Solve Sonar/Eclip...
308
		LOGGER.info("getEPNCoreTableNameTest");
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
309
		EpnTapConnection facade = new EpnTapConnection();
35daa117   Nathanael Jourdane   Improve JUnits te...
310

330431b5   Nathanael Jourdane   Fix a Junit test ...
311
		String epnCoreTableName = facade.getEPNCoreTableName(AMDA_IVOID);
35daa117   Nathanael Jourdane   Improve JUnits te...
312
313

		assertEquals("amdadb.epn_core", epnCoreTableName);
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
314
315
	}

330431b5   Nathanael Jourdane   Fix a Junit test ...
316
317
318
	/**
	 * Unit test for the class {@link EpnTapConnection#getTAPURL(String)}.
	 *
e669c5d3   Nathanael Jourdane   Improve Javadoc.
319
	 * @throws VOTableException Can not get the VOTable corresponding to the service.
330431b5   Nathanael Jourdane   Fix a Junit test ...
320
	 */
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
321
	@Test
e669c5d3   Nathanael Jourdane   Improve Javadoc.
322
	public void getTAPURLTest() throws VOTableException {
fd93317f   Nathanael Jourdane   Solve Sonar/Eclip...
323
		LOGGER.info("getTAPURLTest");
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
324
		EpnTapConnection facade = new EpnTapConnection();
35daa117   Nathanael Jourdane   Improve JUnits te...
325

5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
326
		String tapURL = facade.getTAPURL("ivo://cdpp/amda");
35daa117   Nathanael Jourdane   Improve JUnits te...
327

5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
328
329
330
		assertEquals("http://cdpp-epntap.cesr.fr/__system__/tap/run/tap", tapURL);
	}

35daa117   Nathanael Jourdane   Improve JUnits te...
331
332
	// *** Queries ***

330431b5   Nathanael Jourdane   Fix a Junit test ...
333
334
335
	/**
	 * Unit test for the class {@link EpnTapConnection#sendADQLQuery(String, String)}.
	 *
e669c5d3   Nathanael Jourdane   Improve Javadoc.
336
	 * @throws VOTableException Can not get the VOTable resulting the query.
330431b5   Nathanael Jourdane   Fix a Junit test ...
337
	 */
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
338
	@Test
e669c5d3   Nathanael Jourdane   Improve Javadoc.
339
	public void sendADQLQueryTest() throws VOTableException {
fd93317f   Nathanael Jourdane   Solve Sonar/Eclip...
340
		LOGGER.info("sendADQLQueryTest");
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
341
		EpnTapConnection facade = new EpnTapConnection();
35daa117   Nathanael Jourdane   Improve JUnits te...
342

99642cfe   Nathanael Jourdane   Improve unit test...
343
344
		List<Granule> granules = facade.sendADQLQuery(SERVICE_EPNCOREV2_ACCESS_URL,
				SERVICE_EPNCOREV2_QUERY);
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
345

35daa117   Nathanael Jourdane   Improve JUnits te...
346
		assertNotNull("Granules list not returned.", granules);
99642cfe   Nathanael Jourdane   Improve unit test...
347
348
349
		assertEquals(8, granules.size());
		Granule mars = null;
		for (Granule granule : granules) {
6a2d3842   Nathanael Jourdane   Use getters and s...
350
			if ("Mars".equals(granule.getGranuleUid())) {
99642cfe   Nathanael Jourdane   Improve unit test...
351
352
353
354
				mars = granule;
			}
		}
		assertNotNull("granule 'Mars' is not found.", mars);
6a2d3842   Nathanael Jourdane   Use getters and s...
355
356
		assertEquals("4", mars.getObsId());
		assertEquals(new Integer(5), mars.getProcessingLevel());
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
357
358
	}

330431b5   Nathanael Jourdane   Fix a Junit test ...
359
360
361
	/**
	 * Unit test for the class {@link EpnTapConnection#sendQuery(String, String, Query)}.
	 *
e669c5d3   Nathanael Jourdane   Improve Javadoc.
362
	 * @throws VOTableException Can not get the VOTable resulting the query.
330431b5   Nathanael Jourdane   Fix a Junit test ...
363
	 */
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
364
	@Test
e669c5d3   Nathanael Jourdane   Improve Javadoc.
365
	public void sendADQLQueryWithSchemaNameTest() throws VOTableException {
fd93317f   Nathanael Jourdane   Solve Sonar/Eclip...
366
		LOGGER.info("sendADQLQueryWithSchemaNameTest");
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
367
		EpnTapConnection facade = new EpnTapConnection();
99642cfe   Nathanael Jourdane   Improve unit test...
368
		List<Granule> granules = facade.sendQuery(SERVICE_EPNCOREV2_ACCESS_URL,
125adfc1   Nathanael Jourdane   Use enumerated qu...
369
				SERVICE_EPNCOREV2_TABLE_NAME, Query.GET_SCENE_FROM_TARGET_AND_TIME_INTERVAL);
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
370

35daa117   Nathanael Jourdane   Improve JUnits te...
371
		assertNotNull("Granules list not returned.", granules);
99642cfe   Nathanael Jourdane   Improve unit test...
372
373
374
		assertEquals(8, granules.size());
		Granule mars = null;
		for (Granule granule : granules) {
6a2d3842   Nathanael Jourdane   Use getters and s...
375
			if ("Mars".equals(granule.getGranuleUid())) {
99642cfe   Nathanael Jourdane   Improve unit test...
376
377
378
379
				mars = granule;
			}
		}
		assertNotNull("granule 'Mars' is not found.", mars);
6a2d3842   Nathanael Jourdane   Use getters and s...
380
381
		assertEquals("4", mars.getObsId());
		assertEquals(new Integer(5), mars.getProcessingLevel());
5d00d3ff   Nathanael Jourdane   #5 Add JUnit test...
382
383
	}
}