source: vlo/trunk/vlo_importer/src/test/java/eu/clarin/cmdi/vlo/config/VloConfigTest.java @ 2826

Last change on this file since 2826 was 2826, checked in by keeloo, 11 years ago

Repaired the importer test: made it transparent regarding the
deleteAllFirst parameter.

Added the parameter and logic that causes large files to be
filtered. Added accompanying tests in the vlo test configuration
package.

File size: 20.0 KB
Line 
1
2package eu.clarin.cmdi.vlo.config;
3
4import java.io.File;
5import java.io.UnsupportedEncodingException;
6import java.net.URLEncoder;
7import java.util.ArrayList;
8import java.util.List;
9import static org.junit.Assert.*;
10import org.junit.Before;
11import org.junit.Test;
12
13/**
14 *
15 * @author keeloo
16 */
17public class VloConfigTest {
18   
19    public VloConfigTest() {
20    }
21   
22    @Before
23    public void setUp() {       
24        VloConfig.readPackagedConfig();
25    }
26
27    /**
28     * Test the getDataRoots method.<br><br>
29     *
30     * Use the values defined in the packaged {@literal VloConfig.xml}
31     * configuration file.
32     */
33    @Test
34    public void testGetDataRoots() {
35       
36        ArrayList<DataRoot> dataRoots;
37        dataRoots = new ArrayList<DataRoot> ();
38       
39        dataRoots.add(new DataRoot("MPI IMDI Archive", 
40                                    new File("/lat/apache/htdocs/oai-harvester/mpi-self-harvest/harvested/results/cmdi/"),
41                                   "http://catalog.clarin.eu/",
42                                   "/lat/apache/htdocs/", false));
43        dataRoots.add(new DataRoot("CMDI Providers"  , 
44                                    new File("/lat/apache/htdocs/oai-harvester/cmdi-providers/harvested/results/cmdi/"),
45                                   "http://catalog.clarin.eu/",
46                                   "/lat/apache/htdocs/", false));
47        dataRoots.add(new DataRoot("OLAC Metadata Providers", 
48                                    new File("/lat/apache/htdocs/oai-harvester/olac-and-dc-providers/harvested/results/cmdi/"),
49                                   "http://catalog.clarin.eu/",
50                                   "/lat/apache/htdocs/", false));
51       
52        System.out.println("getDataRoots");
53       
54        List rootsReturned = VloConfig.getDataRoots();
55       
56        assertEquals(dataRoots, rootsReturned);
57    }
58
59    /**
60     * Test the set setDataRoots method
61     */
62    @Test
63    public void testSetDataRoots() {
64       
65        ArrayList<DataRoot> dataRoots = new ArrayList<DataRoot> ();
66       
67        dataRoots.add(new DataRoot("MPI IMDI Archive", 
68                                    new File("/lat/apache/htdocs/oai-harvester/mpi-self-harvest/harvested/results/cmdi/"),
69                                   "http://catalog.clarin.eu/",
70                                   "/lat/apache/htdocs/", false)); 
71        dataRoots.add(new DataRoot("CMDI Providers"  , 
72                                    new File("/lat/apache/htdocs/oai-harvester/cmdi-providers/harvested/results/cmdi/"),
73                                   "http://catalog.clarin.eu/",
74                                   "/lat/apache/htdocs/", false));
75        dataRoots.add(new DataRoot("OLAC Metadata Providers", 
76                                    new File("/lat/apache/htdocs/oai-harvester/olac-and-dc-providers/harvested/results/cmdi/"),
77                                   "http://catalog.clarin.eu/",
78                                   "/lat/apache/htdocs/", false));
79       
80        System.out.println("setDataRoots");
81
82        VloConfig.setDataRoots(dataRoots);
83       
84        List rootsReturned = VloConfig.getDataRoots(); 
85       
86        assertEquals (dataRoots, rootsReturned);
87    }
88
89    /**
90     * Test the getMaxOnHeap method
91     */
92    @Test
93    public void testGetMaxOnHeap() {
94       
95        System.out.println("getMaxOnHeap");
96       
97        int expResult = 128;
98        int result = VloConfig.getMaxOnHeap();
99       
100        assertEquals(expResult, result);
101    }
102
103    /**
104     * Test the setMaxOnHeap method
105     */
106    @Test
107    public void testSetMaxOnHeap() {
108       
109        System.out.println("setMaxOnHeap");
110       
111        int param = 1000;
112       
113        VloConfig.setMaxOnHeap(param);
114
115        int result = VloConfig.getMaxOnHeap();
116       
117        assertEquals(param, result);
118    }
119   
120    /**
121     * Test the getUseMaxFileSize method
122     */
123    @Test
124    public void testGetUseMaxFileSize() {
125       
126        System.out.println("getUseMaxFileSize");
127       
128        boolean expResult = false;
129        boolean result = VloConfig.getUseMaxFileSize();
130       
131        assertEquals(expResult, result);
132    }
133
134    /**
135     * Test the setSetUseMaxFileSize method
136     */
137    @Test
138    public void testSetUseMaxFileSize() {
139       
140        System.out.println("setUseMaxFileSize");
141       
142        boolean param = true;
143       
144        VloConfig.setUseMaxFileSize(param);
145
146        boolean result = VloConfig.getUseMaxFileSize();
147       
148        assertEquals(param, result);
149    }
150   
151        /**
152     * Test the getMaxFileSize method
153     */
154    @Test
155    public void testGetMaxFileSize() {
156       
157        System.out.println("getMaxFileSize");
158       
159        int expResult = 20000000;
160        int result = VloConfig.getMaxFileSize();
161       
162        assertEquals(expResult, result);
163    }
164
165    /**
166     * Test the setMaxFileSize method
167     */
168    @Test
169    public void testSetMaxFileSize() {
170       
171        System.out.println("setMaxFileSize");
172       
173        int param = 10000000;
174       
175        VloConfig.setMaxFileSize(param);
176
177        int result = VloConfig.getMaxFileSize();
178       
179        assertEquals(param, result);
180    }
181   
182    /**
183     * Test the getHandleResolver method
184     */
185    @Test
186    public void testGetUseHandleResolver() {
187       
188        System.out.println("getUseHandleResolver");
189       
190        boolean expResult = false;
191        boolean result = VloConfig.getUseHandleResolver();
192       
193        assertEquals(expResult, result);
194    }
195   
196    /**
197     * Test the setUseHandleResolver method
198     */
199    @Test
200    public void testSetUseHandleResolver() {
201       
202        System.out.println("setUseHandleResolver");
203       
204        boolean param = true;
205       
206        VloConfig.setUseHandleResolver(param);
207
208        boolean result = VloConfig.getUseHandleResolver();
209       
210        assertEquals(param, result);
211    }
212
213    /**
214     * Test the deleteAllFirst method
215     */
216    @Test
217    public void testDeleteAllFirst() {
218       
219        System.out.println("deleteAllFirst");
220       
221        boolean expResult = true;
222        boolean result = VloConfig.deleteAllFirst();
223       
224        assertEquals(expResult, result);
225    }
226
227    /**
228     * Test the deleteAllFirst method
229     */
230    @Test
231    public void testSetDeleteAllFirst() {
232       
233        System.out.println("setDeleteAllFirst");
234       
235        boolean param = true;
236       
237        VloConfig.setDeleteAllFirst(param);
238
239        boolean result = VloConfig.deleteAllFirst();
240       
241        assertEquals(param, result);
242    }
243
244    /**
245     * Test the printMapping method
246     */
247    @Test
248    public void testPrintMapping() {
249       
250        System.out.println("printMapping");
251       
252        boolean expResult = false;
253        boolean result = VloConfig.printMapping();
254       
255        assertEquals(expResult, result);
256    }
257
258    /**
259     * Test the setPrintMapping method
260     */
261    @Test
262    public void testSetPrintMapping() {
263        System.out.println("setPrintMapping");
264       
265        boolean param = false;
266       
267        VloConfig.setPrintMapping(param);
268
269        boolean result = VloConfig.printMapping();
270       
271        assertEquals(param, result);
272    }
273
274    /**
275     * Test the getVloHomeLink method
276     */
277    @Test
278    public void testGetVloHomeLink() {
279       
280        System.out.println("getVloHomeLink");
281       
282        String expResult = "http://www.clarin.eu/vlo";
283        String result = VloConfig.getVloHomeLink();
284       
285        assertEquals(expResult, result);
286    }
287
288    /**
289     * Test the setVloHomeLink method
290     */
291    @Test
292    public void testSetVloHomeLink() {
293       
294        System.out.println("setSetVloHomeLink");
295       
296        String param = "http://www.clarin.eu/vlo";
297       
298        VloConfig.setVloHomeLink(param);
299
300        String result = VloConfig.getVloHomeLink();
301       
302        assertEquals(param, result);
303    }
304
305    /**
306     * Test the getSolrUrl method
307     */
308    @Test
309    public void testGetSolrUrl() {
310       
311        System.out.println("getSolrUrl");
312       
313        String expResult = "http://localhost:8084/vlo_solr/";
314        String result = VloConfig.getSolrUrl();
315       
316        assertEquals(expResult, result);
317    }
318
319    /**
320     * Test the setVloHomeLink method
321     */
322    @Test
323    public void testSetSolrUrl() {
324       
325        System.out.println("setSolrUrl");
326       
327        String param = "http://localhost:8084/vlo_solr/";
328       
329        VloConfig.setSolrUrl(param);
330
331        String result = VloConfig.getSolrUrl();
332       
333        assertEquals(param, result);
334    }
335   
336    /**
337     * Test the getGetComponentRegistryProfileSchema method
338     */
339    @Test
340    public void testGetComponentRegistryProfileSchema() {
341       
342        System.out.println("getComponentRegistryProfileSchema");
343       
344        String expResult = "http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/profiles/someId/xsd";
345        String result = VloConfig.getComponentRegistryProfileSchema("someId");
346       
347        assertEquals(expResult, result);
348    }
349   
350    /**
351     * Test the getComponentRegistryRESTURL method
352     */
353    @Test
354    public void testGetComponentRegistryRESTURL() {
355       
356        System.out.println("getComponentRegistryRESTURL");
357       
358        String expResult = "http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/profiles/";
359        String result = VloConfig.getComponentRegistryRESTURL();
360       
361        assertEquals(expResult, result);
362    }
363
364    /**
365     * Test the setComponentRegistryRESTURL method
366     */
367    @Test
368    public void testComponentRegistryRESTURL() {
369       
370        System.out.println("setComponentRegistryRESTURL");
371       
372        String param = "http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/profiles/";
373       
374        VloConfig.setComponentRegistryRESTURL(param);
375
376        String result = VloConfig.getComponentRegistryRESTURL();
377       
378        assertEquals(param, result);
379    }
380   
381    /**
382     * Test the getHandleServerUrl method
383     */
384    @Test
385    public void testGetHandleServerUrl() {
386       
387        System.out.println("getHandleServerUrl");
388       
389        String expResult = "http://hdl.handle.net/";
390        String result = VloConfig.getHandleServerUrl();
391       
392        assertEquals(expResult, result);
393    }
394
395    /**
396     * Test the setHandleServerUrl method
397     */
398    @Test
399    public void testSetHandleServerUrl() {
400       
401        System.out.println("setHandleServerUrl");
402       
403        String param = "http://hdl.handle.net/";
404       
405        VloConfig.setHandleServerUrl(param);
406
407        String result = VloConfig.getHandleServerUrl();
408       
409        assertEquals(param, result);
410    }
411   
412    /**
413     * Test the getIMDIBrowserUrl method
414     */
415    @Test
416    public void testGetIMDIBrowserUrl() {
417       
418        System.out.println("getIMDIBrowserUrl");
419       
420        String expResult;
421        try {
422            expResult = "http://corpus1.mpi.nl/ds/imdi_browser?openpath=" + URLEncoder.encode("handle", "UTF-8");
423        } catch (UnsupportedEncodingException ex) {
424            expResult = "http://corpus1.mpi.nl/ds/imdi_browser?openpath=" + "handle";
425        }
426        String result = VloConfig.getIMDIBrowserUrl("handle");
427
428        assertEquals(expResult, result);
429    }
430
431    /**
432     * Test the setIMDIBrowserUrl method
433     */
434    @Test
435    public void testSetIMDIBrowserUrl() {
436       
437        System.out.println("setIMDIBrowserUrl");
438       
439        String param = "http://corpus1.mpi.nl/ds/imdi_browser?openpath=";
440       
441        VloConfig.setIMDIBrowserUrl(param);
442
443        String expResult;
444        try {
445            expResult = "http://corpus1.mpi.nl/ds/imdi_browser?openpath=" + URLEncoder.encode("handle", "UTF-8");
446        } catch (UnsupportedEncodingException ex) {
447            expResult = "http://corpus1.mpi.nl/ds/imdi_browser?openpath=" + "handle";
448        }
449       
450        String result = VloConfig.getIMDIBrowserUrl("handle");
451
452        assertEquals(expResult, result);
453    }
454   
455    /**
456     * Test the getLanguageLinkPrefix method
457     */
458    @Test
459    public void testGetLanguageLinkPrefix() {
460       
461        System.out.println("getLanguageLinkPrefix");
462       
463        String expResult = "http://infra.clarin.eu/service/language/info.php?code=";
464        String result = VloConfig.getLanguageLinkPrefix();
465       
466        assertEquals(expResult, result);
467    }
468
469    /**
470     * Test the setLanguageLinkPrefix method
471     */
472    @Test
473    public void testSetLanguageLinkPrefix() {
474       
475        System.out.println("setLanguageLinkPrefix");
476       
477        String param = "http://infra.clarin.eu/service/language/info.php?code=";
478       
479        VloConfig.setLanguageLinkPrefix(param);
480
481        String result = VloConfig.getLanguageLinkPrefix();
482       
483        assertEquals(param, result);
484    }
485   
486    /**
487     * Test the getFeedbackFromUrl method
488     */
489    @Test
490    public void testGetFeedbackFromUrl() {
491       
492        System.out.println("getFeedBackFromUrl");
493       
494        String expResult = "http://www.clarin.eu/node/3759?url=";
495        String result = VloConfig.getFeedbackFromUrl();
496       
497        assertEquals(expResult, result);
498    }
499
500    /**
501     * Test the setFeedbackFromUrl method
502     */
503    @Test
504    public void testSetFeedbackFromUrl() {
505       
506        System.out.println("setFeedbackFromUrl");
507       
508        String param = "http://www.clarin.eu/node/3759?url=";
509       
510        VloConfig.setFeedbackFromUrl(param);
511
512        String result = VloConfig.getFeedbackFromUrl();
513       
514        assertEquals(param, result);
515    }
516   
517    /**
518     * Test the getFederatedContentSearchUrl method
519     */
520    @Test
521    public void testGetFederatedContentSearchUrl() {
522       
523        System.out.println("getFederatedContentSearchUrl");
524       
525        String expResult = "http://weblicht.sfs.uni-tuebingen.de/Aggregator/";
526        String result = VloConfig.getFederatedContentSearchUrl();
527       
528        assertEquals(expResult, result);
529    }
530
531    /**
532     * Test the setFederatedContentSearchUrl method
533     */
534    @Test
535    public void testSetFederatedContentSearchUrl() {
536       
537        System.out.println("setFederatedContentSearchUrl");
538       
539        String param = "http://weblicht.sfs.uni-tuebingen.de/Aggregator/";
540       
541        VloConfig.setFederatedContentSearchUrl(param);
542
543        String result = VloConfig.getFederatedContentSearchUrl();
544       
545        assertEquals(param, result);
546    }
547
548    /**
549     * Test the getNationalProjectMapping method
550     */
551    @Test
552    public void testGetNationalProjectMapping() {
553       
554        System.out.println("getNationalProjectMapping");
555       
556        String expResult = "/nationalProjectsMapping.xml";
557        String result = VloConfig.getNationalProjectMapping();
558       
559        assertEquals(expResult, result);
560    }
561
562    /**
563     * Test the setNationalProjectMapping method
564     */
565    @Test
566    public void testSetNationalProjectMapping() {
567       
568        System.out.println("setFNationalProjectMapping");
569       
570        String param = "nationalProjectsMapping.xml";
571       
572        VloConfig.setNationalProjectMapping(param);
573
574        String result = VloConfig.getNationalProjectMapping();
575       
576        assertEquals(param, result);
577    }   
578
579    /**
580     * Test of getFacetFields method
581     */
582    @Test
583    public void testGetFacetFields() {
584       
585        System.out.println("getFacetFields");
586       
587        String[] expResult = {
588        "collection",
589        "language",
590        "continent",
591        "genre",
592        "country",
593        "subject",
594        "organisation",
595        "resourceType",
596        "dataProvider",
597        "nationalProject"};
598   
599        String[] result = VloConfig.getFacetFields();
600   
601        assertArrayEquals(expResult, result);
602    }
603
604    /**
605     * Test of setFacetFields method, of class VloConfig
606     */
607    @Test
608    public void testSetFacetFields() {
609       
610        System.out.println("setFacetFields");
611       
612        String[] expResult = {
613        "collection",
614        "language",
615        "continent",
616        "genre",
617        "country",
618        "subject",
619        "organisation",
620        "resourceType",
621        "dataProvider",
622        "nationalProject"};
623       
624        VloConfig.setFacetFields(expResult);
625       
626        String result[] = VloConfig.getFacetFields();
627
628        assertArrayEquals(expResult, result);
629    }
630   
631    /**
632     * Test the getCountryComponentUrl method.
633     */
634    @Test
635    public void testCountryComponentUrl() {
636       
637        System.out.println("getCountryComponentUrl");
638       
639        String expResult = "http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/components/clarin.eu:cr1:c_1271859438104/xml";
640        String result = VloConfig.getCountryComponentUrl();
641       
642        assertEquals(expResult, result);
643    }
644
645    /**
646     * Test the setCountryComponentUrl method.
647     */
648    @Test
649    public void testSetCountryComponentUrl() {
650       
651        System.out.println("setCountryComponentUrl");
652       
653        String param = "http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/components/clarin.eu:cr1:c_1271859438104/xml";
654       
655        VloConfig.setCountryComponentUrl(param);
656
657        String result = VloConfig.getCountryComponentUrl();
658       
659        assertEquals(param, result);
660    } 
661   
662    /**
663     * Test the getLanguage2LetterCodeComponentUrl method.
664     */
665    @Test
666    public void testGetLanguage2LetterCodeComponentUrl() {
667       
668        System.out.println("getLanguage2LetterCodeComponentUrl");
669       
670        String expResult = "http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/components/clarin.eu:cr1:c_1271859438109/xml";
671        String result = VloConfig.getLanguage2LetterCodeComponentUrl();
672       
673        assertEquals(expResult, result);
674    }
675
676    /**
677     * Test the setLanguage2LetterCodeComponentUrl method.
678     */
679    @Test
680    public void testSetLanguage2LetterCodeComponentUrl() {
681       
682        System.out.println("setLanguage2LetterCodeComponentUrl");
683       
684        String param = "http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/components/clarin.eu:cr1:c_1271859438109/xml";
685       
686        VloConfig.setLanguage2LetterCodeComponentUrl(param);
687
688        String result = VloConfig.getLanguage2LetterCodeComponentUrl();
689       
690        assertEquals(param, result);
691    }
692   
693    /**
694     * Test the getLanguage3LetterCodeComponentUrl.
695     */
696    @Test
697    public void testGetLanguage3LetterCodeComponentUrl() {
698       
699        System.out.println("getLanguage3LetterCodeComponentUrl");
700       
701        String expResult = "http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/components/clarin.eu:cr1:c_1271859438110/xml";
702        String result = VloConfig.getLanguage3LetterCodeComponentUrl();
703       
704        assertEquals(expResult, result);
705    }
706
707    /**
708     * Test the setLanguage3LetterCodeComponentUrl.
709     */
710    @Test
711    public void testSetLanguage3LetterCodeComponentUrl() {
712       
713        System.out.println("setLanguage3LetterCodeComponentUrl");
714       
715        String param = "http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/components/clarin.eu:cr1:c_1271859438110/xml";
716       
717        VloConfig.setLanguage3LetterCodeComponentUrl(param);
718
719        String result = VloConfig.getLanguage3LetterCodeComponentUrl();
720       
721        assertEquals(param, result);
722    }
723   
724    /**
725     * Test the getSilToISO639CodesUrl method.
726     */
727    @Test
728    public void testGetSilToISO639CodesUrl() {
729       
730        System.out.println("getSilToISO639CodesUrl");
731       
732        String expResult = "http://www.clarin.eu/cmd/xslt/sil_to_iso6393.xml";
733        String result = VloConfig.getSilToISO639CodesUrl();
734       
735        assertEquals(expResult, result);
736    }
737
738    /**
739     * Test the setSilToISO639CodesUrl method.
740     */
741    @Test
742    public void testSetSilToISO639CodesUrl() {
743       
744        System.out.println("setSilToISO639CodesUrl");
745       
746        String param = "http://www.clarin.eu/cmd/xslt/sil_to_iso6393.xml";
747       
748        VloConfig.setSilToISO639CodesUrl(param);
749
750        String result = VloConfig.getSilToISO639CodesUrl();
751       
752        assertEquals(param, result);
753    }
754
755}
Note: See TracBrowser for help on using the repository browser.