source: vlo/trunk/vlo_webapp/src/test/java/eu/clarin/cmdi/vlo/importer/ImporterTestcase.java @ 1007

Last change on this file since 1007 was 1007, checked in by patdui, 13 years ago
  • added resourceType facet and added a list of resources on the show result page.
  • added i18n properties
  • fixed some olac facets supporting multiple patterns to match a facet
File size: 1.8 KB
Line 
1package eu.clarin.cmdi.vlo.importer;
2
3import java.io.File;
4import java.io.IOException;
5
6import org.apache.commons.io.FileUtils;
7import org.junit.AfterClass;
8import org.junit.BeforeClass;
9import org.springframework.beans.factory.BeanFactory;
10import org.springframework.context.support.ClassPathXmlApplicationContext;
11
12public 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}
Note: See TracBrowser for help on using the repository browser.