svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.db / org.gvsig.fmap.dal.db.h2 / src / test / java / org / gvsig / fmap / dal / store / h2 / operations / sql / TestFetchFeatureType.java @ 44871
History | View | Annotate | Download (2.55 KB)
1 | 44678 | jjdelcerro | package org.gvsig.fmap.dal.store.h2.operations.sql; |
---|---|---|---|
2 | 43512 | jjdelcerro | |
3 | 44678 | jjdelcerro | import java.util.Collections; |
4 | 44669 | jjdelcerro | import java.util.List; |
5 | 43512 | jjdelcerro | import junit.framework.TestCase; |
6 | 44669 | jjdelcerro | import org.gvsig.fmap.dal.feature.FeatureStore; |
7 | import org.gvsig.fmap.dal.feature.FeatureType; |
||
8 | 44678 | jjdelcerro | import org.gvsig.fmap.dal.store.h2.TestUtils; |
9 | import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
||
10 | import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
||
11 | import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
||
12 | import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
||
13 | import org.gvsig.fmap.dal.store.jdbc2.spi.operations.FetchFeatureTypeOperation; |
||
14 | 44098 | jjdelcerro | import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
15 | 44669 | jjdelcerro | import org.slf4j.Logger; |
16 | import org.slf4j.LoggerFactory; |
||
17 | 43512 | jjdelcerro | |
18 | 44678 | jjdelcerro | public class TestFetchFeatureType extends TestCase { |
19 | 43512 | jjdelcerro | |
20 | 44678 | jjdelcerro | private static final Logger LOGGER = LoggerFactory.getLogger(TestFetchFeatureType.class); |
21 | 44139 | jjdelcerro | |
22 | 44678 | jjdelcerro | public TestFetchFeatureType(String testName) { |
23 | super(testName);
|
||
24 | } |
||
25 | 44421 | jjdelcerro | |
26 | 44678 | jjdelcerro | @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 | 44685 | jjdelcerro | JDBCHelper helper = TestUtils.getJDBCHelper(); |
42 | 44678 | jjdelcerro | JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
43 | OperationsFactory operations = helper.getOperations(); |
||
44 | |||
45 | List<String> expectedSQLs = TestUtils.getSQLs("fetchFeatureType.sql"); |
||
46 | 44421 | jjdelcerro | |
47 | 44678 | jjdelcerro | FeatureStore sourceStore = TestUtils.openSourceStore1(); |
48 | 44139 | jjdelcerro | |
49 | 44678 | jjdelcerro | 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 | 43512 | jjdelcerro | |
64 | |||
65 | 44678 | jjdelcerro | String retrieveFirstRowOfTableSQL = fetchFeatureType.getSQLToRetrieveFirstRowOfTable();
|
66 | String retrievePrimaryKeysFromInformationSchemaSQL = fetchFeatureType.getSQLToRetrievePrimaryKeysFromInformationSchema();
|
||
67 | 44139 | jjdelcerro | |
68 | 44678 | jjdelcerro | assertEquals("FetchFeatureType first row SQL", expectedSQLs.get(0), retrieveFirstRowOfTableSQL); |
69 | assertEquals("FetchFeatureType get primery keys SQL", expectedSQLs.get(1), retrievePrimaryKeysFromInformationSchemaSQL); |
||
70 | } |
||
71 | |||
72 | 43939 | jjdelcerro | } |