1 | package eu.clarin.cmdi.vlo.importer; |
---|
2 | |
---|
3 | import java.io.File; |
---|
4 | import java.io.IOException; |
---|
5 | |
---|
6 | import org.apache.commons.io.FileUtils; |
---|
7 | import org.junit.AfterClass; |
---|
8 | import org.junit.BeforeClass; |
---|
9 | import org.springframework.beans.factory.BeanFactory; |
---|
10 | import org.springframework.context.support.ClassPathXmlApplicationContext; |
---|
11 | |
---|
12 | public abstract class ImporterTestcase { |
---|
13 | private static File testDir; |
---|
14 | |
---|
15 | protected FacetMapping getOlacFacetMap() { |
---|
16 | BeanFactory factory = new ClassPathXmlApplicationContext(new String[] { ImporterConfig.CONFIG_FILE }); |
---|
17 | FacetMapping facetMapping = (FacetMapping) factory.getBean("olacMapping"); |
---|
18 | return facetMapping; |
---|
19 | } |
---|
20 | |
---|
21 | protected FacetMapping getIMDIFacetMap() { |
---|
22 | BeanFactory factory = new ClassPathXmlApplicationContext(new String[] { ImporterConfig.CONFIG_FILE }); |
---|
23 | FacetMapping facetMapping = (FacetMapping) factory.getBean("imdiMapping"); |
---|
24 | return facetMapping; |
---|
25 | } |
---|
26 | |
---|
27 | protected FacetMapping getLrtFacetMap() { |
---|
28 | BeanFactory factory = new ClassPathXmlApplicationContext(new String[] { ImporterConfig.CONFIG_FILE }); |
---|
29 | FacetMapping facetMapping = (FacetMapping) factory.getBean("lrtMapping"); |
---|
30 | return facetMapping; |
---|
31 | } |
---|
32 | |
---|
33 | protected File createCmdiFile(String name, String content) throws IOException { |
---|
34 | File file = File.createTempFile(name, ".cmdi", testDir); |
---|
35 | FileUtils.writeStringToFile(file, content, "UTF-8"); |
---|
36 | return file; |
---|
37 | } |
---|
38 | |
---|
39 | @AfterClass |
---|
40 | public static void cleanup() { |
---|
41 | FileUtils.deleteQuietly(testDir); |
---|
42 | } |
---|
43 | |
---|
44 | @BeforeClass |
---|
45 | public static void setup() { |
---|
46 | final String baseTempPath = System.getProperty("java.io.tmpdir"); |
---|
47 | testDir = new File(baseTempPath + File.separator + "testRegistry_" + System.currentTimeMillis()); |
---|
48 | testDir.mkdir(); |
---|
49 | testDir.deleteOnExit(); |
---|
50 | } |
---|
51 | |
---|
52 | } |
---|