svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.h2spatial / org.gvsig.h2spatial.h2gis132 / org.gvsig.h2spatial.h2gis132.provider / src / test / java / org / gvsig / fmap / dal / store / h2 / operations / sql / TestFetchFeatureProviderByReference.java @ 46277
History | View | Annotate | Download (2.74 KB)
1 | 45472 | jjdelcerro | package org.gvsig.fmap.dal.store.h2.operations.sql; |
---|---|---|---|
2 | |||
3 | import java.util.List; |
||
4 | import junit.framework.TestCase; |
||
5 | import org.gvsig.fmap.dal.feature.Feature; |
||
6 | import org.gvsig.fmap.dal.feature.FeatureReference; |
||
7 | import org.gvsig.fmap.dal.feature.FeatureStore; |
||
8 | import org.gvsig.fmap.dal.feature.FeatureType; |
||
9 | import org.gvsig.fmap.dal.feature.impl.DefaultFeature; |
||
10 | 45688 | fdiaz | import org.gvsig.fmap.dal.feature.impl.featurereference.FeatureReferenceFactory; |
11 | import org.gvsig.fmap.dal.feature.spi.FeatureReferenceProviderServices; |
||
12 | 45472 | jjdelcerro | import org.gvsig.fmap.dal.store.h2.TestUtils; |
13 | import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
||
14 | import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
||
15 | import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
||
16 | import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
||
17 | import org.gvsig.fmap.dal.store.jdbc2.spi.operations.FetchFeatureProviderByReferenceOperation; |
||
18 | import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
||
19 | import org.slf4j.Logger; |
||
20 | import org.slf4j.LoggerFactory; |
||
21 | |||
22 | public class TestFetchFeatureProviderByReference extends TestCase { |
||
23 | |||
24 | private static final Logger LOGGER = LoggerFactory.getLogger(TestFetchFeatureProviderByReference.class); |
||
25 | |||
26 | public TestFetchFeatureProviderByReference(String testName) { |
||
27 | super(testName);
|
||
28 | } |
||
29 | |||
30 | @Override
|
||
31 | protected void setUp() throws Exception { |
||
32 | super.setUp();
|
||
33 | new DefaultLibrariesInitializer().fullInitialize();
|
||
34 | } |
||
35 | |||
36 | @Override
|
||
37 | protected void tearDown() throws Exception { |
||
38 | super.tearDown();
|
||
39 | } |
||
40 | |||
41 | // TODO add test methods here. The name must begin with 'test'. For example:
|
||
42 | // public void testHello() {}
|
||
43 | |||
44 | public void testFetchFeatureProviderByReference() throws Exception { |
||
45 | 45649 | jjdelcerro | JDBCHelper helper = TestUtils.createJDBCHelper(); |
46 | 45472 | jjdelcerro | JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
47 | OperationsFactory operations = helper.getOperations(); |
||
48 | |||
49 | List<String> expectedSQLs = TestUtils.getSQLs("fetchFeatureProviderByReference.sql"); |
||
50 | |||
51 | FeatureStore sourceStore = TestUtils.openSourceStore1(); |
||
52 | TableReference table = operations.createTableReference( |
||
53 | "dbtest",
|
||
54 | sqlbuilder.default_schema(), |
||
55 | "test",
|
||
56 | null
|
||
57 | ); |
||
58 | FeatureType featureType = sourceStore.getDefaultFeatureType(); |
||
59 | Feature feature = sourceStore.getFeatures().get(1);
|
||
60 | 45688 | fdiaz | FeatureReference reference = FeatureReferenceFactory.createReferencePKFromFeature(feature); |
61 | 45472 | jjdelcerro | |
62 | FetchFeatureProviderByReferenceOperation fetchFeatureProviderByReference = operations.createFetchFeatureProviderByReference( |
||
63 | 45688 | fdiaz | (FeatureReferenceProviderServices) reference, |
64 | 45472 | jjdelcerro | featureType, |
65 | table |
||
66 | ); |
||
67 | |||
68 | String sql = fetchFeatureProviderByReference.getSQL();
|
||
69 | assertEquals("FetchFeatureProviderByReference SQL", expectedSQLs.get(0), sql); |
||
70 | } |
||
71 | |||
72 | } |