4 package eu
.etaxonomy
.cdm
.ext
.sru
;
8 import org
.apache
.logging
.log4j
.LogManager
;
9 import org
.apache
.logging
.log4j
.Logger
;
10 import org
.junit
.Assert
;
11 import org
.junit
.Before
;
12 import org
.junit
.BeforeClass
;
13 import org
.junit
.Ignore
;
14 import org
.junit
.Test
;
16 import eu
.etaxonomy
.cdm
.common
.UriUtils
;
17 import eu
.etaxonomy
.cdm
.ext
.dc
.DublinCoreSchemaAdapter
;
18 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
24 public class SruServiceWrapperTest
{
25 public static final Logger logger
= LogManager
.getLogger(SruServiceWrapperTest
.class);
27 private static final String baseUrl
= "http://gso.gbv.de/sru/DB=1.83/";
30 private SruServiceWrapper sruServiceWrapper
;
32 private static boolean internetIsAvailable
= true;
35 public static void setUpClass() throws Exception
{
36 internetIsAvailable
= true;
40 * @throws java.lang.Exception
43 public void setUp() throws Exception
{
44 sruServiceWrapper
= new SruServiceWrapper();
45 sruServiceWrapper
.setBaseUrl(baseUrl
);
46 sruServiceWrapper
.addSchemaAdapter(new DublinCoreSchemaAdapter());
49 // ******************************* TESTS ******************************************************/
52 @Ignore // ignoring since Global References Index to Biodiversity has problems
53 public void testDoSearchRetrieve(){
55 List
<Reference
> refList_1
= sruServiceWrapper
.doSearchRetrieve("pica.tit=\"Linnaei Species Plantarum\"", "dc");
56 // -> http://gso.gbv.de/sru/DB=2.1/?version=1.1&operation=searchRetrieve&query=pica.tit%3D%22Species+Plantarum%22&recordSchema=dc
58 if (testInternetConnectivity(refList_1
)){
60 Assert
.assertEquals("There should be exactly 5 results for 'Linnaei Species Plantarum'", 5, refList_1
.size());
61 Reference reference_1
= refList_1
.get(0);
62 logger
.info(reference_1
.toString());
64 Assert
.assertEquals("Title of first entry should be 'Caroli Linnaei species plantarum'", "Caroli Linnaei species plantarum", reference_1
.getTitleCache());
66 //--------------------------
68 List
<Reference
> refList_2
= sruServiceWrapper
.doSearchRetrieve("pica.all = \"Species+plantarum\" and pica.dst = \"8305\"", "dc");
69 // -> http://gso.gbv.de/sru/DB=2.1/?version=1.1&operation=searchRetrieve&query=pica.tit%3D%22Species+Plantarum%22&recordSchema=dc
71 Assert
.assertTrue("There should be at least 1 result for 'species+plantarum' and digitized", refList_2
.size() > 0);
72 Reference reference_2
= refList_2
.get(0);
73 logger
.info(reference_2
.toString());
77 private boolean testInternetConnectivity(List
<?
> list
) {
78 if (list
== null || list
.isEmpty()){
79 boolean result
= internetIsAvailable
&& UriUtils
.isInternetAvailable(null);
80 internetIsAvailable
= result
;