1 | package eu.clarin.cmdi.vlo.importer; |
---|
2 | |
---|
3 | import java.io.File; |
---|
4 | import java.io.IOException; |
---|
5 | import java.net.URISyntaxException; |
---|
6 | import java.net.URL; |
---|
7 | import java.util.ArrayList; |
---|
8 | import java.util.Collection; |
---|
9 | import java.util.Enumeration; |
---|
10 | import java.util.regex.Pattern; |
---|
11 | import java.util.zip.ZipEntry; |
---|
12 | import java.util.zip.ZipException; |
---|
13 | import java.util.zip.ZipFile; |
---|
14 | |
---|
15 | import org.apache.commons.io.FileUtils; |
---|
16 | import org.junit.After; |
---|
17 | import org.junit.Before; |
---|
18 | import org.junit.Rule; |
---|
19 | import org.junit.Test; |
---|
20 | import org.junit.rules.TemporaryFolder; |
---|
21 | |
---|
22 | import eu.clarin.cmdi.vlo.LanguageCodeUtils; |
---|
23 | import eu.clarin.cmdi.vlo.config.DefaultVloConfigFactory; |
---|
24 | import eu.clarin.cmdi.vlo.config.VloConfig; |
---|
25 | import eu.clarin.cmdi.vlo.config.VloConfigFactory; |
---|
26 | |
---|
27 | public abstract class ImporterTestcase { |
---|
28 | |
---|
29 | private final String VOC_MAPS_PATH = ""; |
---|
30 | private final VloConfigFactory configFactory = new DefaultVloConfigFactory(); |
---|
31 | protected VloConfig config; |
---|
32 | |
---|
33 | private static int cnt = 0; |
---|
34 | |
---|
35 | @Rule |
---|
36 | public TemporaryFolder tempFolder = new TemporaryFolder(); |
---|
37 | |
---|
38 | protected File createCmdiFile(String name, String content) throws IOException { |
---|
39 | File file = tempFolder.newFile(name + cnt++ + ".cmdi"); |
---|
40 | FileUtils.writeStringToFile(file, content, "UTF-8"); |
---|
41 | return file; |
---|
42 | } |
---|
43 | |
---|
44 | @After |
---|
45 | public void cleanup() { |
---|
46 | MetadataImporter.config = null; |
---|
47 | } |
---|
48 | |
---|
49 | @Before |
---|
50 | public void setup() throws Exception { |
---|
51 | // read the configuration defined in the packaged configuration file |
---|
52 | MetadataImporter.config = configFactory.newConfig(); |
---|
53 | |
---|
54 | // optionally, modify the configuration here |
---|
55 | |
---|
56 | MetadataImporter.config.setComponentRegistryRESTURL("http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/profiles/"); |
---|
57 | //point to transformed maps |
---|
58 | MetadataImporter.config.setLicenseAvailabilityMapUrl(VOC_MAPS_PATH + MetadataImporter.config.getLicenseAvailabilityMapUrl().substring(1)); |
---|
59 | MetadataImporter.config.setLanguageNameVariantsUrl(VOC_MAPS_PATH + MetadataImporter.config.getLanguageNameVariantsUrl().substring(1)); |
---|
60 | MetadataImporter. config.setNationalProjectMapping(VOC_MAPS_PATH + MetadataImporter.config.getNationalProjectMapping().substring(1)); |
---|
61 | MetadataImporter.config.setOrganisationNamesUrl(VOC_MAPS_PATH + MetadataImporter.config.getOrganisationNamesUrl().substring(1)); |
---|
62 | MetadataImporter.config.setResourceClassMapUrl(VOC_MAPS_PATH + MetadataImporter.config.getResourceClassMapUrl().substring(1)); |
---|
63 | |
---|
64 | config = MetadataImporter.config; |
---|
65 | |
---|
66 | MetadataImporter.languageCodeUtils = new LanguageCodeUtils(config); |
---|
67 | |
---|
68 | |
---|
69 | } |
---|
70 | |
---|
71 | public static String getTestFacetConceptFilePath() { |
---|
72 | try { |
---|
73 | return new File(ImporterTestcase.class.getResource("/facetConceptsTest.xml").toURI()).getAbsolutePath(); |
---|
74 | } catch (URISyntaxException ex) { |
---|
75 | throw new RuntimeException(ex); |
---|
76 | } |
---|
77 | } |
---|
78 | |
---|
79 | |
---|
80 | |
---|
81 | } |
---|