svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.sqlite / org.gvsig.sqlite.provider / src / test / java / org / gvsig / sqlite / dal / TestUtilsSQLite.java @ 47456
History | View | Annotate | Download (1.79 KB)
1 | 47456 | jjdelcerro | package org.gvsig.sqlite.dal; |
---|---|---|---|
2 | |||
3 | import java.io.File; |
||
4 | import org.apache.commons.io.FileUtils; |
||
5 | import org.gvsig.fmap.dal.DALLocator; |
||
6 | import org.gvsig.fmap.dal.DataManager; |
||
7 | import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
||
8 | import org.gvsig.fmap.dal.store.jdbc2.AbstractTestUtils; |
||
9 | import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
||
10 | import org.gvsig.fmap.dal.store.jdbc2.spi.FakeConnectionProvider; |
||
11 | import org.gvsig.tools.util.HasAFile; |
||
12 | |||
13 | /**
|
||
14 | *
|
||
15 | * @author jjdelcerro
|
||
16 | */
|
||
17 | public class TestUtilsSQLite extends AbstractTestUtils { |
||
18 | |||
19 | public static final String PROVIDER_NAME = SQLiteLibrary.NAME; |
||
20 | |||
21 | @Override
|
||
22 | public String getProviderName() { |
||
23 | return PROVIDER_NAME;
|
||
24 | } |
||
25 | |||
26 | @Override
|
||
27 | public String getExpectedsPath() { |
||
28 | return "/org/gvsig/sqlite/dal"; |
||
29 | } |
||
30 | |||
31 | @Override
|
||
32 | public JDBCHelper createJDBCHelper() throws Exception { |
||
33 | SQLiteConnectionParameters params = (SQLiteConnectionParameters) this.getServerExplorerParameters("fake"); |
||
34 | SQLiteHelper helper = new SQLiteHelper(params, new FakeConnectionProvider()); |
||
35 | return helper;
|
||
36 | } |
||
37 | |||
38 | @Override
|
||
39 | public JDBCServerExplorerParameters getServerExplorerParameters(String dbname) throws Exception { |
||
40 | DataManager dataManager = DALLocator.getDataManager(); |
||
41 | JDBCServerExplorerParameters conn = (JDBCServerExplorerParameters) dataManager.createServerExplorerParameters(PROVIDER_NAME); |
||
42 | |||
43 | File dbfile = this.getResource(String.format( |
||
44 | "test-dbs/%s-%d-%03d",
|
||
45 | dbname, |
||
46 | System.currentTimeMillis(),
|
||
47 | dbcounter++ |
||
48 | ) |
||
49 | ); |
||
50 | // System.out.println("#### dbfile: " + dbfile.getAbsolutePath());
|
||
51 | FileUtils.forceMkdir(dbfile.getParentFile()); |
||
52 | ((HasAFile) conn).setFile(dbfile); |
||
53 | return conn;
|
||
54 | } |
||
55 | |||
56 | } |