1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2013 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
package eu.etaxonomy.cdm.ext.occurrence.bioCase;
|
11
|
|
12
|
import java.io.BufferedReader;
|
13
|
import java.io.IOException;
|
14
|
import java.io.InputStream;
|
15
|
import java.io.InputStreamReader;
|
16
|
import java.net.URISyntaxException;
|
17
|
|
18
|
import junit.framework.TestCase;
|
19
|
|
20
|
import org.apache.http.client.ClientProtocolException;
|
21
|
import org.apache.log4j.Logger;
|
22
|
import org.junit.Test;
|
23
|
|
24
|
import eu.etaxonomy.cdm.common.UriUtils;
|
25
|
import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery;
|
26
|
import eu.etaxonomy.cdm.ext.occurrence.bioCase.BioCaseQueryServiceWrapper;
|
27
|
|
28
|
/**
|
29
|
* @author pplitzner
|
30
|
* @date 16.09.2013
|
31
|
*
|
32
|
*/
|
33
|
public class BioCaseQueryServiceWrapperTest extends TestCase{
|
34
|
|
35
|
public static final Logger logger = Logger.getLogger(BioCaseQueryServiceWrapperTest.class);
|
36
|
|
37
|
@Test
|
38
|
public void testQuery() {
|
39
|
|
40
|
if( UriUtils.isInternetAvailable(null)){
|
41
|
BioCaseQueryServiceWrapper queryService = new BioCaseQueryServiceWrapper();
|
42
|
try {
|
43
|
OccurenceQuery query = new OccurenceQuery("Campanula*", null, null, null, null, null, null, null);
|
44
|
InputStream response = queryService.query(query);
|
45
|
BufferedReader reader = new BufferedReader(new InputStreamReader(response));
|
46
|
String line = null;
|
47
|
do {
|
48
|
if(line!=null){
|
49
|
System.out.println(line);
|
50
|
}
|
51
|
line = reader.readLine();
|
52
|
} while (line!=null);
|
53
|
} catch (ClientProtocolException e) {
|
54
|
fail(e.getMessage());
|
55
|
} catch (IOException e) {
|
56
|
fail(e.getMessage());
|
57
|
} catch (URISyntaxException e) {
|
58
|
fail(e.getMessage());
|
59
|
}
|
60
|
} else {
|
61
|
logger.warn("SKIPPING TEST: no internet connectivity available");
|
62
|
}
|
63
|
}
|
64
|
}
|