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 / operations / sql / TestFetchFeatureType.java @ 47579
History | View | Annotate | Download (2.76 KB)
1 |
package org.gvsig.sqlite.dal.operations.sql; |
---|---|
2 |
|
3 |
import java.util.Collections; |
4 |
import java.util.List; |
5 |
import junit.framework.TestCase; |
6 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
7 |
import org.gvsig.fmap.dal.feature.FeatureType; |
8 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
9 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
10 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
11 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
12 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.FetchFeatureTypeOperation; |
13 |
import org.gvsig.sqlite.dal.TestUtils; |
14 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
15 |
import org.slf4j.Logger; |
16 |
import org.slf4j.LoggerFactory; |
17 |
|
18 |
public class TestFetchFeatureType extends TestCase { |
19 |
|
20 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestFetchFeatureType.class); |
21 |
|
22 |
public TestFetchFeatureType(String testName) { |
23 |
super(testName);
|
24 |
} |
25 |
|
26 |
@Override
|
27 |
protected void setUp() throws Exception { |
28 |
super.setUp();
|
29 |
new DefaultLibrariesInitializer().fullInitialize();
|
30 |
} |
31 |
|
32 |
@Override
|
33 |
protected void tearDown() throws Exception { |
34 |
super.tearDown();
|
35 |
} |
36 |
|
37 |
// TODO add test methods here. The name must begin with 'test'. For example:
|
38 |
// public void testHello() {}
|
39 |
|
40 |
public void testFetchFeatureType() throws Exception { |
41 |
JDBCHelper helper = TestUtils.createJDBCHelper(); |
42 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
43 |
OperationsFactory operations = helper.getOperations(); |
44 |
|
45 |
List<String> expectedSQLs = TestUtils.getSQLs("fetchFeatureType.sql"); |
46 |
|
47 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
48 |
|
49 |
TableReference table = operations.createTableReference( |
50 |
"dbtest",
|
51 |
sqlbuilder.default_schema(), |
52 |
"test",
|
53 |
null
|
54 |
); |
55 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
56 |
FetchFeatureTypeOperation fetchFeatureType = operations.createFetchFeatureType( |
57 |
featureType.getEditable(), |
58 |
table, |
59 |
Collections.EMPTY_LIST,
|
60 |
null, // "Geometry" |
61 |
featureType.getDefaultSRS() |
62 |
); |
63 |
|
64 |
String retrieveMetadataOfTableSQL = fetchFeatureType.getSQLToRetrieveMetadataOfTable();
|
65 |
String retrievePrimaryKeysFromInformationSchemaSQL = fetchFeatureType.getSQLToRetrievePrimaryKeysFromInformationSchema();
|
66 |
System.out.println("###### FetchFeatureType retrieve metadata SQL:" + retrieveMetadataOfTableSQL); |
67 |
System.out.println("###### FetchFeatureType primery keys SQL:" + retrievePrimaryKeysFromInformationSchemaSQL); |
68 |
|
69 |
assertEquals("FetchFeatureType SQL to retrieve metadata", expectedSQLs.get(0), retrieveMetadataOfTableSQL); |
70 |
assertEquals("FetchFeatureType get primery keys SQL", expectedSQLs.get(1), retrievePrimaryKeysFromInformationSchemaSQL); |
71 |
} |
72 |
|
73 |
} |