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.shp / src / test / java / org / gvsig / fmap / dal / store / shp / TestUtils.java @ 44678
History | View | Annotate | Download (2.18 KB)
1 |
package org.gvsig.fmap.dal.store.shp; |
---|---|
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.DataServerExplorer; |
10 |
import org.gvsig.fmap.dal.DataStore; |
11 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
12 |
import org.slf4j.Logger; |
13 |
import org.slf4j.LoggerFactory; |
14 |
|
15 |
public class TestUtils { |
16 |
|
17 |
public static final Logger LOGGER = LoggerFactory.getLogger(TestUtils.class); |
18 |
|
19 |
|
20 |
public static DataServerExplorer openServerExplorer() throws Exception { |
21 |
DataManager dataManager = DALLocator.getDataManager(); |
22 |
DataServerExplorer explorer = dataManager.openServerExplorer( |
23 |
DataServerExplorer.FILESYSTEM_SERVER_EXPLORER_NAME, |
24 |
"root=", TestUtils.getTargetFolder()
|
25 |
); |
26 |
return explorer;
|
27 |
} |
28 |
|
29 |
public static File getTargetFolder() throws Exception { |
30 |
URL url = TestUtils.class.getResource("/"); |
31 |
File x = new File(url.toURI()); |
32 |
File target = x.getParentFile();
|
33 |
return target;
|
34 |
} |
35 |
|
36 |
public static File getResource(String name) throws Exception { |
37 |
File x = new File(getTargetFolder(), name); |
38 |
return x;
|
39 |
} |
40 |
|
41 |
public static File getResourceAsFile(String pathname) throws Exception { |
42 |
URL url = TestUtils.class.getResource(pathname);
|
43 |
File x = new File(url.toURI()); |
44 |
return x;
|
45 |
} |
46 |
|
47 |
public static void removeDALFile(String fname) throws Exception { |
48 |
File f = getResource(fname);
|
49 |
f = new File(FilenameUtils.removeExtension(f.getAbsolutePath())+".dal"); |
50 |
FileUtils.deleteQuietly(f); |
51 |
} |
52 |
|
53 |
public static FeatureStore openSourceStore1() throws Exception { |
54 |
DataManager dataManager = DALLocator.getDataManager(); |
55 |
File f = getResourceAsFile("/org/gvsig/fmap/dal/store/shp/testCreateSource1.csv"); |
56 |
FeatureStore store = (FeatureStore) dataManager.openStore( |
57 |
DataStore.CSV_PROVIDER_NAME, |
58 |
"file=",f,
|
59 |
"automaticTypesDetection=", false, |
60 |
"locale=","en" |
61 |
); |
62 |
return store;
|
63 |
} |
64 |
|
65 |
} |