Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.file / org.gvsig.fmap.dal.file.dbf / src / test / java / org / gvsig / fmap / dal / store / dbf / TestUtils.java @ 44669

History | View | Annotate | Download (1.75 KB)

1
package org.gvsig.fmap.dal.store.dbf;
2

    
3
import java.io.File;
4
import java.net.URL;
5
import org.apache.commons.io.FileUtils;
6
import org.apache.commons.io.FilenameUtils;
7
import org.gvsig.fmap.dal.DALLocator;
8
import org.gvsig.fmap.dal.DataManager;
9
import org.gvsig.fmap.dal.DataStore;
10
import org.gvsig.fmap.dal.feature.FeatureStore;
11
import org.slf4j.Logger;
12
import org.slf4j.LoggerFactory;
13

    
14
public class TestUtils  {
15
    
16
    public static final Logger LOGGER = LoggerFactory.getLogger(TestUtils.class);
17
    
18
    public static File getTargetFolder() throws Exception {
19
        URL url = TestUtils.class.getResource("/");
20
        File x = new File(url.toURI());
21
        File target = x.getParentFile();
22
        return target;
23
    }
24
    
25
    public static File getResource(String name) throws Exception {
26
        File x = new File(getTargetFolder(), name);
27
        return x;
28
    }
29
    
30
    public static File getResourceAsFile(String pathname) throws Exception {
31
        URL url = TestUtils.class.getResource(pathname);
32
        File x = new File(url.toURI());
33
        return x;
34
    }
35

    
36
    public static void removeDALFile(String fname) throws Exception {
37
        File f = getResource(fname);
38
        f = new File(FilenameUtils.removeExtension(f.getAbsolutePath())+".dal");
39
        FileUtils.deleteQuietly(f);
40
    }
41

    
42
    public static FeatureStore openSourceStore1() throws Exception {
43
        DataManager dataManager = DALLocator.getDataManager();
44
        File f = getResourceAsFile("/org/gvsig/fmap/dal/store/testCreateSource1.csv");
45
        FeatureStore store = (FeatureStore) dataManager.openStore(
46
                DataStore.CSV_PROVIDER_NAME, 
47
                "file",f,
48
                "automaticTypesDetection", false,
49
                "locale","en"
50
        );
51
        return store;
52
    }
53
    
54
}